feat(ai-tools): install/update AI CLIs, remote catalog sync, cached favicons (#40 A2)
This commit is contained in:
@@ -5,7 +5,9 @@
|
||||
* invisible to AI Tools detection and to every lane pane. `$SHELL -ilc` runs
|
||||
* the rc files where those installers add to PATH; delimiters discard
|
||||
* whatever the rc files print, stdin is closed so a prompt gets EOF, and a
|
||||
* timeout bounds a hang. Off with `AGENTHUB_SHELL_PATH=0`. Adapted from Orca's
|
||||
* timeout bounds a hang. Off with `AGENTHUB_SHELL_PATH=0`. The shell's own
|
||||
* PATH is also kept in ITS order (`shellPath()`): the merge appends, so an
|
||||
* install job that must use the shell's npm puts this first. Adapted from Orca's
|
||||
* `hydrate-shell-path.ts` (MIT).
|
||||
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
||||
*/
|
||||
@@ -15,6 +17,11 @@ const path = require("node:path");
|
||||
|
||||
const MARK = "__AGENTHUB_PATH__";
|
||||
|
||||
let lastShellPath = null;
|
||||
|
||||
/** The PATH the login shell last printed, in its order; null before/without one. */
|
||||
const shellPath = () => lastShellPath;
|
||||
|
||||
/**
|
||||
* @returns {Promise<boolean>} whether a shell PATH was read and merged.
|
||||
*/
|
||||
@@ -34,6 +41,7 @@ function hydrateShellPath({
|
||||
(err, stdout) => {
|
||||
const m = String(stdout || "").match(new RegExp(`${MARK}(.*?)${MARK}`, "s"));
|
||||
if (!m) return resolve(false); // timeout, spawn error, no output
|
||||
lastShellPath = m[1];
|
||||
const have = (process.env.PATH || "").split(path.delimiter).filter(Boolean);
|
||||
const add = m[1].split(path.delimiter).filter((d) => d && !have.includes(d));
|
||||
process.env.PATH = [...have, ...new Set(add)].join(path.delimiter);
|
||||
@@ -48,4 +56,4 @@ function hydrateShellPath({
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { hydrateShellPath };
|
||||
module.exports = { hydrateShellPath, shellPath };
|
||||
|
||||
Reference in New Issue
Block a user