@agentvalet/register 0.4.16 → 0.4.17
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 +77 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1763,7 +1763,8 @@ function injectCommand() {
|
|
|
1763
1763
|
import { Command as Command4 } from "commander";
|
|
1764
1764
|
import chalk11 from "chalk";
|
|
1765
1765
|
import { existsSync as existsSync7, readFileSync as readFileSync4, writeFileSync as writeFileSync3, rmSync } from "fs";
|
|
1766
|
-
import { resolve as resolve3 } from "path";
|
|
1766
|
+
import { resolve as resolve3, join as join2 } from "path";
|
|
1767
|
+
import { homedir as homedir2 } from "os";
|
|
1767
1768
|
var CLAUDE_START2 = "<!-- agentvalet:start -->";
|
|
1768
1769
|
var CLAUDE_END2 = "<!-- agentvalet:end -->";
|
|
1769
1770
|
var HOOK_MARKER2 = "agentvalet/register refresh";
|
|
@@ -1795,20 +1796,61 @@ function stripSettingsJson() {
|
|
|
1795
1796
|
} catch {
|
|
1796
1797
|
}
|
|
1797
1798
|
}
|
|
1798
|
-
function stripMcpJson() {
|
|
1799
|
-
|
|
1800
|
-
if (!existsSync7(path8)) return;
|
|
1799
|
+
function stripMcpJson(filePath, options = {}) {
|
|
1800
|
+
if (!existsSync7(filePath)) return false;
|
|
1801
1801
|
try {
|
|
1802
|
-
const config = JSON.parse(readFileSync4(
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1802
|
+
const config = JSON.parse(readFileSync4(filePath, "utf-8"));
|
|
1803
|
+
let removed = false;
|
|
1804
|
+
if (options.wrapped === false) {
|
|
1805
|
+
if (config["agentvalet"] !== void 0) {
|
|
1806
|
+
delete config["agentvalet"];
|
|
1807
|
+
removed = true;
|
|
1808
|
+
}
|
|
1809
|
+
} else {
|
|
1810
|
+
const servers = config.mcpServers ?? {};
|
|
1811
|
+
if (servers["agentvalet"] !== void 0) {
|
|
1812
|
+
delete servers["agentvalet"];
|
|
1813
|
+
config.mcpServers = servers;
|
|
1814
|
+
removed = true;
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
if (removed) {
|
|
1818
|
+
writeFileSync3(filePath, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
1819
|
+
}
|
|
1820
|
+
return removed;
|
|
1807
1821
|
} catch {
|
|
1822
|
+
return false;
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
function stripCodexToml() {
|
|
1826
|
+
const path8 = join2(homedir2(), ".codex", "config.toml");
|
|
1827
|
+
if (!existsSync7(path8)) return false;
|
|
1828
|
+
try {
|
|
1829
|
+
const content = readFileSync4(path8, "utf-8");
|
|
1830
|
+
if (!content.includes("[mcp_servers.agentvalet]")) return false;
|
|
1831
|
+
const stripped = content.replace(
|
|
1832
|
+
/\r?\n?\[mcp_servers\.agentvalet\][\s\S]*?(?=\r?\n\[|\r?\n*$)/,
|
|
1833
|
+
""
|
|
1834
|
+
);
|
|
1835
|
+
writeFileSync3(path8, stripped.replace(/(\r?\n){3,}/g, "\n\n").trimEnd() + "\n", "utf-8");
|
|
1836
|
+
return true;
|
|
1837
|
+
} catch {
|
|
1838
|
+
return false;
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
function isAgentValetGeneratedDoc(filePath, markers) {
|
|
1842
|
+
if (!existsSync7(filePath)) return false;
|
|
1843
|
+
try {
|
|
1844
|
+
const content = readFileSync4(filePath, "utf-8");
|
|
1845
|
+
const firstLine = content.split(/\r?\n/).find((l) => l.trim().length > 0) ?? "";
|
|
1846
|
+
return markers.some((m) => firstLine.startsWith(m));
|
|
1847
|
+
} catch {
|
|
1848
|
+
return false;
|
|
1808
1849
|
}
|
|
1809
1850
|
}
|
|
1810
1851
|
function cleanLocally() {
|
|
1811
1852
|
const removed = [];
|
|
1853
|
+
const stripped = [];
|
|
1812
1854
|
const r = (p) => {
|
|
1813
1855
|
const abs = resolve3(p);
|
|
1814
1856
|
if (existsSync7(abs)) {
|
|
@@ -1816,6 +1858,12 @@ function cleanLocally() {
|
|
|
1816
1858
|
removed.push(abs);
|
|
1817
1859
|
}
|
|
1818
1860
|
};
|
|
1861
|
+
const rAbs = (abs) => {
|
|
1862
|
+
if (existsSync7(abs)) {
|
|
1863
|
+
rmSync(abs, { recursive: true, force: true });
|
|
1864
|
+
removed.push(abs);
|
|
1865
|
+
}
|
|
1866
|
+
};
|
|
1819
1867
|
if (existsSync7(AGENT_KEY_PATH)) {
|
|
1820
1868
|
rmSync(AGENT_KEY_PATH, { force: true });
|
|
1821
1869
|
removed.push(AGENT_KEY_PATH);
|
|
@@ -1828,14 +1876,32 @@ function cleanLocally() {
|
|
|
1828
1876
|
r(".agentvalet");
|
|
1829
1877
|
r("agentvalet.key");
|
|
1830
1878
|
r(".claude/agentvalet-permissions.md");
|
|
1879
|
+
r("AGENTVALET.md");
|
|
1880
|
+
r(".factory/droids/agentvalet.yaml");
|
|
1881
|
+
r(".factory/droids/agentvalet-reliability.yaml");
|
|
1882
|
+
r(".factory/commands/av-status.md");
|
|
1883
|
+
r(".factory/commands/av-register.md");
|
|
1884
|
+
const agentsMd = resolve3("AGENTS.md");
|
|
1885
|
+
if (isAgentValetGeneratedDoc(agentsMd, ["# AgentValet"])) rAbs(agentsMd);
|
|
1886
|
+
const skillMd = resolve3("SKILL.md");
|
|
1887
|
+
if (isAgentValetGeneratedDoc(skillMd, ["# AgentValet"])) rAbs(skillMd);
|
|
1888
|
+
if (stripMcpJson(resolve3(".mcp.json"))) stripped.push(".mcp.json");
|
|
1889
|
+
if (stripMcpJson(resolve3(".cursor/mcp.json"))) stripped.push(".cursor/mcp.json");
|
|
1890
|
+
if (stripMcpJson(resolve3(".factory/mcp.json"), { wrapped: false })) stripped.push(".factory/mcp.json");
|
|
1891
|
+
const homeFactoryMcp = join2(homedir2(), ".factory", "mcp.json");
|
|
1892
|
+
if (stripMcpJson(homeFactoryMcp, { wrapped: false })) stripped.push("~/.factory/mcp.json");
|
|
1893
|
+
if (stripCodexToml()) stripped.push("~/.codex/config.toml");
|
|
1831
1894
|
stripClaudeMd();
|
|
1832
1895
|
stripSettingsJson();
|
|
1833
|
-
|
|
1896
|
+
stripped.push("CLAUDE.md", ".claude/settings.local.json");
|
|
1834
1897
|
if (removed.length > 0) {
|
|
1835
1898
|
console.log(chalk11.green(" \u2713 Removed files:"));
|
|
1836
1899
|
for (const f of removed) console.log(chalk11.dim(` ${f}`));
|
|
1837
1900
|
}
|
|
1838
|
-
|
|
1901
|
+
if (stripped.length > 0) {
|
|
1902
|
+
console.log(chalk11.green(" \u2713 Stripped agentvalet entries from:"));
|
|
1903
|
+
for (const f of stripped) console.log(chalk11.dim(` ${f}`));
|
|
1904
|
+
}
|
|
1839
1905
|
}
|
|
1840
1906
|
var SSE_READ_TIMEOUT_MS = 25e3;
|
|
1841
1907
|
async function pollForApproval(apiUrl, revocationToken, timeoutMs) {
|