@rbbtsn0w/adg 0.7.0 → 0.7.1-beta.2

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.
@@ -1,8 +1,59 @@
1
- import { cpSync, existsSync, rmSync } from "node:fs";
1
+ import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
2
  import { join, resolve } from "node:path";
3
3
  import { isExposed } from "../components.js";
4
4
  import { mcpConfigPath } from "../mcp.js";
5
5
  export const ANTIGRAVITY_MCP_CONFIG = "mcp_config.json";
6
+ const ANTIGRAVITY_MCP_SERVER_KEYS = new Set([
7
+ "command",
8
+ "serverUrl",
9
+ "args",
10
+ "env",
11
+ "cwd",
12
+ "headers",
13
+ "authProviderType",
14
+ "oauth",
15
+ "disabled",
16
+ "disabledTools",
17
+ ]);
18
+ const ANTIGRAVITY_MCP_KEY_ALIASES = {
19
+ url: "serverUrl",
20
+ http_headers: "headers",
21
+ disabled_tools: "disabledTools",
22
+ };
23
+ function toAntigravityMcpServer(value) {
24
+ if (!value || typeof value !== "object" || Array.isArray(value))
25
+ return value;
26
+ const source = value;
27
+ const server = {};
28
+ for (const [key, field] of Object.entries(source)) {
29
+ if (ANTIGRAVITY_MCP_SERVER_KEYS.has(key))
30
+ server[key] = field;
31
+ }
32
+ for (const [sourceKey, targetKey] of Object.entries(ANTIGRAVITY_MCP_KEY_ALIASES)) {
33
+ if (server[targetKey] === undefined && source[sourceKey] !== undefined) {
34
+ server[targetKey] = source[sourceKey];
35
+ }
36
+ }
37
+ return server;
38
+ }
39
+ function toAntigravityMcpConfig(source) {
40
+ const parsed = JSON.parse(readFileSync(source, "utf8"));
41
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
42
+ return parsed;
43
+ const config = parsed;
44
+ const servers = config.mcpServers ?? config.servers;
45
+ if (!servers || typeof servers !== "object" || Array.isArray(servers))
46
+ return config;
47
+ const projected = {
48
+ ...config,
49
+ mcpServers: {},
50
+ };
51
+ delete projected.servers;
52
+ for (const [name, value] of Object.entries(servers)) {
53
+ projected.mcpServers[name] = toAntigravityMcpServer(value);
54
+ }
55
+ return projected;
56
+ }
6
57
  /**
7
58
  * Generate an Antigravity (`agy`) plugin.json from an ADG manifest.
8
59
  *
@@ -22,8 +73,9 @@ export function writeAntigravityMcpConfig(pluginDir, manifest, selection) {
22
73
  // generated projection. Never remove or copy it onto itself.
23
74
  if (source === resolve(target))
24
75
  return;
25
- rmSync(target, { force: true });
26
76
  if (source && isExposed(selection, "mcp") && existsSync(source)) {
27
- cpSync(source, target);
77
+ writeFileSync(target, `${JSON.stringify(toAntigravityMcpConfig(source), null, 2)}\n`);
78
+ return;
28
79
  }
80
+ rmSync(target, { force: true });
29
81
  }
@@ -16,6 +16,28 @@ const CLONE_TIMEOUT_MS = (() => {
16
16
  return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_CLONE_TIMEOUT_MS;
17
17
  })();
18
18
  const execFileAsync = promisify(execFile);
19
+ const UNSAFE_INHERITED_GIT_ENV_KEYS = [
20
+ 'EDITOR',
21
+ 'GIT_ASKPASS',
22
+ 'GIT_CONFIG',
23
+ 'GIT_CONFIG_COUNT',
24
+ 'GIT_CONFIG_GLOBAL',
25
+ 'GIT_CONFIG_PARAMETERS',
26
+ 'GIT_CONFIG_SYSTEM',
27
+ 'GIT_EDITOR',
28
+ 'GIT_EXEC_PATH',
29
+ 'GIT_EXTERNAL_DIFF',
30
+ 'GIT_PAGER',
31
+ 'GIT_PROXY_COMMAND',
32
+ 'GIT_SEQUENCE_EDITOR',
33
+ 'GIT_SSH',
34
+ 'GIT_SSH_COMMAND',
35
+ 'GIT_TEMPLATE_DIR',
36
+ 'PAGER',
37
+ 'PREFIX',
38
+ 'SSH_ASKPASS',
39
+ ];
40
+ const UNSAFE_INHERITED_GIT_ENV_KEY_SET = new Set(UNSAFE_INHERITED_GIT_ENV_KEYS.map((key) => key.toUpperCase()));
19
41
  export class GitCloneError extends Error {
20
42
  url;
21
43
  isTimeout;
@@ -84,6 +106,30 @@ function isAuthFailure(message) {
84
106
  message.includes('requested URL returned error: 403') ||
85
107
  isGitHubSsoAuthError(message));
86
108
  }
109
+ function createGitEnvironment(extraEnv) {
110
+ // ADG patch: hosts such as VS Code inject executable Git helpers (notably
111
+ // GIT_ASKPASS) even when the user has no GitHub account configured.
112
+ // simple-git correctly rejects those inherited hooks as unsafe, but that
113
+ // rejection happened before anonymous public-repository clones could run.
114
+ // Clone from a sanitized copy of the parent environment instead. Normal
115
+ // credential helpers, proxy settings, certificates, and SSH_AUTH_SOCK remain
116
+ // available; only environment entries that can execute or redirect Git are
117
+ // removed. Explicit ADG-controlled overrides are applied afterwards.
118
+ const gitEnv = { ...process.env };
119
+ for (const key of Object.keys(gitEnv)) {
120
+ if (UNSAFE_INHERITED_GIT_ENV_KEY_SET.has(key.toUpperCase())) {
121
+ delete gitEnv[key];
122
+ }
123
+ }
124
+ return {
125
+ ...gitEnv,
126
+ GIT_TERMINAL_PROMPT: '0',
127
+ // When git-lfs IS installed, tell it not to download LFS content during
128
+ // checkout. See #952 for context and empirical impact.
129
+ GIT_LFS_SKIP_SMUDGE: '1',
130
+ ...extraEnv,
131
+ };
132
+ }
87
133
  function createGitClient(extraEnv) {
88
134
  return simpleGit({
89
135
  timeout: { block: CLONE_TIMEOUT_MS },
@@ -114,20 +160,16 @@ function createGitClient(extraEnv) {
114
160
  // exactly the intent of the config above. See vendor/skills/PROVENANCE.md.
115
161
  unsafe: {
116
162
  allowUnsafeFilter: true,
163
+ // Only permits the fixed BatchMode command supplied by the HTTPS auth
164
+ // fallback below; inherited GIT_SSH_COMMAND is removed from gitEnv.
165
+ allowUnsafeSshCommand: true,
117
166
  },
118
167
  // ADG patch: env must be applied via `.env()`, not as a constructor option.
119
168
  // simple-git's factory only reads baseDir/maxConcurrentProcesses/trimmed from
120
169
  // the options object and silently drops `env`, so the GIT_TERMINAL_PROMPT /
121
170
  // GIT_LFS_SKIP_SMUDGE / GIT_SSH_COMMAND overrides below never reached the
122
171
  // spawned git before this. See vendor/skills/PROVENANCE.md.
123
- }).env({
124
- ...process.env,
125
- GIT_TERMINAL_PROMPT: '0',
126
- // When git-lfs IS installed, tell it not to download LFS content during
127
- // checkout. See #952 for context and empirical impact.
128
- GIT_LFS_SKIP_SMUDGE: '1',
129
- ...extraEnv,
130
- });
172
+ }).env(createGitEnvironment(extraEnv));
131
173
  }
132
174
  async function resetTempDir(dir) {
133
175
  await rm(dir, { recursive: true, force: true }).catch(() => { });
@@ -138,7 +180,7 @@ async function tryGhClone(repo, tempDir, ref) {
138
180
  try {
139
181
  const { stdout, stderr } = await execFileAsync('gh', ['auth', 'status', '-h', 'github.com'], {
140
182
  timeout: 5000,
141
- env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
183
+ env: createGitEnvironment(),
142
184
  });
143
185
  const statusOutput = `${stdout}${stderr}`;
144
186
  if (/Git operations protocol:\s+ssh/i.test(statusOutput)) {
@@ -151,7 +193,7 @@ async function tryGhClone(repo, tempDir, ref) {
151
193
  const gitFlags = ref ? ['--depth=1', '--branch', ref] : ['--depth=1'];
152
194
  await execFileAsync('gh', ['repo', 'clone', cloneTarget, tempDir, '--', ...gitFlags], {
153
195
  timeout: CLONE_TIMEOUT_MS,
154
- env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
196
+ env: createGitEnvironment(),
155
197
  });
156
198
  return true;
157
199
  }
@@ -209,7 +251,7 @@ export async function cloneRepo(url, ref) {
209
251
  try {
210
252
  await resetTempDir(tempDir);
211
253
  await createGitClient({
212
- GIT_SSH_COMMAND: process.env.GIT_SSH_COMMAND ?? 'ssh -o BatchMode=yes',
254
+ GIT_SSH_COMMAND: 'ssh -o BatchMode=yes',
213
255
  }).clone(repo.sshUrl, tempDir, cloneOptions);
214
256
  return tempDir;
215
257
  }
@@ -74,9 +74,11 @@ plugin root. The ADG adapter materializes files at these conventional locations.
74
74
 
75
75
  - **Config file name**: `mcp_config.json` (at plugin root — required conventional name).
76
76
  - **Config key**: N/A (no manifest key; discovered by file presence).
77
- - **Special handling**: ADG copies (or symlinks) the source `.mcp.json` to
78
- `mcp_config.json` at the plugin root. If the source IS already `mcp_config.json`,
79
- no copy is performed.
77
+ - **Special handling**: ADG projects the source `.mcp.json` to `mcp_config.json`
78
+ at the plugin root, normalizing canonical aliases such as `url`, `http_headers`,
79
+ and `disabled_tools` to Antigravity's schema. Unsupported source-runtime fields
80
+ are omitted. If the source IS already `mcp_config.json`, it is treated as a
81
+ native override and left unchanged.
80
82
 
81
83
  ---
82
84
 
@@ -318,8 +318,8 @@ Hooks require the most complex adapter logic. See also
318
318
  | :--- | :--- | :--- | :--- |
319
319
  | **Config file** | `.mcp.json` or inline in manifest | `.mcp.json` reference | `mcp_config.json` at plugin root |
320
320
  | **Manifest key** | `mcpServers` | `mcpServers` | N/A (discovered by file presence) |
321
- | **Format** | `{ "mcpServers": { "<name>": { "command": ... } } }` | Same as Claude | Same as Claude |
322
- | **Projection** | Passed through | Passed through | Copied from source `.mcp.json` to `mcp_config.json` |
321
+ | **Format** | `{ "mcpServers": { "<name>": { "command": ... } } }` | Same as Claude | Native schema (`serverUrl`, `headers`, and other camelCase fields) |
322
+ | **Projection** | Passed through | Passed through | Field-normalized from source `.mcp.json`; native `mcp_config.json` overrides pass through |
323
323
 
324
324
  ---
325
325
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbbtsn0w/adg",
3
- "version": "0.7.0",
3
+ "version": "0.7.1-beta.2",
4
4
  "description": "Agent Directory Group (ADG) toolkit — two domains: plugins and skills.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -76,6 +76,7 @@ re-vendoring. Each is marked inline with an `ADG patch:` comment.
76
76
  | `src/git.ts` → `createGitClient` | Add `unsafe: { allowUnsafeFilter: true }` to `simpleGit(...)` | simple-git ≥3.36 blocks `filter.*.smudge/clean` configs (RCE vector) and fails **every** clone with "Configuring filter.smudge is not permitted without enabling allowUnsafeFilter". The configs here set the LFS filter to EMPTY (disabling it), so opting in is safe and matches their intent. |
77
77
  | `src/git.ts` → `import simpleGit from 'simple-git'` | Default → named import `import { simpleGit } from 'simple-git'` | The default import is not callable under ADG's strict root tsconfig (NodeNext + verbatimModuleSyntax, no esModuleInterop); the named export is. Needed for `git.ts` to typecheck when a test imports it (e.g. via `use.ts`). |
78
78
  | `src/git.ts` → `createGitClient` env | Pass env via `.env({...})` instead of as a `simpleGit(...)` constructor option | **Latent runtime bug**: simple-git's factory only reads `baseDir`/`maxConcurrentProcesses`/`config`/`trimmed`/plugins from the options object and silently drops `env`, so `GIT_TERMINAL_PROMPT`/`GIT_LFS_SKIP_SMUDGE`/`GIT_SSH_COMMAND` never reached the spawned git (it inherited the full parent env). `.env(object)` is the documented API and sets the executor env actually used at spawn. |
79
+ | `src/git.ts` → `createGitClient` inherited env sanitization | Case-insensitively remove executable/redirecting Git environment hooks and `GIT_CONFIG_PARAMETERS` before constructing the clone client; allow only ADG's fixed SSH BatchMode override | IDEs can inject `GIT_ASKPASS`, `GIT_PAGER`, config overrides, and similar helpers even for users with no GitHub account. simple-git >=3.36 rejects known hooks before an anonymous public clone can run, while mixed-case Windows keys or config parameters could bypass exact-key deletion. Sanitizing them preserves non-interactive public installs without opting arbitrary parent-process commands into execution. |
79
80
  | `src/skills.ts` → `parseSkillMd` | Narrow `data.metadata` (frontmatter `unknown`) to `Record<string, unknown> \| undefined` before reading `.internal` / returning it | Behavior-preserving type fix so `skills.ts` typechecks under ADG's strict root tsconfig when reached via `use.ts`/tests. |
80
81
  | `src/update.ts` → both `spawnSync` self-CLI re-invokes (+ new `src/self-cli.ts`) | Forward `process.execArgv`, call `skills add` instead of `add`, and wrap in OpenTelemetry CLIENT spans | The child process runs `adg skills add` inside the spawned Node context, ensuring type-stripping flags inherit properly, and OTel spans capture subprocess execution metadata. |
81
82
  | `package.json` → `@vercel/detect-agent` dependency (not a vendored-source change) | `^0.1.0` → `^1.2.3` | `src/detect-agent.ts` (upstream, unpatched) imports `AgentResult` and expects `determineAgent(): Promise<AgentResult>` (object API). The stale `0.1.0` pin only exported `determineAgent(): Promise<string \| false>` and no `AgentResult`, which broke typecheck and left `cachedResult.isAgent` always `undefined` at runtime — agent auto-detection (non-interactive mode in `add`/`sync`/`remove`/`find`/`cli`) silently never fired. The `1.x` line restores the API the fork targets, so `detect-agent.ts` needs **no** local patch. Keep this dependency on `1.x` across re-vendoring. |