agy-scripts 0.1.0__tar.gz
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.
- agy_scripts-0.1.0/LICENSE +21 -0
- agy_scripts-0.1.0/PKG-INFO +97 -0
- agy_scripts-0.1.0/README.md +87 -0
- agy_scripts-0.1.0/pyproject.toml +19 -0
- agy_scripts-0.1.0/setup.cfg +4 -0
- agy_scripts-0.1.0/src/agy_scripts/__init__.py +3 -0
- agy_scripts-0.1.0/src/agy_scripts/control_cli.py +145 -0
- agy_scripts-0.1.0/src/agy_scripts/instances.py +156 -0
- agy_scripts-0.1.0/src/agy_scripts/mcp.py +235 -0
- agy_scripts-0.1.0/src/agy_scripts/paths.py +73 -0
- agy_scripts-0.1.0/src/agy_scripts/sessions.py +389 -0
- agy_scripts-0.1.0/src/agy_scripts.egg-info/PKG-INFO +97 -0
- agy_scripts-0.1.0/src/agy_scripts.egg-info/SOURCES.txt +15 -0
- agy_scripts-0.1.0/src/agy_scripts.egg-info/dependency_links.txt +1 -0
- agy_scripts-0.1.0/src/agy_scripts.egg-info/entry_points.txt +3 -0
- agy_scripts-0.1.0/src/agy_scripts.egg-info/top_level.txt +1 -0
- agy_scripts-0.1.0/tests/test_agy_scripts.py +112 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 jon allen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agy-scripts
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Cross-platform CLI utilities for managing Google Antigravity instances, MCP configs/profiles, and session search
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
|
|
11
|
+
# agy_scripts
|
|
12
|
+
|
|
13
|
+
Cross-platform CLI utilities and shell scripts for managing Google Antigravity (`antigravity-ide`, `antigravity`, and `agy`).
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Install the Python CLI tools (`agy-control` and `agy-session-search`) in editable mode so they are available directly on your `PATH`:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
uv tool install -e .
|
|
21
|
+
# or with pip:
|
|
22
|
+
pip install -e .
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Tools
|
|
26
|
+
|
|
27
|
+
### 1. `agy-control`
|
|
28
|
+
Unified cross-platform (Linux, macOS, Windows) CLI to list/restart Antigravity instances, edit MCP servers/tools, switch MCP profiles, maintain a master MCP reserve, and create date-stamped backups.
|
|
29
|
+
|
|
30
|
+
#### Subcommands
|
|
31
|
+
- `list` - List running Antigravity hub/IDE/app instances and show the active MCP profile
|
|
32
|
+
- `restart <PID|WORKSPACE|all>` - Restart matching hub instance(s) to pick up `mcp_config.json` changes
|
|
33
|
+
- `launch [WORKSPACE] [--ide|--app|--cli] [--new] [--profile NAME]` - Launch Antigravity IDE (default), Standalone App, or `agy` CLI (optionally forcing a new window/instance and activating a profile)
|
|
34
|
+
- `mcp list|tools [SERVER]|show <SERVER>` - Inspect MCP servers and tools (`--profile NAME` targets a saved profile)
|
|
35
|
+
- `mcp enable|disable|remove <SERVER> [--profile NAME] [--restart [TARGET]]` - Manage servers with automatic date-stamped backup and master reserve sync
|
|
36
|
+
- `mcp enable-tool|disable-tool <SERVER> <TOOL...> [--profile NAME] [--restart [TARGET]]` - Toggle individual tools
|
|
37
|
+
- `profile list|save <NAME>|use <NAME>` - Manage named MCP profiles in `~/.gemini/config/mcp_profiles/`
|
|
38
|
+
- `reserve sync|list` / `recover <SERVER>` - Sync known servers to `~/.gemini/config/mcp_master.json` and restore removed servers
|
|
39
|
+
- `backup` - Create a date-stamped backup in `~/.gemini/config/mcp_backups/`
|
|
40
|
+
|
|
41
|
+
#### Examples
|
|
42
|
+
```bash
|
|
43
|
+
# List running instances and active MCP profile
|
|
44
|
+
agy-control list
|
|
45
|
+
|
|
46
|
+
# List MCP servers and tools
|
|
47
|
+
agy-control mcp list
|
|
48
|
+
agy-control mcp tools mcp_remdev_serv_fedora
|
|
49
|
+
|
|
50
|
+
# Disable a tool and restart matching workspace instance
|
|
51
|
+
agy-control mcp disable-tool mcp_remdev_serv_fedora run_command --restart emdash
|
|
52
|
+
|
|
53
|
+
# Save and launch with a profile
|
|
54
|
+
agy-control profile save coding
|
|
55
|
+
agy-control launch ~/github2/emdash --ide --new --profile coding
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### 2. `agy-session-search`
|
|
61
|
+
Search, inspect, export, and resume Google Antigravity sessions (both `.db` and legacy encrypted `.pb`) using `~/.gemini/antigravity/conversation_summaries.db` and `brain/<UUID>/` artifacts.
|
|
62
|
+
|
|
63
|
+
#### Subcommands
|
|
64
|
+
- `list [--workspace PATH] [--since DAYS] [--format db|pb] [-n LIMIT]`
|
|
65
|
+
- `search <query> [--role user|agent] [--workspace PATH] [-n LIMIT]`
|
|
66
|
+
- `show <UUID>` / `export <UUID> [-o FILE]`
|
|
67
|
+
- `resume <UUID>` - Resume session via `agy -r <UUID>`
|
|
68
|
+
- `--info <UUID>` (or `info <UUID>`) - Show metadata, kebab-case slug, and best FTS5 search term
|
|
69
|
+
|
|
70
|
+
#### Examples
|
|
71
|
+
```bash
|
|
72
|
+
agy-session-search list -n 10
|
|
73
|
+
agy-session-search search "ChatDSL" --role user
|
|
74
|
+
agy-session-search --info 1e7c708f-b55e-46cb-a043-6798c7507d79
|
|
75
|
+
agy-session-search export 1e7c708f-b55e-46cb-a043-6798c7507d79 -o session.md
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### 3. `update_antigravity.sh`
|
|
81
|
+
Automated Linux (`x86_64`) installer and updater for Antigravity IDE (`~/Apps/antigravity-ide`), Standalone App (`~/Apps/antigravity`), and `agy` CLI (`~/.local/bin/agy`).
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
./update_antigravity.sh # Check and update all components
|
|
85
|
+
./update_antigravity.sh --check # Check versions and pre-download only
|
|
86
|
+
./update_antigravity.sh --install --cli # Install/update only agy CLI
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Development & Tests
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
PYTHONPATH=src python3 -m unittest discover -s tests -v
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
MIT - see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# agy_scripts
|
|
2
|
+
|
|
3
|
+
Cross-platform CLI utilities and shell scripts for managing Google Antigravity (`antigravity-ide`, `antigravity`, and `agy`).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the Python CLI tools (`agy-control` and `agy-session-search`) in editable mode so they are available directly on your `PATH`:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
uv tool install -e .
|
|
11
|
+
# or with pip:
|
|
12
|
+
pip install -e .
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Tools
|
|
16
|
+
|
|
17
|
+
### 1. `agy-control`
|
|
18
|
+
Unified cross-platform (Linux, macOS, Windows) CLI to list/restart Antigravity instances, edit MCP servers/tools, switch MCP profiles, maintain a master MCP reserve, and create date-stamped backups.
|
|
19
|
+
|
|
20
|
+
#### Subcommands
|
|
21
|
+
- `list` - List running Antigravity hub/IDE/app instances and show the active MCP profile
|
|
22
|
+
- `restart <PID|WORKSPACE|all>` - Restart matching hub instance(s) to pick up `mcp_config.json` changes
|
|
23
|
+
- `launch [WORKSPACE] [--ide|--app|--cli] [--new] [--profile NAME]` - Launch Antigravity IDE (default), Standalone App, or `agy` CLI (optionally forcing a new window/instance and activating a profile)
|
|
24
|
+
- `mcp list|tools [SERVER]|show <SERVER>` - Inspect MCP servers and tools (`--profile NAME` targets a saved profile)
|
|
25
|
+
- `mcp enable|disable|remove <SERVER> [--profile NAME] [--restart [TARGET]]` - Manage servers with automatic date-stamped backup and master reserve sync
|
|
26
|
+
- `mcp enable-tool|disable-tool <SERVER> <TOOL...> [--profile NAME] [--restart [TARGET]]` - Toggle individual tools
|
|
27
|
+
- `profile list|save <NAME>|use <NAME>` - Manage named MCP profiles in `~/.gemini/config/mcp_profiles/`
|
|
28
|
+
- `reserve sync|list` / `recover <SERVER>` - Sync known servers to `~/.gemini/config/mcp_master.json` and restore removed servers
|
|
29
|
+
- `backup` - Create a date-stamped backup in `~/.gemini/config/mcp_backups/`
|
|
30
|
+
|
|
31
|
+
#### Examples
|
|
32
|
+
```bash
|
|
33
|
+
# List running instances and active MCP profile
|
|
34
|
+
agy-control list
|
|
35
|
+
|
|
36
|
+
# List MCP servers and tools
|
|
37
|
+
agy-control mcp list
|
|
38
|
+
agy-control mcp tools mcp_remdev_serv_fedora
|
|
39
|
+
|
|
40
|
+
# Disable a tool and restart matching workspace instance
|
|
41
|
+
agy-control mcp disable-tool mcp_remdev_serv_fedora run_command --restart emdash
|
|
42
|
+
|
|
43
|
+
# Save and launch with a profile
|
|
44
|
+
agy-control profile save coding
|
|
45
|
+
agy-control launch ~/github2/emdash --ide --new --profile coding
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
### 2. `agy-session-search`
|
|
51
|
+
Search, inspect, export, and resume Google Antigravity sessions (both `.db` and legacy encrypted `.pb`) using `~/.gemini/antigravity/conversation_summaries.db` and `brain/<UUID>/` artifacts.
|
|
52
|
+
|
|
53
|
+
#### Subcommands
|
|
54
|
+
- `list [--workspace PATH] [--since DAYS] [--format db|pb] [-n LIMIT]`
|
|
55
|
+
- `search <query> [--role user|agent] [--workspace PATH] [-n LIMIT]`
|
|
56
|
+
- `show <UUID>` / `export <UUID> [-o FILE]`
|
|
57
|
+
- `resume <UUID>` - Resume session via `agy -r <UUID>`
|
|
58
|
+
- `--info <UUID>` (or `info <UUID>`) - Show metadata, kebab-case slug, and best FTS5 search term
|
|
59
|
+
|
|
60
|
+
#### Examples
|
|
61
|
+
```bash
|
|
62
|
+
agy-session-search list -n 10
|
|
63
|
+
agy-session-search search "ChatDSL" --role user
|
|
64
|
+
agy-session-search --info 1e7c708f-b55e-46cb-a043-6798c7507d79
|
|
65
|
+
agy-session-search export 1e7c708f-b55e-46cb-a043-6798c7507d79 -o session.md
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### 3. `update_antigravity.sh`
|
|
71
|
+
Automated Linux (`x86_64`) installer and updater for Antigravity IDE (`~/Apps/antigravity-ide`), Standalone App (`~/Apps/antigravity`), and `agy` CLI (`~/.local/bin/agy`).
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
./update_antigravity.sh # Check and update all components
|
|
75
|
+
./update_antigravity.sh --check # Check versions and pre-download only
|
|
76
|
+
./update_antigravity.sh --install --cli # Install/update only agy CLI
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Development & Tests
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
PYTHONPATH=src python3 -m unittest discover -s tests -v
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
MIT - see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "agy-scripts"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Cross-platform CLI utilities for managing Google Antigravity instances, MCP configs/profiles, and session search"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
dependencies = []
|
|
13
|
+
|
|
14
|
+
[project.scripts]
|
|
15
|
+
agy-control = "agy_scripts.control_cli:main"
|
|
16
|
+
agy-session-search = "agy_scripts.sessions:main"
|
|
17
|
+
|
|
18
|
+
[tool.setuptools.packages.find]
|
|
19
|
+
where = ["src"]
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""CLI entrypoint for agy-control."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
from . import instances, mcp
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def cmd_list(_args) -> None:
|
|
10
|
+
print(f"Active MCP Profile: {mcp.get_active_profile()}\n")
|
|
11
|
+
found = instances.find_instances()
|
|
12
|
+
if not found:
|
|
13
|
+
print("No running Antigravity instances found.")
|
|
14
|
+
return
|
|
15
|
+
print(f"{'PID':>7} {'TYPE':4} {'PORT':6} WORKSPACE")
|
|
16
|
+
print("-" * 70)
|
|
17
|
+
for inst in found:
|
|
18
|
+
print(f"{inst['pid']:>7} {inst['type']:4} {inst['port']:6} {inst['workspace']}")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def cmd_restart(args) -> None:
|
|
22
|
+
instances.restart_instances(args.target)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def cmd_launch(args) -> None:
|
|
26
|
+
if args.profile:
|
|
27
|
+
mcp.cmd_profile(argparse.Namespace(profile_cmd="use", name=args.profile))
|
|
28
|
+
new_inst = getattr(args, "new", False)
|
|
29
|
+
if args.cli:
|
|
30
|
+
cmd = ["agy"] + (["--add-dir", args.workspace] if args.workspace else [])
|
|
31
|
+
os.execvp("agy", cmd)
|
|
32
|
+
elif args.app:
|
|
33
|
+
instances.launch_gui("app", args.workspace, new_instance=new_inst)
|
|
34
|
+
print("Launched Antigravity Standalone App" + (f" for {args.workspace}" if args.workspace else "") + ".")
|
|
35
|
+
else:
|
|
36
|
+
instances.launch_gui("ide", args.workspace, new_instance=new_inst)
|
|
37
|
+
print("Launched Antigravity IDE" + (f" for {args.workspace}" if args.workspace else "") + ".")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def main() -> None:
|
|
41
|
+
parser = argparse.ArgumentParser(
|
|
42
|
+
prog="agy-control",
|
|
43
|
+
description="Unified cross-platform Antigravity instance manager, MCP config editor, and profiles.",
|
|
44
|
+
)
|
|
45
|
+
sub = parser.add_subparsers(dest="command")
|
|
46
|
+
|
|
47
|
+
sub.add_parser("list", help="List running Antigravity instances and active MCP profile")
|
|
48
|
+
|
|
49
|
+
p_res = sub.add_parser("restart", help="Restart instance(s) to pick up MCP config changes")
|
|
50
|
+
p_res.add_argument("target", help="PID, workspace substring, or 'all'")
|
|
51
|
+
|
|
52
|
+
sub.add_parser("backup", help="Create a date-stamped backup of mcp_config.json")
|
|
53
|
+
|
|
54
|
+
p_rsv = sub.add_parser("reserve", help="Manage master MCP server reserve")
|
|
55
|
+
rsv_sub = p_rsv.add_subparsers(dest="reserve_cmd")
|
|
56
|
+
rsv_sub.add_parser("sync", help="Sync current mcp_config.json servers into master reserve")
|
|
57
|
+
rsv_sub.add_parser("list", help="List all servers in master reserve")
|
|
58
|
+
|
|
59
|
+
p_rec = sub.add_parser("recover", help="Recover a removed MCP server from master reserve")
|
|
60
|
+
p_rec.add_argument("server", help="Server name to recover")
|
|
61
|
+
|
|
62
|
+
p_prof = sub.add_parser("profile", help="Manage MCP profiles")
|
|
63
|
+
prof_sub = p_prof.add_subparsers(dest="profile_cmd")
|
|
64
|
+
prof_sub.add_parser("list", help="List saved MCP profiles (marks active)")
|
|
65
|
+
p_psave = prof_sub.add_parser("save", help="Save current mcp_config.json as a profile")
|
|
66
|
+
p_psave.add_argument("name", help="Profile name")
|
|
67
|
+
p_puse = prof_sub.add_parser("use", help="Switch mcp_config.json to a saved profile")
|
|
68
|
+
p_puse.add_argument("name", help="Profile name")
|
|
69
|
+
|
|
70
|
+
p_launch = sub.add_parser("launch", help="Launch Antigravity IDE, Standalone App, or CLI with an optional MCP profile")
|
|
71
|
+
p_launch.add_argument("workspace", nargs="?", help="Workspace directory path")
|
|
72
|
+
p_launch.add_argument("--profile", help="MCP profile name to activate before launching")
|
|
73
|
+
target_grp = p_launch.add_mutually_exclusive_group()
|
|
74
|
+
target_grp.add_argument("--ide", action="store_true", help="Launch Antigravity IDE (default)")
|
|
75
|
+
target_grp.add_argument("--app", action="store_true", help="Launch Antigravity Standalone App")
|
|
76
|
+
target_grp.add_argument("--cli", action="store_true", help="Launch agy CLI")
|
|
77
|
+
p_launch.add_argument("--new", action="store_true", help="Force a new window/instance (--new-window)")
|
|
78
|
+
|
|
79
|
+
# `mcp` namespace
|
|
80
|
+
p_mcp = sub.add_parser("mcp", help="Inspect and edit MCP servers and tools")
|
|
81
|
+
mcp_sub = p_mcp.add_subparsers(dest="mcp_cmd")
|
|
82
|
+
|
|
83
|
+
def add_profile_arg(p):
|
|
84
|
+
p.add_argument("--profile", help="Edit a saved profile instead of active mcp_config.json")
|
|
85
|
+
|
|
86
|
+
def add_restart_arg(p):
|
|
87
|
+
p.add_argument("--restart", nargs="?", const="all", help="Restart instance(s) after edit (default: all)")
|
|
88
|
+
|
|
89
|
+
p_ml = mcp_sub.add_parser("list", help="List MCP servers")
|
|
90
|
+
add_profile_arg(p_ml)
|
|
91
|
+
|
|
92
|
+
p_mt = mcp_sub.add_parser("tools", help="List tools for an MCP server")
|
|
93
|
+
p_mt.add_argument("server", nargs="?", help="Server name (optional)")
|
|
94
|
+
add_profile_arg(p_mt)
|
|
95
|
+
|
|
96
|
+
p_ms = mcp_sub.add_parser("show", help="Show JSON config for a server")
|
|
97
|
+
p_ms.add_argument("server", help="Server name")
|
|
98
|
+
p_ms.add_argument("--raw", action="store_true", help="Show unredacted env values")
|
|
99
|
+
add_profile_arg(p_ms)
|
|
100
|
+
|
|
101
|
+
for act in ("enable", "disable", "remove"):
|
|
102
|
+
p_act = mcp_sub.add_parser(act, help=f"{act.capitalize()} an MCP server")
|
|
103
|
+
p_act.add_argument("server", help="Server name")
|
|
104
|
+
add_profile_arg(p_act)
|
|
105
|
+
add_restart_arg(p_act)
|
|
106
|
+
|
|
107
|
+
for act in ("enable-tool", "disable-tool"):
|
|
108
|
+
p_tact = mcp_sub.add_parser(act, help=f"{act.replace('-', ' ').capitalize()} on a server")
|
|
109
|
+
p_tact.add_argument("server", help="Server name")
|
|
110
|
+
p_tact.add_argument("tools", nargs="+", help="Tool name(s)")
|
|
111
|
+
add_profile_arg(p_tact)
|
|
112
|
+
add_restart_arg(p_tact)
|
|
113
|
+
|
|
114
|
+
args = parser.parse_args()
|
|
115
|
+
if args.command == "list":
|
|
116
|
+
cmd_list(args)
|
|
117
|
+
elif args.command == "restart":
|
|
118
|
+
cmd_restart(args)
|
|
119
|
+
elif args.command == "backup":
|
|
120
|
+
mcp.cmd_backup(args)
|
|
121
|
+
elif args.command == "reserve":
|
|
122
|
+
if not args.reserve_cmd:
|
|
123
|
+
p_rsv.print_help()
|
|
124
|
+
else:
|
|
125
|
+
mcp.cmd_reserve(args)
|
|
126
|
+
elif args.command == "recover":
|
|
127
|
+
mcp.cmd_recover(args)
|
|
128
|
+
elif args.command == "profile":
|
|
129
|
+
if not args.profile_cmd:
|
|
130
|
+
p_prof.print_help()
|
|
131
|
+
else:
|
|
132
|
+
mcp.cmd_profile(args)
|
|
133
|
+
elif args.command == "launch":
|
|
134
|
+
cmd_launch(args)
|
|
135
|
+
elif args.command == "mcp":
|
|
136
|
+
if not args.mcp_cmd:
|
|
137
|
+
p_mcp.print_help()
|
|
138
|
+
else:
|
|
139
|
+
mcp.cmd_mcp(args)
|
|
140
|
+
else:
|
|
141
|
+
parser.print_help()
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
if __name__ == "__main__":
|
|
145
|
+
main()
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"""Cross-platform Antigravity instance discovery, launch, and restart."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import platform
|
|
6
|
+
import re
|
|
7
|
+
import shutil
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
|
|
11
|
+
SYSTEM = platform.system() # 'Linux', 'Darwin', 'Windows'
|
|
12
|
+
|
|
13
|
+
_NOISE_PATTERNS = (
|
|
14
|
+
"--type=",
|
|
15
|
+
"--utility-sub-type=",
|
|
16
|
+
"chrome_crashpad_handler",
|
|
17
|
+
"shellintegration-",
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_processes() -> list[dict]:
|
|
22
|
+
"""Return list of {pid, cmd} for running Antigravity/agy processes."""
|
|
23
|
+
procs = []
|
|
24
|
+
if SYSTEM in ("Linux", "Darwin"):
|
|
25
|
+
try:
|
|
26
|
+
out = subprocess.check_output(["ps", "-eo", "pid,args"], text=True, errors="replace")
|
|
27
|
+
for line in out.splitlines()[1:]:
|
|
28
|
+
line = line.strip()
|
|
29
|
+
if not line:
|
|
30
|
+
continue
|
|
31
|
+
parts = line.split(None, 1)
|
|
32
|
+
if len(parts) < 2 or not parts[0].isdigit():
|
|
33
|
+
continue
|
|
34
|
+
pid_str, cmd = parts
|
|
35
|
+
low = cmd.lower()
|
|
36
|
+
if "antigravity" in low or "agy --hub" in low:
|
|
37
|
+
procs.append({"pid": int(pid_str), "cmd": cmd})
|
|
38
|
+
except Exception as e:
|
|
39
|
+
print(f"Warning: failed to list processes: {e}", file=sys.stderr)
|
|
40
|
+
elif SYSTEM == "Windows":
|
|
41
|
+
try:
|
|
42
|
+
ps_cmd = (
|
|
43
|
+
"Get-CimInstance Win32_Process | "
|
|
44
|
+
"Where-Object { $_.CommandLine -match 'antigravity|agy.*--hub' } | "
|
|
45
|
+
"Select-Object ProcessId, CommandLine | ConvertTo-Json -Compress"
|
|
46
|
+
)
|
|
47
|
+
out = subprocess.check_output(
|
|
48
|
+
["powershell", "-NoProfile", "-Command", ps_cmd],
|
|
49
|
+
text=True,
|
|
50
|
+
errors="replace",
|
|
51
|
+
)
|
|
52
|
+
if out.strip():
|
|
53
|
+
items = json.loads(out)
|
|
54
|
+
if isinstance(items, dict):
|
|
55
|
+
items = [items]
|
|
56
|
+
for item in items:
|
|
57
|
+
procs.append({"pid": int(item["ProcessId"]), "cmd": item.get("CommandLine") or ""})
|
|
58
|
+
except Exception as e:
|
|
59
|
+
print(f"Warning: failed to list Windows processes: {e}", file=sys.stderr)
|
|
60
|
+
return procs
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def parse_instances(procs: list[dict]) -> list[dict]:
|
|
64
|
+
"""Extract structured Antigravity hub/IDE/app instances, filtering helper noise."""
|
|
65
|
+
instances = []
|
|
66
|
+
for p in procs:
|
|
67
|
+
cmd = p["cmd"]
|
|
68
|
+
low = cmd.lower()
|
|
69
|
+
if any(noise in low for noise in _NOISE_PATTERNS):
|
|
70
|
+
continue
|
|
71
|
+
|
|
72
|
+
if "--hub" in cmd and "agy" in cmd:
|
|
73
|
+
port_m = re.search(r"--hub-port=(\d+)", cmd)
|
|
74
|
+
dir_m = re.search(r"--add-dir=(\S+)", cmd)
|
|
75
|
+
instances.append({
|
|
76
|
+
"pid": p["pid"],
|
|
77
|
+
"type": "hub",
|
|
78
|
+
"port": port_m.group(1) if port_m else "-",
|
|
79
|
+
"workspace": dir_m.group(1) if dir_m else "(none)",
|
|
80
|
+
"cmd": cmd,
|
|
81
|
+
})
|
|
82
|
+
elif any(tok in cmd for tok in ("antigravity-ide", "Antigravity.exe", "Antigravity.app")) or (
|
|
83
|
+
"/Apps/antigravity/antigravity" in cmd
|
|
84
|
+
):
|
|
85
|
+
inst_type = "ide" if ("antigravity-ide" in cmd or "Antigravity IDE" in cmd) else "app"
|
|
86
|
+
instances.append({
|
|
87
|
+
"pid": p["pid"],
|
|
88
|
+
"type": inst_type,
|
|
89
|
+
"port": "-",
|
|
90
|
+
"workspace": "-",
|
|
91
|
+
"cmd": cmd,
|
|
92
|
+
})
|
|
93
|
+
return instances
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def find_instances() -> list[dict]:
|
|
97
|
+
return parse_instances(get_processes())
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def kill_pid(pid: int) -> None:
|
|
101
|
+
if SYSTEM == "Windows":
|
|
102
|
+
subprocess.run(["taskkill", "/PID", str(pid), "/F"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
103
|
+
else:
|
|
104
|
+
try:
|
|
105
|
+
os.kill(pid, 15)
|
|
106
|
+
except ProcessLookupError:
|
|
107
|
+
pass
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def launch_gui(target: str = "ide", workspace: str | None = None, new_instance: bool = False) -> None:
|
|
111
|
+
"""Launch Antigravity IDE ('ide') or Standalone App ('app') across platforms."""
|
|
112
|
+
bin_name = "antigravity-ide" if target == "ide" else "antigravity"
|
|
113
|
+
mac_app = "Antigravity IDE" if target == "ide" else "Antigravity"
|
|
114
|
+
ws_args = [workspace] if workspace and workspace not in ("-", "(none)") else []
|
|
115
|
+
new_args = ["--new-window"] if new_instance else []
|
|
116
|
+
|
|
117
|
+
if SYSTEM == "Windows":
|
|
118
|
+
exe = shutil.which(bin_name) or bin_name
|
|
119
|
+
cmd = [exe] + new_args + ws_args
|
|
120
|
+
subprocess.Popen(cmd, creationflags=0x00000008 | 0x00000200, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
121
|
+
elif SYSTEM == "Darwin":
|
|
122
|
+
cmd = ["open", "-na", mac_app]
|
|
123
|
+
extra = new_args + ws_args
|
|
124
|
+
if extra:
|
|
125
|
+
cmd += ["--args"] + extra
|
|
126
|
+
subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
127
|
+
else:
|
|
128
|
+
exe = shutil.which(bin_name) or os.path.expanduser(f"~/.local/bin/{bin_name}")
|
|
129
|
+
cmd = [exe, "--no-sandbox"] + new_args + ws_args
|
|
130
|
+
subprocess.Popen(cmd, start_new_session=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def restart_instances(target: str) -> None:
|
|
134
|
+
instances = find_instances()
|
|
135
|
+
hubs = [i for i in instances if i["type"] == "hub"]
|
|
136
|
+
if not hubs:
|
|
137
|
+
print("No active workspace hubs found to restart.")
|
|
138
|
+
return
|
|
139
|
+
|
|
140
|
+
if target == "all":
|
|
141
|
+
targets = hubs
|
|
142
|
+
elif target.isdigit():
|
|
143
|
+
pid = int(target)
|
|
144
|
+
targets = [i for i in hubs if i["pid"] == pid]
|
|
145
|
+
else:
|
|
146
|
+
targets = [i for i in hubs if target in i["workspace"]]
|
|
147
|
+
|
|
148
|
+
if not targets:
|
|
149
|
+
print(f"No matching hub instance found for '{target}'.", file=sys.stderr)
|
|
150
|
+
sys.exit(1)
|
|
151
|
+
|
|
152
|
+
for inst in targets:
|
|
153
|
+
print(f"Restarting hub PID {inst['pid']} (workspace: {inst['workspace']})...")
|
|
154
|
+
kill_pid(inst["pid"])
|
|
155
|
+
launch_gui("ide", inst["workspace"])
|
|
156
|
+
print("Done. New instance(s) will pick up the current mcp_config.json.")
|