@swmansion/argent 0.10.0 → 0.12.0
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 +4 -1
- package/assets/argent.tracecfg.pbtxt +133 -0
- package/assets/queries/README.md +93 -0
- package/assets/queries/cpu-hotspots.sql +106 -0
- package/assets/queries/function-callers.sql +62 -0
- package/assets/queries/hang-folds-batched.sql +88 -0
- package/assets/queries/hang-main-thread-samples.sql +32 -0
- package/assets/queries/hang-state-breakdown.sql +44 -0
- package/assets/queries/memory-rss.sql +25 -0
- package/assets/queries/thread-breakdown.sql +34 -0
- package/assets/queries/trace-bounds.sql +6 -0
- package/assets/queries/ui-hangs.sql +59 -0
- package/assets/trace-processor/LICENSE +235 -0
- package/assets/trace-processor/SHA256SUMS +4 -0
- package/assets/trace-processor/engine.mjs +42423 -0
- package/assets/trace-processor/engine_bundle.node.js +11130 -0
- package/assets/trace-processor/trace_processor.wasm +0 -0
- package/{dist → bin}/argent-android-devtools-0.1.0.apk +0 -0
- package/bin/argent-simulator-server.cjs +11 -3
- package/bin/darwin/ax-service +0 -0
- package/bin/darwin/resources/android/LICENSE.txt +186 -0
- package/bin/darwin/resources/android/README.md +11 -0
- package/bin/darwin/resources/android/arm64-v8a/libscreen-sharing-agent.so +0 -0
- package/bin/darwin/resources/android/armeabi-v7a/libscreen-sharing-agent.so +0 -0
- package/bin/darwin/resources/android/screen-sharing-agent.jar +0 -0
- package/bin/darwin/resources/android/x86_64/libscreen-sharing-agent.so +0 -0
- package/bin/darwin/simulator-server +0 -0
- package/bin/linux/resources/android/LICENSE.txt +186 -0
- package/bin/linux/resources/android/README.md +11 -0
- package/bin/linux/resources/android/arm64-v8a/libscreen-sharing-agent.so +0 -0
- package/bin/linux/resources/android/armeabi-v7a/libscreen-sharing-agent.so +0 -0
- package/bin/linux/resources/android/screen-sharing-agent.jar +0 -0
- package/bin/linux/resources/android/x86_64/libscreen-sharing-agent.so +0 -0
- package/bin/linux/simulator-server +0 -0
- package/bin/linux-arm64/resources/android/LICENSE.txt +186 -0
- package/bin/linux-arm64/resources/android/README.md +11 -0
- package/bin/linux-arm64/resources/android/arm64-v8a/libscreen-sharing-agent.so +0 -0
- package/bin/linux-arm64/resources/android/armeabi-v7a/libscreen-sharing-agent.so +0 -0
- package/bin/linux-arm64/resources/android/screen-sharing-agent.jar +0 -0
- package/bin/linux-arm64/resources/android/x86_64/libscreen-sharing-agent.so +0 -0
- package/bin/linux-arm64/simulator-server +0 -0
- package/dist/cli-cmds.mjs +1858 -1578
- package/dist/cli.js +0 -3
- package/dist/cli.js.map +1 -1
- package/dist/installer.mjs +119 -96
- package/dist/mcp-server.mjs +452 -92
- package/dist/preview-ui/index.html +4500 -645
- package/dist/preview-ui/theme.css +231 -0
- package/dist/preview-window/main.cjs +182 -0
- package/dist/tool-server.cjs +11265 -5220
- package/dylibs/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/libKeyboardPatch.dylib +0 -0
- package/dylibs/libNativeDevtoolsIos.dylib +0 -0
- package/package.json +5 -2
- package/rules/argent.md +8 -2
- package/scripts/postinstall.cjs +6 -2
- package/skills/argent-device-interact/SKILL.md +36 -28
- package/skills/argent-lens/SKILL.md +101 -0
- package/skills/argent-metro-debugger/SKILL.md +18 -16
- package/skills/argent-native-profiler/SKILL.md +5 -5
- package/skills/argent-react-native-app-workflow/SKILL.md +8 -8
- /package/{dist → assets}/Argent.tracetemplate +0 -0
- /package/{manifest.json → assets/manifest.json} +0 -0
package/dist/cli-cmds.mjs
CHANGED
|
@@ -6,7 +6,11 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
|
|
9
|
+
try {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
} catch (e2) {
|
|
12
|
+
throw mod = 0, e2;
|
|
13
|
+
}
|
|
10
14
|
};
|
|
11
15
|
var __copyProps = (to, from, except, desc) => {
|
|
12
16
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -25,62 +29,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
29
|
mod
|
|
26
30
|
));
|
|
27
31
|
|
|
28
|
-
// ../../node_modules/sisteransi/src/index.js
|
|
29
|
-
var require_src = __commonJS({
|
|
30
|
-
"../../node_modules/sisteransi/src/index.js"(exports, module) {
|
|
31
|
-
"use strict";
|
|
32
|
-
var ESC2 = "\x1B";
|
|
33
|
-
var CSI2 = `${ESC2}[`;
|
|
34
|
-
var beep = "\x07";
|
|
35
|
-
var cursor = {
|
|
36
|
-
to(x3, y) {
|
|
37
|
-
if (!y) return `${CSI2}${x3 + 1}G`;
|
|
38
|
-
return `${CSI2}${y + 1};${x3 + 1}H`;
|
|
39
|
-
},
|
|
40
|
-
move(x3, y) {
|
|
41
|
-
let ret = "";
|
|
42
|
-
if (x3 < 0) ret += `${CSI2}${-x3}D`;
|
|
43
|
-
else if (x3 > 0) ret += `${CSI2}${x3}C`;
|
|
44
|
-
if (y < 0) ret += `${CSI2}${-y}A`;
|
|
45
|
-
else if (y > 0) ret += `${CSI2}${y}B`;
|
|
46
|
-
return ret;
|
|
47
|
-
},
|
|
48
|
-
up: (count = 1) => `${CSI2}${count}A`,
|
|
49
|
-
down: (count = 1) => `${CSI2}${count}B`,
|
|
50
|
-
forward: (count = 1) => `${CSI2}${count}C`,
|
|
51
|
-
backward: (count = 1) => `${CSI2}${count}D`,
|
|
52
|
-
nextLine: (count = 1) => `${CSI2}E`.repeat(count),
|
|
53
|
-
prevLine: (count = 1) => `${CSI2}F`.repeat(count),
|
|
54
|
-
left: `${CSI2}G`,
|
|
55
|
-
hide: `${CSI2}?25l`,
|
|
56
|
-
show: `${CSI2}?25h`,
|
|
57
|
-
save: `${ESC2}7`,
|
|
58
|
-
restore: `${ESC2}8`
|
|
59
|
-
};
|
|
60
|
-
var scroll = {
|
|
61
|
-
up: (count = 1) => `${CSI2}S`.repeat(count),
|
|
62
|
-
down: (count = 1) => `${CSI2}T`.repeat(count)
|
|
63
|
-
};
|
|
64
|
-
var erase = {
|
|
65
|
-
screen: `${CSI2}2J`,
|
|
66
|
-
up: (count = 1) => `${CSI2}1J`.repeat(count),
|
|
67
|
-
down: (count = 1) => `${CSI2}J`.repeat(count),
|
|
68
|
-
line: `${CSI2}2K`,
|
|
69
|
-
lineEnd: `${CSI2}K`,
|
|
70
|
-
lineStart: `${CSI2}1K`,
|
|
71
|
-
lines(count) {
|
|
72
|
-
let clear = "";
|
|
73
|
-
for (let i = 0; i < count; i++)
|
|
74
|
-
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
75
|
-
if (count)
|
|
76
|
-
clear += cursor.left;
|
|
77
|
-
return clear;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
module.exports = { cursor, scroll, erase, beep };
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
32
|
// ../../node_modules/picocolors/picocolors.js
|
|
85
33
|
var require_picocolors = __commonJS({
|
|
86
34
|
"../../node_modules/picocolors/picocolors.js"(exports, module) {
|
|
@@ -153,9 +101,65 @@ var require_picocolors = __commonJS({
|
|
|
153
101
|
}
|
|
154
102
|
});
|
|
155
103
|
|
|
104
|
+
// ../../node_modules/sisteransi/src/index.js
|
|
105
|
+
var require_src = __commonJS({
|
|
106
|
+
"../../node_modules/sisteransi/src/index.js"(exports, module) {
|
|
107
|
+
"use strict";
|
|
108
|
+
var ESC2 = "\x1B";
|
|
109
|
+
var CSI2 = `${ESC2}[`;
|
|
110
|
+
var beep = "\x07";
|
|
111
|
+
var cursor = {
|
|
112
|
+
to(x3, y) {
|
|
113
|
+
if (!y) return `${CSI2}${x3 + 1}G`;
|
|
114
|
+
return `${CSI2}${y + 1};${x3 + 1}H`;
|
|
115
|
+
},
|
|
116
|
+
move(x3, y) {
|
|
117
|
+
let ret = "";
|
|
118
|
+
if (x3 < 0) ret += `${CSI2}${-x3}D`;
|
|
119
|
+
else if (x3 > 0) ret += `${CSI2}${x3}C`;
|
|
120
|
+
if (y < 0) ret += `${CSI2}${-y}A`;
|
|
121
|
+
else if (y > 0) ret += `${CSI2}${y}B`;
|
|
122
|
+
return ret;
|
|
123
|
+
},
|
|
124
|
+
up: (count = 1) => `${CSI2}${count}A`,
|
|
125
|
+
down: (count = 1) => `${CSI2}${count}B`,
|
|
126
|
+
forward: (count = 1) => `${CSI2}${count}C`,
|
|
127
|
+
backward: (count = 1) => `${CSI2}${count}D`,
|
|
128
|
+
nextLine: (count = 1) => `${CSI2}E`.repeat(count),
|
|
129
|
+
prevLine: (count = 1) => `${CSI2}F`.repeat(count),
|
|
130
|
+
left: `${CSI2}G`,
|
|
131
|
+
hide: `${CSI2}?25l`,
|
|
132
|
+
show: `${CSI2}?25h`,
|
|
133
|
+
save: `${ESC2}7`,
|
|
134
|
+
restore: `${ESC2}8`
|
|
135
|
+
};
|
|
136
|
+
var scroll = {
|
|
137
|
+
up: (count = 1) => `${CSI2}S`.repeat(count),
|
|
138
|
+
down: (count = 1) => `${CSI2}T`.repeat(count)
|
|
139
|
+
};
|
|
140
|
+
var erase = {
|
|
141
|
+
screen: `${CSI2}2J`,
|
|
142
|
+
up: (count = 1) => `${CSI2}1J`.repeat(count),
|
|
143
|
+
down: (count = 1) => `${CSI2}J`.repeat(count),
|
|
144
|
+
line: `${CSI2}2K`,
|
|
145
|
+
lineEnd: `${CSI2}K`,
|
|
146
|
+
lineStart: `${CSI2}1K`,
|
|
147
|
+
lines(count) {
|
|
148
|
+
let clear = "";
|
|
149
|
+
for (let i = 0; i < count; i++)
|
|
150
|
+
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
151
|
+
if (count)
|
|
152
|
+
clear += cursor.left;
|
|
153
|
+
return clear;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
module.exports = { cursor, scroll, erase, beep };
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
156
160
|
// ../argent-cli/src/run.ts
|
|
157
161
|
import * as fs2 from "node:fs";
|
|
158
|
-
import * as
|
|
162
|
+
import * as path4 from "node:path";
|
|
159
163
|
|
|
160
164
|
// ../argent-tools-client/src/launcher.ts
|
|
161
165
|
import * as net from "node:net";
|
|
@@ -513,12 +517,104 @@ function parseLinkTarget(input) {
|
|
|
513
517
|
const host = u.hostname.startsWith("[") ? u.hostname.slice(1, -1) : u.hostname;
|
|
514
518
|
if (!host) throw new Error(`URL "${input}" is missing a host.`);
|
|
515
519
|
const port = u.port ? Number(u.port) : u.protocol === "https:" ? 443 : 80;
|
|
516
|
-
const
|
|
517
|
-
const url = `${u.protocol}//${u.host}${
|
|
520
|
+
const path7 = u.pathname === "/" ? "" : u.pathname.replace(/\/+$/, "");
|
|
521
|
+
const url = `${u.protocol}//${u.host}${path7}`;
|
|
518
522
|
const token = u.username ? decodeURIComponent(u.username) : void 0;
|
|
519
523
|
return { url, host, port, ...token ? { token } : {} };
|
|
520
524
|
}
|
|
521
525
|
|
|
526
|
+
// ../argent-tools-client/src/file-inputs.ts
|
|
527
|
+
import { mkdir as mkdir3, stat, writeFile as writeFile3 } from "node:fs/promises";
|
|
528
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
529
|
+
import * as path3 from "node:path";
|
|
530
|
+
var FILE_INPUT_MARKER = "__argentFileInput";
|
|
531
|
+
var CLIENT_FILE_MARKER = "__argentClientFile";
|
|
532
|
+
var MAX_CONTENT_BYTES = 32 * 1024 * 1024;
|
|
533
|
+
function interpolatePath(template, args) {
|
|
534
|
+
let missing = false;
|
|
535
|
+
const out = template.replace(/\$\{([A-Za-z0-9_]+)\}/g, (_m, name) => {
|
|
536
|
+
const v2 = args[name];
|
|
537
|
+
if (typeof v2 !== "string" || v2.length === 0) {
|
|
538
|
+
missing = true;
|
|
539
|
+
return "";
|
|
540
|
+
}
|
|
541
|
+
return v2;
|
|
542
|
+
});
|
|
543
|
+
return missing ? null : out;
|
|
544
|
+
}
|
|
545
|
+
async function prepareFileInputs(specs, args, opts) {
|
|
546
|
+
if (!specs || specs.length === 0 || typeof args !== "object" || args === null) {
|
|
547
|
+
return args;
|
|
548
|
+
}
|
|
549
|
+
const record = args;
|
|
550
|
+
let out = null;
|
|
551
|
+
for (const spec of specs) {
|
|
552
|
+
if (spec.target in record && typeof record[spec.target] !== "string") continue;
|
|
553
|
+
const filePath = interpolatePath(spec.path, record);
|
|
554
|
+
if (filePath === null) continue;
|
|
555
|
+
if (spec.target in record && record[spec.target] !== filePath) continue;
|
|
556
|
+
const wire = { [FILE_INPUT_MARKER]: true, path: filePath };
|
|
557
|
+
if (spec.kind === "file") {
|
|
558
|
+
try {
|
|
559
|
+
const st2 = await stat(filePath);
|
|
560
|
+
if (st2.isFile()) {
|
|
561
|
+
wire.size = st2.size;
|
|
562
|
+
wire.mtimeMs = st2.mtimeMs;
|
|
563
|
+
if (opts.includeContent && st2.size <= MAX_CONTENT_BYTES) {
|
|
564
|
+
wire.content = (await readFile3(filePath)).toString("base64");
|
|
565
|
+
} else if (opts.includeContent) {
|
|
566
|
+
wire.contentOmitted = "size-limit";
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
} catch {
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
out = out ?? { ...record };
|
|
573
|
+
out[spec.target] = wire;
|
|
574
|
+
}
|
|
575
|
+
return out ?? args;
|
|
576
|
+
}
|
|
577
|
+
function isAllowedClientFilePath(p2) {
|
|
578
|
+
if (!path3.isAbsolute(p2)) return false;
|
|
579
|
+
const segments = p2.split(/[\\/]+/);
|
|
580
|
+
if (segments.includes("..")) return false;
|
|
581
|
+
const file = segments[segments.length - 1] ?? "";
|
|
582
|
+
if (!/^[A-Za-z0-9_-]+\.yaml$/.test(file)) return false;
|
|
583
|
+
return segments[segments.length - 3] === ".argent" && segments[segments.length - 2] === "flows";
|
|
584
|
+
}
|
|
585
|
+
function isClientFileDirective(value) {
|
|
586
|
+
return !!value && typeof value === "object" && value[CLIENT_FILE_MARKER] === true && typeof value.path === "string" && typeof value.content === "string";
|
|
587
|
+
}
|
|
588
|
+
async function applyClientFileDirectives(result) {
|
|
589
|
+
const written = [];
|
|
590
|
+
async function walk(value) {
|
|
591
|
+
if (isClientFileDirective(value)) {
|
|
592
|
+
if (!isAllowedClientFilePath(value.path)) return null;
|
|
593
|
+
try {
|
|
594
|
+
await mkdir3(path3.dirname(value.path), { recursive: true });
|
|
595
|
+
await writeFile3(value.path, value.content, "utf8");
|
|
596
|
+
written.push(value.path);
|
|
597
|
+
return value.path;
|
|
598
|
+
} catch {
|
|
599
|
+
return null;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
if (Array.isArray(value)) {
|
|
603
|
+
return Promise.all(value.map(walk));
|
|
604
|
+
}
|
|
605
|
+
if (value && typeof value === "object") {
|
|
606
|
+
const out = {};
|
|
607
|
+
for (const [k2, v2] of Object.entries(value)) {
|
|
608
|
+
out[k2] = await walk(v2);
|
|
609
|
+
}
|
|
610
|
+
return out;
|
|
611
|
+
}
|
|
612
|
+
return value;
|
|
613
|
+
}
|
|
614
|
+
const rewritten = await walk(result);
|
|
615
|
+
return { result: rewritten, written };
|
|
616
|
+
}
|
|
617
|
+
|
|
522
618
|
// ../argent-tools-client/src/tools-client.ts
|
|
523
619
|
function authHeaders2(token) {
|
|
524
620
|
return token ? { Authorization: `Bearer ${token}` } : {};
|
|
@@ -552,20 +648,161 @@ function createToolsClient(options = {}) {
|
|
|
552
648
|
}
|
|
553
649
|
async function callTool(name, args) {
|
|
554
650
|
const { url, token } = await baseUrl();
|
|
651
|
+
let finalArgs = args;
|
|
652
|
+
const meta = await fetchTool(name);
|
|
653
|
+
if (meta?.fileInputs?.length) {
|
|
654
|
+
const { url: routedUrl } = await getResolvedToolsUrl();
|
|
655
|
+
finalArgs = await prepareFileInputs(meta.fileInputs, args ?? {}, {
|
|
656
|
+
includeContent: routedUrl !== null
|
|
657
|
+
});
|
|
658
|
+
}
|
|
555
659
|
const res = await fetch(`${url}/tools/${encodeURIComponent(name)}`, {
|
|
556
660
|
method: "POST",
|
|
557
661
|
headers: { "Content-Type": "application/json", ...authHeaders2(token) },
|
|
558
|
-
body: JSON.stringify(
|
|
662
|
+
body: JSON.stringify(finalArgs ?? {})
|
|
559
663
|
});
|
|
560
664
|
const json = await res.json().catch(() => ({}));
|
|
561
665
|
if (!res.ok) {
|
|
562
666
|
throw new Error(json.error ?? json.message ?? `${res.status} ${res.statusText}`);
|
|
563
667
|
}
|
|
564
|
-
|
|
668
|
+
const { result: data } = await applyClientFileDirectives(json.data);
|
|
669
|
+
return { data, note: json.note };
|
|
565
670
|
}
|
|
566
671
|
return { fetchTools, fetchTool, callTool, baseUrl };
|
|
567
672
|
}
|
|
568
673
|
|
|
674
|
+
// ../argent-tools-client/src/artifacts.ts
|
|
675
|
+
import { mkdir as mkdir4, readFile as readFile4, rm, stat as stat2, writeFile as writeFile4 } from "node:fs/promises";
|
|
676
|
+
import { tmpdir } from "node:os";
|
|
677
|
+
import { basename, join as join3 } from "node:path";
|
|
678
|
+
import { createHash } from "node:crypto";
|
|
679
|
+
import { execFile } from "node:child_process";
|
|
680
|
+
import { promisify } from "node:util";
|
|
681
|
+
var execFileAsync = promisify(execFile);
|
|
682
|
+
var ARTIFACT_MARKER = "__argentArtifact";
|
|
683
|
+
function isArtifactHandle(value) {
|
|
684
|
+
return !!value && typeof value === "object" && value[ARTIFACT_MARKER] === true && typeof value.id === "string" && typeof value.filename === "string";
|
|
685
|
+
}
|
|
686
|
+
var SESSION_ID = null;
|
|
687
|
+
function sessionId() {
|
|
688
|
+
if (!SESSION_ID) {
|
|
689
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:T]/g, (m2) => m2 === "T" ? "-" : "").slice(0, 15);
|
|
690
|
+
SESSION_ID = `${stamp}-${process.pid}`;
|
|
691
|
+
}
|
|
692
|
+
return SESSION_ID;
|
|
693
|
+
}
|
|
694
|
+
function sanitizeSegment(segment) {
|
|
695
|
+
return segment.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
696
|
+
}
|
|
697
|
+
function projectSlug() {
|
|
698
|
+
const cwd = process.cwd();
|
|
699
|
+
const hash = createHash("sha1").update(cwd).digest("hex").slice(0, 6);
|
|
700
|
+
const name = sanitizeSegment(basename(cwd)) || "root";
|
|
701
|
+
return `${name}-${hash}`;
|
|
702
|
+
}
|
|
703
|
+
function artifactsRoot() {
|
|
704
|
+
return process.env.ARGENT_ARTIFACTS_DIR ?? join3(tmpdir(), "argent-artifacts");
|
|
705
|
+
}
|
|
706
|
+
function artifactDir(deviceId) {
|
|
707
|
+
const parts = [artifactsRoot(), projectSlug(), sessionId()];
|
|
708
|
+
if (deviceId) parts.push(sanitizeSegment(deviceId));
|
|
709
|
+
return join3(...parts);
|
|
710
|
+
}
|
|
711
|
+
async function resolveLocalFile(handle) {
|
|
712
|
+
if (!handle.hostPath) return null;
|
|
713
|
+
try {
|
|
714
|
+
const st2 = await stat2(handle.hostPath);
|
|
715
|
+
if (handle.archive) {
|
|
716
|
+
return st2.isDirectory() ? handle.hostPath : null;
|
|
717
|
+
}
|
|
718
|
+
if (!st2.isFile()) return null;
|
|
719
|
+
if (st2.size !== handle.size) return null;
|
|
720
|
+
if (handle.mtimeMs != null && Math.round(st2.mtimeMs) !== Math.round(handle.mtimeMs)) {
|
|
721
|
+
return null;
|
|
722
|
+
}
|
|
723
|
+
return handle.hostPath;
|
|
724
|
+
} catch {
|
|
725
|
+
return null;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
async function downloadAndExtractArchive(handle, data, dir) {
|
|
729
|
+
const tarball = join3(dir, `${sanitizeSegment(handle.filename)}.tar.gz`);
|
|
730
|
+
try {
|
|
731
|
+
await writeFile4(tarball, data);
|
|
732
|
+
await execFileAsync("tar", ["-xzf", tarball, "-C", dir]);
|
|
733
|
+
return join3(dir, handle.filename);
|
|
734
|
+
} catch {
|
|
735
|
+
return null;
|
|
736
|
+
} finally {
|
|
737
|
+
await rm(tarball, { force: true }).catch(() => {
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
async function materializeArtifacts(result, ctx) {
|
|
742
|
+
const images = [];
|
|
743
|
+
const fetchFn = ctx.fetchImpl ?? fetch;
|
|
744
|
+
const authHeaders3 = ctx.authToken ? { Authorization: `Bearer ${ctx.authToken}` } : {};
|
|
745
|
+
const dir = artifactDir(ctx.deviceId);
|
|
746
|
+
let dirReady = false;
|
|
747
|
+
async function ensureDir() {
|
|
748
|
+
if (!dirReady) {
|
|
749
|
+
await mkdir4(dir, { recursive: true });
|
|
750
|
+
dirReady = true;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
async function walk(value) {
|
|
754
|
+
if (isArtifactHandle(value)) {
|
|
755
|
+
const localPath = await resolveLocalFile(value);
|
|
756
|
+
if (localPath) {
|
|
757
|
+
if (value.mimeType.startsWith("image/")) {
|
|
758
|
+
images.push({ localPath, data: await readFile4(localPath), mimeType: value.mimeType });
|
|
759
|
+
}
|
|
760
|
+
return localPath;
|
|
761
|
+
}
|
|
762
|
+
try {
|
|
763
|
+
const res = await fetchFn(`${ctx.toolsUrl}/artifacts/${value.id}`, {
|
|
764
|
+
headers: authHeaders3
|
|
765
|
+
});
|
|
766
|
+
if (!res.ok) return null;
|
|
767
|
+
const data = Buffer.from(await res.arrayBuffer());
|
|
768
|
+
await ensureDir();
|
|
769
|
+
if (value.archive === "tar.gz") {
|
|
770
|
+
return await downloadAndExtractArchive(value, data, dir);
|
|
771
|
+
}
|
|
772
|
+
if (value.size > 0 && data.length !== value.size) return null;
|
|
773
|
+
const downloadedPath = join3(dir, sanitizeSegment(value.filename));
|
|
774
|
+
await writeFile4(downloadedPath, data);
|
|
775
|
+
if (value.mimeType.startsWith("image/")) {
|
|
776
|
+
images.push({ localPath: downloadedPath, data, mimeType: value.mimeType });
|
|
777
|
+
}
|
|
778
|
+
return downloadedPath;
|
|
779
|
+
} catch {
|
|
780
|
+
return null;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
if (Array.isArray(value)) {
|
|
784
|
+
return Promise.all(value.map(walk));
|
|
785
|
+
}
|
|
786
|
+
if (value && typeof value === "object") {
|
|
787
|
+
const out = {};
|
|
788
|
+
for (const [k2, v2] of Object.entries(value)) {
|
|
789
|
+
out[k2] = await walk(v2);
|
|
790
|
+
}
|
|
791
|
+
return out;
|
|
792
|
+
}
|
|
793
|
+
return value;
|
|
794
|
+
}
|
|
795
|
+
const rewritten = await walk(result);
|
|
796
|
+
return { result: rewritten, images };
|
|
797
|
+
}
|
|
798
|
+
function getDeviceIdFromArgs(args) {
|
|
799
|
+
if (!args || typeof args !== "object") return void 0;
|
|
800
|
+
const rec = args;
|
|
801
|
+
if (typeof rec.udid === "string") return rec.udid;
|
|
802
|
+
if (typeof rec.device_id === "string") return rec.device_id;
|
|
803
|
+
return void 0;
|
|
804
|
+
}
|
|
805
|
+
|
|
569
806
|
// ../argent-cli/src/flag-parser.ts
|
|
570
807
|
var FlagParseException = class extends Error {
|
|
571
808
|
};
|
|
@@ -798,20 +1035,22 @@ async function fetchImageToFile(result, outPath) {
|
|
|
798
1035
|
const res = await fetch(url);
|
|
799
1036
|
if (!res.ok) throw new Error(`Failed to download image: ${res.status} ${res.statusText}`);
|
|
800
1037
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
801
|
-
fs2.mkdirSync(
|
|
1038
|
+
fs2.mkdirSync(path4.dirname(path4.resolve(outPath)), { recursive: true });
|
|
802
1039
|
fs2.writeFileSync(outPath, buf);
|
|
803
1040
|
}
|
|
804
|
-
function renderResult(result, outputHint, json) {
|
|
1041
|
+
function renderResult(result, outputHint, images, json) {
|
|
805
1042
|
if (json) return JSON.stringify(result, null, 2);
|
|
806
|
-
if (outputHint === "image"
|
|
807
|
-
|
|
808
|
-
|
|
1043
|
+
if (outputHint === "image") {
|
|
1044
|
+
if (images.length > 0) return `Saved screenshot: ${images[0].localPath}`;
|
|
1045
|
+
if (result && typeof result === "object" && "path" in result && typeof result.path === "string") {
|
|
1046
|
+
return `Saved screenshot: ${result.path}`;
|
|
1047
|
+
}
|
|
809
1048
|
}
|
|
810
1049
|
if (typeof result === "string") return result;
|
|
811
1050
|
return JSON.stringify(result, null, 2);
|
|
812
1051
|
}
|
|
813
1052
|
async function run(argv, options) {
|
|
814
|
-
const { fetchTool, callTool } = createToolsClient({ paths: options.paths });
|
|
1053
|
+
const { fetchTool, callTool, baseUrl } = createToolsClient({ paths: options.paths });
|
|
815
1054
|
const [toolName, ...rest] = argv;
|
|
816
1055
|
if (!toolName || toolName === "--help" || toolName === "-h") {
|
|
817
1056
|
console.log(`Usage: argent run <tool> [flags]
|
|
@@ -873,24 +1112,37 @@ Examples:
|
|
|
873
1112
|
}
|
|
874
1113
|
let result;
|
|
875
1114
|
let note;
|
|
1115
|
+
let images = [];
|
|
876
1116
|
try {
|
|
877
1117
|
const resp = await callTool(toolName, payload);
|
|
878
|
-
|
|
1118
|
+
const { url, token } = await baseUrl();
|
|
1119
|
+
const materialized = await materializeArtifacts(resp.data, {
|
|
1120
|
+
toolsUrl: url,
|
|
1121
|
+
authToken: token,
|
|
1122
|
+
deviceId: getDeviceIdFromArgs(payload)
|
|
1123
|
+
});
|
|
1124
|
+
result = materialized.result;
|
|
1125
|
+
images = materialized.images;
|
|
879
1126
|
note = resp.note;
|
|
880
1127
|
} catch (err) {
|
|
881
1128
|
console.error(err instanceof Error ? err.message : String(err));
|
|
882
1129
|
process.exit(1);
|
|
883
1130
|
}
|
|
884
|
-
if (outPath && meta.outputHint === "image"
|
|
1131
|
+
if (outPath && meta.outputHint === "image") {
|
|
885
1132
|
try {
|
|
886
|
-
|
|
1133
|
+
if (images.length > 0) {
|
|
1134
|
+
fs2.mkdirSync(path4.dirname(path4.resolve(outPath)), { recursive: true });
|
|
1135
|
+
fs2.writeFileSync(outPath, images[0].data);
|
|
1136
|
+
} else if (result && typeof result === "object") {
|
|
1137
|
+
await fetchImageToFile(result, outPath);
|
|
1138
|
+
}
|
|
887
1139
|
} catch (err) {
|
|
888
1140
|
console.error(`Failed to save image: ${err instanceof Error ? err.message : err}`);
|
|
889
1141
|
process.exit(1);
|
|
890
1142
|
}
|
|
891
1143
|
}
|
|
892
1144
|
if (note) console.error(note);
|
|
893
|
-
console.log(renderResult(result, meta.outputHint, json));
|
|
1145
|
+
console.log(renderResult(result, meta.outputHint, images, json));
|
|
894
1146
|
if (outPath && meta.outputHint === "image" && !json) {
|
|
895
1147
|
console.log(`Wrote: ${outPath}`);
|
|
896
1148
|
}
|
|
@@ -975,12 +1227,12 @@ Options:
|
|
|
975
1227
|
|
|
976
1228
|
// ../argent-cli/src/server.ts
|
|
977
1229
|
import * as fs3 from "node:fs";
|
|
978
|
-
import * as
|
|
1230
|
+
import * as path5 from "node:path";
|
|
979
1231
|
import { homedir as homedir3, networkInterfaces } from "node:os";
|
|
980
1232
|
import { spawn as spawn2 } from "node:child_process";
|
|
981
|
-
var STATE_DIR2 =
|
|
982
|
-
var STATE_FILE2 =
|
|
983
|
-
var LOG_FILE2 =
|
|
1233
|
+
var STATE_DIR2 = path5.join(homedir3(), ".argent");
|
|
1234
|
+
var STATE_FILE2 = path5.join(STATE_DIR2, "tool-server.json");
|
|
1235
|
+
var LOG_FILE2 = path5.join(STATE_DIR2, "tool-server.log");
|
|
984
1236
|
function readState2() {
|
|
985
1237
|
try {
|
|
986
1238
|
return JSON.parse(fs3.readFileSync(STATE_FILE2, "utf8"));
|
|
@@ -1375,1632 +1627,1660 @@ async function server(argv, options) {
|
|
|
1375
1627
|
}
|
|
1376
1628
|
}
|
|
1377
1629
|
|
|
1378
|
-
//
|
|
1379
|
-
|
|
1380
|
-
import { stdout as x, stdin as D } from "node:process";
|
|
1381
|
-
import * as b from "node:readline";
|
|
1382
|
-
import E from "node:readline";
|
|
1630
|
+
// ../argent-cli/src/flags.ts
|
|
1631
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
1383
1632
|
|
|
1384
|
-
//
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1633
|
+
// ../configuration-core/src/flags.ts
|
|
1634
|
+
import * as fs4 from "node:fs";
|
|
1635
|
+
import * as path6 from "node:path";
|
|
1636
|
+
import { homedir as homedir4 } from "node:os";
|
|
1637
|
+
var FLAG_REGISTRY = [
|
|
1638
|
+
{
|
|
1639
|
+
name: "disable-auto-screenshot",
|
|
1640
|
+
description: "Disable the automatic screenshot captured after interaction tools."
|
|
1641
|
+
},
|
|
1642
|
+
{
|
|
1643
|
+
name: "argent-lens",
|
|
1644
|
+
description: "Argent Lens \u2014 the propose_variant / await_user_selection tools and the Electron preview window for staging UI design variants and letting a human pick among them. Off by default while the feature is in development."
|
|
1645
|
+
},
|
|
1646
|
+
{
|
|
1647
|
+
name: "artifacts-list-endpoint",
|
|
1648
|
+
description: "Expose GET /artifacts for remote artifact inventory consumers."
|
|
1649
|
+
}
|
|
1650
|
+
];
|
|
1651
|
+
function getFlagDefinition(name, registry = FLAG_REGISTRY) {
|
|
1652
|
+
return registry.find((def) => def.name === name);
|
|
1653
|
+
}
|
|
1654
|
+
var PROJECT_MARKERS = [".argent", ".git", "package.json"];
|
|
1655
|
+
function resolveProjectRoot(startDir) {
|
|
1656
|
+
const initial = path6.resolve(startDir);
|
|
1657
|
+
let current = initial;
|
|
1658
|
+
while (true) {
|
|
1659
|
+
for (const marker of PROJECT_MARKERS) {
|
|
1660
|
+
if (fs4.existsSync(path6.join(current, marker))) return current;
|
|
1392
1661
|
}
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
const
|
|
1421
|
-
|
|
1422
|
-
const
|
|
1423
|
-
const
|
|
1424
|
-
[
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
let truncationEnabled = false;
|
|
1436
|
-
let truncationIndex = length;
|
|
1437
|
-
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
1438
|
-
let unmatchedStart = 0;
|
|
1439
|
-
let unmatchedEnd = 0;
|
|
1440
|
-
let width = 0;
|
|
1441
|
-
let widthExtra = 0;
|
|
1442
|
-
outer: while (true) {
|
|
1443
|
-
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
1444
|
-
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
1445
|
-
lengthExtra = 0;
|
|
1446
|
-
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
1447
|
-
const codePoint = char.codePointAt(0) || 0;
|
|
1448
|
-
if (isFullWidth(codePoint)) {
|
|
1449
|
-
widthExtra = FULL_WIDTH_WIDTH;
|
|
1450
|
-
} else if (isWideNotCJKTNotEmoji(codePoint)) {
|
|
1451
|
-
widthExtra = WIDE_WIDTH;
|
|
1452
|
-
} else {
|
|
1453
|
-
widthExtra = REGULAR_WIDTH;
|
|
1454
|
-
}
|
|
1455
|
-
if (width + widthExtra > truncationLimit) {
|
|
1456
|
-
truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
1457
|
-
}
|
|
1458
|
-
if (width + widthExtra > LIMIT) {
|
|
1459
|
-
truncationEnabled = true;
|
|
1460
|
-
break outer;
|
|
1461
|
-
}
|
|
1462
|
-
lengthExtra += char.length;
|
|
1463
|
-
width += widthExtra;
|
|
1464
|
-
}
|
|
1465
|
-
unmatchedStart = unmatchedEnd = 0;
|
|
1466
|
-
}
|
|
1467
|
-
if (index >= length) {
|
|
1468
|
-
break outer;
|
|
1469
|
-
}
|
|
1470
|
-
for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
|
|
1471
|
-
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
1472
|
-
BLOCK_RE.lastIndex = index;
|
|
1473
|
-
if (BLOCK_RE.test(input)) {
|
|
1474
|
-
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
1475
|
-
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
1476
|
-
if (width + widthExtra > truncationLimit) {
|
|
1477
|
-
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
1478
|
-
}
|
|
1479
|
-
if (width + widthExtra > LIMIT) {
|
|
1480
|
-
truncationEnabled = true;
|
|
1481
|
-
break outer;
|
|
1482
|
-
}
|
|
1483
|
-
width += widthExtra;
|
|
1484
|
-
unmatchedStart = indexPrev;
|
|
1485
|
-
unmatchedEnd = index;
|
|
1486
|
-
index = indexPrev = BLOCK_RE.lastIndex;
|
|
1487
|
-
continue outer;
|
|
1662
|
+
const parent = path6.dirname(current);
|
|
1663
|
+
if (parent === current) return initial;
|
|
1664
|
+
current = parent;
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
function getFlagsPath(scope, options = {}) {
|
|
1668
|
+
const home = options.homeDir ?? homedir4();
|
|
1669
|
+
if (scope === "global") {
|
|
1670
|
+
return path6.join(home, ".argent", "flags.json");
|
|
1671
|
+
}
|
|
1672
|
+
const cwd = options.cwd ?? process.cwd();
|
|
1673
|
+
return path6.join(resolveProjectRoot(cwd), ".argent", "flags.json");
|
|
1674
|
+
}
|
|
1675
|
+
function readFlagsFile(filePath) {
|
|
1676
|
+
let raw;
|
|
1677
|
+
try {
|
|
1678
|
+
raw = fs4.readFileSync(filePath, "utf8");
|
|
1679
|
+
} catch {
|
|
1680
|
+
return {};
|
|
1681
|
+
}
|
|
1682
|
+
let parsed;
|
|
1683
|
+
try {
|
|
1684
|
+
parsed = JSON.parse(raw);
|
|
1685
|
+
} catch {
|
|
1686
|
+
return {};
|
|
1687
|
+
}
|
|
1688
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
|
|
1689
|
+
const flags2 = parsed.flags;
|
|
1690
|
+
if (!flags2 || typeof flags2 !== "object" || Array.isArray(flags2)) return {};
|
|
1691
|
+
const out = {};
|
|
1692
|
+
for (const [k2, v2] of Object.entries(flags2)) {
|
|
1693
|
+
if (typeof v2 === "boolean") out[k2] = v2;
|
|
1694
|
+
}
|
|
1695
|
+
return out;
|
|
1696
|
+
}
|
|
1697
|
+
function writeFlagsFile(filePath, flags2) {
|
|
1698
|
+
if (Object.keys(flags2).length === 0) {
|
|
1699
|
+
if (fs4.existsSync(filePath)) fs4.rmSync(filePath, { force: true });
|
|
1700
|
+
const parent = path6.dirname(filePath);
|
|
1701
|
+
try {
|
|
1702
|
+
if (fs4.existsSync(parent) && fs4.readdirSync(parent).length === 0) {
|
|
1703
|
+
fs4.rmdirSync(parent);
|
|
1488
1704
|
}
|
|
1705
|
+
} catch {
|
|
1489
1706
|
}
|
|
1490
|
-
|
|
1707
|
+
return;
|
|
1491
1708
|
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1709
|
+
fs4.mkdirSync(path6.dirname(filePath), { recursive: true });
|
|
1710
|
+
const tmp = `${filePath}.${process.pid}.tmp`;
|
|
1711
|
+
fs4.writeFileSync(tmp, JSON.stringify({ flags: flags2 }, null, 2) + "\n");
|
|
1712
|
+
fs4.renameSync(tmp, filePath);
|
|
1713
|
+
}
|
|
1714
|
+
function readFlags(scope, options = {}) {
|
|
1715
|
+
return readFlagsFile(getFlagsPath(scope, options));
|
|
1716
|
+
}
|
|
1717
|
+
function setFlag(name, value, scope, options = {}) {
|
|
1718
|
+
const filePath = getFlagsPath(scope, options);
|
|
1719
|
+
const current = readFlagsFile(filePath);
|
|
1720
|
+
current[name] = value;
|
|
1721
|
+
writeFlagsFile(filePath, current);
|
|
1722
|
+
}
|
|
1723
|
+
function unsetFlag(name, scope, options = {}) {
|
|
1724
|
+
const filePath = getFlagsPath(scope, options);
|
|
1725
|
+
const current = readFlagsFile(filePath);
|
|
1726
|
+
if (!Object.hasOwn(current, name)) return false;
|
|
1727
|
+
delete current[name];
|
|
1728
|
+
writeFlagsFile(filePath, current);
|
|
1729
|
+
return true;
|
|
1730
|
+
}
|
|
1731
|
+
function isFlagEnabled(name, options = {}) {
|
|
1732
|
+
const projectFlags = readFlags("project", options);
|
|
1733
|
+
if (Object.hasOwn(projectFlags, name)) return projectFlags[name];
|
|
1734
|
+
const globalFlags = readFlags("global", options);
|
|
1735
|
+
if (Object.hasOwn(globalFlags, name)) return globalFlags[name];
|
|
1736
|
+
return false;
|
|
1737
|
+
}
|
|
1511
1738
|
|
|
1512
|
-
//
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
var
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
if (openingCode >= 100 && openingCode <= 107)
|
|
1530
|
-
return 49;
|
|
1531
|
-
if (openingCode === 1 || openingCode === 2)
|
|
1532
|
-
return 22;
|
|
1533
|
-
if (openingCode === 3)
|
|
1534
|
-
return 23;
|
|
1535
|
-
if (openingCode === 4)
|
|
1536
|
-
return 24;
|
|
1537
|
-
if (openingCode === 7)
|
|
1538
|
-
return 27;
|
|
1539
|
-
if (openingCode === 8)
|
|
1540
|
-
return 28;
|
|
1541
|
-
if (openingCode === 9)
|
|
1542
|
-
return 29;
|
|
1543
|
-
if (openingCode === 0)
|
|
1544
|
-
return 0;
|
|
1545
|
-
return void 0;
|
|
1546
|
-
};
|
|
1547
|
-
var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
1548
|
-
var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
1549
|
-
var wrapWord = (rows, word, columns) => {
|
|
1550
|
-
const characters = word[Symbol.iterator]();
|
|
1551
|
-
let isInsideEscape = false;
|
|
1552
|
-
let isInsideLinkEscape = false;
|
|
1553
|
-
let lastRow = rows.at(-1);
|
|
1554
|
-
let visible = lastRow === void 0 ? 0 : dist_default2(lastRow);
|
|
1555
|
-
let currentCharacter = characters.next();
|
|
1556
|
-
let nextCharacter = characters.next();
|
|
1557
|
-
let rawCharacterIndex = 0;
|
|
1558
|
-
while (!currentCharacter.done) {
|
|
1559
|
-
const character = currentCharacter.value;
|
|
1560
|
-
const characterLength = dist_default2(character);
|
|
1561
|
-
if (visible + characterLength <= columns) {
|
|
1562
|
-
rows[rows.length - 1] += character;
|
|
1563
|
-
} else {
|
|
1564
|
-
rows.push(character);
|
|
1565
|
-
visible = 0;
|
|
1739
|
+
// ../argent-cli/src/flags.ts
|
|
1740
|
+
function colorState(enabled) {
|
|
1741
|
+
const label = (enabled ? "enabled" : "disabled").padEnd(8);
|
|
1742
|
+
if (!process.stdout.isTTY) return label;
|
|
1743
|
+
return enabled ? import_picocolors.default.green(label) : import_picocolors.default.red(label);
|
|
1744
|
+
}
|
|
1745
|
+
var FLAG_NAME_RE = /^[a-zA-Z][a-zA-Z0-9._-]*$/;
|
|
1746
|
+
function parseToggleArgs(argv, command) {
|
|
1747
|
+
let name = null;
|
|
1748
|
+
let scope = "global";
|
|
1749
|
+
let positionalOnly = false;
|
|
1750
|
+
for (let i = 0; i < argv.length; i++) {
|
|
1751
|
+
const tok = argv[i];
|
|
1752
|
+
if (positionalOnly) {
|
|
1753
|
+
if (name !== null) throw new Error(`Unexpected extra argument: "${tok}"`);
|
|
1754
|
+
name = tok;
|
|
1755
|
+
continue;
|
|
1566
1756
|
}
|
|
1567
|
-
if (
|
|
1568
|
-
|
|
1569
|
-
|
|
1757
|
+
if (tok === "--") {
|
|
1758
|
+
positionalOnly = true;
|
|
1759
|
+
continue;
|
|
1570
1760
|
}
|
|
1571
|
-
if (
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
1578
|
-
isInsideEscape = false;
|
|
1579
|
-
}
|
|
1580
|
-
} else {
|
|
1581
|
-
visible += characterLength;
|
|
1582
|
-
if (visible === columns && !nextCharacter.done) {
|
|
1583
|
-
rows.push("");
|
|
1584
|
-
visible = 0;
|
|
1585
|
-
}
|
|
1761
|
+
if (tok === "--scope") {
|
|
1762
|
+
const v2 = argv[i + 1];
|
|
1763
|
+
if (v2 === void 0) throw new Error("--scope requires a value (project|global)");
|
|
1764
|
+
scope = parseScope(v2);
|
|
1765
|
+
i += 1;
|
|
1766
|
+
continue;
|
|
1586
1767
|
}
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
}
|
|
1591
|
-
lastRow = rows.at(-1);
|
|
1592
|
-
if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) {
|
|
1593
|
-
rows[rows.length - 2] += rows.pop();
|
|
1594
|
-
}
|
|
1595
|
-
};
|
|
1596
|
-
var stringVisibleTrimSpacesRight = (string) => {
|
|
1597
|
-
const words = string.split(" ");
|
|
1598
|
-
let last = words.length;
|
|
1599
|
-
while (last) {
|
|
1600
|
-
if (dist_default2(words[last - 1])) {
|
|
1601
|
-
break;
|
|
1768
|
+
if (tok.startsWith("--scope=")) {
|
|
1769
|
+
scope = parseScope(tok.slice("--scope=".length));
|
|
1770
|
+
continue;
|
|
1602
1771
|
}
|
|
1603
|
-
|
|
1772
|
+
if (tok.startsWith("--")) {
|
|
1773
|
+
throw new Error(`Unknown flag: ${tok}`);
|
|
1774
|
+
}
|
|
1775
|
+
if (name !== null) {
|
|
1776
|
+
throw new Error(`Unexpected extra argument: "${tok}"`);
|
|
1777
|
+
}
|
|
1778
|
+
name = tok;
|
|
1604
1779
|
}
|
|
1605
|
-
if (
|
|
1606
|
-
|
|
1780
|
+
if (name === null) {
|
|
1781
|
+
throw new Error(`Usage: argent ${command} <flag-name> [--scope project|global]`);
|
|
1607
1782
|
}
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
return "";
|
|
1613
|
-
}
|
|
1614
|
-
let returnValue = "";
|
|
1615
|
-
let escapeCode;
|
|
1616
|
-
let escapeUrl;
|
|
1617
|
-
const words = string.split(" ");
|
|
1618
|
-
let rows = [""];
|
|
1619
|
-
let rowLength = 0;
|
|
1620
|
-
for (let index = 0; index < words.length; index++) {
|
|
1621
|
-
const word = words[index];
|
|
1622
|
-
if (options.trim !== false) {
|
|
1623
|
-
const row = rows.at(-1) ?? "";
|
|
1624
|
-
const trimmed = row.trimStart();
|
|
1625
|
-
if (row.length !== trimmed.length) {
|
|
1626
|
-
rows[rows.length - 1] = trimmed;
|
|
1627
|
-
rowLength = dist_default2(trimmed);
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
if (index !== 0) {
|
|
1631
|
-
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
1632
|
-
rows.push("");
|
|
1633
|
-
rowLength = 0;
|
|
1634
|
-
}
|
|
1635
|
-
if (rowLength || options.trim === false) {
|
|
1636
|
-
rows[rows.length - 1] += " ";
|
|
1637
|
-
rowLength++;
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
const wordLength = dist_default2(word);
|
|
1641
|
-
if (options.hard && wordLength > columns) {
|
|
1642
|
-
const remainingColumns = columns - rowLength;
|
|
1643
|
-
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
1644
|
-
const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
|
|
1645
|
-
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
1646
|
-
rows.push("");
|
|
1647
|
-
}
|
|
1648
|
-
wrapWord(rows, word, columns);
|
|
1649
|
-
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
1650
|
-
continue;
|
|
1651
|
-
}
|
|
1652
|
-
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
1653
|
-
if (options.wordWrap === false && rowLength < columns) {
|
|
1654
|
-
wrapWord(rows, word, columns);
|
|
1655
|
-
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
1656
|
-
continue;
|
|
1657
|
-
}
|
|
1658
|
-
rows.push("");
|
|
1659
|
-
rowLength = 0;
|
|
1660
|
-
}
|
|
1661
|
-
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
1662
|
-
wrapWord(rows, word, columns);
|
|
1663
|
-
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
1664
|
-
continue;
|
|
1665
|
-
}
|
|
1666
|
-
rows[rows.length - 1] += word;
|
|
1667
|
-
rowLength += wordLength;
|
|
1668
|
-
}
|
|
1669
|
-
if (options.trim !== false) {
|
|
1670
|
-
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
1671
|
-
}
|
|
1672
|
-
const preString = rows.join("\n");
|
|
1673
|
-
let inSurrogate = false;
|
|
1674
|
-
for (let i = 0; i < preString.length; i++) {
|
|
1675
|
-
const character = preString[i];
|
|
1676
|
-
returnValue += character;
|
|
1677
|
-
if (!inSurrogate) {
|
|
1678
|
-
inSurrogate = character >= "\uD800" && character <= "\uDBFF";
|
|
1679
|
-
if (inSurrogate) {
|
|
1680
|
-
continue;
|
|
1681
|
-
}
|
|
1682
|
-
} else {
|
|
1683
|
-
inSurrogate = false;
|
|
1684
|
-
}
|
|
1685
|
-
if (character === ESC || character === CSI) {
|
|
1686
|
-
GROUP_REGEX.lastIndex = i + 1;
|
|
1687
|
-
const groupsResult = GROUP_REGEX.exec(preString);
|
|
1688
|
-
const groups = groupsResult?.groups;
|
|
1689
|
-
if (groups?.code !== void 0) {
|
|
1690
|
-
const code = Number.parseFloat(groups.code);
|
|
1691
|
-
escapeCode = code === END_CODE ? void 0 : code;
|
|
1692
|
-
} else if (groups?.uri !== void 0) {
|
|
1693
|
-
escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
if (preString[i + 1] === "\n") {
|
|
1697
|
-
if (escapeUrl) {
|
|
1698
|
-
returnValue += wrapAnsiHyperlink("");
|
|
1699
|
-
}
|
|
1700
|
-
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
|
|
1701
|
-
if (escapeCode && closingCode) {
|
|
1702
|
-
returnValue += wrapAnsiCode(closingCode);
|
|
1703
|
-
}
|
|
1704
|
-
} else if (character === "\n") {
|
|
1705
|
-
if (escapeCode && getClosingCode(escapeCode)) {
|
|
1706
|
-
returnValue += wrapAnsiCode(escapeCode);
|
|
1707
|
-
}
|
|
1708
|
-
if (escapeUrl) {
|
|
1709
|
-
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
1710
|
-
}
|
|
1711
|
-
}
|
|
1783
|
+
if (!FLAG_NAME_RE.test(name)) {
|
|
1784
|
+
throw new Error(
|
|
1785
|
+
`Invalid flag name "${name}". Must start with a letter and contain only letters, digits, ".", "_", or "-".`
|
|
1786
|
+
);
|
|
1712
1787
|
}
|
|
1713
|
-
return
|
|
1714
|
-
};
|
|
1715
|
-
var CRLF_OR_LF = /\r?\n/;
|
|
1716
|
-
function wrapAnsi(string, columns, options) {
|
|
1717
|
-
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
|
|
1718
|
-
}
|
|
1719
|
-
|
|
1720
|
-
// ../../node_modules/@clack/core/dist/index.mjs
|
|
1721
|
-
var import_sisteransi = __toESM(require_src(), 1);
|
|
1722
|
-
import { ReadStream as O } from "node:tty";
|
|
1723
|
-
function f(r, t, s) {
|
|
1724
|
-
if (!s.some((o) => !o.disabled)) return r;
|
|
1725
|
-
const e2 = r + t, i = Math.max(s.length - 1, 0), n = e2 < 0 ? i : e2 > i ? 0 : e2;
|
|
1726
|
-
return s[n].disabled ? f(n, t < 0 ? -1 : 1, s) : n;
|
|
1727
|
-
}
|
|
1728
|
-
var G = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
1729
|
-
var K = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
1730
|
-
var h = { actions: new Set(G), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true, date: { monthNames: [...K], messages: { required: "Please enter a valid date", invalidMonth: "There are only 12 months in a year", invalidDay: (r, t) => `There are only ${r} days in ${t}`, afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`, beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}` } } };
|
|
1731
|
-
function C(r, t) {
|
|
1732
|
-
if (typeof r == "string") return h.aliases.get(r) === t;
|
|
1733
|
-
for (const s of r) if (s !== void 0 && C(s, t)) return true;
|
|
1734
|
-
return false;
|
|
1735
|
-
}
|
|
1736
|
-
function z(r, t) {
|
|
1737
|
-
if (r === t) return;
|
|
1738
|
-
const s = r.split(`
|
|
1739
|
-
`), e2 = t.split(`
|
|
1740
|
-
`), i = Math.max(s.length, e2.length), n = [];
|
|
1741
|
-
for (let o = 0; o < i; o++) s[o] !== e2[o] && n.push(o);
|
|
1742
|
-
return { lines: n, numLinesBefore: s.length, numLinesAfter: e2.length, numLines: i };
|
|
1743
|
-
}
|
|
1744
|
-
var Y = globalThis.process.platform.startsWith("win");
|
|
1745
|
-
var k = /* @__PURE__ */ Symbol("clack:cancel");
|
|
1746
|
-
function q(r) {
|
|
1747
|
-
return r === k;
|
|
1788
|
+
return { name, scope };
|
|
1748
1789
|
}
|
|
1749
|
-
function
|
|
1750
|
-
|
|
1751
|
-
|
|
1790
|
+
function parseScope(raw) {
|
|
1791
|
+
if (raw === "global" || raw === "project") return raw;
|
|
1792
|
+
throw new Error(`--scope must be "project" or "global", got "${raw}"`);
|
|
1752
1793
|
}
|
|
1753
|
-
function
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
return;
|
|
1761
|
-
}
|
|
1762
|
-
if (!s) return;
|
|
1763
|
-
const c = u === "return" ? 0 : -1, y = u === "return" ? -1 : 0;
|
|
1764
|
-
b.moveCursor(t, c, y, () => {
|
|
1765
|
-
b.clearLine(t, 1, () => {
|
|
1766
|
-
r.once("keypress", n);
|
|
1767
|
-
});
|
|
1768
|
-
});
|
|
1769
|
-
};
|
|
1770
|
-
return e2 && t.write(import_sisteransi.cursor.hide), r.once("keypress", n), () => {
|
|
1771
|
-
r.off("keypress", n), e2 && t.write(import_sisteransi.cursor.show), r instanceof O && r.isTTY && !Y && r.setRawMode(false), i.terminal = false, i.close();
|
|
1772
|
-
};
|
|
1794
|
+
function formatAvailableFlags(registry) {
|
|
1795
|
+
if (registry.length === 0) {
|
|
1796
|
+
return "Available flags:\n (none defined)";
|
|
1797
|
+
}
|
|
1798
|
+
const maxName = registry.reduce((m2, def) => Math.max(m2, def.name.length), 0);
|
|
1799
|
+
const lines = registry.map((def) => ` ${def.name.padEnd(maxName)} ${def.description}`);
|
|
1800
|
+
return ["Available flags:", ...lines].join("\n");
|
|
1773
1801
|
}
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1802
|
+
function printToggleHelp(command, registry) {
|
|
1803
|
+
const summary = command === "enable" ? "Enable a predefined feature flag (see `argent flags`) at the chosen scope." : "Remove a feature flag entry at the chosen scope. Falls back to the global value if set; otherwise the flag is treated as off.";
|
|
1804
|
+
console.log(`Usage: argent ${command} <flag-name> [--scope project|global]
|
|
1805
|
+
|
|
1806
|
+
${summary}
|
|
1807
|
+
|
|
1808
|
+
${formatAvailableFlags(registry)}
|
|
1809
|
+
|
|
1810
|
+
Storage:
|
|
1811
|
+
~/.argent/flags.json (global, default)
|
|
1812
|
+
<project-root>/.argent/flags.json (project, with --scope project)
|
|
1813
|
+
|
|
1814
|
+
Options:
|
|
1815
|
+
--scope <global|project> Where to write (default: global)
|
|
1816
|
+
--help, -h Show this help
|
|
1783
1817
|
`);
|
|
1784
1818
|
}
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
rl;
|
|
1790
|
-
opts;
|
|
1791
|
-
_render;
|
|
1792
|
-
_track = false;
|
|
1793
|
-
_prevFrame = "";
|
|
1794
|
-
_subscribers = /* @__PURE__ */ new Map();
|
|
1795
|
-
_cursor = 0;
|
|
1796
|
-
state = "initial";
|
|
1797
|
-
error = "";
|
|
1798
|
-
value;
|
|
1799
|
-
userInput = "";
|
|
1800
|
-
constructor(t, s = true) {
|
|
1801
|
-
const { input: e2 = D, output: i = x, render: n, signal: o, ...u } = t;
|
|
1802
|
-
this.opts = u, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = o, this.input = e2, this.output = i;
|
|
1803
|
-
}
|
|
1804
|
-
unsubscribe() {
|
|
1805
|
-
this._subscribers.clear();
|
|
1819
|
+
function runToggle(argv, command, registry) {
|
|
1820
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
1821
|
+
printToggleHelp(command, registry);
|
|
1822
|
+
return;
|
|
1806
1823
|
}
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1824
|
+
let parsed;
|
|
1825
|
+
try {
|
|
1826
|
+
parsed = parseToggleArgs(argv, command);
|
|
1827
|
+
} catch (err) {
|
|
1828
|
+
console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
1829
|
+
process.exit(2);
|
|
1810
1830
|
}
|
|
1811
|
-
|
|
1812
|
-
|
|
1831
|
+
if (command === "enable" && getFlagDefinition(parsed.name, registry) === void 0) {
|
|
1832
|
+
console.error(
|
|
1833
|
+
`Error: Unknown feature flag "${parsed.name}". Run \`argent flags\` to see available flags.`
|
|
1834
|
+
);
|
|
1835
|
+
process.exit(2);
|
|
1813
1836
|
}
|
|
1814
|
-
|
|
1815
|
-
|
|
1837
|
+
const filePath = getFlagsPath(parsed.scope);
|
|
1838
|
+
try {
|
|
1839
|
+
if (command === "enable") {
|
|
1840
|
+
setFlag(parsed.name, true, parsed.scope);
|
|
1841
|
+
} else {
|
|
1842
|
+
unsetFlag(parsed.name, parsed.scope);
|
|
1843
|
+
}
|
|
1844
|
+
} catch (err) {
|
|
1845
|
+
console.error(`Failed to ${command} flag: ${err instanceof Error ? err.message : String(err)}`);
|
|
1846
|
+
process.exit(1);
|
|
1816
1847
|
}
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1848
|
+
if (command === "enable") {
|
|
1849
|
+
console.log(`Enabled flag "${parsed.name}" (${parsed.scope}). Stored at ${filePath}.`);
|
|
1850
|
+
} else {
|
|
1851
|
+
console.log(`Disabled flag "${parsed.name}" (${parsed.scope}).`);
|
|
1821
1852
|
}
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
return
|
|
1853
|
+
}
|
|
1854
|
+
function enable(argv, registry = FLAG_REGISTRY) {
|
|
1855
|
+
runToggle(argv, "enable", registry);
|
|
1856
|
+
}
|
|
1857
|
+
function disable(argv, registry = FLAG_REGISTRY) {
|
|
1858
|
+
runToggle(argv, "disable", registry);
|
|
1859
|
+
}
|
|
1860
|
+
function flags(argv, registry = FLAG_REGISTRY) {
|
|
1861
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
1862
|
+
console.log(`Usage: argent flags [--json]
|
|
1863
|
+
|
|
1864
|
+
List the available feature flags and their current state. Flags are
|
|
1865
|
+
predefined; project-scoped values override global ones.
|
|
1866
|
+
|
|
1867
|
+
${formatAvailableFlags(registry)}
|
|
1868
|
+
|
|
1869
|
+
Options:
|
|
1870
|
+
--json Print machine-readable JSON
|
|
1871
|
+
`);
|
|
1872
|
+
return;
|
|
1842
1873
|
}
|
|
1843
|
-
|
|
1844
|
-
|
|
1874
|
+
const json = argv.includes("--json");
|
|
1875
|
+
const projectFlags = readFlags("project");
|
|
1876
|
+
const globalFlags = readFlags("global");
|
|
1877
|
+
const effective = {};
|
|
1878
|
+
for (const [k2, v2] of Object.entries(globalFlags)) effective[k2] = { value: v2, scope: "global" };
|
|
1879
|
+
for (const [k2, v2] of Object.entries(projectFlags)) effective[k2] = { value: v2, scope: "project" };
|
|
1880
|
+
const registryView = registry.map((def) => {
|
|
1881
|
+
const eff = Object.hasOwn(effective, def.name) ? effective[def.name] : void 0;
|
|
1882
|
+
return {
|
|
1883
|
+
name: def.name,
|
|
1884
|
+
description: def.description,
|
|
1885
|
+
enabled: eff?.value ?? false,
|
|
1886
|
+
scope: eff?.scope ?? null
|
|
1887
|
+
};
|
|
1888
|
+
});
|
|
1889
|
+
const known = new Set(registry.map((def) => def.name));
|
|
1890
|
+
const unrecognized = Object.keys(effective).filter((name) => !known.has(name)).sort().map((name) => ({ name, enabled: effective[name].value, scope: effective[name].scope }));
|
|
1891
|
+
if (json) {
|
|
1892
|
+
console.log(
|
|
1893
|
+
JSON.stringify(
|
|
1894
|
+
{
|
|
1895
|
+
flags: registryView,
|
|
1896
|
+
unrecognized,
|
|
1897
|
+
global: globalFlags,
|
|
1898
|
+
project: projectFlags,
|
|
1899
|
+
effective,
|
|
1900
|
+
paths: {
|
|
1901
|
+
global: getFlagsPath("global"),
|
|
1902
|
+
project: getFlagsPath("project")
|
|
1903
|
+
}
|
|
1904
|
+
},
|
|
1905
|
+
null,
|
|
1906
|
+
2
|
|
1907
|
+
)
|
|
1908
|
+
);
|
|
1909
|
+
return;
|
|
1845
1910
|
}
|
|
1846
|
-
|
|
1847
|
-
|
|
1911
|
+
if (registryView.length === 0) {
|
|
1912
|
+
console.log("No feature flags are defined.");
|
|
1913
|
+
} else {
|
|
1914
|
+
console.log("Feature flags (project overrides global):");
|
|
1915
|
+
const maxName = registryView.reduce((m2, f2) => Math.max(m2, f2.name.length), 0);
|
|
1916
|
+
for (const f2 of registryView) {
|
|
1917
|
+
const scopeLabel = f2.scope ? ` (${f2.scope})` : "";
|
|
1918
|
+
console.log(` ${f2.name.padEnd(maxName, " ")} ${colorState(f2.enabled)}${scopeLabel}`);
|
|
1919
|
+
console.log(` ${" ".repeat(maxName)} ${f2.description}`);
|
|
1920
|
+
}
|
|
1848
1921
|
}
|
|
1849
|
-
|
|
1850
|
-
|
|
1922
|
+
if (unrecognized.length > 0) {
|
|
1923
|
+
console.log("\nStored but no longer recognized (safe to `argent disable`):");
|
|
1924
|
+
const maxName = unrecognized.reduce((m2, f2) => Math.max(m2, f2.name.length), 0);
|
|
1925
|
+
for (const f2 of unrecognized) {
|
|
1926
|
+
console.log(` ${f2.name.padEnd(maxName, " ")} ${colorState(f2.enabled)} (${f2.scope})`);
|
|
1927
|
+
}
|
|
1851
1928
|
}
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1929
|
+
console.log(`
|
|
1930
|
+
Global: ${getFlagsPath("global")}`);
|
|
1931
|
+
console.log(` Project: ${getFlagsPath("project")}`);
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
// ../../node_modules/@clack/core/dist/index.mjs
|
|
1935
|
+
import { styleText as v } from "node:util";
|
|
1936
|
+
import { stdout as x, stdin as D } from "node:process";
|
|
1937
|
+
import * as b from "node:readline";
|
|
1938
|
+
import E from "node:readline";
|
|
1939
|
+
|
|
1940
|
+
// ../../node_modules/fast-string-truncated-width/dist/utils.js
|
|
1941
|
+
var getCodePointsLength = /* @__PURE__ */ (() => {
|
|
1942
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
1943
|
+
return (input) => {
|
|
1944
|
+
let surrogatePairsNr = 0;
|
|
1945
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
1946
|
+
while (SURROGATE_PAIR_RE.test(input)) {
|
|
1947
|
+
surrogatePairsNr += 1;
|
|
1948
|
+
}
|
|
1949
|
+
return input.length - surrogatePairsNr;
|
|
1950
|
+
};
|
|
1951
|
+
})();
|
|
1952
|
+
var isFullWidth = (x3) => {
|
|
1953
|
+
return x3 === 12288 || x3 >= 65281 && x3 <= 65376 || x3 >= 65504 && x3 <= 65510;
|
|
1954
|
+
};
|
|
1955
|
+
var isWideNotCJKTNotEmoji = (x3) => {
|
|
1956
|
+
return x3 === 8987 || x3 === 9001 || x3 >= 12272 && x3 <= 12287 || x3 >= 12289 && x3 <= 12350 || x3 >= 12441 && x3 <= 12543 || x3 >= 12549 && x3 <= 12591 || x3 >= 12593 && x3 <= 12686 || x3 >= 12688 && x3 <= 12771 || x3 >= 12783 && x3 <= 12830 || x3 >= 12832 && x3 <= 12871 || x3 >= 12880 && x3 <= 19903 || x3 >= 65040 && x3 <= 65049 || x3 >= 65072 && x3 <= 65106 || x3 >= 65108 && x3 <= 65126 || x3 >= 65128 && x3 <= 65131 || x3 >= 127488 && x3 <= 127490 || x3 >= 127504 && x3 <= 127547 || x3 >= 127552 && x3 <= 127560 || x3 >= 131072 && x3 <= 196605 || x3 >= 196608 && x3 <= 262141;
|
|
1957
|
+
};
|
|
1958
|
+
|
|
1959
|
+
// ../../node_modules/fast-string-truncated-width/dist/index.js
|
|
1960
|
+
var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
1961
|
+
var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
1962
|
+
var CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
|
|
1963
|
+
var TAB_RE = /\t{1,1000}/y;
|
|
1964
|
+
var EMOJI_RE = new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*", "yu");
|
|
1965
|
+
var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
1966
|
+
var MODIFIER_RE = new RegExp("\\p{M}+", "gu");
|
|
1967
|
+
var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
|
|
1968
|
+
var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
1969
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
1970
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
1971
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
1972
|
+
const ANSI_WIDTH = 0;
|
|
1973
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
1974
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
1975
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
1976
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
1977
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
1978
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
1979
|
+
const PARSE_BLOCKS = [
|
|
1980
|
+
[LATIN_RE, REGULAR_WIDTH],
|
|
1981
|
+
[ANSI_RE, ANSI_WIDTH],
|
|
1982
|
+
[CONTROL_RE, CONTROL_WIDTH],
|
|
1983
|
+
[TAB_RE, TAB_WIDTH],
|
|
1984
|
+
[EMOJI_RE, EMOJI_WIDTH],
|
|
1985
|
+
[CJKT_WIDE_RE, WIDE_WIDTH]
|
|
1986
|
+
];
|
|
1987
|
+
let indexPrev = 0;
|
|
1988
|
+
let index = 0;
|
|
1989
|
+
let length = input.length;
|
|
1990
|
+
let lengthExtra = 0;
|
|
1991
|
+
let truncationEnabled = false;
|
|
1992
|
+
let truncationIndex = length;
|
|
1993
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
1994
|
+
let unmatchedStart = 0;
|
|
1995
|
+
let unmatchedEnd = 0;
|
|
1996
|
+
let width = 0;
|
|
1997
|
+
let widthExtra = 0;
|
|
1998
|
+
outer: while (true) {
|
|
1999
|
+
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
2000
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
2001
|
+
lengthExtra = 0;
|
|
2002
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
2003
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
2004
|
+
if (isFullWidth(codePoint)) {
|
|
2005
|
+
widthExtra = FULL_WIDTH_WIDTH;
|
|
2006
|
+
} else if (isWideNotCJKTNotEmoji(codePoint)) {
|
|
2007
|
+
widthExtra = WIDE_WIDTH;
|
|
2008
|
+
} else {
|
|
2009
|
+
widthExtra = REGULAR_WIDTH;
|
|
2010
|
+
}
|
|
2011
|
+
if (width + widthExtra > truncationLimit) {
|
|
2012
|
+
truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
2013
|
+
}
|
|
2014
|
+
if (width + widthExtra > LIMIT) {
|
|
2015
|
+
truncationEnabled = true;
|
|
2016
|
+
break outer;
|
|
2017
|
+
}
|
|
2018
|
+
lengthExtra += char.length;
|
|
2019
|
+
width += widthExtra;
|
|
1857
2020
|
}
|
|
1858
|
-
|
|
2021
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
1859
2022
|
}
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
render() {
|
|
1872
|
-
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
|
|
1873
|
-
if (t !== this._prevFrame) {
|
|
1874
|
-
if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
|
|
1875
|
-
else {
|
|
1876
|
-
const s = z(this._prevFrame, t), e2 = L(this.output);
|
|
1877
|
-
if (this.restoreCursor(), s) {
|
|
1878
|
-
const i = Math.max(0, s.numLinesAfter - e2), n = Math.max(0, s.numLinesBefore - e2);
|
|
1879
|
-
let o = s.lines.find((u) => u >= i);
|
|
1880
|
-
if (o === void 0) {
|
|
1881
|
-
this._prevFrame = t;
|
|
1882
|
-
return;
|
|
1883
|
-
}
|
|
1884
|
-
if (s.lines.length === 1) {
|
|
1885
|
-
this.output.write(import_sisteransi.cursor.move(0, o - n)), this.output.write(import_sisteransi.erase.lines(1));
|
|
1886
|
-
const u = t.split(`
|
|
1887
|
-
`);
|
|
1888
|
-
this.output.write(u[o]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, u.length - o - 1));
|
|
1889
|
-
return;
|
|
1890
|
-
} else if (s.lines.length > 1) {
|
|
1891
|
-
if (i < n) o = i;
|
|
1892
|
-
else {
|
|
1893
|
-
const a = o - n;
|
|
1894
|
-
a > 0 && this.output.write(import_sisteransi.cursor.move(0, a));
|
|
1895
|
-
}
|
|
1896
|
-
this.output.write(import_sisteransi.erase.down());
|
|
1897
|
-
const u = t.split(`
|
|
1898
|
-
`).slice(o);
|
|
1899
|
-
this.output.write(u.join(`
|
|
1900
|
-
`)), this._prevFrame = t;
|
|
1901
|
-
return;
|
|
1902
|
-
}
|
|
2023
|
+
if (index >= length) {
|
|
2024
|
+
break outer;
|
|
2025
|
+
}
|
|
2026
|
+
for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
|
|
2027
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
2028
|
+
BLOCK_RE.lastIndex = index;
|
|
2029
|
+
if (BLOCK_RE.test(input)) {
|
|
2030
|
+
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
2031
|
+
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
2032
|
+
if (width + widthExtra > truncationLimit) {
|
|
2033
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
1903
2034
|
}
|
|
1904
|
-
|
|
2035
|
+
if (width + widthExtra > LIMIT) {
|
|
2036
|
+
truncationEnabled = true;
|
|
2037
|
+
break outer;
|
|
2038
|
+
}
|
|
2039
|
+
width += widthExtra;
|
|
2040
|
+
unmatchedStart = indexPrev;
|
|
2041
|
+
unmatchedEnd = index;
|
|
2042
|
+
index = indexPrev = BLOCK_RE.lastIndex;
|
|
2043
|
+
continue outer;
|
|
1905
2044
|
}
|
|
1906
|
-
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
1907
2045
|
}
|
|
2046
|
+
index += 1;
|
|
1908
2047
|
}
|
|
2048
|
+
return {
|
|
2049
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
2050
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
2051
|
+
truncated: truncationEnabled,
|
|
2052
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
2053
|
+
};
|
|
1909
2054
|
};
|
|
1910
|
-
var
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
constructor(t) {
|
|
1918
|
-
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
1919
|
-
this.value = this._value;
|
|
1920
|
-
}), this.on("confirm", (s) => {
|
|
1921
|
-
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
|
|
1922
|
-
}), this.on("cursor", () => {
|
|
1923
|
-
this.value = !this.value;
|
|
1924
|
-
});
|
|
1925
|
-
}
|
|
1926
|
-
};
|
|
1927
|
-
var ut = class extends m {
|
|
1928
|
-
options;
|
|
1929
|
-
cursor = 0;
|
|
1930
|
-
get _selectedValue() {
|
|
1931
|
-
return this.options[this.cursor];
|
|
1932
|
-
}
|
|
1933
|
-
changeValue() {
|
|
1934
|
-
this.value = this._selectedValue.value;
|
|
1935
|
-
}
|
|
1936
|
-
constructor(t) {
|
|
1937
|
-
super(t, false), this.options = t.options;
|
|
1938
|
-
const s = this.options.findIndex(({ value: i }) => i === t.initialValue), e2 = s === -1 ? 0 : s;
|
|
1939
|
-
this.cursor = this.options[e2].disabled ? f(e2, 1, this.options) : e2, this.changeValue(), this.on("cursor", (i) => {
|
|
1940
|
-
switch (i) {
|
|
1941
|
-
case "left":
|
|
1942
|
-
case "up":
|
|
1943
|
-
this.cursor = f(this.cursor, -1, this.options);
|
|
1944
|
-
break;
|
|
1945
|
-
case "down":
|
|
1946
|
-
case "right":
|
|
1947
|
-
this.cursor = f(this.cursor, 1, this.options);
|
|
1948
|
-
break;
|
|
1949
|
-
}
|
|
1950
|
-
this.changeValue();
|
|
1951
|
-
});
|
|
1952
|
-
}
|
|
2055
|
+
var dist_default = getStringTruncatedWidth;
|
|
2056
|
+
|
|
2057
|
+
// ../../node_modules/fast-string-width/dist/index.js
|
|
2058
|
+
var NO_TRUNCATION2 = {
|
|
2059
|
+
limit: Infinity,
|
|
2060
|
+
ellipsis: "",
|
|
2061
|
+
ellipsisWidth: 0
|
|
1953
2062
|
};
|
|
1954
|
-
var
|
|
1955
|
-
|
|
1956
|
-
if (this.state === "submit") return this.userInput;
|
|
1957
|
-
const t = this.userInput;
|
|
1958
|
-
if (this.cursor >= t.length) return `${this.userInput}\u2588`;
|
|
1959
|
-
const s = t.slice(0, this.cursor), [e2, ...i] = t.slice(this.cursor);
|
|
1960
|
-
return `${s}${v("inverse", e2)}${i.join("")}`;
|
|
1961
|
-
}
|
|
1962
|
-
get cursor() {
|
|
1963
|
-
return this._cursor;
|
|
1964
|
-
}
|
|
1965
|
-
constructor(t) {
|
|
1966
|
-
super({ ...t, initialUserInput: t.initialUserInput ?? t.initialValue }), this.on("userInput", (s) => {
|
|
1967
|
-
this._setValue(s);
|
|
1968
|
-
}), this.on("finalize", () => {
|
|
1969
|
-
this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
|
|
1970
|
-
});
|
|
1971
|
-
}
|
|
2063
|
+
var fastStringWidth = (input, options = {}) => {
|
|
2064
|
+
return dist_default(input, NO_TRUNCATION2, options).width;
|
|
1972
2065
|
};
|
|
2066
|
+
var dist_default2 = fastStringWidth;
|
|
1973
2067
|
|
|
1974
|
-
// ../../node_modules
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
var
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
}
|
|
1983
|
-
var
|
|
1984
|
-
var
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
var pt = w2("\u25C6", "*");
|
|
2009
|
-
var mt = w2("\u25B2", "!");
|
|
2010
|
-
var gt = w2("\u25A0", "x");
|
|
2011
|
-
var P = (t) => {
|
|
2012
|
-
switch (t) {
|
|
2013
|
-
case "initial":
|
|
2014
|
-
case "active":
|
|
2015
|
-
return e("cyan", Tt);
|
|
2016
|
-
case "cancel":
|
|
2017
|
-
return e("red", at2);
|
|
2018
|
-
case "error":
|
|
2019
|
-
return e("yellow", ut2);
|
|
2020
|
-
case "submit":
|
|
2021
|
-
return e("green", H);
|
|
2022
|
-
}
|
|
2068
|
+
// ../../node_modules/fast-wrap-ansi/lib/main.js
|
|
2069
|
+
var ESC = "\x1B";
|
|
2070
|
+
var CSI = "\x9B";
|
|
2071
|
+
var END_CODE = 39;
|
|
2072
|
+
var ANSI_ESCAPE_BELL = "\x07";
|
|
2073
|
+
var ANSI_CSI = "[";
|
|
2074
|
+
var ANSI_OSC = "]";
|
|
2075
|
+
var ANSI_SGR_TERMINATOR = "m";
|
|
2076
|
+
var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
2077
|
+
var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
2078
|
+
var getClosingCode = (openingCode) => {
|
|
2079
|
+
if (openingCode >= 30 && openingCode <= 37)
|
|
2080
|
+
return 39;
|
|
2081
|
+
if (openingCode >= 90 && openingCode <= 97)
|
|
2082
|
+
return 39;
|
|
2083
|
+
if (openingCode >= 40 && openingCode <= 47)
|
|
2084
|
+
return 49;
|
|
2085
|
+
if (openingCode >= 100 && openingCode <= 107)
|
|
2086
|
+
return 49;
|
|
2087
|
+
if (openingCode === 1 || openingCode === 2)
|
|
2088
|
+
return 22;
|
|
2089
|
+
if (openingCode === 3)
|
|
2090
|
+
return 23;
|
|
2091
|
+
if (openingCode === 4)
|
|
2092
|
+
return 24;
|
|
2093
|
+
if (openingCode === 7)
|
|
2094
|
+
return 27;
|
|
2095
|
+
if (openingCode === 8)
|
|
2096
|
+
return 28;
|
|
2097
|
+
if (openingCode === 9)
|
|
2098
|
+
return 29;
|
|
2099
|
+
if (openingCode === 0)
|
|
2100
|
+
return 0;
|
|
2101
|
+
return void 0;
|
|
2023
2102
|
};
|
|
2024
|
-
var
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2103
|
+
var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
2104
|
+
var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
2105
|
+
var wrapWord = (rows, word, columns) => {
|
|
2106
|
+
const characters = word[Symbol.iterator]();
|
|
2107
|
+
let isInsideEscape = false;
|
|
2108
|
+
let isInsideLinkEscape = false;
|
|
2109
|
+
let lastRow = rows.at(-1);
|
|
2110
|
+
let visible = lastRow === void 0 ? 0 : dist_default2(lastRow);
|
|
2111
|
+
let currentCharacter = characters.next();
|
|
2112
|
+
let nextCharacter = characters.next();
|
|
2113
|
+
let rawCharacterIndex = 0;
|
|
2114
|
+
while (!currentCharacter.done) {
|
|
2115
|
+
const character = currentCharacter.value;
|
|
2116
|
+
const characterLength = dist_default2(character);
|
|
2117
|
+
if (visible + characterLength <= columns) {
|
|
2118
|
+
rows[rows.length - 1] += character;
|
|
2119
|
+
} else {
|
|
2120
|
+
rows.push(character);
|
|
2121
|
+
visible = 0;
|
|
2122
|
+
}
|
|
2123
|
+
if (character === ESC || character === CSI) {
|
|
2124
|
+
isInsideEscape = true;
|
|
2125
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
2126
|
+
}
|
|
2127
|
+
if (isInsideEscape) {
|
|
2128
|
+
if (isInsideLinkEscape) {
|
|
2129
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
2130
|
+
isInsideEscape = false;
|
|
2131
|
+
isInsideLinkEscape = false;
|
|
2132
|
+
}
|
|
2133
|
+
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
2134
|
+
isInsideEscape = false;
|
|
2135
|
+
}
|
|
2136
|
+
} else {
|
|
2137
|
+
visible += characterLength;
|
|
2138
|
+
if (visible === columns && !nextCharacter.done) {
|
|
2139
|
+
rows.push("");
|
|
2140
|
+
visible = 0;
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
currentCharacter = nextCharacter;
|
|
2144
|
+
nextCharacter = characters.next();
|
|
2145
|
+
rawCharacterIndex += character.length;
|
|
2146
|
+
}
|
|
2147
|
+
lastRow = rows.at(-1);
|
|
2148
|
+
if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) {
|
|
2149
|
+
rows[rows.length - 2] += rows.pop();
|
|
2035
2150
|
}
|
|
2036
2151
|
};
|
|
2037
|
-
var
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
let p2 = 0;
|
|
2046
|
-
t >= g - 3 && (p2 = Math.max(Math.min(t - g + 3, i.length - g), 0));
|
|
2047
|
-
let f2 = g < i.length && p2 > 0, h2 = g < i.length && p2 + g < i.length;
|
|
2048
|
-
const I = Math.min(p2 + g, i.length), m2 = [];
|
|
2049
|
-
let y = 0;
|
|
2050
|
-
f2 && y++, h2 && y++;
|
|
2051
|
-
const v2 = p2 + (f2 ? 1 : 0), C2 = I - (h2 ? 1 : 0);
|
|
2052
|
-
for (let b2 = v2; b2 < C2; b2++) {
|
|
2053
|
-
const G2 = wrapAnsi(s(i[b2], b2 === t), c, { hard: true, trim: false }).split(`
|
|
2054
|
-
`);
|
|
2055
|
-
m2.push(G2), y += G2.length;
|
|
2152
|
+
var stringVisibleTrimSpacesRight = (string) => {
|
|
2153
|
+
const words = string.split(" ");
|
|
2154
|
+
let last = words.length;
|
|
2155
|
+
while (last) {
|
|
2156
|
+
if (dist_default2(words[last - 1])) {
|
|
2157
|
+
break;
|
|
2158
|
+
}
|
|
2159
|
+
last--;
|
|
2056
2160
|
}
|
|
2057
|
-
if (
|
|
2058
|
-
|
|
2059
|
-
const N = t - v2;
|
|
2060
|
-
let O2 = d;
|
|
2061
|
-
const j2 = () => Ot(m2, M, 0, N, O2), k2 = () => Ot(m2, M, N + 1, m2.length, O2, true);
|
|
2062
|
-
f2 ? ({ lineCount: M, removals: b2 } = j2(), M > O2 && (h2 || (O2 -= 1), { lineCount: M, removals: G2 } = k2())) : (h2 || (O2 -= 1), { lineCount: M, removals: G2 } = k2(), M > O2 && (O2 -= 1, { lineCount: M, removals: b2 } = j2())), b2 > 0 && (f2 = true, m2.splice(0, b2)), G2 > 0 && (h2 = true, m2.splice(m2.length - G2, G2));
|
|
2161
|
+
if (last === words.length) {
|
|
2162
|
+
return string;
|
|
2063
2163
|
}
|
|
2064
|
-
|
|
2065
|
-
f2 && S.push(l);
|
|
2066
|
-
for (const b2 of m2) for (const G2 of b2) S.push(G2);
|
|
2067
|
-
return h2 && S.push(l), S;
|
|
2164
|
+
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
2068
2165
|
};
|
|
2069
|
-
var
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2166
|
+
var exec = (string, columns, options = {}) => {
|
|
2167
|
+
if (options.trim !== false && string.trim() === "") {
|
|
2168
|
+
return "";
|
|
2169
|
+
}
|
|
2170
|
+
let returnValue = "";
|
|
2171
|
+
let escapeCode;
|
|
2172
|
+
let escapeUrl;
|
|
2173
|
+
const words = string.split(" ");
|
|
2174
|
+
let rows = [""];
|
|
2175
|
+
let rowLength = 0;
|
|
2176
|
+
for (let index = 0; index < words.length; index++) {
|
|
2177
|
+
const word = words[index];
|
|
2178
|
+
if (options.trim !== false) {
|
|
2179
|
+
const row = rows.at(-1) ?? "";
|
|
2180
|
+
const trimmed = row.trimStart();
|
|
2181
|
+
if (row.length !== trimmed.length) {
|
|
2182
|
+
rows[rows.length - 1] = trimmed;
|
|
2183
|
+
rowLength = dist_default2(trimmed);
|
|
2079
2184
|
}
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2185
|
+
}
|
|
2186
|
+
if (index !== 0) {
|
|
2187
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
2188
|
+
rows.push("");
|
|
2189
|
+
rowLength = 0;
|
|
2084
2190
|
}
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
${e("cyan", $)} ` : `
|
|
2089
|
-
` : ` ${e("dim", "/")} `}${this.value ? `${e("dim", U)} ${e("dim", s)}` : `${e("green", z2)} ${s}`}
|
|
2090
|
-
${d}
|
|
2091
|
-
`;
|
|
2191
|
+
if (rowLength || options.trim === false) {
|
|
2192
|
+
rows[rows.length - 1] += " ";
|
|
2193
|
+
rowLength++;
|
|
2092
2194
|
}
|
|
2093
2195
|
}
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2196
|
+
const wordLength = dist_default2(word);
|
|
2197
|
+
if (options.hard && wordLength > columns) {
|
|
2198
|
+
const remainingColumns = columns - rowLength;
|
|
2199
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
2200
|
+
const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
|
|
2201
|
+
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
2202
|
+
rows.push("");
|
|
2203
|
+
}
|
|
2204
|
+
wrapWord(rows, word, columns);
|
|
2205
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
2206
|
+
continue;
|
|
2207
|
+
}
|
|
2208
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
2209
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
2210
|
+
wrapWord(rows, word, columns);
|
|
2211
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
2212
|
+
continue;
|
|
2213
|
+
}
|
|
2214
|
+
rows.push("");
|
|
2215
|
+
rowLength = 0;
|
|
2216
|
+
}
|
|
2217
|
+
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
2218
|
+
wrapWord(rows, word, columns);
|
|
2219
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
2220
|
+
continue;
|
|
2221
|
+
}
|
|
2222
|
+
rows[rows.length - 1] += word;
|
|
2223
|
+
rowLength += wordLength;
|
|
2105
2224
|
}
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
R2.warn(t, i);
|
|
2119
|
-
}, error: (t, i) => {
|
|
2120
|
-
R2.message(t, { ...i, symbol: e("red", gt) });
|
|
2121
|
-
} };
|
|
2122
|
-
var me = (t = "", i) => {
|
|
2123
|
-
const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${e("gray", x2)} ` : "";
|
|
2124
|
-
s.write(`${r}${e("red", t)}
|
|
2125
|
-
|
|
2126
|
-
`);
|
|
2127
|
-
};
|
|
2128
|
-
var ge = (t = "", i) => {
|
|
2129
|
-
const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${e("gray", lt)} ` : "";
|
|
2130
|
-
s.write(`${r}${t}
|
|
2131
|
-
`);
|
|
2132
|
-
};
|
|
2133
|
-
var ye = (t = "", i) => {
|
|
2134
|
-
const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${e("gray", $)}
|
|
2135
|
-
${e("gray", x2)} ` : "";
|
|
2136
|
-
s.write(`${r}${t}
|
|
2137
|
-
|
|
2138
|
-
`);
|
|
2139
|
-
};
|
|
2140
|
-
var Te = (t) => e("magenta", t);
|
|
2141
|
-
var ft = ({ indicator: t = "dots", onCancel: i, output: s = process.stdout, cancelMessage: r, errorMessage: u, frames: n = tt ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], delay: a = tt ? 80 : 120, signal: c, ...o } = {}) => {
|
|
2142
|
-
const l = ot2();
|
|
2143
|
-
let d, g, p2 = false, f2 = false, h2 = "", I, m2 = performance.now();
|
|
2144
|
-
const y = A(s), v2 = o?.styleFrame ?? Te, C2 = (_) => {
|
|
2145
|
-
const A2 = _ > 1 ? u ?? h.messages.error : r ?? h.messages.cancel;
|
|
2146
|
-
f2 = _ === 1, p2 && (W2(A2, _), f2 && typeof i == "function" && i());
|
|
2147
|
-
}, S = () => C2(2), b2 = () => C2(1), G2 = () => {
|
|
2148
|
-
process.on("uncaughtExceptionMonitor", S), process.on("unhandledRejection", S), process.on("SIGINT", b2), process.on("SIGTERM", b2), process.on("exit", C2), c && c.addEventListener("abort", b2);
|
|
2149
|
-
}, M = () => {
|
|
2150
|
-
process.removeListener("uncaughtExceptionMonitor", S), process.removeListener("unhandledRejection", S), process.removeListener("SIGINT", b2), process.removeListener("SIGTERM", b2), process.removeListener("exit", C2), c && c.removeEventListener("abort", b2);
|
|
2151
|
-
}, N = () => {
|
|
2152
|
-
if (I === void 0) return;
|
|
2153
|
-
l && s.write(`
|
|
2154
|
-
`);
|
|
2155
|
-
const _ = wrapAnsi(I, y, { hard: true, trim: false }).split(`
|
|
2156
|
-
`);
|
|
2157
|
-
_.length > 1 && s.write(import_sisteransi2.cursor.up(_.length - 1)), s.write(import_sisteransi2.cursor.to(0)), s.write(import_sisteransi2.erase.down());
|
|
2158
|
-
}, O2 = (_) => _.replace(/\.+$/, ""), j2 = (_) => {
|
|
2159
|
-
const A2 = (performance.now() - _) / 1e3, L2 = Math.floor(A2 / 60), D2 = Math.floor(A2 % 60);
|
|
2160
|
-
return L2 > 0 ? `[${L2}m ${D2}s]` : `[${D2}s]`;
|
|
2161
|
-
}, k2 = o.withGuide ?? h.withGuide, rt2 = (_ = "") => {
|
|
2162
|
-
p2 = true, d = R({ output: s }), h2 = O2(_), m2 = performance.now(), k2 && s.write(`${e("gray", $)}
|
|
2163
|
-
`);
|
|
2164
|
-
let A2 = 0, L2 = 0;
|
|
2165
|
-
G2(), g = setInterval(() => {
|
|
2166
|
-
if (l && h2 === I) return;
|
|
2167
|
-
N(), I = h2;
|
|
2168
|
-
const D2 = v2(n[A2]);
|
|
2169
|
-
let Z;
|
|
2170
|
-
if (l) Z = `${D2} ${h2}...`;
|
|
2171
|
-
else if (t === "timer") Z = `${D2} ${h2} ${j2(m2)}`;
|
|
2172
|
-
else {
|
|
2173
|
-
const kt = ".".repeat(Math.floor(L2)).slice(0, 3);
|
|
2174
|
-
Z = `${D2} ${h2}${kt}`;
|
|
2225
|
+
if (options.trim !== false) {
|
|
2226
|
+
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
2227
|
+
}
|
|
2228
|
+
const preString = rows.join("\n");
|
|
2229
|
+
let inSurrogate = false;
|
|
2230
|
+
for (let i = 0; i < preString.length; i++) {
|
|
2231
|
+
const character = preString[i];
|
|
2232
|
+
returnValue += character;
|
|
2233
|
+
if (!inSurrogate) {
|
|
2234
|
+
inSurrogate = character >= "\uD800" && character <= "\uDBFF";
|
|
2235
|
+
if (inSurrogate) {
|
|
2236
|
+
continue;
|
|
2175
2237
|
}
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
}, a);
|
|
2179
|
-
}, W2 = (_ = "", A2 = 0, L2 = false) => {
|
|
2180
|
-
if (!p2) return;
|
|
2181
|
-
p2 = false, clearInterval(g), N();
|
|
2182
|
-
const D2 = A2 === 0 ? e("green", H) : A2 === 1 ? e("red", at2) : e("red", ut2);
|
|
2183
|
-
h2 = _ ?? h2, L2 || (t === "timer" ? s.write(`${D2} ${h2} ${j2(m2)}
|
|
2184
|
-
`) : s.write(`${D2} ${h2}
|
|
2185
|
-
`)), M(), d();
|
|
2186
|
-
};
|
|
2187
|
-
return { start: rt2, stop: (_ = "") => W2(_, 0), message: (_ = "") => {
|
|
2188
|
-
h2 = O2(_ ?? h2);
|
|
2189
|
-
}, cancel: (_ = "") => W2(_, 1), error: (_ = "") => W2(_, 2), clear: () => W2("", 0, true), get isCancelled() {
|
|
2190
|
-
return f2;
|
|
2191
|
-
} };
|
|
2192
|
-
};
|
|
2193
|
-
var jt = { light: w2("\u2500", "-"), heavy: w2("\u2501", "="), block: w2("\u2588", "#") };
|
|
2194
|
-
var it2 = (t, i) => t.includes(`
|
|
2195
|
-
`) ? t.split(`
|
|
2196
|
-
`).map((s) => i(s)).join(`
|
|
2197
|
-
`) : i(t);
|
|
2198
|
-
var xe = (t) => {
|
|
2199
|
-
const i = (s, r) => {
|
|
2200
|
-
const u = s.label ?? String(s.value);
|
|
2201
|
-
switch (r) {
|
|
2202
|
-
case "disabled":
|
|
2203
|
-
return `${e("gray", U)} ${it2(u, (n) => e("gray", n))}${s.hint ? ` ${e("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
2204
|
-
case "selected":
|
|
2205
|
-
return `${it2(u, (n) => e("dim", n))}`;
|
|
2206
|
-
case "active":
|
|
2207
|
-
return `${e("green", z2)} ${u}${s.hint ? ` ${e("dim", `(${s.hint})`)}` : ""}`;
|
|
2208
|
-
case "cancelled":
|
|
2209
|
-
return `${it2(u, (n) => e(["strikethrough", "dim"], n))}`;
|
|
2210
|
-
default:
|
|
2211
|
-
return `${e("dim", U)} ${it2(u, (n) => e("dim", n))}`;
|
|
2238
|
+
} else {
|
|
2239
|
+
inSurrogate = false;
|
|
2212
2240
|
}
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2241
|
+
if (character === ESC || character === CSI) {
|
|
2242
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
2243
|
+
const groupsResult = GROUP_REGEX.exec(preString);
|
|
2244
|
+
const groups = groupsResult?.groups;
|
|
2245
|
+
if (groups?.code !== void 0) {
|
|
2246
|
+
const code = Number.parseFloat(groups.code);
|
|
2247
|
+
escapeCode = code === END_CODE ? void 0 : code;
|
|
2248
|
+
} else if (groups?.uri !== void 0) {
|
|
2249
|
+
escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
2222
2250
|
}
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2251
|
+
}
|
|
2252
|
+
if (preString[i + 1] === "\n") {
|
|
2253
|
+
if (escapeUrl) {
|
|
2254
|
+
returnValue += wrapAnsiHyperlink("");
|
|
2227
2255
|
}
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2256
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
|
|
2257
|
+
if (escapeCode && closingCode) {
|
|
2258
|
+
returnValue += wrapAnsiCode(closingCode);
|
|
2259
|
+
}
|
|
2260
|
+
} else if (character === "\n") {
|
|
2261
|
+
if (escapeCode && getClosingCode(escapeCode)) {
|
|
2262
|
+
returnValue += wrapAnsiCode(escapeCode);
|
|
2263
|
+
}
|
|
2264
|
+
if (escapeUrl) {
|
|
2265
|
+
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
2235
2266
|
}
|
|
2236
2267
|
}
|
|
2237
|
-
}
|
|
2268
|
+
}
|
|
2269
|
+
return returnValue;
|
|
2238
2270
|
};
|
|
2239
|
-
var
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
`, r = t.placeholder ? e("inverse", t.placeholder[0]) + e("dim", t.placeholder.slice(1)) : e(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
|
|
2244
|
-
switch (this.state) {
|
|
2245
|
-
case "error": {
|
|
2246
|
-
const a = this.error ? ` ${e("yellow", this.error)}` : "", c = i ? `${e("yellow", $)} ` : "", o = i ? e("yellow", x2) : "";
|
|
2247
|
-
return `${s.trim()}
|
|
2248
|
-
${c}${u}
|
|
2249
|
-
${o}${a}
|
|
2250
|
-
`;
|
|
2251
|
-
}
|
|
2252
|
-
case "submit": {
|
|
2253
|
-
const a = n ? ` ${e("dim", n)}` : "", c = i ? e("gray", $) : "";
|
|
2254
|
-
return `${s}${c}${a}`;
|
|
2255
|
-
}
|
|
2256
|
-
case "cancel": {
|
|
2257
|
-
const a = n ? ` ${e(["strikethrough", "dim"], n)}` : "", c = i ? e("gray", $) : "";
|
|
2258
|
-
return `${s}${c}${a}${n.trim() ? `
|
|
2259
|
-
${c}` : ""}`;
|
|
2260
|
-
}
|
|
2261
|
-
default: {
|
|
2262
|
-
const a = i ? `${e("cyan", $)} ` : "", c = i ? e("cyan", x2) : "";
|
|
2263
|
-
return `${s}${a}${u}
|
|
2264
|
-
${c}
|
|
2265
|
-
`;
|
|
2266
|
-
}
|
|
2267
|
-
}
|
|
2268
|
-
} }).prompt();
|
|
2271
|
+
var CRLF_OR_LF = /\r?\n/;
|
|
2272
|
+
function wrapAnsi(string, columns, options) {
|
|
2273
|
+
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
|
|
2274
|
+
}
|
|
2269
2275
|
|
|
2270
|
-
//
|
|
2271
|
-
var
|
|
2272
|
-
|
|
2273
|
-
function
|
|
2274
|
-
|
|
2276
|
+
// ../../node_modules/@clack/core/dist/index.mjs
|
|
2277
|
+
var import_sisteransi = __toESM(require_src(), 1);
|
|
2278
|
+
import { ReadStream as O } from "node:tty";
|
|
2279
|
+
function f(r, t, s) {
|
|
2280
|
+
if (!s.some((o) => !o.disabled)) return r;
|
|
2281
|
+
const e2 = r + t, i = Math.max(s.length - 1, 0), n = e2 < 0 ? i : e2 > i ? 0 : e2;
|
|
2282
|
+
return s[n].disabled ? f(n, t < 0 ? -1 : 1, s) : n;
|
|
2275
2283
|
}
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
return trimmed;
|
|
2284
|
+
var G = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
2285
|
+
var K = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
2286
|
+
var h = { actions: new Set(G), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true, date: { monthNames: [...K], messages: { required: "Please enter a valid date", invalidMonth: "There are only 12 months in a year", invalidDay: (r, t) => `There are only ${r} days in ${t}`, afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`, beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}` } } };
|
|
2287
|
+
function C(r, t) {
|
|
2288
|
+
if (typeof r == "string") return h.aliases.get(r) === t;
|
|
2289
|
+
for (const s of r) if (s !== void 0 && C(s, t)) return true;
|
|
2290
|
+
return false;
|
|
2284
2291
|
}
|
|
2285
|
-
function
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2292
|
+
function z(r, t) {
|
|
2293
|
+
if (r === t) return;
|
|
2294
|
+
const s = r.split(`
|
|
2295
|
+
`), e2 = t.split(`
|
|
2296
|
+
`), i = Math.max(s.length, e2.length), n = [];
|
|
2297
|
+
for (let o = 0; o < i; o++) s[o] !== e2[o] && n.push(o);
|
|
2298
|
+
return { lines: n, numLinesBefore: s.length, numLinesAfter: e2.length, numLines: i };
|
|
2291
2299
|
}
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
token: null,
|
|
2297
|
-
url: null,
|
|
2298
|
-
yes: false,
|
|
2299
|
-
noVerify: false,
|
|
2300
|
-
help: false
|
|
2301
|
-
};
|
|
2302
|
-
for (let i = 0; i < argv.length; i++) {
|
|
2303
|
-
const tok = argv[i];
|
|
2304
|
-
const takeValue = (name) => {
|
|
2305
|
-
const v2 = argv[i + 1];
|
|
2306
|
-
if (v2 === void 0) throw new StartFlagError(`${name} requires a value`);
|
|
2307
|
-
i += 1;
|
|
2308
|
-
return v2;
|
|
2309
|
-
};
|
|
2310
|
-
if (tok === "--help" || tok === "-h") {
|
|
2311
|
-
flags2.help = true;
|
|
2312
|
-
continue;
|
|
2313
|
-
}
|
|
2314
|
-
if (tok === "--yes" || tok === "-y") {
|
|
2315
|
-
flags2.yes = true;
|
|
2316
|
-
continue;
|
|
2317
|
-
}
|
|
2318
|
-
if (tok === "--no-verify") {
|
|
2319
|
-
flags2.noVerify = true;
|
|
2320
|
-
continue;
|
|
2321
|
-
}
|
|
2322
|
-
if (tok === "--host") {
|
|
2323
|
-
flags2.host = validateHost(takeValue("--host"));
|
|
2324
|
-
continue;
|
|
2325
|
-
}
|
|
2326
|
-
if (tok.startsWith("--host=")) {
|
|
2327
|
-
flags2.host = validateHost(tok.slice("--host=".length));
|
|
2328
|
-
continue;
|
|
2329
|
-
}
|
|
2330
|
-
if (tok === "--port" || tok === "-p") {
|
|
2331
|
-
flags2.port = validateConnectPort(takeValue("--port"));
|
|
2332
|
-
continue;
|
|
2333
|
-
}
|
|
2334
|
-
if (tok.startsWith("--port=")) {
|
|
2335
|
-
flags2.port = validateConnectPort(tok.slice("--port=".length));
|
|
2336
|
-
continue;
|
|
2337
|
-
}
|
|
2338
|
-
if (tok === "--token") {
|
|
2339
|
-
flags2.token = takeValue("--token");
|
|
2340
|
-
continue;
|
|
2341
|
-
}
|
|
2342
|
-
if (tok.startsWith("--token=")) {
|
|
2343
|
-
flags2.token = tok.slice("--token=".length);
|
|
2344
|
-
continue;
|
|
2345
|
-
}
|
|
2346
|
-
if (!tok.startsWith("-")) {
|
|
2347
|
-
const parsed = parseLinkTarget(tok);
|
|
2348
|
-
if (!parsed) {
|
|
2349
|
-
throw new StartFlagError(
|
|
2350
|
-
`Unrecognized argument "${tok}". Expected an argent://\u2026 pairing string, an http(s):// URL, or flags (see --help).`
|
|
2351
|
-
);
|
|
2352
|
-
}
|
|
2353
|
-
flags2.host = validateHost(parsed.host);
|
|
2354
|
-
flags2.port = validateConnectPort(String(parsed.port));
|
|
2355
|
-
flags2.url = parsed.url;
|
|
2356
|
-
if (parsed.token) flags2.token = parsed.token;
|
|
2357
|
-
continue;
|
|
2358
|
-
}
|
|
2359
|
-
throw new StartFlagError(`Unknown flag: ${tok}`);
|
|
2360
|
-
}
|
|
2361
|
-
return flags2;
|
|
2300
|
+
var Y = globalThis.process.platform.startsWith("win");
|
|
2301
|
+
var k = /* @__PURE__ */ Symbol("clack:cancel");
|
|
2302
|
+
function q(r) {
|
|
2303
|
+
return r === k;
|
|
2362
2304
|
}
|
|
2363
|
-
function
|
|
2364
|
-
const
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2305
|
+
function w(r, t) {
|
|
2306
|
+
const s = r;
|
|
2307
|
+
s.isTTY && s.setRawMode(t);
|
|
2308
|
+
}
|
|
2309
|
+
function R({ input: r = D, output: t = x, overwrite: s = true, hideCursor: e2 = true } = {}) {
|
|
2310
|
+
const i = b.createInterface({ input: r, output: t, prompt: "", tabSize: 1 });
|
|
2311
|
+
b.emitKeypressEvents(r, i), r instanceof O && r.isTTY && r.setRawMode(true);
|
|
2312
|
+
const n = (o, { name: u, sequence: a }) => {
|
|
2313
|
+
const l = String(o);
|
|
2314
|
+
if (C([l, u, a], "cancel")) {
|
|
2315
|
+
e2 && t.write(import_sisteransi.cursor.show), process.exit(0);
|
|
2316
|
+
return;
|
|
2373
2317
|
}
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2318
|
+
if (!s) return;
|
|
2319
|
+
const c = u === "return" ? 0 : -1, y = u === "return" ? -1 : 0;
|
|
2320
|
+
b.moveCursor(t, c, y, () => {
|
|
2321
|
+
b.clearLine(t, 1, () => {
|
|
2322
|
+
r.once("keypress", n);
|
|
2323
|
+
});
|
|
2324
|
+
});
|
|
2325
|
+
};
|
|
2326
|
+
return e2 && t.write(import_sisteransi.cursor.hide), r.once("keypress", n), () => {
|
|
2327
|
+
r.off("keypress", n), e2 && t.write(import_sisteransi.cursor.show), r instanceof O && r.isTTY && !Y && r.setRawMode(false), i.terminal = false, i.close();
|
|
2328
|
+
};
|
|
2377
2329
|
}
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
- http(s)://<host>[:<port>][/path] a full URL \u2014 use this for a reverse proxy
|
|
2388
|
-
or tunnel (ngrok, cloudflared, nginx). The
|
|
2389
|
-
scheme and any path prefix are preserved;
|
|
2390
|
-
requests go to <url>/tools.
|
|
2391
|
-
|
|
2392
|
-
The easiest LAN path is to paste the connection string from \`argent server start\`:
|
|
2393
|
-
argent link argent://<token>@10.0.0.42:3001
|
|
2394
|
-
For a tunnel, point at its public URL and pass the server's token:
|
|
2395
|
-
argent link https://argent.example.com --token <token>
|
|
2396
|
-
|
|
2397
|
-
Resolution order for the tool-server URL:
|
|
2398
|
-
1. ARGENT_TOOLS_URL environment variable (highest precedence)
|
|
2399
|
-
2. ~/.argent/link.json (this command)
|
|
2400
|
-
3. Auto-spawn a local tool-server (default)
|
|
2401
|
-
|
|
2402
|
-
Flags:
|
|
2403
|
-
--host <h> Remote host or IP to connect to. Prompts interactively if
|
|
2404
|
-
omitted. Wildcards (0.0.0.0, ::) are bind addresses, not
|
|
2405
|
-
connect targets, and are rejected \u2014 use 127.0.0.1 or the
|
|
2406
|
-
actual reachable host.
|
|
2407
|
-
--port, -p <n> Remote port (1..65535). Defaults to 3001. Prompts if omitted.
|
|
2408
|
-
--token <t> Bearer token for a server that enforces auth. Usually
|
|
2409
|
-
supplied inside the argent:// string instead.
|
|
2410
|
-
--no-verify Skip the pre-flight GET /tools health check.
|
|
2411
|
-
--yes, -y Non-interactive. Requires --host (port defaults to 3001).
|
|
2412
|
-
Fails if --host is missing.
|
|
2413
|
-
--help, -h Show this help.
|
|
2414
|
-
|
|
2415
|
-
Examples:
|
|
2416
|
-
argent link argent://ab12\u2026c2@10.0.0.42:3001 Pair from a server-start string.
|
|
2417
|
-
argent link https://argent.example.com --token ab12\u2026c2
|
|
2418
|
-
Link through an HTTPS tunnel/proxy.
|
|
2419
|
-
argent link Interactive prompts for host and port.
|
|
2420
|
-
argent link --host 10.0.0.42 --port 3001 Confirms interactively, then saves.
|
|
2421
|
-
argent link --host 10.0.0.42 --token ab12\u2026c2 --yes
|
|
2422
|
-
Non-interactive, authenticated.
|
|
2423
|
-
argent link --host 10.0.0.42 --yes --no-verify
|
|
2424
|
-
Saves immediately, no health check.
|
|
2425
|
-
|
|
2426
|
-
Security:
|
|
2427
|
-
The token (if any) is stored 0600 and sent as a bearer header. An http:// link
|
|
2428
|
-
has no TLS \u2014 treat any non-loopback http link as trusted-network-only. Prefer
|
|
2429
|
-
an https:// tunnel/proxy when crossing untrusted networks.
|
|
2430
|
-
|
|
2431
|
-
Notes:
|
|
2432
|
-
- If ARGENT_TOOLS_URL is also set in your environment, it overrides the link.
|
|
2433
|
-
- To stop using the remote target, run \`argent unlink\`.
|
|
2434
|
-
- \`argent server start/stop/status\` manage the local tool-server lifecycle
|
|
2435
|
-
and are unaffected by linking.
|
|
2436
|
-
- Restart your editor (Claude / Cursor / VS Code) afterwards \u2014 a running
|
|
2437
|
-
\`argent mcp\` process caches the target at startup and won't pick up the
|
|
2438
|
-
new link until it's relaunched.
|
|
2330
|
+
var A = (r) => "columns" in r && typeof r.columns == "number" ? r.columns : 80;
|
|
2331
|
+
var L = (r) => "rows" in r && typeof r.rows == "number" ? r.rows : 20;
|
|
2332
|
+
function W(r, t, s, e2 = s, i = s, n) {
|
|
2333
|
+
const o = A(r ?? x);
|
|
2334
|
+
return wrapAnsi(t, o - s.length, { hard: true, trim: false }).split(`
|
|
2335
|
+
`).map((u, a, l) => {
|
|
2336
|
+
const c = n ? n(u, a) : u;
|
|
2337
|
+
return a === 0 ? `${e2}${c}` : a === l.length - 1 ? `${i}${c}` : `${s}${c}`;
|
|
2338
|
+
}).join(`
|
|
2439
2339
|
`);
|
|
2440
2340
|
}
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2341
|
+
var m = class {
|
|
2342
|
+
input;
|
|
2343
|
+
output;
|
|
2344
|
+
_abortSignal;
|
|
2345
|
+
rl;
|
|
2346
|
+
opts;
|
|
2347
|
+
_render;
|
|
2348
|
+
_track = false;
|
|
2349
|
+
_prevFrame = "";
|
|
2350
|
+
_subscribers = /* @__PURE__ */ new Map();
|
|
2351
|
+
_cursor = 0;
|
|
2352
|
+
state = "initial";
|
|
2353
|
+
error = "";
|
|
2354
|
+
value;
|
|
2355
|
+
userInput = "";
|
|
2356
|
+
constructor(t, s = true) {
|
|
2357
|
+
const { input: e2 = D, output: i = x, render: n, signal: o, ...u } = t;
|
|
2358
|
+
this.opts = u, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = o, this.input = e2, this.output = i;
|
|
2359
|
+
}
|
|
2360
|
+
unsubscribe() {
|
|
2361
|
+
this._subscribers.clear();
|
|
2362
|
+
}
|
|
2363
|
+
setSubscriber(t, s) {
|
|
2364
|
+
const e2 = this._subscribers.get(t) ?? [];
|
|
2365
|
+
e2.push(s), this._subscribers.set(t, e2);
|
|
2366
|
+
}
|
|
2367
|
+
on(t, s) {
|
|
2368
|
+
this.setSubscriber(t, { cb: s });
|
|
2369
|
+
}
|
|
2370
|
+
once(t, s) {
|
|
2371
|
+
this.setSubscriber(t, { cb: s, once: true });
|
|
2372
|
+
}
|
|
2373
|
+
emit(t, ...s) {
|
|
2374
|
+
const e2 = this._subscribers.get(t) ?? [], i = [];
|
|
2375
|
+
for (const n of e2) n.cb(...s), n.once && i.push(() => e2.splice(e2.indexOf(n), 1));
|
|
2376
|
+
for (const n of i) n();
|
|
2377
|
+
}
|
|
2378
|
+
prompt() {
|
|
2379
|
+
return new Promise((t) => {
|
|
2380
|
+
if (this._abortSignal) {
|
|
2381
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(k);
|
|
2382
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
2383
|
+
this.state = "cancel", this.close();
|
|
2384
|
+
}, { once: true });
|
|
2385
|
+
}
|
|
2386
|
+
this.rl = E.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), w(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
2387
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(this.value);
|
|
2388
|
+
}), this.once("cancel", () => {
|
|
2389
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(k);
|
|
2390
|
+
});
|
|
2391
|
+
});
|
|
2392
|
+
}
|
|
2393
|
+
_isActionKey(t, s) {
|
|
2394
|
+
return t === " ";
|
|
2395
|
+
}
|
|
2396
|
+
_shouldSubmit(t, s) {
|
|
2397
|
+
return true;
|
|
2398
|
+
}
|
|
2399
|
+
_setValue(t) {
|
|
2400
|
+
this.value = t, this.emit("value", this.value);
|
|
2401
|
+
}
|
|
2402
|
+
_setUserInput(t, s) {
|
|
2403
|
+
this.userInput = t ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
2404
|
+
}
|
|
2405
|
+
_clearUserInput() {
|
|
2406
|
+
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
2407
|
+
}
|
|
2408
|
+
onKeypress(t, s) {
|
|
2409
|
+
if (this._track && s.name !== "return" && (s.name && this._isActionKey(t, s) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && h.aliases.has(s.name) && this.emit("cursor", h.aliases.get(s.name)), h.actions.has(s.name) && this.emit("cursor", s.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t?.toLowerCase(), s), s?.name === "return" && this._shouldSubmit(t, s)) {
|
|
2410
|
+
if (this.opts.validate) {
|
|
2411
|
+
const e2 = this.opts.validate(this.value);
|
|
2412
|
+
e2 && (this.error = e2 instanceof Error ? e2.message : e2, this.state = "error", this.rl?.write(this.userInput));
|
|
2475
2413
|
}
|
|
2414
|
+
this.state !== "error" && (this.state = "submit");
|
|
2476
2415
|
}
|
|
2477
|
-
|
|
2478
|
-
if (q(hostInput)) {
|
|
2479
|
-
me("Link cancelled.");
|
|
2480
|
-
process.exit(0);
|
|
2416
|
+
C([t, s?.name, s?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
2481
2417
|
}
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2418
|
+
close() {
|
|
2419
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
2420
|
+
`), w(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
2421
|
+
}
|
|
2422
|
+
restoreCursor() {
|
|
2423
|
+
const t = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
2424
|
+
`).length - 1;
|
|
2425
|
+
this.output.write(import_sisteransi.cursor.move(-999, t * -1));
|
|
2426
|
+
}
|
|
2427
|
+
render() {
|
|
2428
|
+
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
|
|
2429
|
+
if (t !== this._prevFrame) {
|
|
2430
|
+
if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
|
|
2431
|
+
else {
|
|
2432
|
+
const s = z(this._prevFrame, t), e2 = L(this.output);
|
|
2433
|
+
if (this.restoreCursor(), s) {
|
|
2434
|
+
const i = Math.max(0, s.numLinesAfter - e2), n = Math.max(0, s.numLinesBefore - e2);
|
|
2435
|
+
let o = s.lines.find((u) => u >= i);
|
|
2436
|
+
if (o === void 0) {
|
|
2437
|
+
this._prevFrame = t;
|
|
2438
|
+
return;
|
|
2439
|
+
}
|
|
2440
|
+
if (s.lines.length === 1) {
|
|
2441
|
+
this.output.write(import_sisteransi.cursor.move(0, o - n)), this.output.write(import_sisteransi.erase.lines(1));
|
|
2442
|
+
const u = t.split(`
|
|
2443
|
+
`);
|
|
2444
|
+
this.output.write(u[o]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, u.length - o - 1));
|
|
2445
|
+
return;
|
|
2446
|
+
} else if (s.lines.length > 1) {
|
|
2447
|
+
if (i < n) o = i;
|
|
2448
|
+
else {
|
|
2449
|
+
const a = o - n;
|
|
2450
|
+
a > 0 && this.output.write(import_sisteransi.cursor.move(0, a));
|
|
2451
|
+
}
|
|
2452
|
+
this.output.write(import_sisteransi.erase.down());
|
|
2453
|
+
const u = t.split(`
|
|
2454
|
+
`).slice(o);
|
|
2455
|
+
this.output.write(u.join(`
|
|
2456
|
+
`)), this._prevFrame = t;
|
|
2457
|
+
return;
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
this.output.write(import_sisteransi.erase.down());
|
|
2497
2461
|
}
|
|
2462
|
+
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
2498
2463
|
}
|
|
2499
|
-
});
|
|
2500
|
-
if (q(portInput)) {
|
|
2501
|
-
me("Link cancelled.");
|
|
2502
|
-
process.exit(0);
|
|
2503
2464
|
}
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2465
|
+
};
|
|
2466
|
+
var X = class extends m {
|
|
2467
|
+
get cursor() {
|
|
2468
|
+
return this.value ? 0 : 1;
|
|
2469
|
+
}
|
|
2470
|
+
get _value() {
|
|
2471
|
+
return this.cursor === 0;
|
|
2472
|
+
}
|
|
2473
|
+
constructor(t) {
|
|
2474
|
+
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
2475
|
+
this.value = this._value;
|
|
2476
|
+
}), this.on("confirm", (s) => {
|
|
2477
|
+
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
|
|
2478
|
+
}), this.on("cursor", () => {
|
|
2479
|
+
this.value = !this.value;
|
|
2513
2480
|
});
|
|
2514
|
-
if (!res.ok) {
|
|
2515
|
-
const hint = res.status === 401 ? " \u2014 the server requires a token; pass --token or use the argent:// link from `server start`" : res.status === 403 ? " \u2014 the server refused this host (DNS-rebinding guard); reach it by its bind host or start it with --host" : "";
|
|
2516
|
-
return { ok: false, error: `${res.status} ${res.statusText}${hint}` };
|
|
2517
|
-
}
|
|
2518
|
-
return { ok: true };
|
|
2519
|
-
} catch (err) {
|
|
2520
|
-
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
2521
|
-
} finally {
|
|
2522
|
-
clearTimeout(timer);
|
|
2523
2481
|
}
|
|
2524
|
-
}
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
)
|
|
2529
|
-
|
|
2530
|
-
function printSecurityCaveat(host, token, url) {
|
|
2531
|
-
if (isLoopback2(host)) return;
|
|
2532
|
-
const tls = url.startsWith("https://");
|
|
2533
|
-
if (tls) {
|
|
2534
|
-
if (!token) {
|
|
2535
|
-
process.stderr.write(
|
|
2536
|
-
import_picocolors.default.yellow(
|
|
2537
|
-
`WARNING: ${host} is reached over HTTPS but with NO token \u2014 anyone who can reach the URL can drive the server. Pair with a token.
|
|
2538
|
-
`
|
|
2539
|
-
)
|
|
2540
|
-
);
|
|
2541
|
-
}
|
|
2542
|
-
return;
|
|
2482
|
+
};
|
|
2483
|
+
var ut = class extends m {
|
|
2484
|
+
options;
|
|
2485
|
+
cursor = 0;
|
|
2486
|
+
get _selectedValue() {
|
|
2487
|
+
return this.options[this.cursor];
|
|
2543
2488
|
}
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
import_picocolors.default.dim(
|
|
2547
|
-
`Note: ${host} is reached over plain HTTP (bearer-token auth, no TLS). Keep this link to a trusted network or VPN, or front it with an https:// tunnel.
|
|
2548
|
-
`
|
|
2549
|
-
)
|
|
2550
|
-
);
|
|
2551
|
-
return;
|
|
2489
|
+
changeValue() {
|
|
2490
|
+
this.value = this._selectedValue.value;
|
|
2552
2491
|
}
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2492
|
+
constructor(t) {
|
|
2493
|
+
super(t, false), this.options = t.options;
|
|
2494
|
+
const s = this.options.findIndex(({ value: i }) => i === t.initialValue), e2 = s === -1 ? 0 : s;
|
|
2495
|
+
this.cursor = this.options[e2].disabled ? f(e2, 1, this.options) : e2, this.changeValue(), this.on("cursor", (i) => {
|
|
2496
|
+
switch (i) {
|
|
2497
|
+
case "left":
|
|
2498
|
+
case "up":
|
|
2499
|
+
this.cursor = f(this.cursor, -1, this.options);
|
|
2500
|
+
break;
|
|
2501
|
+
case "down":
|
|
2502
|
+
case "right":
|
|
2503
|
+
this.cursor = f(this.cursor, 1, this.options);
|
|
2504
|
+
break;
|
|
2505
|
+
}
|
|
2506
|
+
this.changeValue();
|
|
2507
|
+
});
|
|
2508
|
+
}
|
|
2509
|
+
};
|
|
2510
|
+
var ht = class extends m {
|
|
2511
|
+
get userInputWithCursor() {
|
|
2512
|
+
if (this.state === "submit") return this.userInput;
|
|
2513
|
+
const t = this.userInput;
|
|
2514
|
+
if (this.cursor >= t.length) return `${this.userInput}\u2588`;
|
|
2515
|
+
const s = t.slice(0, this.cursor), [e2, ...i] = t.slice(this.cursor);
|
|
2516
|
+
return `${s}${v("inverse", e2)}${i.join("")}`;
|
|
2517
|
+
}
|
|
2518
|
+
get cursor() {
|
|
2519
|
+
return this._cursor;
|
|
2520
|
+
}
|
|
2521
|
+
constructor(t) {
|
|
2522
|
+
super({ ...t, initialUserInput: t.initialUserInput ?? t.initialValue }), this.on("userInput", (s) => {
|
|
2523
|
+
this._setValue(s);
|
|
2524
|
+
}), this.on("finalize", () => {
|
|
2525
|
+
this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
|
|
2526
|
+
});
|
|
2527
|
+
}
|
|
2528
|
+
};
|
|
2529
|
+
|
|
2530
|
+
// ../../node_modules/@clack/prompts/dist/index.mjs
|
|
2531
|
+
import { styleText as e, stripVTControlCharacters as nt2 } from "node:util";
|
|
2532
|
+
import V2 from "node:process";
|
|
2533
|
+
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
2534
|
+
import { existsSync as Qt, lstatSync as wt, readdirSync as Zt } from "node:fs";
|
|
2535
|
+
import { dirname as bt, join as te } from "node:path";
|
|
2536
|
+
function ee() {
|
|
2537
|
+
return V2.platform !== "win32" ? V2.env.TERM !== "linux" : !!V2.env.CI || !!V2.env.WT_SESSION || !!V2.env.TERMINUS_SUBLIME || V2.env.ConEmuTask === "{cmd::Cmder}" || V2.env.TERM_PROGRAM === "Terminus-Sublime" || V2.env.TERM_PROGRAM === "vscode" || V2.env.TERM === "xterm-256color" || V2.env.TERM === "alacritty" || V2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
2538
|
+
}
|
|
2539
|
+
var tt = ee();
|
|
2540
|
+
var ot2 = () => process.env.CI === "true";
|
|
2541
|
+
var w2 = (t, i) => tt ? t : i;
|
|
2542
|
+
var Tt = w2("\u25C6", "*");
|
|
2543
|
+
var at2 = w2("\u25A0", "x");
|
|
2544
|
+
var ut2 = w2("\u25B2", "x");
|
|
2545
|
+
var H = w2("\u25C7", "o");
|
|
2546
|
+
var lt = w2("\u250C", "T");
|
|
2547
|
+
var $ = w2("\u2502", "|");
|
|
2548
|
+
var x2 = w2("\u2514", "\u2014");
|
|
2549
|
+
var _t = w2("\u2510", "T");
|
|
2550
|
+
var xt = w2("\u2518", "\u2014");
|
|
2551
|
+
var z2 = w2("\u25CF", ">");
|
|
2552
|
+
var U = w2("\u25CB", " ");
|
|
2553
|
+
var et2 = w2("\u25FB", "[\u2022]");
|
|
2554
|
+
var K2 = w2("\u25FC", "[+]");
|
|
2555
|
+
var Y2 = w2("\u25FB", "[ ]");
|
|
2556
|
+
var Et = w2("\u25AA", "\u2022");
|
|
2557
|
+
var st = w2("\u2500", "-");
|
|
2558
|
+
var ct = w2("\u256E", "+");
|
|
2559
|
+
var Gt = w2("\u251C", "+");
|
|
2560
|
+
var $t = w2("\u256F", "+");
|
|
2561
|
+
var dt = w2("\u2570", "+");
|
|
2562
|
+
var Mt = w2("\u256D", "+");
|
|
2563
|
+
var ht2 = w2("\u25CF", "\u2022");
|
|
2564
|
+
var pt = w2("\u25C6", "*");
|
|
2565
|
+
var mt = w2("\u25B2", "!");
|
|
2566
|
+
var gt = w2("\u25A0", "x");
|
|
2567
|
+
var P = (t) => {
|
|
2568
|
+
switch (t) {
|
|
2569
|
+
case "initial":
|
|
2570
|
+
case "active":
|
|
2571
|
+
return e("cyan", Tt);
|
|
2572
|
+
case "cancel":
|
|
2573
|
+
return e("red", at2);
|
|
2574
|
+
case "error":
|
|
2575
|
+
return e("yellow", ut2);
|
|
2576
|
+
case "submit":
|
|
2577
|
+
return e("green", H);
|
|
2578
|
+
}
|
|
2579
|
+
};
|
|
2580
|
+
var yt = (t) => {
|
|
2581
|
+
switch (t) {
|
|
2582
|
+
case "initial":
|
|
2583
|
+
case "active":
|
|
2584
|
+
return e("cyan", $);
|
|
2585
|
+
case "cancel":
|
|
2586
|
+
return e("red", $);
|
|
2587
|
+
case "error":
|
|
2588
|
+
return e("yellow", $);
|
|
2589
|
+
case "submit":
|
|
2590
|
+
return e("green", $);
|
|
2591
|
+
}
|
|
2592
|
+
};
|
|
2593
|
+
var Ot = (t, i, s, r, u, n = false) => {
|
|
2594
|
+
let a = i, c = 0;
|
|
2595
|
+
if (n) for (let o = r - 1; o >= s && (a -= t[o].length, c++, !(a <= u)); o--) ;
|
|
2596
|
+
else for (let o = s; o < r && (a -= t[o].length, c++, !(a <= u)); o++) ;
|
|
2597
|
+
return { lineCount: a, removals: c };
|
|
2598
|
+
};
|
|
2599
|
+
var F = ({ cursor: t, options: i, style: s, output: r = process.stdout, maxItems: u = Number.POSITIVE_INFINITY, columnPadding: n = 0, rowPadding: a = 4 }) => {
|
|
2600
|
+
const c = A(r) - n, o = L(r), l = e("dim", "..."), d = Math.max(o - a, 0), g = Math.max(Math.min(u, d), 5);
|
|
2601
|
+
let p2 = 0;
|
|
2602
|
+
t >= g - 3 && (p2 = Math.max(Math.min(t - g + 3, i.length - g), 0));
|
|
2603
|
+
let f2 = g < i.length && p2 > 0, h2 = g < i.length && p2 + g < i.length;
|
|
2604
|
+
const I = Math.min(p2 + g, i.length), m2 = [];
|
|
2605
|
+
let y = 0;
|
|
2606
|
+
f2 && y++, h2 && y++;
|
|
2607
|
+
const v2 = p2 + (f2 ? 1 : 0), C2 = I - (h2 ? 1 : 0);
|
|
2608
|
+
for (let b2 = v2; b2 < C2; b2++) {
|
|
2609
|
+
const G2 = wrapAnsi(s(i[b2], b2 === t), c, { hard: true, trim: false }).split(`
|
|
2610
|
+
`);
|
|
2611
|
+
m2.push(G2), y += G2.length;
|
|
2612
|
+
}
|
|
2613
|
+
if (y > d) {
|
|
2614
|
+
let b2 = 0, G2 = 0, M = y;
|
|
2615
|
+
const N = t - v2;
|
|
2616
|
+
let O2 = d;
|
|
2617
|
+
const j2 = () => Ot(m2, M, 0, N, O2), k2 = () => Ot(m2, M, N + 1, m2.length, O2, true);
|
|
2618
|
+
f2 ? ({ lineCount: M, removals: b2 } = j2(), M > O2 && (h2 || (O2 -= 1), { lineCount: M, removals: G2 } = k2())) : (h2 || (O2 -= 1), { lineCount: M, removals: G2 } = k2(), M > O2 && (O2 -= 1, { lineCount: M, removals: b2 } = j2())), b2 > 0 && (f2 = true, m2.splice(0, b2)), G2 > 0 && (h2 = true, m2.splice(m2.length - G2, G2));
|
|
2619
|
+
}
|
|
2620
|
+
const S = [];
|
|
2621
|
+
f2 && S.push(l);
|
|
2622
|
+
for (const b2 of m2) for (const G2 of b2) S.push(G2);
|
|
2623
|
+
return h2 && S.push(l), S;
|
|
2624
|
+
};
|
|
2625
|
+
var ue = (t) => {
|
|
2626
|
+
const i = t.active ?? "Yes", s = t.inactive ?? "No";
|
|
2627
|
+
return new X({ active: i, inactive: s, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue ?? true, render() {
|
|
2628
|
+
const r = t.withGuide ?? h.withGuide, u = `${P(this.state)} `, n = r ? `${e("gray", $)} ` : "", a = W(t.output, t.message, n, u), c = `${r ? `${e("gray", $)}
|
|
2629
|
+
` : ""}${a}
|
|
2630
|
+
`, o = this.value ? i : s;
|
|
2631
|
+
switch (this.state) {
|
|
2632
|
+
case "submit": {
|
|
2633
|
+
const l = r ? `${e("gray", $)} ` : "";
|
|
2634
|
+
return `${c}${l}${e("dim", o)}`;
|
|
2635
|
+
}
|
|
2636
|
+
case "cancel": {
|
|
2637
|
+
const l = r ? `${e("gray", $)} ` : "";
|
|
2638
|
+
return `${c}${l}${e(["strikethrough", "dim"], o)}${r ? `
|
|
2639
|
+
${e("gray", $)}` : ""}`;
|
|
2640
|
+
}
|
|
2641
|
+
default: {
|
|
2642
|
+
const l = r ? `${e("cyan", $)} ` : "", d = r ? e("cyan", x2) : "";
|
|
2643
|
+
return `${c}${l}${this.value ? `${e("green", z2)} ${i}` : `${e("dim", U)} ${e("dim", i)}`}${t.vertical ? r ? `
|
|
2644
|
+
${e("cyan", $)} ` : `
|
|
2645
|
+
` : ` ${e("dim", "/")} `}${this.value ? `${e("dim", U)} ${e("dim", s)}` : `${e("green", z2)} ${s}`}
|
|
2646
|
+
${d}
|
|
2647
|
+
`;
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
} }).prompt();
|
|
2651
|
+
};
|
|
2652
|
+
var R2 = { message: (t = [], { symbol: i = e("gray", $), secondarySymbol: s = e("gray", $), output: r = process.stdout, spacing: u = 1, withGuide: n } = {}) => {
|
|
2653
|
+
const a = [], c = n ?? h.withGuide, o = c ? s : "", l = c ? `${i} ` : "", d = c ? `${s} ` : "";
|
|
2654
|
+
for (let p2 = 0; p2 < u; p2++) a.push(o);
|
|
2655
|
+
const g = Array.isArray(t) ? t : t.split(`
|
|
2656
|
+
`);
|
|
2657
|
+
if (g.length > 0) {
|
|
2658
|
+
const [p2, ...f2] = g;
|
|
2659
|
+
p2.length > 0 ? a.push(`${l}${p2}`) : a.push(c ? i : "");
|
|
2660
|
+
for (const h2 of f2) h2.length > 0 ? a.push(`${d}${h2}`) : a.push(c ? s : "");
|
|
2661
|
+
}
|
|
2662
|
+
r.write(`${a.join(`
|
|
2663
|
+
`)}
|
|
2664
|
+
`);
|
|
2665
|
+
}, info: (t, i) => {
|
|
2666
|
+
R2.message(t, { ...i, symbol: e("blue", ht2) });
|
|
2667
|
+
}, success: (t, i) => {
|
|
2668
|
+
R2.message(t, { ...i, symbol: e("green", pt) });
|
|
2669
|
+
}, step: (t, i) => {
|
|
2670
|
+
R2.message(t, { ...i, symbol: e("green", H) });
|
|
2671
|
+
}, warn: (t, i) => {
|
|
2672
|
+
R2.message(t, { ...i, symbol: e("yellow", mt) });
|
|
2673
|
+
}, warning: (t, i) => {
|
|
2674
|
+
R2.warn(t, i);
|
|
2675
|
+
}, error: (t, i) => {
|
|
2676
|
+
R2.message(t, { ...i, symbol: e("red", gt) });
|
|
2677
|
+
} };
|
|
2678
|
+
var me = (t = "", i) => {
|
|
2679
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${e("gray", x2)} ` : "";
|
|
2680
|
+
s.write(`${r}${e("red", t)}
|
|
2681
|
+
|
|
2682
|
+
`);
|
|
2683
|
+
};
|
|
2684
|
+
var ge = (t = "", i) => {
|
|
2685
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${e("gray", lt)} ` : "";
|
|
2686
|
+
s.write(`${r}${t}
|
|
2687
|
+
`);
|
|
2688
|
+
};
|
|
2689
|
+
var ye = (t = "", i) => {
|
|
2690
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${e("gray", $)}
|
|
2691
|
+
${e("gray", x2)} ` : "";
|
|
2692
|
+
s.write(`${r}${t}
|
|
2693
|
+
|
|
2694
|
+
`);
|
|
2695
|
+
};
|
|
2696
|
+
var Te = (t) => e("magenta", t);
|
|
2697
|
+
var ft = ({ indicator: t = "dots", onCancel: i, output: s = process.stdout, cancelMessage: r, errorMessage: u, frames: n = tt ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], delay: a = tt ? 80 : 120, signal: c, ...o } = {}) => {
|
|
2698
|
+
const l = ot2();
|
|
2699
|
+
let d, g, p2 = false, f2 = false, h2 = "", I, m2 = performance.now();
|
|
2700
|
+
const y = A(s), v2 = o?.styleFrame ?? Te, C2 = (_) => {
|
|
2701
|
+
const A2 = _ > 1 ? u ?? h.messages.error : r ?? h.messages.cancel;
|
|
2702
|
+
f2 = _ === 1, p2 && (W2(A2, _), f2 && typeof i == "function" && i());
|
|
2703
|
+
}, S = () => C2(2), b2 = () => C2(1), G2 = () => {
|
|
2704
|
+
process.on("uncaughtExceptionMonitor", S), process.on("unhandledRejection", S), process.on("SIGINT", b2), process.on("SIGTERM", b2), process.on("exit", C2), c && c.addEventListener("abort", b2);
|
|
2705
|
+
}, M = () => {
|
|
2706
|
+
process.removeListener("uncaughtExceptionMonitor", S), process.removeListener("unhandledRejection", S), process.removeListener("SIGINT", b2), process.removeListener("SIGTERM", b2), process.removeListener("exit", C2), c && c.removeEventListener("abort", b2);
|
|
2707
|
+
}, N = () => {
|
|
2708
|
+
if (I === void 0) return;
|
|
2709
|
+
l && s.write(`
|
|
2710
|
+
`);
|
|
2711
|
+
const _ = wrapAnsi(I, y, { hard: true, trim: false }).split(`
|
|
2712
|
+
`);
|
|
2713
|
+
_.length > 1 && s.write(import_sisteransi2.cursor.up(_.length - 1)), s.write(import_sisteransi2.cursor.to(0)), s.write(import_sisteransi2.erase.down());
|
|
2714
|
+
}, O2 = (_) => _.replace(/\.+$/, ""), j2 = (_) => {
|
|
2715
|
+
const A2 = (performance.now() - _) / 1e3, L2 = Math.floor(A2 / 60), D2 = Math.floor(A2 % 60);
|
|
2716
|
+
return L2 > 0 ? `[${L2}m ${D2}s]` : `[${D2}s]`;
|
|
2717
|
+
}, k2 = o.withGuide ?? h.withGuide, rt2 = (_ = "") => {
|
|
2718
|
+
p2 = true, d = R({ output: s }), h2 = O2(_), m2 = performance.now(), k2 && s.write(`${e("gray", $)}
|
|
2719
|
+
`);
|
|
2720
|
+
let A2 = 0, L2 = 0;
|
|
2721
|
+
G2(), g = setInterval(() => {
|
|
2722
|
+
if (l && h2 === I) return;
|
|
2723
|
+
N(), I = h2;
|
|
2724
|
+
const D2 = v2(n[A2]);
|
|
2725
|
+
let Z;
|
|
2726
|
+
if (l) Z = `${D2} ${h2}...`;
|
|
2727
|
+
else if (t === "timer") Z = `${D2} ${h2} ${j2(m2)}`;
|
|
2728
|
+
else {
|
|
2729
|
+
const kt = ".".repeat(Math.floor(L2)).slice(0, 3);
|
|
2730
|
+
Z = `${D2} ${h2}${kt}`;
|
|
2731
|
+
}
|
|
2732
|
+
const Bt = wrapAnsi(Z, y, { hard: true, trim: false });
|
|
2733
|
+
s.write(Bt), A2 = A2 + 1 < n.length ? A2 + 1 : 0, L2 = L2 < 4 ? L2 + 0.125 : 0;
|
|
2734
|
+
}, a);
|
|
2735
|
+
}, W2 = (_ = "", A2 = 0, L2 = false) => {
|
|
2736
|
+
if (!p2) return;
|
|
2737
|
+
p2 = false, clearInterval(g), N();
|
|
2738
|
+
const D2 = A2 === 0 ? e("green", H) : A2 === 1 ? e("red", at2) : e("red", ut2);
|
|
2739
|
+
h2 = _ ?? h2, L2 || (t === "timer" ? s.write(`${D2} ${h2} ${j2(m2)}
|
|
2740
|
+
`) : s.write(`${D2} ${h2}
|
|
2741
|
+
`)), M(), d();
|
|
2742
|
+
};
|
|
2743
|
+
return { start: rt2, stop: (_ = "") => W2(_, 0), message: (_ = "") => {
|
|
2744
|
+
h2 = O2(_ ?? h2);
|
|
2745
|
+
}, cancel: (_ = "") => W2(_, 1), error: (_ = "") => W2(_, 2), clear: () => W2("", 0, true), get isCancelled() {
|
|
2746
|
+
return f2;
|
|
2747
|
+
} };
|
|
2748
|
+
};
|
|
2749
|
+
var jt = { light: w2("\u2500", "-"), heavy: w2("\u2501", "="), block: w2("\u2588", "#") };
|
|
2750
|
+
var it2 = (t, i) => t.includes(`
|
|
2751
|
+
`) ? t.split(`
|
|
2752
|
+
`).map((s) => i(s)).join(`
|
|
2753
|
+
`) : i(t);
|
|
2754
|
+
var xe = (t) => {
|
|
2755
|
+
const i = (s, r) => {
|
|
2756
|
+
const u = s.label ?? String(s.value);
|
|
2757
|
+
switch (r) {
|
|
2758
|
+
case "disabled":
|
|
2759
|
+
return `${e("gray", U)} ${it2(u, (n) => e("gray", n))}${s.hint ? ` ${e("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
2760
|
+
case "selected":
|
|
2761
|
+
return `${it2(u, (n) => e("dim", n))}`;
|
|
2762
|
+
case "active":
|
|
2763
|
+
return `${e("green", z2)} ${u}${s.hint ? ` ${e("dim", `(${s.hint})`)}` : ""}`;
|
|
2764
|
+
case "cancelled":
|
|
2765
|
+
return `${it2(u, (n) => e(["strikethrough", "dim"], n))}`;
|
|
2766
|
+
default:
|
|
2767
|
+
return `${e("dim", U)} ${it2(u, (n) => e("dim", n))}`;
|
|
2768
|
+
}
|
|
2769
|
+
};
|
|
2770
|
+
return new ut({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, render() {
|
|
2771
|
+
const s = t.withGuide ?? h.withGuide, r = `${P(this.state)} `, u = `${yt(this.state)} `, n = W(t.output, t.message, u, r), a = `${s ? `${e("gray", $)}
|
|
2772
|
+
` : ""}${n}
|
|
2773
|
+
`;
|
|
2774
|
+
switch (this.state) {
|
|
2775
|
+
case "submit": {
|
|
2776
|
+
const c = s ? `${e("gray", $)} ` : "", o = W(t.output, i(this.options[this.cursor], "selected"), c);
|
|
2777
|
+
return `${a}${o}`;
|
|
2778
|
+
}
|
|
2779
|
+
case "cancel": {
|
|
2780
|
+
const c = s ? `${e("gray", $)} ` : "", o = W(t.output, i(this.options[this.cursor], "cancelled"), c);
|
|
2781
|
+
return `${a}${o}${s ? `
|
|
2782
|
+
${e("gray", $)}` : ""}`;
|
|
2783
|
+
}
|
|
2784
|
+
default: {
|
|
2785
|
+
const c = s ? `${e("cyan", $)} ` : "", o = s ? e("cyan", x2) : "", l = a.split(`
|
|
2786
|
+
`).length, d = s ? 2 : 1;
|
|
2787
|
+
return `${a}${c}${F({ output: t.output, cursor: this.cursor, options: this.options, maxItems: t.maxItems, columnPadding: c.length, rowPadding: l + d, style: (g, p2) => i(g, g.disabled ? "disabled" : p2 ? "active" : "inactive") }).join(`
|
|
2788
|
+
${c}`)}
|
|
2789
|
+
${o}
|
|
2790
|
+
`;
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
} }).prompt();
|
|
2794
|
+
};
|
|
2795
|
+
var Nt = `${e("gray", $)} `;
|
|
2796
|
+
var Pe = (t) => new ht({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, output: t.output, signal: t.signal, input: t.input, render() {
|
|
2797
|
+
const i = t?.withGuide ?? h.withGuide, s = `${`${i ? `${e("gray", $)}
|
|
2798
|
+
` : ""}${P(this.state)} `}${t.message}
|
|
2799
|
+
`, r = t.placeholder ? e("inverse", t.placeholder[0]) + e("dim", t.placeholder.slice(1)) : e(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
|
|
2800
|
+
switch (this.state) {
|
|
2801
|
+
case "error": {
|
|
2802
|
+
const a = this.error ? ` ${e("yellow", this.error)}` : "", c = i ? `${e("yellow", $)} ` : "", o = i ? e("yellow", x2) : "";
|
|
2803
|
+
return `${s.trim()}
|
|
2804
|
+
${c}${u}
|
|
2805
|
+
${o}${a}
|
|
2806
|
+
`;
|
|
2807
|
+
}
|
|
2808
|
+
case "submit": {
|
|
2809
|
+
const a = n ? ` ${e("dim", n)}` : "", c = i ? e("gray", $) : "";
|
|
2810
|
+
return `${s}${c}${a}`;
|
|
2811
|
+
}
|
|
2812
|
+
case "cancel": {
|
|
2813
|
+
const a = n ? ` ${e(["strikethrough", "dim"], n)}` : "", c = i ? e("gray", $) : "";
|
|
2814
|
+
return `${s}${c}${a}${n.trim() ? `
|
|
2815
|
+
${c}` : ""}`;
|
|
2816
|
+
}
|
|
2817
|
+
default: {
|
|
2818
|
+
const a = i ? `${e("cyan", $)} ` : "", c = i ? e("cyan", x2) : "";
|
|
2819
|
+
return `${s}${a}${u}
|
|
2820
|
+
${c}
|
|
2821
|
+
`;
|
|
2570
2822
|
}
|
|
2571
|
-
throw err;
|
|
2572
2823
|
}
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2824
|
+
} }).prompt();
|
|
2825
|
+
|
|
2826
|
+
// ../argent-cli/src/link.ts
|
|
2827
|
+
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
2828
|
+
var WILDCARD_HOSTS = /* @__PURE__ */ new Set(["0.0.0.0", "::", "::0", ""]);
|
|
2829
|
+
function isLoopback2(host) {
|
|
2830
|
+
return host === "127.0.0.1" || host === "localhost" || host === "::1";
|
|
2831
|
+
}
|
|
2832
|
+
function validateHost(raw) {
|
|
2833
|
+
const trimmed = raw.trim();
|
|
2834
|
+
if (WILDCARD_HOSTS.has(trimmed)) {
|
|
2835
|
+
throw new StartFlagError(
|
|
2836
|
+
`--host ${trimmed === "" ? '""' : trimmed} is a bind address, not a connect address \u2014 use 127.0.0.1 or the actual reachable host.`
|
|
2837
|
+
);
|
|
2576
2838
|
}
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2839
|
+
return trimmed;
|
|
2840
|
+
}
|
|
2841
|
+
function validateConnectPort(raw) {
|
|
2842
|
+
const port = parsePort(raw);
|
|
2843
|
+
if (port === 0) {
|
|
2844
|
+
throw new StartFlagError(`--port must be 1..65535 for a connect target, got "${raw}"`);
|
|
2581
2845
|
}
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2846
|
+
return port;
|
|
2847
|
+
}
|
|
2848
|
+
function parseLinkFlags(argv) {
|
|
2849
|
+
const flags2 = {
|
|
2850
|
+
host: null,
|
|
2851
|
+
port: null,
|
|
2852
|
+
token: null,
|
|
2853
|
+
url: null,
|
|
2854
|
+
yes: false,
|
|
2855
|
+
noVerify: false,
|
|
2856
|
+
help: false
|
|
2857
|
+
};
|
|
2858
|
+
for (let i = 0; i < argv.length; i++) {
|
|
2859
|
+
const tok = argv[i];
|
|
2860
|
+
const takeValue = (name) => {
|
|
2861
|
+
const v2 = argv[i + 1];
|
|
2862
|
+
if (v2 === void 0) throw new StartFlagError(`${name} requires a value`);
|
|
2863
|
+
i += 1;
|
|
2864
|
+
return v2;
|
|
2865
|
+
};
|
|
2866
|
+
if (tok === "--help" || tok === "-h") {
|
|
2867
|
+
flags2.help = true;
|
|
2868
|
+
continue;
|
|
2590
2869
|
}
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
if (flags2.port !== null) {
|
|
2595
|
-
port = flags2.port;
|
|
2596
|
-
} else if (flags2.yes) {
|
|
2597
|
-
port = 3001;
|
|
2598
|
-
} else {
|
|
2599
|
-
port = await promptPort(existing);
|
|
2600
|
-
}
|
|
2601
|
-
const token = flags2.token ?? (existing && existing.host === host && existing.port === port ? existing.token : void 0);
|
|
2602
|
-
let url = flags2.url ?? formatUrl(host, port);
|
|
2603
|
-
if (!flags2.yes && existing) {
|
|
2604
|
-
if (existing.url === url) {
|
|
2605
|
-
R2.info(`Already linked to ${import_picocolors.default.cyan(url)}.`);
|
|
2606
|
-
ye("No changes.");
|
|
2607
|
-
return;
|
|
2870
|
+
if (tok === "--yes" || tok === "-y") {
|
|
2871
|
+
flags2.yes = true;
|
|
2872
|
+
continue;
|
|
2608
2873
|
}
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
});
|
|
2613
|
-
if (q(overwrite) || !overwrite) {
|
|
2614
|
-
me("Link cancelled.");
|
|
2615
|
-
process.exit(0);
|
|
2874
|
+
if (tok === "--no-verify") {
|
|
2875
|
+
flags2.noVerify = true;
|
|
2876
|
+
continue;
|
|
2616
2877
|
}
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2878
|
+
if (tok === "--host") {
|
|
2879
|
+
flags2.host = validateHost(takeValue("--host"));
|
|
2880
|
+
continue;
|
|
2881
|
+
}
|
|
2882
|
+
if (tok.startsWith("--host=")) {
|
|
2883
|
+
flags2.host = validateHost(tok.slice("--host=".length));
|
|
2884
|
+
continue;
|
|
2885
|
+
}
|
|
2886
|
+
if (tok === "--port" || tok === "-p") {
|
|
2887
|
+
flags2.port = validateConnectPort(takeValue("--port"));
|
|
2888
|
+
continue;
|
|
2889
|
+
}
|
|
2890
|
+
if (tok.startsWith("--port=")) {
|
|
2891
|
+
flags2.port = validateConnectPort(tok.slice("--port=".length));
|
|
2892
|
+
continue;
|
|
2893
|
+
}
|
|
2894
|
+
if (tok === "--token") {
|
|
2895
|
+
flags2.token = takeValue("--token");
|
|
2896
|
+
continue;
|
|
2897
|
+
}
|
|
2898
|
+
if (tok.startsWith("--token=")) {
|
|
2899
|
+
flags2.token = tok.slice("--token=".length);
|
|
2900
|
+
continue;
|
|
2901
|
+
}
|
|
2902
|
+
if (!tok.startsWith("-")) {
|
|
2903
|
+
const parsed = parseLinkTarget(tok);
|
|
2904
|
+
if (!parsed) {
|
|
2905
|
+
throw new StartFlagError(
|
|
2906
|
+
`Unrecognized argument "${tok}". Expected an argent://\u2026 pairing string, an http(s):// URL, or flags (see --help).`
|
|
2636
2907
|
);
|
|
2637
|
-
process.exit(1);
|
|
2638
|
-
}
|
|
2639
|
-
R2.error(`pre-flight GET ${url}/tools failed${detail}.`);
|
|
2640
|
-
const action = await xe({
|
|
2641
|
-
message: "How would you like to proceed?",
|
|
2642
|
-
options: [
|
|
2643
|
-
{ value: "retry", label: "Retry verification" },
|
|
2644
|
-
{ value: "modify", label: "Modify host and port, then retry" },
|
|
2645
|
-
{ value: "skip", label: "Skip verification and save anyway" },
|
|
2646
|
-
{ value: "cancel", label: "Cancel" }
|
|
2647
|
-
],
|
|
2648
|
-
initialValue: "retry"
|
|
2649
|
-
});
|
|
2650
|
-
if (q(action) || action === "cancel") {
|
|
2651
|
-
me("Link cancelled.");
|
|
2652
|
-
process.exit(0);
|
|
2653
|
-
}
|
|
2654
|
-
if (action === "skip") break;
|
|
2655
|
-
if (action === "modify") {
|
|
2656
|
-
host = await promptHost(existing, host);
|
|
2657
|
-
port = await promptPort(existing, port);
|
|
2658
|
-
url = formatUrl(host, port);
|
|
2659
2908
|
}
|
|
2909
|
+
flags2.host = validateHost(parsed.host);
|
|
2910
|
+
flags2.port = validateConnectPort(String(parsed.port));
|
|
2911
|
+
flags2.url = parsed.url;
|
|
2912
|
+
if (parsed.token) flags2.token = parsed.token;
|
|
2913
|
+
continue;
|
|
2660
2914
|
}
|
|
2915
|
+
throw new StartFlagError(`Unknown flag: ${tok}`);
|
|
2661
2916
|
}
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
printSecurityCaveat(host, token, url);
|
|
2677
|
-
if (process.env.ARGENT_TOOLS_URL) {
|
|
2678
|
-
console.log(
|
|
2679
|
-
import_picocolors.default.yellow(
|
|
2680
|
-
`Note: ARGENT_TOOLS_URL=${process.env.ARGENT_TOOLS_URL} is set in your environment and takes precedence over the link.`
|
|
2681
|
-
)
|
|
2682
|
-
);
|
|
2917
|
+
return flags2;
|
|
2918
|
+
}
|
|
2919
|
+
function parseUnlinkFlags(argv) {
|
|
2920
|
+
const flags2 = { yes: false, help: false };
|
|
2921
|
+
for (const tok of argv) {
|
|
2922
|
+
if (tok === "--help" || tok === "-h") {
|
|
2923
|
+
flags2.help = true;
|
|
2924
|
+
continue;
|
|
2925
|
+
}
|
|
2926
|
+
if (tok === "--yes" || tok === "-y") {
|
|
2927
|
+
flags2.yes = true;
|
|
2928
|
+
continue;
|
|
2929
|
+
}
|
|
2930
|
+
throw new StartFlagError(`Unknown flag: ${tok}`);
|
|
2683
2931
|
}
|
|
2684
|
-
|
|
2932
|
+
return flags2;
|
|
2685
2933
|
}
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2934
|
+
function printLinkHelp() {
|
|
2935
|
+
console.log(`Usage: argent link [<target>] [flags]
|
|
2936
|
+
|
|
2937
|
+
Route argent client requests (argent tools / run / mcp) to a remote tool-server
|
|
2938
|
+
instead of auto-spawning a local one. The target is persisted to ~/.argent/link.json
|
|
2939
|
+
and survives shell restarts.
|
|
2940
|
+
|
|
2941
|
+
<target> may be:
|
|
2942
|
+
- argent://[<token>@]<host>:<port> the string \`argent server start\` prints
|
|
2943
|
+
- http(s)://<host>[:<port>][/path] a full URL \u2014 use this for a reverse proxy
|
|
2944
|
+
or tunnel (ngrok, cloudflared, nginx). The
|
|
2945
|
+
scheme and any path prefix are preserved;
|
|
2946
|
+
requests go to <url>/tools.
|
|
2947
|
+
|
|
2948
|
+
The easiest LAN path is to paste the connection string from \`argent server start\`:
|
|
2949
|
+
argent link argent://<token>@10.0.0.42:3001
|
|
2950
|
+
For a tunnel, point at its public URL and pass the server's token:
|
|
2951
|
+
argent link https://argent.example.com --token <token>
|
|
2952
|
+
|
|
2953
|
+
Resolution order for the tool-server URL:
|
|
2954
|
+
1. ARGENT_TOOLS_URL environment variable (highest precedence)
|
|
2955
|
+
2. ~/.argent/link.json (this command)
|
|
2956
|
+
3. Auto-spawn a local tool-server (default)
|
|
2957
|
+
|
|
2958
|
+
Flags:
|
|
2959
|
+
--host <h> Remote host or IP to connect to. Prompts interactively if
|
|
2960
|
+
omitted. Wildcards (0.0.0.0, ::) are bind addresses, not
|
|
2961
|
+
connect targets, and are rejected \u2014 use 127.0.0.1 or the
|
|
2962
|
+
actual reachable host.
|
|
2963
|
+
--port, -p <n> Remote port (1..65535). Defaults to 3001. Prompts if omitted.
|
|
2964
|
+
--token <t> Bearer token for a server that enforces auth. Usually
|
|
2965
|
+
supplied inside the argent:// string instead.
|
|
2966
|
+
--no-verify Skip the pre-flight GET /tools health check.
|
|
2967
|
+
--yes, -y Non-interactive. Requires --host (port defaults to 3001).
|
|
2968
|
+
Fails if --host is missing.
|
|
2969
|
+
--help, -h Show this help.
|
|
2970
|
+
|
|
2971
|
+
Examples:
|
|
2972
|
+
argent link argent://ab12\u2026c2@10.0.0.42:3001 Pair from a server-start string.
|
|
2973
|
+
argent link https://argent.example.com --token ab12\u2026c2
|
|
2974
|
+
Link through an HTTPS tunnel/proxy.
|
|
2975
|
+
argent link Interactive prompts for host and port.
|
|
2976
|
+
argent link --host 10.0.0.42 --port 3001 Confirms interactively, then saves.
|
|
2977
|
+
argent link --host 10.0.0.42 --token ab12\u2026c2 --yes
|
|
2978
|
+
Non-interactive, authenticated.
|
|
2979
|
+
argent link --host 10.0.0.42 --yes --no-verify
|
|
2980
|
+
Saves immediately, no health check.
|
|
2981
|
+
|
|
2982
|
+
Security:
|
|
2983
|
+
The token (if any) is stored 0600 and sent as a bearer header. An http:// link
|
|
2984
|
+
has no TLS \u2014 treat any non-loopback http link as trusted-network-only. Prefer
|
|
2985
|
+
an https:// tunnel/proxy when crossing untrusted networks.
|
|
2986
|
+
|
|
2987
|
+
Notes:
|
|
2988
|
+
- If ARGENT_TOOLS_URL is also set in your environment, it overrides the link.
|
|
2989
|
+
- To stop using the remote target, run \`argent unlink\`.
|
|
2990
|
+
- \`argent server start/stop/status\` manage the local tool-server lifecycle
|
|
2991
|
+
and are unaffected by linking.
|
|
2992
|
+
- Restart your editor (Claude / Cursor / VS Code) afterwards \u2014 a running
|
|
2993
|
+
\`argent mcp\` process caches the target at startup and won't pick up the
|
|
2994
|
+
new link until it's relaunched.
|
|
2693
2995
|
`);
|
|
2694
|
-
printUnlinkHelp();
|
|
2695
|
-
process.exit(2);
|
|
2696
|
-
}
|
|
2697
|
-
throw err;
|
|
2698
|
-
}
|
|
2699
|
-
if (flags2.help) {
|
|
2700
|
-
printUnlinkHelp();
|
|
2701
|
-
return;
|
|
2702
|
-
}
|
|
2703
|
-
const existing = await readLinkConfig();
|
|
2704
|
-
if (!existing) {
|
|
2705
|
-
console.log("Not currently linked \u2014 already using local tool-server.");
|
|
2706
|
-
return;
|
|
2707
|
-
}
|
|
2708
|
-
if (!flags2.yes) {
|
|
2709
|
-
const confirmed = await ue({
|
|
2710
|
-
message: `Remove link to ${import_picocolors.default.cyan(existing.url)}?`,
|
|
2711
|
-
initialValue: true
|
|
2712
|
-
});
|
|
2713
|
-
if (q(confirmed) || !confirmed) {
|
|
2714
|
-
me("Unlink cancelled.");
|
|
2715
|
-
process.exit(0);
|
|
2716
|
-
}
|
|
2717
|
-
}
|
|
2718
|
-
await clearLinkConfig();
|
|
2719
|
-
console.log(`${import_picocolors.default.green("\u2713")} Unlinked from ${import_picocolors.default.dim(existing.url)}.`);
|
|
2720
|
-
if (process.env.ARGENT_TOOLS_URL) {
|
|
2721
|
-
console.log(
|
|
2722
|
-
import_picocolors.default.yellow(
|
|
2723
|
-
`The env var ARGENT_TOOLS_URL is also set in your shell (=${process.env.ARGENT_TOOLS_URL}) and takes precedence \u2014 unset it manually if you want fully local behaviour.`
|
|
2724
|
-
)
|
|
2725
|
-
);
|
|
2726
|
-
}
|
|
2727
|
-
printRestartHint();
|
|
2728
2996
|
}
|
|
2997
|
+
function printUnlinkHelp() {
|
|
2998
|
+
console.log(`Usage: argent unlink [flags]
|
|
2729
2999
|
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
3000
|
+
Remove the persisted remote tool-server link (~/.argent/link.json) and return
|
|
3001
|
+
to default local auto-spawn behaviour.
|
|
3002
|
+
|
|
3003
|
+
Flags:
|
|
3004
|
+
--yes, -y Skip the confirmation prompt.
|
|
3005
|
+
--help, -h Show this help.
|
|
3006
|
+
|
|
3007
|
+
Examples:
|
|
3008
|
+
argent unlink Confirms, then removes the link.
|
|
3009
|
+
argent unlink --yes Removes without confirmation. Safe in scripts.
|
|
3010
|
+
|
|
3011
|
+
Notes:
|
|
3012
|
+
- No-op (exit 0) if no link is currently set.
|
|
3013
|
+
- If ARGENT_TOOLS_URL is also set in your environment, it still takes
|
|
3014
|
+
precedence after unlinking \u2014 unset it manually for fully local behaviour.
|
|
3015
|
+
- This does not stop or start any tool-server process. Use
|
|
3016
|
+
\`argent server stop\` if you also want to terminate a running local server.
|
|
3017
|
+
- Restart your editor afterwards \u2014 a running \`argent mcp\` process won't
|
|
3018
|
+
revert to local auto-spawn until it's relaunched.
|
|
3019
|
+
`);
|
|
2742
3020
|
}
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
if (
|
|
3021
|
+
async function promptHost(existing, initial) {
|
|
3022
|
+
const hostInput = await Pe({
|
|
3023
|
+
message: "Remote host or IP to connect to",
|
|
3024
|
+
placeholder: existing?.host ?? "127.0.0.1",
|
|
3025
|
+
initialValue: initial ?? existing?.host,
|
|
3026
|
+
validate(value) {
|
|
3027
|
+
if (!value || !value.trim()) return "Host cannot be empty.";
|
|
3028
|
+
const trimmed = value.trim();
|
|
3029
|
+
if (WILDCARD_HOSTS.has(trimmed)) {
|
|
3030
|
+
return `${trimmed} is a bind address, not a connect address \u2014 use 127.0.0.1 or the actual reachable host.`;
|
|
3031
|
+
}
|
|
2750
3032
|
}
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
3033
|
+
});
|
|
3034
|
+
if (q(hostInput)) {
|
|
3035
|
+
me("Link cancelled.");
|
|
3036
|
+
process.exit(0);
|
|
2754
3037
|
}
|
|
3038
|
+
return hostInput.trim();
|
|
2755
3039
|
}
|
|
2756
|
-
function
|
|
2757
|
-
const
|
|
2758
|
-
|
|
2759
|
-
|
|
3040
|
+
async function promptPort(existing, initial) {
|
|
3041
|
+
const defaultPort = initial ?? existing?.port ?? 3001;
|
|
3042
|
+
const portInput = await Pe({
|
|
3043
|
+
message: "Remote port",
|
|
3044
|
+
placeholder: String(defaultPort),
|
|
3045
|
+
initialValue: String(defaultPort),
|
|
3046
|
+
validate(value) {
|
|
3047
|
+
if (!value || !value.trim()) return "Port cannot be empty.";
|
|
3048
|
+
try {
|
|
3049
|
+
validateConnectPort(value.trim());
|
|
3050
|
+
} catch (err) {
|
|
3051
|
+
if (err instanceof StartFlagError) return err.message;
|
|
3052
|
+
throw err;
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
});
|
|
3056
|
+
if (q(portInput)) {
|
|
3057
|
+
me("Link cancelled.");
|
|
3058
|
+
process.exit(0);
|
|
2760
3059
|
}
|
|
2761
|
-
|
|
2762
|
-
return path5.join(resolveProjectRoot(cwd), ".argent", "flags.json");
|
|
3060
|
+
return validateConnectPort(portInput.trim());
|
|
2763
3061
|
}
|
|
2764
|
-
function
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
raw = fs4.readFileSync(filePath, "utf8");
|
|
2768
|
-
} catch {
|
|
2769
|
-
return {};
|
|
2770
|
-
}
|
|
2771
|
-
let parsed;
|
|
3062
|
+
async function preflightHealth(url, token) {
|
|
3063
|
+
const controller = new AbortController();
|
|
3064
|
+
const timer = setTimeout(() => controller.abort(), 3e3);
|
|
2772
3065
|
try {
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
const out = {};
|
|
2781
|
-
for (const [k2, v2] of Object.entries(flags2)) {
|
|
2782
|
-
if (typeof v2 === "boolean") out[k2] = v2;
|
|
2783
|
-
}
|
|
2784
|
-
return out;
|
|
2785
|
-
}
|
|
2786
|
-
function writeFlagsFile(filePath, flags2) {
|
|
2787
|
-
if (Object.keys(flags2).length === 0) {
|
|
2788
|
-
if (fs4.existsSync(filePath)) fs4.rmSync(filePath, { force: true });
|
|
2789
|
-
const parent = path5.dirname(filePath);
|
|
2790
|
-
try {
|
|
2791
|
-
if (fs4.existsSync(parent) && fs4.readdirSync(parent).length === 0) {
|
|
2792
|
-
fs4.rmdirSync(parent);
|
|
2793
|
-
}
|
|
2794
|
-
} catch {
|
|
3066
|
+
const res = await fetch(`${url}/tools`, {
|
|
3067
|
+
signal: controller.signal,
|
|
3068
|
+
headers: token ? { Authorization: `Bearer ${token}` } : {}
|
|
3069
|
+
});
|
|
3070
|
+
if (!res.ok) {
|
|
3071
|
+
const hint = res.status === 401 ? " \u2014 the server requires a token; pass --token or use the argent:// link from `server start`" : res.status === 403 ? " \u2014 the server refused this host (DNS-rebinding guard); reach it by its bind host or start it with --host" : "";
|
|
3072
|
+
return { ok: false, error: `${res.status} ${res.statusText}${hint}` };
|
|
2795
3073
|
}
|
|
2796
|
-
return;
|
|
3074
|
+
return { ok: true };
|
|
3075
|
+
} catch (err) {
|
|
3076
|
+
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
3077
|
+
} finally {
|
|
3078
|
+
clearTimeout(timer);
|
|
2797
3079
|
}
|
|
2798
|
-
fs4.mkdirSync(path5.dirname(filePath), { recursive: true });
|
|
2799
|
-
const tmp = `${filePath}.${process.pid}.tmp`;
|
|
2800
|
-
fs4.writeFileSync(tmp, JSON.stringify({ flags: flags2 }, null, 2) + "\n");
|
|
2801
|
-
fs4.renameSync(tmp, filePath);
|
|
2802
|
-
}
|
|
2803
|
-
function readFlags(scope, options = {}) {
|
|
2804
|
-
return readFlagsFile(getFlagsPath(scope, options));
|
|
2805
|
-
}
|
|
2806
|
-
function setFlag(name, value, scope, options = {}) {
|
|
2807
|
-
const filePath = getFlagsPath(scope, options);
|
|
2808
|
-
const current = readFlagsFile(filePath);
|
|
2809
|
-
current[name] = value;
|
|
2810
|
-
writeFlagsFile(filePath, current);
|
|
2811
|
-
}
|
|
2812
|
-
function unsetFlag(name, scope, options = {}) {
|
|
2813
|
-
const filePath = getFlagsPath(scope, options);
|
|
2814
|
-
const current = readFlagsFile(filePath);
|
|
2815
|
-
if (!Object.hasOwn(current, name)) return false;
|
|
2816
|
-
delete current[name];
|
|
2817
|
-
writeFlagsFile(filePath, current);
|
|
2818
|
-
return true;
|
|
2819
3080
|
}
|
|
2820
|
-
function
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
if (Object.hasOwn(globalFlags, name)) return globalFlags[name];
|
|
2825
|
-
return false;
|
|
3081
|
+
function printRestartHint() {
|
|
3082
|
+
console.log(
|
|
3083
|
+
import_picocolors2.default.dim("Restart your editor to apply the change to any running `argent mcp` session.")
|
|
3084
|
+
);
|
|
2826
3085
|
}
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
}
|
|
2839
|
-
if (tok === "--") {
|
|
2840
|
-
positionalOnly = true;
|
|
2841
|
-
continue;
|
|
2842
|
-
}
|
|
2843
|
-
if (tok === "--scope") {
|
|
2844
|
-
const v2 = argv[i + 1];
|
|
2845
|
-
if (v2 === void 0) throw new Error("--scope requires a value (project|global)");
|
|
2846
|
-
scope = parseScope(v2);
|
|
2847
|
-
i += 1;
|
|
2848
|
-
continue;
|
|
2849
|
-
}
|
|
2850
|
-
if (tok.startsWith("--scope=")) {
|
|
2851
|
-
scope = parseScope(tok.slice("--scope=".length));
|
|
2852
|
-
continue;
|
|
2853
|
-
}
|
|
2854
|
-
if (tok.startsWith("--")) {
|
|
2855
|
-
throw new Error(`Unknown flag: ${tok}`);
|
|
2856
|
-
}
|
|
2857
|
-
if (name !== null) {
|
|
2858
|
-
throw new Error(`Unexpected extra argument: "${tok}"`);
|
|
3086
|
+
function printSecurityCaveat(host, token, url) {
|
|
3087
|
+
if (isLoopback2(host)) return;
|
|
3088
|
+
const tls = url.startsWith("https://");
|
|
3089
|
+
if (tls) {
|
|
3090
|
+
if (!token) {
|
|
3091
|
+
process.stderr.write(
|
|
3092
|
+
import_picocolors2.default.yellow(
|
|
3093
|
+
`WARNING: ${host} is reached over HTTPS but with NO token \u2014 anyone who can reach the URL can drive the server. Pair with a token.
|
|
3094
|
+
`
|
|
3095
|
+
)
|
|
3096
|
+
);
|
|
2859
3097
|
}
|
|
2860
|
-
|
|
2861
|
-
}
|
|
2862
|
-
if (
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
3098
|
+
return;
|
|
3099
|
+
}
|
|
3100
|
+
if (token) {
|
|
3101
|
+
process.stderr.write(
|
|
3102
|
+
import_picocolors2.default.dim(
|
|
3103
|
+
`Note: ${host} is reached over plain HTTP (bearer-token auth, no TLS). Keep this link to a trusted network or VPN, or front it with an https:// tunnel.
|
|
3104
|
+
`
|
|
3105
|
+
)
|
|
2868
3106
|
);
|
|
3107
|
+
return;
|
|
2869
3108
|
}
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
3109
|
+
process.stderr.write(
|
|
3110
|
+
import_picocolors2.default.yellow(
|
|
3111
|
+
`WARNING: linked target ${host} is non-loopback and has NO token \u2014 tool calls travel over plain HTTP with no auth. Treat this link as trusted-network-only, or pair with a token (start the server without --no-auth).
|
|
3112
|
+
`
|
|
3113
|
+
)
|
|
3114
|
+
);
|
|
2875
3115
|
}
|
|
2876
|
-
function
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
~/.argent/flags.json (global, default)
|
|
2884
|
-
<project-root>/.argent/flags.json (project, with --scope project)
|
|
2885
|
-
|
|
2886
|
-
Options:
|
|
2887
|
-
--scope <global|project> Where to write (default: global)
|
|
2888
|
-
--help, -h Show this help
|
|
3116
|
+
async function link(argv) {
|
|
3117
|
+
let flags2;
|
|
3118
|
+
try {
|
|
3119
|
+
flags2 = parseLinkFlags(argv);
|
|
3120
|
+
} catch (err) {
|
|
3121
|
+
if (err instanceof StartFlagError) {
|
|
3122
|
+
console.error(`Error: ${err.message}
|
|
2889
3123
|
`);
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
3124
|
+
printLinkHelp();
|
|
3125
|
+
process.exit(2);
|
|
3126
|
+
}
|
|
3127
|
+
throw err;
|
|
3128
|
+
}
|
|
3129
|
+
if (flags2.help) {
|
|
3130
|
+
printLinkHelp();
|
|
2894
3131
|
return;
|
|
2895
3132
|
}
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
} catch (err) {
|
|
2900
|
-
console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
3133
|
+
if (flags2.yes && flags2.host === null) {
|
|
3134
|
+
console.error("Error: --yes requires --host (port defaults to 3001).\n");
|
|
3135
|
+
printLinkHelp();
|
|
2901
3136
|
process.exit(2);
|
|
2902
3137
|
}
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
3138
|
+
const existing = await readLinkConfig();
|
|
3139
|
+
let host;
|
|
3140
|
+
if (flags2.host !== null) {
|
|
3141
|
+
host = flags2.host;
|
|
3142
|
+
} else {
|
|
3143
|
+
ge(import_picocolors2.default.bgCyan(import_picocolors2.default.black(" argent link ")));
|
|
3144
|
+
if (existing) {
|
|
3145
|
+
R2.info(`Current link: ${import_picocolors2.default.cyan(existing.url)} (${existing.createdAt})`);
|
|
3146
|
+
}
|
|
3147
|
+
host = await promptHost(existing);
|
|
2908
3148
|
}
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
3149
|
+
let port;
|
|
3150
|
+
if (flags2.port !== null) {
|
|
3151
|
+
port = flags2.port;
|
|
3152
|
+
} else if (flags2.yes) {
|
|
3153
|
+
port = 3001;
|
|
3154
|
+
} else {
|
|
3155
|
+
port = await promptPort(existing);
|
|
3156
|
+
}
|
|
3157
|
+
const token = flags2.token ?? (existing && existing.host === host && existing.port === port ? existing.token : void 0);
|
|
3158
|
+
let url = flags2.url ?? formatUrl(host, port);
|
|
3159
|
+
if (!flags2.yes && existing) {
|
|
3160
|
+
if (existing.url === url) {
|
|
3161
|
+
R2.info(`Already linked to ${import_picocolors2.default.cyan(url)}.`);
|
|
3162
|
+
ye("No changes.");
|
|
3163
|
+
return;
|
|
3164
|
+
}
|
|
3165
|
+
const overwrite = await ue({
|
|
3166
|
+
message: `Replace existing link ${import_picocolors2.default.dim(existing.url)} with ${import_picocolors2.default.cyan(url)}?`,
|
|
3167
|
+
initialValue: true
|
|
3168
|
+
});
|
|
3169
|
+
if (q(overwrite) || !overwrite) {
|
|
3170
|
+
me("Link cancelled.");
|
|
3171
|
+
process.exit(0);
|
|
2915
3172
|
}
|
|
2916
|
-
} catch (err) {
|
|
2917
|
-
console.error(`Failed to ${command} flag: ${err instanceof Error ? err.message : String(err)}`);
|
|
2918
|
-
process.exit(1);
|
|
2919
3173
|
}
|
|
2920
|
-
if (
|
|
2921
|
-
|
|
3174
|
+
if (!flags2.noVerify) {
|
|
3175
|
+
while (true) {
|
|
3176
|
+
const spinnerActive = !flags2.yes;
|
|
3177
|
+
let spinner = null;
|
|
3178
|
+
if (spinnerActive) {
|
|
3179
|
+
spinner = ft();
|
|
3180
|
+
spinner.start(`Verifying tool-server at ${url}...`);
|
|
3181
|
+
}
|
|
3182
|
+
const result = await preflightHealth(url, token);
|
|
3183
|
+
if (result.ok) {
|
|
3184
|
+
if (spinner) spinner.stop(import_picocolors2.default.green("Tool-server reachable."));
|
|
3185
|
+
break;
|
|
3186
|
+
}
|
|
3187
|
+
if (spinner) spinner.stop(import_picocolors2.default.red("Verification failed."));
|
|
3188
|
+
const detail = result.error ? ` (${result.error})` : "";
|
|
3189
|
+
if (flags2.yes) {
|
|
3190
|
+
console.error(
|
|
3191
|
+
`Error: pre-flight GET ${url}/tools failed${detail}. Make sure the remote tool-server is running, or pass --no-verify to skip.`
|
|
3192
|
+
);
|
|
3193
|
+
process.exit(1);
|
|
3194
|
+
}
|
|
3195
|
+
R2.error(`pre-flight GET ${url}/tools failed${detail}.`);
|
|
3196
|
+
const action = await xe({
|
|
3197
|
+
message: "How would you like to proceed?",
|
|
3198
|
+
options: [
|
|
3199
|
+
{ value: "retry", label: "Retry verification" },
|
|
3200
|
+
{ value: "modify", label: "Modify host and port, then retry" },
|
|
3201
|
+
{ value: "skip", label: "Skip verification and save anyway" },
|
|
3202
|
+
{ value: "cancel", label: "Cancel" }
|
|
3203
|
+
],
|
|
3204
|
+
initialValue: "retry"
|
|
3205
|
+
});
|
|
3206
|
+
if (q(action) || action === "cancel") {
|
|
3207
|
+
me("Link cancelled.");
|
|
3208
|
+
process.exit(0);
|
|
3209
|
+
}
|
|
3210
|
+
if (action === "skip") break;
|
|
3211
|
+
if (action === "modify") {
|
|
3212
|
+
host = await promptHost(existing, host);
|
|
3213
|
+
port = await promptPort(existing, port);
|
|
3214
|
+
url = formatUrl(host, port);
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3218
|
+
const cfg = {
|
|
3219
|
+
url,
|
|
3220
|
+
host,
|
|
3221
|
+
port,
|
|
3222
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3223
|
+
...token ? { token } : {}
|
|
3224
|
+
};
|
|
3225
|
+
await writeLinkConfig(cfg);
|
|
3226
|
+
if (existing && existing.url !== url) {
|
|
3227
|
+
console.log(`${import_picocolors2.default.green("\u2713")} Link updated: ${import_picocolors2.default.dim(existing.url)} \u2192 ${import_picocolors2.default.cyan(url)}`);
|
|
2922
3228
|
} else {
|
|
2923
|
-
console.log(
|
|
3229
|
+
console.log(`${import_picocolors2.default.green("\u2713")} Linked: ${import_picocolors2.default.cyan(url)}`);
|
|
2924
3230
|
}
|
|
3231
|
+
if (token) console.log(import_picocolors2.default.dim(" auth: token stored in ~/.argent/link.json (0600)"));
|
|
3232
|
+
printSecurityCaveat(host, token, url);
|
|
3233
|
+
if (process.env.ARGENT_TOOLS_URL) {
|
|
3234
|
+
console.log(
|
|
3235
|
+
import_picocolors2.default.yellow(
|
|
3236
|
+
`Note: ARGENT_TOOLS_URL=${process.env.ARGENT_TOOLS_URL} is set in your environment and takes precedence over the link.`
|
|
3237
|
+
)
|
|
3238
|
+
);
|
|
3239
|
+
}
|
|
3240
|
+
printRestartHint();
|
|
2925
3241
|
}
|
|
2926
|
-
function
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
if (argv.includes("--help") || argv.includes("-h")) {
|
|
2934
|
-
console.log(`Usage: argent flags [--json]
|
|
2935
|
-
|
|
2936
|
-
List the available feature flags and their current state. Flags are
|
|
2937
|
-
predefined; project-scoped values override global ones.
|
|
2938
|
-
|
|
2939
|
-
Options:
|
|
2940
|
-
--json Print machine-readable JSON
|
|
3242
|
+
async function unlink3(argv) {
|
|
3243
|
+
let flags2;
|
|
3244
|
+
try {
|
|
3245
|
+
flags2 = parseUnlinkFlags(argv);
|
|
3246
|
+
} catch (err) {
|
|
3247
|
+
if (err instanceof StartFlagError) {
|
|
3248
|
+
console.error(`Error: ${err.message}
|
|
2941
3249
|
`);
|
|
3250
|
+
printUnlinkHelp();
|
|
3251
|
+
process.exit(2);
|
|
3252
|
+
}
|
|
3253
|
+
throw err;
|
|
3254
|
+
}
|
|
3255
|
+
if (flags2.help) {
|
|
3256
|
+
printUnlinkHelp();
|
|
2942
3257
|
return;
|
|
2943
3258
|
}
|
|
2944
|
-
const
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
const effective = {};
|
|
2948
|
-
for (const [k2, v2] of Object.entries(globalFlags)) effective[k2] = { value: v2, scope: "global" };
|
|
2949
|
-
for (const [k2, v2] of Object.entries(projectFlags)) effective[k2] = { value: v2, scope: "project" };
|
|
2950
|
-
const registryView = registry.map((def) => {
|
|
2951
|
-
const eff = Object.hasOwn(effective, def.name) ? effective[def.name] : void 0;
|
|
2952
|
-
return {
|
|
2953
|
-
name: def.name,
|
|
2954
|
-
description: def.description,
|
|
2955
|
-
enabled: eff?.value ?? false,
|
|
2956
|
-
scope: eff?.scope ?? null
|
|
2957
|
-
};
|
|
2958
|
-
});
|
|
2959
|
-
const known = new Set(registry.map((def) => def.name));
|
|
2960
|
-
const unrecognized = Object.keys(effective).filter((name) => !known.has(name)).sort().map((name) => ({ name, enabled: effective[name].value, scope: effective[name].scope }));
|
|
2961
|
-
if (json) {
|
|
2962
|
-
console.log(
|
|
2963
|
-
JSON.stringify(
|
|
2964
|
-
{
|
|
2965
|
-
flags: registryView,
|
|
2966
|
-
unrecognized,
|
|
2967
|
-
global: globalFlags,
|
|
2968
|
-
project: projectFlags,
|
|
2969
|
-
effective,
|
|
2970
|
-
paths: {
|
|
2971
|
-
global: getFlagsPath("global"),
|
|
2972
|
-
project: getFlagsPath("project")
|
|
2973
|
-
}
|
|
2974
|
-
},
|
|
2975
|
-
null,
|
|
2976
|
-
2
|
|
2977
|
-
)
|
|
2978
|
-
);
|
|
3259
|
+
const existing = await readLinkConfig();
|
|
3260
|
+
if (!existing) {
|
|
3261
|
+
console.log("Not currently linked \u2014 already using local tool-server.");
|
|
2979
3262
|
return;
|
|
2980
3263
|
}
|
|
2981
|
-
if (
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
console.log(` ${f2.name.padEnd(maxName, " ")} ${stateLabel.padEnd(8)}${scopeLabel}`);
|
|
2990
|
-
console.log(` ${" ".repeat(maxName)} ${f2.description}`);
|
|
3264
|
+
if (!flags2.yes) {
|
|
3265
|
+
const confirmed = await ue({
|
|
3266
|
+
message: `Remove link to ${import_picocolors2.default.cyan(existing.url)}?`,
|
|
3267
|
+
initialValue: true
|
|
3268
|
+
});
|
|
3269
|
+
if (q(confirmed) || !confirmed) {
|
|
3270
|
+
me("Unlink cancelled.");
|
|
3271
|
+
process.exit(0);
|
|
2991
3272
|
}
|
|
2992
3273
|
}
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3274
|
+
await clearLinkConfig();
|
|
3275
|
+
console.log(`${import_picocolors2.default.green("\u2713")} Unlinked from ${import_picocolors2.default.dim(existing.url)}.`);
|
|
3276
|
+
if (process.env.ARGENT_TOOLS_URL) {
|
|
3277
|
+
console.log(
|
|
3278
|
+
import_picocolors2.default.yellow(
|
|
3279
|
+
`The env var ARGENT_TOOLS_URL is also set in your shell (=${process.env.ARGENT_TOOLS_URL}) and takes precedence \u2014 unset it manually if you want fully local behaviour.`
|
|
3280
|
+
)
|
|
3281
|
+
);
|
|
3000
3282
|
}
|
|
3001
|
-
|
|
3002
|
-
Global: ${getFlagsPath("global")}`);
|
|
3003
|
-
console.log(` Project: ${getFlagsPath("project")}`);
|
|
3283
|
+
printRestartHint();
|
|
3004
3284
|
}
|
|
3005
3285
|
export {
|
|
3006
3286
|
FLAG_REGISTRY,
|