nomoreide 0.1.68 → 0.1.70
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/core/agent-env/antigravity-reader.d.ts +7 -0
- package/dist/core/agent-env/antigravity-reader.js +86 -0
- package/dist/core/agent-env/antigravity-reader.js.map +1 -0
- package/dist/core/agent-env/availability.d.ts +6 -0
- package/dist/core/agent-env/availability.js +79 -0
- package/dist/core/agent-env/availability.js.map +1 -0
- package/dist/core/agent-env/claude-reader.d.ts +7 -0
- package/dist/core/agent-env/claude-reader.js +93 -0
- package/dist/core/agent-env/claude-reader.js.map +1 -0
- package/dist/core/agent-env/codex-reader.d.ts +9 -0
- package/dist/core/agent-env/codex-reader.js +145 -0
- package/dist/core/agent-env/codex-reader.js.map +1 -0
- package/dist/core/agent-env/index.d.ts +9 -0
- package/dist/core/agent-env/index.js +29 -0
- package/dist/core/agent-env/index.js.map +1 -0
- package/dist/core/agent-env/managed-plugins.d.ts +13 -0
- package/dist/core/agent-env/managed-plugins.js +36 -0
- package/dist/core/agent-env/managed-plugins.js.map +1 -0
- package/dist/core/agent-env/plugin-reader.d.ts +9 -0
- package/dist/core/agent-env/plugin-reader.js +174 -0
- package/dist/core/agent-env/plugin-reader.js.map +1 -0
- package/dist/core/agent-env/shared.d.ts +25 -0
- package/dist/core/agent-env/shared.js +115 -0
- package/dist/core/agent-env/shared.js.map +1 -0
- package/dist/core/agent-env/types.d.ts +66 -0
- package/dist/core/agent-env/types.js +7 -0
- package/dist/core/agent-env/types.js.map +1 -0
- package/dist/core/agent-env-actions.d.ts +117 -0
- package/dist/core/agent-env-actions.js +234 -0
- package/dist/core/agent-env-actions.js.map +1 -0
- package/dist/core/agent-env-writers.d.ts +46 -0
- package/dist/core/agent-env-writers.js +385 -0
- package/dist/core/agent-env-writers.js.map +1 -0
- package/dist/mcp/tools/agent-env.d.ts +9 -0
- package/dist/mcp/tools/agent-env.js +160 -0
- package/dist/mcp/tools/agent-env.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +1 -1
- package/dist/mcp/tools/index.js +3 -0
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/web/client/assets/{code-editor-woFvM3aJ.js → code-editor-tF2NdMJV.js} +1 -1
- package/dist/web/client/assets/index-C7lI87cF.css +1 -0
- package/dist/web/client/assets/{index-B4hwsHPU.js → index-CQmdoyuK.js} +111 -111
- package/dist/web/client/index.html +2 -2
- package/dist/web/routes/agent-env-routes.d.ts +9 -0
- package/dist/web/routes/agent-env-routes.js +86 -0
- package/dist/web/routes/agent-env-routes.js.map +1 -0
- package/dist/web/routes/index.js +2 -0
- package/dist/web/routes/index.js.map +1 -1
- package/dist/web/routes/shell-routes.js +1 -0
- package/dist/web/routes/shell-routes.js.map +1 -1
- package/package.json +1 -1
- package/dist/web/client/assets/index-CeyRPbeV.css +0 -1
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { readFile, readdir, stat } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
/** Marketplace plugins from Claude's `~/.claude/plugins/installed_plugins.json`. */
|
|
4
|
+
export async function readInstalledPlugins(installedPluginsPath) {
|
|
5
|
+
const source = await readFile(installedPluginsPath, "utf8");
|
|
6
|
+
const data = JSON.parse(source);
|
|
7
|
+
const results = [];
|
|
8
|
+
for (const [key, records] of Object.entries(data.plugins ?? {})) {
|
|
9
|
+
const [name, pluginSource] = key.split("@");
|
|
10
|
+
const installPath = records[0]?.installPath;
|
|
11
|
+
const pluginSkills = installPath ? await readPluginSkills(installPath) : [];
|
|
12
|
+
const pluginMcps = installPath ? await readPluginMcpKeys(installPath) : [];
|
|
13
|
+
const pluginAgents = installPath ? await readPluginAgentNames(installPath) : [];
|
|
14
|
+
const pluginCommands = installPath ? await readPluginCommandNames(installPath) : [];
|
|
15
|
+
results.push({
|
|
16
|
+
name,
|
|
17
|
+
source: pluginSource,
|
|
18
|
+
kind: "plugin",
|
|
19
|
+
scope: "user",
|
|
20
|
+
installPath,
|
|
21
|
+
pluginSkills,
|
|
22
|
+
...(pluginMcps.length > 0 ? { pluginMcps } : {}),
|
|
23
|
+
...(pluginAgents.length > 0 ? { pluginAgents } : {}),
|
|
24
|
+
...(pluginCommands.length > 0 ? { pluginCommands } : {}),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return results;
|
|
28
|
+
}
|
|
29
|
+
/** Enabled Codex plugins declared in config.toml and materialized in the plugins cache. */
|
|
30
|
+
export async function readCodexPlugins(options) {
|
|
31
|
+
let tomlSource;
|
|
32
|
+
try {
|
|
33
|
+
tomlSource = await readFile(options.configTomlPath, "utf8");
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const entries = [];
|
|
39
|
+
for (const { name, marketplace, enabled } of parseCodexPluginDeclarations(tomlSource)) {
|
|
40
|
+
if (!enabled)
|
|
41
|
+
continue;
|
|
42
|
+
const installPath = await resolveCodexPluginInstallPath({
|
|
43
|
+
pluginsCacheDir: options.pluginsCacheDir,
|
|
44
|
+
marketplace,
|
|
45
|
+
name,
|
|
46
|
+
});
|
|
47
|
+
if (!installPath)
|
|
48
|
+
continue;
|
|
49
|
+
const pluginSkills = await readPluginSkills(installPath);
|
|
50
|
+
const pluginMcps = await readPluginMcpKeys(installPath);
|
|
51
|
+
const pluginAgents = await readPluginAgentNames(installPath);
|
|
52
|
+
const pluginCommands = await readPluginCommandNames(installPath);
|
|
53
|
+
entries.push({
|
|
54
|
+
name,
|
|
55
|
+
source: marketplace,
|
|
56
|
+
kind: "plugin",
|
|
57
|
+
scope: "user",
|
|
58
|
+
installPath,
|
|
59
|
+
pluginSkills,
|
|
60
|
+
...(pluginMcps.length > 0 ? { pluginMcps } : {}),
|
|
61
|
+
...(pluginAgents.length > 0 ? { pluginAgents } : {}),
|
|
62
|
+
...(pluginCommands.length > 0 ? { pluginCommands } : {}),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
66
|
+
}
|
|
67
|
+
function parseCodexPluginDeclarations(source) {
|
|
68
|
+
const results = [];
|
|
69
|
+
const lines = source.split("\n");
|
|
70
|
+
let current = null;
|
|
71
|
+
const flush = () => {
|
|
72
|
+
if (current) {
|
|
73
|
+
results.push(current);
|
|
74
|
+
current = null;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
for (const line of lines) {
|
|
78
|
+
const trimmed = line.trim();
|
|
79
|
+
const sectionMatch = trimmed.match(/^\[plugins\."([^"@]+)@([^"]+)"\]$/);
|
|
80
|
+
if (sectionMatch) {
|
|
81
|
+
flush();
|
|
82
|
+
current = { name: sectionMatch[1], marketplace: sectionMatch[2], enabled: false };
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (/^\[/.test(trimmed)) {
|
|
86
|
+
flush();
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (!current)
|
|
90
|
+
continue;
|
|
91
|
+
const kv = trimmed.match(/^(\w+)\s*=\s*(.+)$/);
|
|
92
|
+
if (kv && kv[1] === "enabled") {
|
|
93
|
+
current.enabled = kv[2].trim() === "true";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
flush();
|
|
97
|
+
return results;
|
|
98
|
+
}
|
|
99
|
+
async function resolveCodexPluginInstallPath(options) {
|
|
100
|
+
const pluginRoot = path.join(options.pluginsCacheDir, options.marketplace, options.name);
|
|
101
|
+
let versionDirs;
|
|
102
|
+
try {
|
|
103
|
+
const entries = await readdir(pluginRoot, { withFileTypes: true });
|
|
104
|
+
versionDirs = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
if (versionDirs.length === 0)
|
|
110
|
+
return null;
|
|
111
|
+
if (versionDirs.length === 1)
|
|
112
|
+
return path.join(pluginRoot, versionDirs[0]);
|
|
113
|
+
const stats = await Promise.all(versionDirs.map(async (dir) => {
|
|
114
|
+
try {
|
|
115
|
+
const info = await stat(path.join(pluginRoot, dir));
|
|
116
|
+
return { dir, mtime: info.mtimeMs };
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return { dir, mtime: 0 };
|
|
120
|
+
}
|
|
121
|
+
}));
|
|
122
|
+
stats.sort((left, right) => right.mtime - left.mtime);
|
|
123
|
+
return path.join(pluginRoot, stats[0].dir);
|
|
124
|
+
}
|
|
125
|
+
async function readPluginSkills(installPath) {
|
|
126
|
+
try {
|
|
127
|
+
const entries = await readdir(path.join(installPath, "skills"), { withFileTypes: true });
|
|
128
|
+
return entries
|
|
129
|
+
.filter((entry) => !entry.name.startsWith(".") && entry.isDirectory())
|
|
130
|
+
.map((entry) => entry.name)
|
|
131
|
+
.sort((left, right) => left.localeCompare(right));
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async function readPluginAgentNames(installPath) {
|
|
138
|
+
try {
|
|
139
|
+
const entries = await readdir(path.join(installPath, "agents"), { withFileTypes: true });
|
|
140
|
+
return entries
|
|
141
|
+
.filter((entry) => entry.isFile() && (entry.name.endsWith(".md") || entry.name.endsWith(".toml")))
|
|
142
|
+
.map((entry) => entry.name.replace(/\.(md|toml)$/, ""))
|
|
143
|
+
.sort((left, right) => left.localeCompare(right));
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return [];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async function readPluginCommandNames(installPath) {
|
|
150
|
+
try {
|
|
151
|
+
const entries = await readdir(path.join(installPath, "commands"), { withFileTypes: true });
|
|
152
|
+
return entries
|
|
153
|
+
.filter((entry) => entry.isFile() && entry.name.endsWith(".md"))
|
|
154
|
+
.map((entry) => entry.name.replace(/\.md$/, ""))
|
|
155
|
+
.sort((left, right) => left.localeCompare(right));
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return [];
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
export async function readPluginMcpKeys(installPath) {
|
|
162
|
+
try {
|
|
163
|
+
const source = await readFile(path.join(installPath, ".mcp.json"), "utf8");
|
|
164
|
+
const parsed = JSON.parse(source);
|
|
165
|
+
const servers = parsed.mcpServers && typeof parsed.mcpServers === "object" && !Array.isArray(parsed.mcpServers)
|
|
166
|
+
? parsed.mcpServers
|
|
167
|
+
: parsed;
|
|
168
|
+
return Object.keys(servers).sort((left, right) => left.localeCompare(right));
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return [];
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=plugin-reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-reader.js","sourceRoot":"","sources":["../../../src/core/agent-env/plugin-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,IAAI,MAAM,WAAW,CAAC;AAW7B,oFAAoF;AACpF,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,oBAA4B;IAE5B,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;IAC5D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAyB,CAAC;IACxD,MAAM,OAAO,GAAsB,EAAE,CAAC;IAEtC,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,CAAC;QAChE,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5C,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC;QAC5C,MAA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AAK,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC;YAC7F,CAAC,CAAE,MAAM,CAAC,UAAsC;YAChD,CAAC,CAAC,MAAM,CAAC;QACb,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AgentMcpEntry, AgentSkillEntry, RemoteMcpEntry } from "./types.js";
|
|
2
|
+
export declare function parseEnvObject(value: unknown): Record<string, string> | undefined;
|
|
3
|
+
/** Read skill directories (Claude, Codex, and Antigravity share the SKILL.md dir convention). */
|
|
4
|
+
export declare function readSkillDirs(skillsDir: string, scope?: "user" | "project"): Promise<AgentSkillEntry[]>;
|
|
5
|
+
/**
|
|
6
|
+
* Walk from `cwd` up to the repo root (first ancestor containing `.git`, or
|
|
7
|
+
* the filesystem root) and emit skills declared in `<ancestor>/.claude/skills/`
|
|
8
|
+
* with `scope: "project"`. Only Claude reads project-scoped skills; the closer
|
|
9
|
+
* ancestor wins on name collisions.
|
|
10
|
+
*/
|
|
11
|
+
export declare function readProjectSkills(cwd: string): Promise<AgentSkillEntry[]>;
|
|
12
|
+
export interface McpMaps {
|
|
13
|
+
mcpServers: Record<string, AgentMcpEntry>;
|
|
14
|
+
remoteMcpServers: Record<string, RemoteMcpEntry>;
|
|
15
|
+
projectMcpServers: Record<string, AgentMcpEntry>;
|
|
16
|
+
projectRemoteMcpServers: Record<string, RemoteMcpEntry>;
|
|
17
|
+
}
|
|
18
|
+
/** Drop MCP servers that a plugin owns — the plugin card already lists them. */
|
|
19
|
+
export declare function filterPluginOwnedMcps(maps: McpMaps, skills: AgentSkillEntry[]): McpMaps;
|
|
20
|
+
/**
|
|
21
|
+
* Project-scoped MCPs recorded by brainctl at `<cwd>/.brainctl/project-mcps.json`
|
|
22
|
+
* for agents without native per-project config (Codex, Antigravity). Read for
|
|
23
|
+
* compatibility so brainctl users see their full setup after migrating.
|
|
24
|
+
*/
|
|
25
|
+
export declare function readBrainctlProjectMcps(cwd: string, agent: "codex" | "antigravity"): Promise<Pick<McpMaps, "projectMcpServers" | "projectRemoteMcpServers">>;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { readFile, readdir, stat } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
export function parseEnvObject(value) {
|
|
4
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
5
|
+
return undefined;
|
|
6
|
+
const result = {};
|
|
7
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
8
|
+
result[key] = String(entry);
|
|
9
|
+
}
|
|
10
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
11
|
+
}
|
|
12
|
+
/** Read skill directories (Claude, Codex, and Antigravity share the SKILL.md dir convention). */
|
|
13
|
+
export async function readSkillDirs(skillsDir, scope = "user") {
|
|
14
|
+
const entries = await readdir(skillsDir, { withFileTypes: true });
|
|
15
|
+
const skills = [];
|
|
16
|
+
for (const entry of entries) {
|
|
17
|
+
if (entry.name.startsWith("."))
|
|
18
|
+
continue;
|
|
19
|
+
const installPath = path.join(skillsDir, entry.name);
|
|
20
|
+
if (entry.isDirectory()) {
|
|
21
|
+
skills.push({ name: entry.name, source: "local", kind: "skill", scope, installPath });
|
|
22
|
+
}
|
|
23
|
+
else if (entry.isSymbolicLink()) {
|
|
24
|
+
skills.push({ name: entry.name, source: "linked", kind: "skill", scope, installPath });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return skills;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Walk from `cwd` up to the repo root (first ancestor containing `.git`, or
|
|
31
|
+
* the filesystem root) and emit skills declared in `<ancestor>/.claude/skills/`
|
|
32
|
+
* with `scope: "project"`. Only Claude reads project-scoped skills; the closer
|
|
33
|
+
* ancestor wins on name collisions.
|
|
34
|
+
*/
|
|
35
|
+
export async function readProjectSkills(cwd) {
|
|
36
|
+
const seen = new Map();
|
|
37
|
+
let current = path.resolve(cwd);
|
|
38
|
+
const visited = new Set();
|
|
39
|
+
while (!visited.has(current)) {
|
|
40
|
+
visited.add(current);
|
|
41
|
+
const skillsDir = path.join(current, ".claude", "skills");
|
|
42
|
+
try {
|
|
43
|
+
const entries = await readSkillDirs(skillsDir, "project");
|
|
44
|
+
for (const entry of entries) {
|
|
45
|
+
if (!seen.has(entry.name))
|
|
46
|
+
seen.set(entry.name, entry);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// no skills dir at this level
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
await stat(path.join(current, ".git"));
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// not a repo root; continue up
|
|
58
|
+
}
|
|
59
|
+
const parent = path.dirname(current);
|
|
60
|
+
if (parent === current)
|
|
61
|
+
break;
|
|
62
|
+
current = parent;
|
|
63
|
+
}
|
|
64
|
+
return Array.from(seen.values());
|
|
65
|
+
}
|
|
66
|
+
/** Drop MCP servers that a plugin owns — the plugin card already lists them. */
|
|
67
|
+
export function filterPluginOwnedMcps(maps, skills) {
|
|
68
|
+
const pluginOwned = new Set(skills.flatMap((skill) => skill.pluginMcps ?? []));
|
|
69
|
+
if (pluginOwned.size === 0)
|
|
70
|
+
return maps;
|
|
71
|
+
const notOwned = ([key]) => !pluginOwned.has(key);
|
|
72
|
+
return {
|
|
73
|
+
mcpServers: Object.fromEntries(Object.entries(maps.mcpServers).filter(notOwned)),
|
|
74
|
+
remoteMcpServers: Object.fromEntries(Object.entries(maps.remoteMcpServers).filter(notOwned)),
|
|
75
|
+
projectMcpServers: Object.fromEntries(Object.entries(maps.projectMcpServers).filter(notOwned)),
|
|
76
|
+
projectRemoteMcpServers: Object.fromEntries(Object.entries(maps.projectRemoteMcpServers).filter(notOwned)),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Project-scoped MCPs recorded by brainctl at `<cwd>/.brainctl/project-mcps.json`
|
|
81
|
+
* for agents without native per-project config (Codex, Antigravity). Read for
|
|
82
|
+
* compatibility so brainctl users see their full setup after migrating.
|
|
83
|
+
*/
|
|
84
|
+
export async function readBrainctlProjectMcps(cwd, agent) {
|
|
85
|
+
try {
|
|
86
|
+
const filePath = path.join(cwd, ".brainctl", "project-mcps.json");
|
|
87
|
+
const data = JSON.parse(await readFile(filePath, "utf8"));
|
|
88
|
+
const agentData = (data[agent] ?? {});
|
|
89
|
+
const rawServers = (agentData.mcpServers ?? {});
|
|
90
|
+
const projectMcpServers = {};
|
|
91
|
+
const projectRemoteMcpServers = {};
|
|
92
|
+
for (const [name, entry] of Object.entries(rawServers)) {
|
|
93
|
+
if (typeof entry.url === "string" && entry.url) {
|
|
94
|
+
projectRemoteMcpServers[name] = {
|
|
95
|
+
transport: entry.transport ?? "http",
|
|
96
|
+
url: entry.url,
|
|
97
|
+
headers: parseEnvObject(entry.headers),
|
|
98
|
+
env: parseEnvObject(entry.env),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
projectMcpServers[name] = {
|
|
103
|
+
command: String(entry.command ?? ""),
|
|
104
|
+
args: Array.isArray(entry.args) ? entry.args.map(String) : undefined,
|
|
105
|
+
env: parseEnvObject(entry.env),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return { projectMcpServers, projectRemoteMcpServers };
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return { projectMcpServers: {}, projectRemoteMcpServers: {} };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared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C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;oBACpE,GAAG,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC;iBAC/B,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,iBAAiB,EAAE,EAAE,EAAE,uBAAuB,EAAE,EAAE,EAAE,CAAC;IAChE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Environments — read-only view of coding agents' live configuration
|
|
3
|
+
* (MCP servers + skills) across Claude Code, Codex CLI, and Antigravity.
|
|
4
|
+
* Ported from brainctl's sync/agent-reader layer (see ROR-59/ROR-60).
|
|
5
|
+
*/
|
|
6
|
+
export type AgentName = "claude" | "codex" | "antigravity";
|
|
7
|
+
export declare const AGENT_NAMES: AgentName[];
|
|
8
|
+
export interface AgentMcpEntry {
|
|
9
|
+
command: string;
|
|
10
|
+
args?: string[];
|
|
11
|
+
env?: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
export interface RemoteMcpEntry {
|
|
14
|
+
transport: "http" | "sse";
|
|
15
|
+
url: string;
|
|
16
|
+
headers?: Record<string, string>;
|
|
17
|
+
env?: Record<string, string>;
|
|
18
|
+
}
|
|
19
|
+
export interface AgentSkillEntry {
|
|
20
|
+
name: string;
|
|
21
|
+
/** e.g. "claude-plugins-official", "local", "linked", or a marketplace id. */
|
|
22
|
+
source?: string;
|
|
23
|
+
kind?: "skill" | "plugin";
|
|
24
|
+
/**
|
|
25
|
+
* Where this skill lives:
|
|
26
|
+
* - "user" — `~/.<agent>/skills/` or a user-installed plugin
|
|
27
|
+
* - "project" — `<repo>/.claude/skills/` (Claude only)
|
|
28
|
+
*/
|
|
29
|
+
scope: "user" | "project";
|
|
30
|
+
pluginSkills?: string[];
|
|
31
|
+
pluginMcps?: string[];
|
|
32
|
+
pluginAgents?: string[];
|
|
33
|
+
pluginCommands?: string[];
|
|
34
|
+
installPath?: string;
|
|
35
|
+
managed?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface AgentLiveConfig {
|
|
38
|
+
agent: AgentName;
|
|
39
|
+
configPath: string;
|
|
40
|
+
exists: boolean;
|
|
41
|
+
mcpServers: Record<string, AgentMcpEntry>;
|
|
42
|
+
remoteMcpServers: Record<string, RemoteMcpEntry>;
|
|
43
|
+
projectMcpServers: Record<string, AgentMcpEntry>;
|
|
44
|
+
projectRemoteMcpServers: Record<string, RemoteMcpEntry>;
|
|
45
|
+
skills: AgentSkillEntry[];
|
|
46
|
+
}
|
|
47
|
+
export interface AgentAvailability {
|
|
48
|
+
agent: AgentName;
|
|
49
|
+
available: boolean;
|
|
50
|
+
command: string;
|
|
51
|
+
resolvedPath?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface AgentDoctorCheck {
|
|
54
|
+
label: string;
|
|
55
|
+
status: "ok" | "warn";
|
|
56
|
+
message: string;
|
|
57
|
+
}
|
|
58
|
+
export interface AgentDoctorResult {
|
|
59
|
+
checks: AgentDoctorCheck[];
|
|
60
|
+
hasIssues: boolean;
|
|
61
|
+
}
|
|
62
|
+
/** Options shared by every reader; `homeDir` is injectable for tests. */
|
|
63
|
+
export interface AgentEnvReadOptions {
|
|
64
|
+
cwd: string;
|
|
65
|
+
homeDir?: string;
|
|
66
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Environments — read-only view of coding agents' live configuration
|
|
3
|
+
* (MCP servers + skills) across Claude Code, Codex CLI, and Antigravity.
|
|
4
|
+
* Ported from brainctl's sync/agent-reader layer (see ROR-59/ROR-60).
|
|
5
|
+
*/
|
|
6
|
+
export const AGENT_NAMES = ["claude", "codex", "antigravity"];
|
|
7
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/agent-env/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,CAAC,MAAM,WAAW,GAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Environments staged writes (ROR-61) — the write-guarded surface over
|
|
3
|
+
* `agent-env-writers.ts`. Mirrors the GitManager/GitActions and DbPeek/DbWrite
|
|
4
|
+
* split: `core/agent-env/` only reads; every mutation flows through this
|
|
5
|
+
* module's preview → apply gate and reports the backup files it created.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { type AgentName } from "./agent-env/index.js";
|
|
9
|
+
/** One staged mutation. `name` is the MCP key or the skill directory name. */
|
|
10
|
+
export declare const pendingChangeSchema: z.ZodObject<{
|
|
11
|
+
category: z.ZodEnum<["mcp", "skill"]>;
|
|
12
|
+
action: z.ZodEnum<["copy", "move", "remove"]>;
|
|
13
|
+
name: z.ZodString;
|
|
14
|
+
sourceAgent: z.ZodEnum<["claude", "codex", "antigravity"]>;
|
|
15
|
+
sourceScope: z.ZodDefault<z.ZodEnum<["user", "project"]>>;
|
|
16
|
+
targetAgent: z.ZodOptional<z.ZodEnum<["claude", "codex", "antigravity"]>>;
|
|
17
|
+
targetScope: z.ZodOptional<z.ZodEnum<["user", "project"]>>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
action: "remove" | "copy" | "move";
|
|
20
|
+
name: string;
|
|
21
|
+
category: "mcp" | "skill";
|
|
22
|
+
sourceAgent: "claude" | "codex" | "antigravity";
|
|
23
|
+
sourceScope: "user" | "project";
|
|
24
|
+
targetAgent?: "claude" | "codex" | "antigravity" | undefined;
|
|
25
|
+
targetScope?: "user" | "project" | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
action: "remove" | "copy" | "move";
|
|
28
|
+
name: string;
|
|
29
|
+
category: "mcp" | "skill";
|
|
30
|
+
sourceAgent: "claude" | "codex" | "antigravity";
|
|
31
|
+
sourceScope?: "user" | "project" | undefined;
|
|
32
|
+
targetAgent?: "claude" | "codex" | "antigravity" | undefined;
|
|
33
|
+
targetScope?: "user" | "project" | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
export type PendingChange = z.infer<typeof pendingChangeSchema>;
|
|
36
|
+
export declare const pendingChangesSchema: z.ZodArray<z.ZodObject<{
|
|
37
|
+
category: z.ZodEnum<["mcp", "skill"]>;
|
|
38
|
+
action: z.ZodEnum<["copy", "move", "remove"]>;
|
|
39
|
+
name: z.ZodString;
|
|
40
|
+
sourceAgent: z.ZodEnum<["claude", "codex", "antigravity"]>;
|
|
41
|
+
sourceScope: z.ZodDefault<z.ZodEnum<["user", "project"]>>;
|
|
42
|
+
targetAgent: z.ZodOptional<z.ZodEnum<["claude", "codex", "antigravity"]>>;
|
|
43
|
+
targetScope: z.ZodOptional<z.ZodEnum<["user", "project"]>>;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
action: "remove" | "copy" | "move";
|
|
46
|
+
name: string;
|
|
47
|
+
category: "mcp" | "skill";
|
|
48
|
+
sourceAgent: "claude" | "codex" | "antigravity";
|
|
49
|
+
sourceScope: "user" | "project";
|
|
50
|
+
targetAgent?: "claude" | "codex" | "antigravity" | undefined;
|
|
51
|
+
targetScope?: "user" | "project" | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
action: "remove" | "copy" | "move";
|
|
54
|
+
name: string;
|
|
55
|
+
category: "mcp" | "skill";
|
|
56
|
+
sourceAgent: "claude" | "codex" | "antigravity";
|
|
57
|
+
sourceScope?: "user" | "project" | undefined;
|
|
58
|
+
targetAgent?: "claude" | "codex" | "antigravity" | undefined;
|
|
59
|
+
targetScope?: "user" | "project" | undefined;
|
|
60
|
+
}>, "many">;
|
|
61
|
+
export interface ChangePreviewItem {
|
|
62
|
+
change: PendingChange;
|
|
63
|
+
ok: boolean;
|
|
64
|
+
/** Human-readable, e.g. `Copy MCP "linear" from Claude Code to Codex CLI (user scope)`. */
|
|
65
|
+
summary: string;
|
|
66
|
+
warnings: string[];
|
|
67
|
+
error?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface AgentDiffSummary {
|
|
70
|
+
agent: AgentName;
|
|
71
|
+
add: string[];
|
|
72
|
+
remove: string[];
|
|
73
|
+
}
|
|
74
|
+
export interface ChangePreview {
|
|
75
|
+
valid: boolean;
|
|
76
|
+
items: ChangePreviewItem[];
|
|
77
|
+
agents: AgentDiffSummary[];
|
|
78
|
+
}
|
|
79
|
+
export interface AppliedChange {
|
|
80
|
+
change: PendingChange;
|
|
81
|
+
ok: boolean;
|
|
82
|
+
summary: string;
|
|
83
|
+
backups: string[];
|
|
84
|
+
error?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface ApplyResult {
|
|
87
|
+
ok: boolean;
|
|
88
|
+
applied: number;
|
|
89
|
+
failed: number;
|
|
90
|
+
results: AppliedChange[];
|
|
91
|
+
/** Every backup file/directory created across all changes. */
|
|
92
|
+
backups: string[];
|
|
93
|
+
}
|
|
94
|
+
export interface AgentEnvActionOptions {
|
|
95
|
+
cwd: string;
|
|
96
|
+
homeDir?: string;
|
|
97
|
+
}
|
|
98
|
+
export declare function previewChanges(options: AgentEnvActionOptions & {
|
|
99
|
+
changes: PendingChange[];
|
|
100
|
+
}): Promise<ChangePreview>;
|
|
101
|
+
export declare function describeChange(change: PendingChange): string;
|
|
102
|
+
/**
|
|
103
|
+
* Validate the full batch, then apply changes in order. Validation failures
|
|
104
|
+
* abort before anything is written; a mid-batch write failure stops the batch
|
|
105
|
+
* (earlier changes stay applied — their backups are in the result).
|
|
106
|
+
*/
|
|
107
|
+
export declare function applyChanges(options: AgentEnvActionOptions & {
|
|
108
|
+
changes: PendingChange[];
|
|
109
|
+
}): Promise<ApplyResult>;
|
|
110
|
+
export interface SnapshotResult {
|
|
111
|
+
agent: AgentName;
|
|
112
|
+
backups: string[];
|
|
113
|
+
}
|
|
114
|
+
/** Back up an agent's live config file (`<file>.bak.<ts>`) before bulk edits. */
|
|
115
|
+
export declare function snapshotAgent(options: AgentEnvActionOptions & {
|
|
116
|
+
agent: AgentName;
|
|
117
|
+
}): Promise<SnapshotResult>;
|