@standardagents/code 0.9.3 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +178 -37
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import os10, { homedir } from 'os';
|
|
3
3
|
import path3 from 'path';
|
|
4
4
|
import readline2 from 'readline/promises';
|
|
5
5
|
import { stdout, stdin } from 'process';
|
|
@@ -1112,7 +1112,7 @@ function detailSuffix(tool, result) {
|
|
|
1112
1112
|
const lines = result.split("\n").length;
|
|
1113
1113
|
return ` (${lines} line${lines === 1 ? "" : "s"})`;
|
|
1114
1114
|
}
|
|
1115
|
-
var LOG_DIR = path3.join(
|
|
1115
|
+
var LOG_DIR = path3.join(os10.homedir(), ".standardagents", "process-logs");
|
|
1116
1116
|
var KEY2 = "bg_processes";
|
|
1117
1117
|
function isAlive(pid) {
|
|
1118
1118
|
try {
|
|
@@ -1189,7 +1189,7 @@ var ProcessRegistry = class {
|
|
|
1189
1189
|
}
|
|
1190
1190
|
};
|
|
1191
1191
|
function configFile() {
|
|
1192
|
-
return process.env.STANDARDAGENTS_MCP_CONFIG || path3.join(
|
|
1192
|
+
return process.env.STANDARDAGENTS_MCP_CONFIG || path3.join(os10.homedir(), ".standardagents", "mcp.json");
|
|
1193
1193
|
}
|
|
1194
1194
|
function loadMcpConfig() {
|
|
1195
1195
|
try {
|
|
@@ -1491,7 +1491,7 @@ var HostTools = class {
|
|
|
1491
1491
|
}
|
|
1492
1492
|
}
|
|
1493
1493
|
const hash = crypto.createHash("sha256").update(JSON.stringify(files)).digest("hex").slice(0, 12);
|
|
1494
|
-
const skillDir = path3.join(
|
|
1494
|
+
const skillDir = path3.join(os10.tmpdir(), "standardcode-skills", `${skill}-${hash}`);
|
|
1495
1495
|
for (const f of files) {
|
|
1496
1496
|
const dest = path3.resolve(skillDir, f.path);
|
|
1497
1497
|
if (path3.relative(skillDir, dest).startsWith("..")) {
|
|
@@ -2816,7 +2816,7 @@ function fromFile(filePath) {
|
|
|
2816
2816
|
}
|
|
2817
2817
|
}
|
|
2818
2818
|
async function readDarwin() {
|
|
2819
|
-
const tmp = path3.join(
|
|
2819
|
+
const tmp = path3.join(os10.tmpdir(), `sc-clip-${process.pid}-${Date.now()}.png`);
|
|
2820
2820
|
const script = [
|
|
2821
2821
|
`set d to the clipboard as \xABclass PNGf\xBB`,
|
|
2822
2822
|
`set f to open for access POSIX file "${tmp}" with write permission`,
|
|
@@ -2853,7 +2853,7 @@ async function readLinux() {
|
|
|
2853
2853
|
return null;
|
|
2854
2854
|
}
|
|
2855
2855
|
async function readWindows() {
|
|
2856
|
-
const tmp = path3.join(
|
|
2856
|
+
const tmp = path3.join(os10.tmpdir(), `sc-clip-${process.pid}-${Date.now()}.png`);
|
|
2857
2857
|
const ps = [
|
|
2858
2858
|
"Add-Type -AssemblyName System.Windows.Forms;",
|
|
2859
2859
|
"$img = [System.Windows.Forms.Clipboard]::GetImage();",
|
|
@@ -4920,7 +4920,7 @@ function renderMarkdown(src, cols2 = 80) {
|
|
|
4920
4920
|
}
|
|
4921
4921
|
return out;
|
|
4922
4922
|
}
|
|
4923
|
-
var DIR = path3.join(
|
|
4923
|
+
var DIR = path3.join(os10.homedir(), ".standardagents");
|
|
4924
4924
|
var FILE = path3.join(DIR, "credentials");
|
|
4925
4925
|
function normalizeEndpoint(endpoint) {
|
|
4926
4926
|
let e = endpoint.trim();
|
|
@@ -5054,7 +5054,7 @@ function relaxTlsForLocalEndpoint(endpoint) {
|
|
|
5054
5054
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
5055
5055
|
return true;
|
|
5056
5056
|
}
|
|
5057
|
-
var dir = () => path3.join(
|
|
5057
|
+
var dir = () => path3.join(os10.homedir(), ".standardagents");
|
|
5058
5058
|
var file = () => path3.join(dir(), "machine.json");
|
|
5059
5059
|
function loadMachineIdentity() {
|
|
5060
5060
|
try {
|
|
@@ -5088,6 +5088,8 @@ function machineIdFromDaemonClientId(clientId) {
|
|
|
5088
5088
|
var KEY_PREFIX = "standardcode.machine.";
|
|
5089
5089
|
var CMD_SUFFIX = ".cmd";
|
|
5090
5090
|
var NAME_SUFFIX = ".name";
|
|
5091
|
+
var FSREQ_SUFFIX = ".fsreq";
|
|
5092
|
+
var FSRES_SUFFIX = ".fsres";
|
|
5091
5093
|
var DAEMON_ONLINE_WINDOW_MS = 90 * 1e3;
|
|
5092
5094
|
function machineKey(machineId) {
|
|
5093
5095
|
return `${KEY_PREFIX}${machineId}`;
|
|
@@ -5098,6 +5100,30 @@ function commandKey(machineId) {
|
|
|
5098
5100
|
function nameKey(machineId) {
|
|
5099
5101
|
return `${KEY_PREFIX}${machineId}${NAME_SUFFIX}`;
|
|
5100
5102
|
}
|
|
5103
|
+
function fsRequestKey(machineId) {
|
|
5104
|
+
return `${KEY_PREFIX}${machineId}${FSREQ_SUFFIX}`;
|
|
5105
|
+
}
|
|
5106
|
+
function fsResponseKey(machineId) {
|
|
5107
|
+
return `${KEY_PREFIX}${machineId}${FSRES_SUFFIX}`;
|
|
5108
|
+
}
|
|
5109
|
+
function parseFsRequest(value) {
|
|
5110
|
+
if (!value || typeof value !== "object") return null;
|
|
5111
|
+
const r = value;
|
|
5112
|
+
if (typeof r.nonce !== "string" || r.op !== "list" || typeof r.path !== "string") return null;
|
|
5113
|
+
return {
|
|
5114
|
+
nonce: r.nonce,
|
|
5115
|
+
op: "list",
|
|
5116
|
+
path: r.path,
|
|
5117
|
+
show_hidden: r.show_hidden === true,
|
|
5118
|
+
requested_at: typeof r.requested_at === "number" ? r.requested_at : Date.now()
|
|
5119
|
+
};
|
|
5120
|
+
}
|
|
5121
|
+
async function readFsRequest(api, machineId) {
|
|
5122
|
+
return parseFsRequest(await api.userKvGet(fsRequestKey(machineId)));
|
|
5123
|
+
}
|
|
5124
|
+
async function writeFsResponse(api, machineId, res) {
|
|
5125
|
+
await api.userKvSet(fsResponseKey(machineId), { ...res, responded_at: Date.now() });
|
|
5126
|
+
}
|
|
5101
5127
|
function machineDisplayName(record) {
|
|
5102
5128
|
return record.name?.trim() || "" || (record.hostname || "") || (record.id || "") || "machine";
|
|
5103
5129
|
}
|
|
@@ -5164,8 +5190,8 @@ function newRecord(identity) {
|
|
|
5164
5190
|
const now = Date.now();
|
|
5165
5191
|
return {
|
|
5166
5192
|
id: identity.machine_id,
|
|
5167
|
-
name:
|
|
5168
|
-
hostname:
|
|
5193
|
+
name: os10.hostname(),
|
|
5194
|
+
hostname: os10.hostname(),
|
|
5169
5195
|
platform: process.platform,
|
|
5170
5196
|
arch: process.arch,
|
|
5171
5197
|
version: readVersion() || void 0,
|
|
@@ -5178,7 +5204,7 @@ function newRecord(identity) {
|
|
|
5178
5204
|
async function updateOwnMachineRecord(api, identity, mutate) {
|
|
5179
5205
|
const existing = await loadRawMachine(api, identity.machine_id);
|
|
5180
5206
|
const record = existing ?? newRecord(identity);
|
|
5181
|
-
record.hostname =
|
|
5207
|
+
record.hostname = os10.hostname();
|
|
5182
5208
|
record.platform = process.platform;
|
|
5183
5209
|
record.arch = process.arch;
|
|
5184
5210
|
record.version = readVersion() || record.version;
|
|
@@ -5263,16 +5289,16 @@ async function clearMachineCommands(api, machineId, appliedIds) {
|
|
|
5263
5289
|
async function applyMachineCommand(api, identity, cmd) {
|
|
5264
5290
|
switch (cmd.kind) {
|
|
5265
5291
|
case "add_project": {
|
|
5266
|
-
const
|
|
5267
|
-
if (!
|
|
5268
|
-
await registerProject(api, identity,
|
|
5269
|
-
return `added project ${
|
|
5292
|
+
const path13 = typeof cmd.args?.path === "string" ? cmd.args.path : "";
|
|
5293
|
+
if (!path13) return "add_project: ignored (no path)";
|
|
5294
|
+
await registerProject(api, identity, path13);
|
|
5295
|
+
return `added project ${path13}`;
|
|
5270
5296
|
}
|
|
5271
5297
|
case "remove_project": {
|
|
5272
|
-
const
|
|
5273
|
-
if (!
|
|
5274
|
-
await unregisterProject(api, identity,
|
|
5275
|
-
return `removed project ${
|
|
5298
|
+
const path13 = typeof cmd.args?.path === "string" ? cmd.args.path : "";
|
|
5299
|
+
if (!path13) return "remove_project: ignored (no path)";
|
|
5300
|
+
await unregisterProject(api, identity, path13);
|
|
5301
|
+
return `removed project ${path13}`;
|
|
5276
5302
|
}
|
|
5277
5303
|
case "update":
|
|
5278
5304
|
return "update requested";
|
|
@@ -5334,6 +5360,94 @@ async function awaitApprovalViaRelay(api, threadId, request, options = {}) {
|
|
|
5334
5360
|
});
|
|
5335
5361
|
}
|
|
5336
5362
|
}
|
|
5363
|
+
var PROJECT_MARKERS = [
|
|
5364
|
+
".git",
|
|
5365
|
+
"package.json",
|
|
5366
|
+
"pyproject.toml",
|
|
5367
|
+
"Cargo.toml",
|
|
5368
|
+
"go.mod",
|
|
5369
|
+
"pom.xml",
|
|
5370
|
+
"build.gradle",
|
|
5371
|
+
"Gemfile",
|
|
5372
|
+
"composer.json",
|
|
5373
|
+
"requirements.txt",
|
|
5374
|
+
".standardagents"
|
|
5375
|
+
];
|
|
5376
|
+
var MAX_ENTRIES2 = 500;
|
|
5377
|
+
function resolveBrowsePath(input3) {
|
|
5378
|
+
const home = os10.homedir();
|
|
5379
|
+
let p = (input3 ?? "").trim();
|
|
5380
|
+
if (!p) return home;
|
|
5381
|
+
if (p === "~") return home;
|
|
5382
|
+
if (p.startsWith("~/")) p = path3.join(home, p.slice(2));
|
|
5383
|
+
return path3.resolve(p);
|
|
5384
|
+
}
|
|
5385
|
+
function markers(dirPath) {
|
|
5386
|
+
let repo = false;
|
|
5387
|
+
let project = false;
|
|
5388
|
+
for (const marker of PROJECT_MARKERS) {
|
|
5389
|
+
let hit = false;
|
|
5390
|
+
try {
|
|
5391
|
+
hit = fs4.existsSync(path3.join(dirPath, marker));
|
|
5392
|
+
} catch {
|
|
5393
|
+
hit = false;
|
|
5394
|
+
}
|
|
5395
|
+
if (!hit) continue;
|
|
5396
|
+
project = true;
|
|
5397
|
+
if (marker === ".git") repo = true;
|
|
5398
|
+
if (repo) break;
|
|
5399
|
+
}
|
|
5400
|
+
return { project, repo };
|
|
5401
|
+
}
|
|
5402
|
+
function browseDirectory(input3, opts = {}) {
|
|
5403
|
+
const home = os10.homedir();
|
|
5404
|
+
const abs = resolveBrowsePath(input3);
|
|
5405
|
+
const parent = path3.dirname(abs);
|
|
5406
|
+
const base = {
|
|
5407
|
+
path: abs,
|
|
5408
|
+
parent: parent === abs ? null : parent,
|
|
5409
|
+
home
|
|
5410
|
+
};
|
|
5411
|
+
let dirents;
|
|
5412
|
+
try {
|
|
5413
|
+
const stat = fs4.statSync(abs);
|
|
5414
|
+
if (!stat.isDirectory()) {
|
|
5415
|
+
return { ...base, entries: [], truncated: false, error: "Not a directory" };
|
|
5416
|
+
}
|
|
5417
|
+
dirents = fs4.readdirSync(abs, { withFileTypes: true });
|
|
5418
|
+
} catch (err) {
|
|
5419
|
+
const code = err?.code;
|
|
5420
|
+
const message = code === "EACCES" || code === "EPERM" ? "Permission denied" : code === "ENOENT" ? "Folder not found" : "Could not read this folder";
|
|
5421
|
+
return { ...base, entries: [], truncated: false, error: message };
|
|
5422
|
+
}
|
|
5423
|
+
const showHidden = !!opts.showHidden;
|
|
5424
|
+
const rawDirs = [];
|
|
5425
|
+
const rawFiles = [];
|
|
5426
|
+
for (const d of dirents) {
|
|
5427
|
+
const name = d.name;
|
|
5428
|
+
if (!showHidden && name.startsWith(".")) continue;
|
|
5429
|
+
let isDir = d.isDirectory();
|
|
5430
|
+
if (d.isSymbolicLink()) {
|
|
5431
|
+
try {
|
|
5432
|
+
isDir = fs4.statSync(path3.join(abs, name)).isDirectory();
|
|
5433
|
+
} catch {
|
|
5434
|
+
isDir = false;
|
|
5435
|
+
}
|
|
5436
|
+
}
|
|
5437
|
+
if (isDir) {
|
|
5438
|
+
const { project, repo } = markers(path3.join(abs, name));
|
|
5439
|
+
rawDirs.push({ name, dir: true, project: project || void 0, repo: repo || void 0 });
|
|
5440
|
+
} else {
|
|
5441
|
+
rawFiles.push({ name, dir: false });
|
|
5442
|
+
}
|
|
5443
|
+
}
|
|
5444
|
+
const cmp = (a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase());
|
|
5445
|
+
rawDirs.sort(cmp);
|
|
5446
|
+
rawFiles.sort(cmp);
|
|
5447
|
+
const all = [...rawDirs, ...rawFiles];
|
|
5448
|
+
const truncated = all.length > MAX_ENTRIES2;
|
|
5449
|
+
return { ...base, entries: truncated ? all.slice(0, MAX_ENTRIES2) : all, truncated };
|
|
5450
|
+
}
|
|
5337
5451
|
var PKG_NAME = "@standardagents/code";
|
|
5338
5452
|
var REGISTRY_URL = `https://registry.npmjs.org/${encodeURIComponent(PKG_NAME)}`;
|
|
5339
5453
|
var CACHE_REL_DIR = ".config/standardagents-cli";
|
|
@@ -5514,12 +5628,13 @@ function runUpdate(pm) {
|
|
|
5514
5628
|
// src/daemon.ts
|
|
5515
5629
|
var HEARTBEAT_MS = 3e4;
|
|
5516
5630
|
var COMMAND_POLL_MS = 8e3;
|
|
5631
|
+
var FS_POLL_MS = 1e3;
|
|
5517
5632
|
var RECLAIM_PROBE_MS = 2 * 6e4;
|
|
5518
5633
|
var UPDATE_CHECK_MS = 6 * 60 * 6e4;
|
|
5519
5634
|
var SWEEP_MS = 10 * 6e4;
|
|
5520
5635
|
var MAX_WORKERS = 30;
|
|
5521
5636
|
var LOG_MAX_BYTES = 1e6;
|
|
5522
|
-
var LOG_FILE = path3.join(
|
|
5637
|
+
var LOG_FILE = path3.join(os10.homedir(), ".standardagents", "daemon.log");
|
|
5523
5638
|
function daemonLog(line) {
|
|
5524
5639
|
try {
|
|
5525
5640
|
fs4.mkdirSync(path3.dirname(LOG_FILE), { recursive: true });
|
|
@@ -5538,7 +5653,7 @@ function pathFromTags(tags) {
|
|
|
5538
5653
|
const tag = tags.find((t) => t.startsWith("path:"));
|
|
5539
5654
|
if (!tag) return null;
|
|
5540
5655
|
const raw = tag.slice("path:".length);
|
|
5541
|
-
return raw.replace(/^~(?=\/|$)/,
|
|
5656
|
+
return raw.replace(/^~(?=\/|$)/, os10.homedir());
|
|
5542
5657
|
}
|
|
5543
5658
|
var ThreadWorker = class {
|
|
5544
5659
|
constructor(api, identity, machineName, threadId, projectDir, createdAt) {
|
|
@@ -5670,7 +5785,7 @@ Run \`standardcode daemon install\` (or plain \`standardcode\`) once to sign in.
|
|
|
5670
5785
|
process.exit(1);
|
|
5671
5786
|
}
|
|
5672
5787
|
let displayName = machineDisplayName(await loadMachine(api, identity.machine_id).catch(() => null) ?? {
|
|
5673
|
-
hostname:
|
|
5788
|
+
hostname: os10.hostname(),
|
|
5674
5789
|
id: identity.machine_id
|
|
5675
5790
|
});
|
|
5676
5791
|
const applied = consumeAppliedUpdate(version);
|
|
@@ -5832,6 +5947,31 @@ Run \`standardcode daemon install\` (or plain \`standardcode\`) once to sign in.
|
|
|
5832
5947
|
};
|
|
5833
5948
|
void drainCommands();
|
|
5834
5949
|
const commandTimer = setInterval(() => void drainCommands(), COMMAND_POLL_MS);
|
|
5950
|
+
let lastFsNonce = null;
|
|
5951
|
+
let fsBusy = false;
|
|
5952
|
+
const drainFsRequests = async () => {
|
|
5953
|
+
if (fsBusy) return;
|
|
5954
|
+
fsBusy = true;
|
|
5955
|
+
try {
|
|
5956
|
+
const req = await readFsRequest(api, identity.machine_id).catch(() => null);
|
|
5957
|
+
if (!req || req.nonce === lastFsNonce) return;
|
|
5958
|
+
lastFsNonce = req.nonce;
|
|
5959
|
+
let ok = true;
|
|
5960
|
+
let result;
|
|
5961
|
+
let error;
|
|
5962
|
+
try {
|
|
5963
|
+
result = browseDirectory(req.path, { showHidden: req.show_hidden });
|
|
5964
|
+
} catch (err) {
|
|
5965
|
+
ok = false;
|
|
5966
|
+
error = err instanceof Error ? err.message : "browse failed";
|
|
5967
|
+
}
|
|
5968
|
+
await writeFsResponse(api, identity.machine_id, { nonce: req.nonce, ok, result, error }).catch(() => {
|
|
5969
|
+
});
|
|
5970
|
+
} finally {
|
|
5971
|
+
fsBusy = false;
|
|
5972
|
+
}
|
|
5973
|
+
};
|
|
5974
|
+
const fsTimer = setInterval(() => void drainFsRequests(), FS_POLL_MS);
|
|
5835
5975
|
const sweeper = setInterval(() => {
|
|
5836
5976
|
if (updateReady && ![...workers.values()].some((w) => w.busy)) {
|
|
5837
5977
|
daemonLog("restarting to apply the installed update");
|
|
@@ -5845,6 +5985,7 @@ Run \`standardcode daemon install\` (or plain \`standardcode\`) once to sign in.
|
|
|
5845
5985
|
clearInterval(reclaim);
|
|
5846
5986
|
clearInterval(updateTimer);
|
|
5847
5987
|
clearInterval(commandTimer);
|
|
5988
|
+
clearInterval(fsTimer);
|
|
5848
5989
|
clearInterval(sweeper);
|
|
5849
5990
|
for (const worker of workers.values()) worker.stop();
|
|
5850
5991
|
events.close();
|
|
@@ -5902,8 +6043,8 @@ function run2(cmd, args) {
|
|
|
5902
6043
|
const output4 = `${res.stdout ?? ""}${res.stderr ?? ""}`.trim();
|
|
5903
6044
|
return { ok: res.status === 0, output: output4 };
|
|
5904
6045
|
}
|
|
5905
|
-
var plistPath = () => path3.join(
|
|
5906
|
-
var unitPath = () => path3.join(
|
|
6046
|
+
var plistPath = () => path3.join(os10.homedir(), "Library", "LaunchAgents", `${SERVICE_LABEL}.plist`);
|
|
6047
|
+
var unitPath = () => path3.join(os10.homedir(), ".config", "systemd", "user", SYSTEMD_UNIT);
|
|
5907
6048
|
var xmlEscape = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
5908
6049
|
function installService(command, endpoint) {
|
|
5909
6050
|
if (process.platform === "darwin") return installLaunchd(command, endpoint);
|
|
@@ -5915,7 +6056,7 @@ function installService(command, endpoint) {
|
|
|
5915
6056
|
};
|
|
5916
6057
|
}
|
|
5917
6058
|
function installLaunchd(command, endpoint) {
|
|
5918
|
-
const logDir = path3.join(
|
|
6059
|
+
const logDir = path3.join(os10.homedir(), ".standardagents");
|
|
5919
6060
|
fs4.mkdirSync(logDir, { recursive: true });
|
|
5920
6061
|
fs4.mkdirSync(path3.dirname(plistPath()), { recursive: true });
|
|
5921
6062
|
const envEntries = [
|
|
@@ -5988,10 +6129,10 @@ WantedBy=default.target
|
|
|
5988
6129
|
if (!enable.ok) {
|
|
5989
6130
|
return { ok: false, detail: `systemctl enable failed: ${enable.output}` };
|
|
5990
6131
|
}
|
|
5991
|
-
const linger = run2("loginctl", ["enable-linger",
|
|
6132
|
+
const linger = run2("loginctl", ["enable-linger", os10.userInfo().username]);
|
|
5992
6133
|
return {
|
|
5993
6134
|
ok: true,
|
|
5994
|
-
detail: `systemd user unit installed (${unitPath()})` + (linger.ok ? ", lingering enabled" : ` \u2014 enable lingering manually: sudo loginctl enable-linger ${
|
|
6135
|
+
detail: `systemd user unit installed (${unitPath()})` + (linger.ok ? ", lingering enabled" : ` \u2014 enable lingering manually: sudo loginctl enable-linger ${os10.userInfo().username}`)
|
|
5995
6136
|
};
|
|
5996
6137
|
}
|
|
5997
6138
|
function uninstallService() {
|
|
@@ -6119,7 +6260,7 @@ async function installCommand(endpointFlag) {
|
|
|
6119
6260
|
const api = await ensureSignedIn(endpoint);
|
|
6120
6261
|
const identity = loadMachineIdentity();
|
|
6121
6262
|
const existing = await loadMachine(api, identity.machine_id).catch(() => null);
|
|
6122
|
-
const suggested = machineDisplayName(existing ?? { hostname:
|
|
6263
|
+
const suggested = machineDisplayName(existing ?? { hostname: os10.hostname(), id: identity.machine_id });
|
|
6123
6264
|
const rl = readline2.createInterface({ input: stdin, output: stdout });
|
|
6124
6265
|
const answer = (await rl.question(
|
|
6125
6266
|
`${c2.bold}Machine name${c2.reset} ${c2.dim}(shown in the session picker)${c2.reset} [${suggested}]: `
|
|
@@ -6179,7 +6320,7 @@ async function statusCommand() {
|
|
|
6179
6320
|
const cred = getCredential(endpoint);
|
|
6180
6321
|
if (!cred) {
|
|
6181
6322
|
stdout.write(
|
|
6182
|
-
`${c2.bold}Machine:${c2.reset} ${
|
|
6323
|
+
`${c2.bold}Machine:${c2.reset} ${os10.hostname()} ${c2.dim}(${identity.machine_id})${c2.reset}
|
|
6183
6324
|
`
|
|
6184
6325
|
);
|
|
6185
6326
|
stdout.write(`${c2.bold}Account:${c2.reset} ${c2.yellow}not signed in to ${endpoint}${c2.reset}
|
|
@@ -6190,7 +6331,7 @@ async function statusCommand() {
|
|
|
6190
6331
|
const api = new ApiClient(endpoint, cred.access_token);
|
|
6191
6332
|
const record = await loadMachine(api, identity.machine_id).catch(() => null);
|
|
6192
6333
|
stdout.write(
|
|
6193
|
-
`${c2.bold}Machine:${c2.reset} ${machineDisplayName(record ?? { hostname:
|
|
6334
|
+
`${c2.bold}Machine:${c2.reset} ${machineDisplayName(record ?? { hostname: os10.hostname(), id: identity.machine_id })} ${c2.dim}(${identity.machine_id})${c2.reset}
|
|
6194
6335
|
`
|
|
6195
6336
|
);
|
|
6196
6337
|
if (!record) {
|
|
@@ -6224,7 +6365,7 @@ async function projectCommand(action, target) {
|
|
|
6224
6365
|
const api = await ensureSignedIn(endpoint);
|
|
6225
6366
|
const identity = loadMachineIdentity();
|
|
6226
6367
|
const record = await loadMachine(api, identity.machine_id).catch(() => null);
|
|
6227
|
-
const displayName = machineDisplayName(record ?? { hostname:
|
|
6368
|
+
const displayName = machineDisplayName(record ?? { hostname: os10.hostname(), id: identity.machine_id });
|
|
6228
6369
|
if (action === "add") {
|
|
6229
6370
|
await registerProject(api, identity, dir2);
|
|
6230
6371
|
stdout.write(`${c2.green}\u2713${c2.reset} Registered ${dir2} for remote sessions on ${displayName}.
|
|
@@ -6424,7 +6565,7 @@ ${c3.teal}\u25C7${c3.reset} ${c3.dim}Standard Code \u2014 see you soon.${c3.rese
|
|
|
6424
6565
|
`);
|
|
6425
6566
|
}
|
|
6426
6567
|
function printWelcome(endpoint, projectDir) {
|
|
6427
|
-
const home =
|
|
6568
|
+
const home = os10.homedir();
|
|
6428
6569
|
const dir2 = projectDir.startsWith(home) ? "~" + projectDir.slice(home.length) : projectDir;
|
|
6429
6570
|
const host = endpoint.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
|
6430
6571
|
const version = readVersion();
|
|
@@ -6492,7 +6633,7 @@ async function main() {
|
|
|
6492
6633
|
const endpointOverride = cliArgs.promptEndpoint || typeof endpointArg === "string" && endpointArg.trim() !== "";
|
|
6493
6634
|
const dirArg = cliArgs.dir;
|
|
6494
6635
|
const projectDir = path3.resolve(dirArg || process.cwd());
|
|
6495
|
-
const machine =
|
|
6636
|
+
const machine = os10.hostname();
|
|
6496
6637
|
const reader = { rl: null };
|
|
6497
6638
|
let handoffClosing = false;
|
|
6498
6639
|
let preflightArmed = false;
|
|
@@ -6677,7 +6818,7 @@ ${c3.dim}Press Control-C again to exit${c3.reset}
|
|
|
6677
6818
|
void registerProject(api, identity, projectDir).catch(() => {
|
|
6678
6819
|
});
|
|
6679
6820
|
const tui = new Tui(1);
|
|
6680
|
-
const home =
|
|
6821
|
+
const home = os10.homedir();
|
|
6681
6822
|
const tildeDir = projectDir.startsWith(home) ? "~" + projectDir.slice(home.length) : projectDir;
|
|
6682
6823
|
const shortDir = tildeDir.length > 38 ? "\u2026" + tildeDir.slice(-37) : tildeDir;
|
|
6683
6824
|
const session = { mode: "local", identity };
|
|
@@ -7833,12 +7974,12 @@ async function manageMachineProjects(tui, api, self, machine, dispatch, applyNot
|
|
|
7833
7974
|
);
|
|
7834
7975
|
if (!picked) return;
|
|
7835
7976
|
if (picked === ADD) {
|
|
7836
|
-
const
|
|
7977
|
+
const path13 = await tui.prompt(
|
|
7837
7978
|
`Absolute project path on ${machine.name}`,
|
|
7838
7979
|
machine.id === self.machine_id ? process.cwd() : "/home/you/project"
|
|
7839
7980
|
);
|
|
7840
|
-
if (!
|
|
7841
|
-
const trimmed =
|
|
7981
|
+
if (!path13 || !path13.trim()) return;
|
|
7982
|
+
const trimmed = path13.trim();
|
|
7842
7983
|
if (!trimmed.startsWith("/") && !trimmed.startsWith("~")) {
|
|
7843
7984
|
tui.print(`${c3.yellow}Use an absolute path (starting with / or ~).${c3.reset}`);
|
|
7844
7985
|
return;
|