Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/core/antigravity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ export interface AntigravityMcpPayload {
[key: string]: unknown
}

/**
* Resolve the absolute filesystem path for the Antigravity CLI workspace MCP configuration file.
*
* @param projectRoot - The root directory of the project
* @returns Absolute path to the workspace MCP JSON file (`.agents/mcp_config.json`)
*/
export function getAntigravityWorkspaceMcpPath(projectRoot: string): string {
return path.join(projectRoot, '.agents', 'mcp_config.json')
Comment on lines +17 to +18

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

node --input-type=module <<'NODE'
import path from 'node:path'

const joined = path.join('relative-project', '.agents', 'mcp_config.json')
if (path.isAbsolute(joined)) {
  throw new Error('path.join unexpectedly returned an absolute path')
}

const resolved = path.resolve('relative-project', '.agents', 'mcp_config.json')
if (!path.isAbsolute(resolved)) {
  throw new Error('path.resolve did not return an absolute path')
}
NODE

Repository: amtiYo/agents

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '--- locate antigravity ---\n'
fd -a 'antigravity\.ts$' . || true

printf '\n--- inspect antigravity if present ---\n'
file=$(fd 'antigravity\.ts$' . | head -n 1)
if [ -n "${file:-}" ]; then
  wc -l "$file"
  sed -n '1,120p' "$file" | cat -n
fi

printf '\n--- locate paths helpers ---\n'
fd -a 'paths\.js$|paths\.ts$' . | sed 's#^\./##' || true

pathfile=$(fd 'paths\.(js|ts)$' src/core | head -n 1)
if [ -n "${pathfile:-}" ]; then
  printf '\n--- paths summary ---\n'
  ast-grep outline "$pathfile" --view compact || true
  printf '\n--- paths content ---\n'
  cat -n "$pathfile"
fi

printf '\n--- search function declaration/usages ---\n'
rg -n "getAntigravityWorkspaceMcpPath|path\.join\\(projectRoot|\\.agents/mcp_config\\.json|\\.agents/mcp_config\.json" .

Repository: amtiYo/agents

Length of output: 242


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- locate antigravity ---'
fd -a 'antigravity\.ts$' . || true

printf '%s\n' ''
printf '%s\n' '--- inspect antigravity if present ---'
file=$(fd 'antigravity\.ts$' . | head -n 1)
if [ -n "${file:-}" ]; then
  wc -l "$file"
  sed -n '1,140p' "$file" | cat -n
fi

printf '%s\n' ''
printf '%s\n' '--- locate paths helpers ---'
fd -a 'paths\.js$|paths\.ts$' . | sed 's#^\./##' || true

pathfile=$(fd 'paths\.(js|ts)$' src 2>/dev/null | head -n 1)
if [ -n "${pathfile:-}" ]; then
  printf '%s\n' ''
  printf '%s\n' '--- paths summary ---'
  ast-grep outline "$pathfile" --view compact || true
  printf '%s\n' ''
  printf '%s\n' '--- paths content ---'
  cat -n "$pathfile"
fi

printf '%s\n' ''
printf '%s\n' '--- search function declaration/usages ---'
rg -n "getAntigravityWorkspaceMcpPath|path\.join\\(projectRoot|\\.agents/mcp_config\\.json|\\.agents/mcp_config\.json" .

Repository: amtiYo/agents

Length of output: 38562


🏁 Script executed:

#!/bin/bash
set -euo pipefail

node --input-type=module <<'NODE'
import path from 'node:path'

const cases = [
  { projectRoot: 'repo', wantRelative: 'repo/.agents/mcp_config.json' },
  { projectRoot: '../repo', wantRelative: '../repo/.agents/mcp_config.json' },
  { projectRoot: '/tmp/repo', wantPrefix: '/tmp/repo/.agents/mcp_config.json' },
]

for (const { projectRoot, wantRelative, wantPrefix } of cases) {
  const result = path.join(projectRoot, '.agents', 'mcp_config.json')
  const isAbsolute = path.isAbsolute(result)
  const matches = wantRelative ? String(result) === wantRelative : String(result).startsWith(String(wantPrefix))
  console.log(JSON.stringify({
    input: projectRoot,
    joined: result,
    joinedIsAbsolute: isAbsolute,
    matchesExpectation: matches,
  }, null, 2))
}

const resolved = path.resolve('repo', '.agents', 'mcp_config.json')
console.log(JSON.stringify({
  resolved: resolved,
  resolutionIsAbsolute: path.isAbsolute(resolved),
}, null, 2))
NODE

Repository: amtiYo/agents

Length of output: 641


Отдавайте абсолютный путь независимо от формата projectRoot.

path.join() не делает абсолютным относительный projectRoot; например, при projectRoot = 'repo' функция возвращает repo/.agents/mcp_config.json, хотя JSDoc документирует абсолютный путь. Используйте helper из src/core/paths.ts, который нормализует корень через path.resolve, либо path.resolve(projectRoot, '.agents', 'mcp_config.json') с валидацией входного пути.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/core/antigravity.ts` around lines 17 - 18, Update
getAntigravityWorkspaceMcpPath to always return an absolute path when
projectRoot is relative, replacing path.join with the existing
path-normalization helper from paths.ts or path.resolve(projectRoot, '.agents',
'mcp_config.json') while preserving the documented MCP configuration location.

Source: Coding guidelines

}

/**
* Resolve the absolute filesystem path for the legacy global Antigravity MCP configuration file.
*
Expand Down