shellscripts 0.24.1__py3-none-any.whl → 0.25.0__py3-none-any.whl
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.
- shell_scripts/__init__.py +1 -1
- shell_scripts/commands/__init__.py +1 -1
- shell_scripts/commands/agy.py +81 -0
- shell_scripts/core.py +1 -1
- shell_scripts/utils.py +1 -1
- {shellscripts-0.24.1.dist-info → shellscripts-0.25.0.dist-info}/METADATA +9 -23
- {shellscripts-0.24.1.dist-info → shellscripts-0.25.0.dist-info}/RECORD +11 -11
- shell_scripts/commands/ai_install.py +0 -453
- {shellscripts-0.24.1.dist-info → shellscripts-0.25.0.dist-info}/WHEEL +0 -0
- {shellscripts-0.24.1.dist-info → shellscripts-0.25.0.dist-info}/entry_points.txt +0 -0
- {shellscripts-0.24.1.dist-info → shellscripts-0.25.0.dist-info}/licenses/LICENSE +0 -0
- {shellscripts-0.24.1.dist-info → shellscripts-0.25.0.dist-info}/top_level.txt +0 -0
shell_scripts/__init__.py
CHANGED
|
@@ -15,7 +15,7 @@ from types import ModuleType
|
|
|
15
15
|
# Removing an entry removes command discoverability and dispatch reachability.
|
|
16
16
|
# @satisfies PRJ-003, DES-001
|
|
17
17
|
_COMMAND_MODULES = {
|
|
18
|
-
"
|
|
18
|
+
"agy": "shell_scripts.commands.agy",
|
|
19
19
|
"clean": "shell_scripts.commands.clean",
|
|
20
20
|
"claude": "shell_scripts.commands.claude",
|
|
21
21
|
"codex": "shell_scripts.commands.codex",
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""@brief Antigravity CLI launcher in project context.
|
|
3
|
+
|
|
4
|
+
@details Ensures project-root prerequisite and executable availability before
|
|
5
|
+
blocking subprocess invocation of `agy` in YOLO mode
|
|
6
|
+
(`--dangerously-skip-permissions`); inline help lists the registered AI CLI
|
|
7
|
+
launch commands in alphabetical order.
|
|
8
|
+
@satisfies REQ-085, REQ-086, REQ-055, REQ-056, REQ-064
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import subprocess
|
|
12
|
+
|
|
13
|
+
from shell_scripts.utils import require_project_root, require_commands
|
|
14
|
+
|
|
15
|
+
## @var PROGRAM
|
|
16
|
+
# @brief Base CLI program name used in help output.
|
|
17
|
+
# @details Constant identifier for usage-line rendering in command help.
|
|
18
|
+
PROGRAM = "shellscripts"
|
|
19
|
+
## @var DESCRIPTION
|
|
20
|
+
# @brief One-line command description for dispatcher help surfaces.
|
|
21
|
+
# @details Exposed by command registry introspection (`get_all_commands`).
|
|
22
|
+
DESCRIPTION = "Launch Antigravity CLI in the project context."
|
|
23
|
+
## @var AI_CLI_COMMANDS
|
|
24
|
+
# @brief Alphabetically sorted AI CLI launch command tokens rendered in inline help.
|
|
25
|
+
# @details Derived through `sorted()` at import time so token-set edits preserve
|
|
26
|
+
# the REQ-086 alphabetical rendering contract; contains launcher commands only
|
|
27
|
+
# and excludes installer command tokens.
|
|
28
|
+
# @satisfies REQ-086
|
|
29
|
+
AI_CLI_COMMANDS = tuple(sorted((
|
|
30
|
+
"agy",
|
|
31
|
+
"claude",
|
|
32
|
+
"codex",
|
|
33
|
+
"copilot",
|
|
34
|
+
"gemini",
|
|
35
|
+
"kiro",
|
|
36
|
+
"opencode",
|
|
37
|
+
"pi",
|
|
38
|
+
)))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def print_help(version):
|
|
42
|
+
"""@brief Print command-specific help for `agy`.
|
|
43
|
+
|
|
44
|
+
@details Emits usage and pass-through argument behavior, then renders the
|
|
45
|
+
AI CLI launch command tokens from `AI_CLI_COMMANDS`, one per line, in
|
|
46
|
+
ascending alphabetical order; does not mutate process state.
|
|
47
|
+
Time complexity O(n) over registered AI CLI token count.
|
|
48
|
+
@param version {str} CLI version string propagated by dispatcher.
|
|
49
|
+
@return {None} Writes help text to stdout.
|
|
50
|
+
@satisfies DES-008, REQ-086
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
print(f"Usage: {PROGRAM} agy [args...] ({version})")
|
|
54
|
+
print()
|
|
55
|
+
print("agy options:")
|
|
56
|
+
print(" All arguments are passed through to the Antigravity CLI.")
|
|
57
|
+
print(" --help - Show this help message.")
|
|
58
|
+
print()
|
|
59
|
+
print("Available AI CLIs (alphabetical order):")
|
|
60
|
+
for command_token in AI_CLI_COMMANDS:
|
|
61
|
+
print(f" {command_token}")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def run(args):
|
|
65
|
+
"""@brief Launch Antigravity CLI in YOLO mode after executable validation.
|
|
66
|
+
|
|
67
|
+
@details Resolves project root, builds the fixed command vector
|
|
68
|
+
`[agy, --dangerously-skip-permissions] + args`, resolves the executable
|
|
69
|
+
path via `require_commands`, then executes it through blocking
|
|
70
|
+
`subprocess.run` with inherited stdio. Time complexity O(n) over forwarded
|
|
71
|
+
argument count.
|
|
72
|
+
@param args {list[str]} Additional CLI args forwarded to Antigravity.
|
|
73
|
+
@return {int} Child process return code.
|
|
74
|
+
@satisfies REQ-085, REQ-055, REQ-056, REQ-064
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
require_project_root()
|
|
78
|
+
cmd = ["agy", "--dangerously-skip-permissions"] + args
|
|
79
|
+
cmd[0] = require_commands(cmd[0])
|
|
80
|
+
result = subprocess.run(cmd)
|
|
81
|
+
return result.returncode
|
shell_scripts/core.py
CHANGED
shell_scripts/utils.py
CHANGED
|
@@ -155,7 +155,7 @@ def is_windows():
|
|
|
155
155
|
|
|
156
156
|
@details Evaluates cached runtime token from `get_runtime_os`.
|
|
157
157
|
@return {bool} `True` when runtime OS is Windows; otherwise `False`.
|
|
158
|
-
@satisfies
|
|
158
|
+
@satisfies REQ-047
|
|
159
159
|
"""
|
|
160
160
|
|
|
161
161
|
return get_runtime_os() == "windows"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: shellscripts
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.25.0
|
|
4
4
|
Summary: Execute useful shell scripts via an uvx-compatible CLI interface.
|
|
5
5
|
Author: Francesco Rolando
|
|
6
6
|
License-Expression: GPL-3.0-only
|
|
@@ -31,7 +31,7 @@ Dynamic: license-file
|
|
|
31
31
|
> * **No Support or Feature Requests:** Please **do not** open issues, bug reports, or feature requests. They will not be addressed or accepted at this stage of development.
|
|
32
32
|
> * **No Warranty:** This software is provided **"AS IS"**, without warranty of any kind, express or implied. You may use it strictly for **testing and evaluation purposes** at your own sole risk.
|
|
33
33
|
|
|
34
|
-
# s/shellScripts (0.
|
|
34
|
+
# s/shellScripts (0.25.0)
|
|
35
35
|
|
|
36
36
|
<p align="center">
|
|
37
37
|
<img src="https://img.shields.io/badge/python-3.11%2B-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python 3.11+">
|
|
@@ -65,8 +65,7 @@ PDF/DICOM utilities, development helpers, and editor integrations, exposed throu
|
|
|
65
65
|
|
|
66
66
|
## Feature Highlights
|
|
67
67
|
- Single CLI entrypoint with command dispatch and grouped built-in help (`shellscripts` and alias `s`).
|
|
68
|
-
-
|
|
69
|
-
- Project-context launchers for AI CLIs (`claude`, `codex`, `copilot`, `gemini`, `kiro`, `opencode`, `pi`) and IDEs (`vscode`, `vsinsider`).
|
|
68
|
+
- Project-context launchers for AI CLIs (`agy`, `claude`, `codex`, `copilot`, `gemini`, `kiro`, `opencode`, `pi`) and IDEs (`vscode`, `vsinsider`).
|
|
70
69
|
- PDF workflow commands for crop, merge, split, TOC cleanup, and tiling.
|
|
71
70
|
- DICOM helpers (`dicom2jpg`, `dicomviewer`) and video transcoders (`video2h264`, `video2h265`).
|
|
72
71
|
- Project maintenance and automation commands (`req`, `clean`, `venv`, `tests`, `doxygen`, `ubuntu-dark-theme`).
|
|
@@ -77,9 +76,8 @@ PDF/DICOM utilities, development helpers, and editor integrations, exposed throu
|
|
|
77
76
|
|
|
78
77
|
- Python `>=3.11`.
|
|
79
78
|
- Astral `uv` is required for install and runtime flows (`uv tool install`, `uvx`, `uv run`).
|
|
80
|
-
- Git is required for commands that enforce repository-root execution (`claude`, `codex`, `copilot`, `gemini`, `kiro`, `opencode`, `pi`, `clean`, `venv`, `tests`, `doxygen`, `vscode`, `vsinsider`).
|
|
79
|
+
- Git is required for commands that enforce repository-root execution (`agy`, `claude`, `codex`, `copilot`, `gemini`, `kiro`, `opencode`, `pi`, `clean`, `venv`, `tests`, `doxygen`, `vscode`, `vsinsider`).
|
|
81
80
|
- Command-specific external tools are required only for related commands:
|
|
82
|
-
- `npm` (and `sudo` on non-Windows) for npm-based `ai-install` targets.
|
|
83
81
|
- `req` for the `req` command.
|
|
84
82
|
- `doxygen` (plus optional `make` and `pdflatex`) for `doxygen`.
|
|
85
83
|
- `gs`, `pdfinfo`, `qpdf`, `pdftk`, `plakativ` for PDF commands.
|
|
@@ -200,14 +198,14 @@ Top-level configuration keys:
|
|
|
200
198
|
|
|
201
199
|
| Command | Purpose |
|
|
202
200
|
|---|---|
|
|
203
|
-
| `
|
|
201
|
+
| `agy` | Launch Antigravity CLI in project context (YOLO mode, pass-through args). |
|
|
204
202
|
| `claude` | Launch Claude CLI in project context. |
|
|
205
203
|
| `codex` | Launch Codex CLI in project context with auth sync and `CODEX_HOME`. |
|
|
206
204
|
| `copilot` | Launch Copilot CLI in project context. |
|
|
207
205
|
| `gemini` | Launch Gemini CLI in project context. |
|
|
208
206
|
| `kiro` | Launch Kiro CLI in project context. |
|
|
209
207
|
| `opencode` | Launch OpenCode CLI in project context. |
|
|
210
|
-
| `pi` | Launch pi.dev CLI in project context (
|
|
208
|
+
| `pi` | Launch pi.dev CLI in project context (forwards all arguments unchanged). |
|
|
211
209
|
| `clean` | Find and delete cache directories under the project root (or a passed directory). |
|
|
212
210
|
| `req` | Run useReq bootstrap on current directory, first-level dirs, or recursively. |
|
|
213
211
|
| `venv` | Recreate `.venv` and install `requirements.txt` if present. |
|
|
@@ -233,25 +231,13 @@ Top-level configuration keys:
|
|
|
233
231
|
|
|
234
232
|
### Selected Usage Examples
|
|
235
233
|
|
|
236
|
-
|
|
234
|
+
Launch Antigravity CLI in YOLO mode (command help lists the available AI CLIs in alphabetical order):
|
|
237
235
|
|
|
238
236
|
```bash
|
|
239
|
-
s
|
|
237
|
+
s agy
|
|
240
238
|
```
|
|
241
239
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
```bash
|
|
245
|
-
s ai-install --codex --gemini --claude
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
Run pi.dev with default tools injected automatically:
|
|
249
|
-
|
|
250
|
-
```bash
|
|
251
|
-
s pi
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
Override pi tools explicitly:
|
|
240
|
+
Run pi.dev CLI forwarding all arguments unchanged (no implicit option injection):
|
|
255
241
|
|
|
256
242
|
```bash
|
|
257
243
|
s pi --tools read,bash,grep,find
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
shell_scripts/__init__.py,sha256=
|
|
1
|
+
shell_scripts/__init__.py,sha256=sWpk4dCD9V5rWwB5mF0ld3eINn_1tk9T2otaWU4Q7z0,96
|
|
2
2
|
shell_scripts/__main__.py,sha256=-wEmwKTfeY5TphAH82E38XRPoB4KT5QDLDgRZz84PTs,83
|
|
3
3
|
shell_scripts/config.py,sha256=YUs8QWsZ31lJPrMpFqvn7YLQdseQnlaiu7OXcXsKdEw,12640
|
|
4
|
-
shell_scripts/core.py,sha256=
|
|
5
|
-
shell_scripts/utils.py,sha256=
|
|
4
|
+
shell_scripts/core.py,sha256=Fcu8wGiBsLhouK4VSuVXsacT4f78HnXrm1LzwCeNkUs,11197
|
|
5
|
+
shell_scripts/utils.py,sha256=ckIJRJ_F7XTu_SqpFu_vI_70xNOmVM3S48YiTzxpO7o,14115
|
|
6
6
|
shell_scripts/version_check.py,sha256=KVXVksy-T5V6rAYAnWACzv5MHi2dnrsYiNYg_yW0Eks,13184
|
|
7
|
-
shell_scripts/commands/__init__.py,sha256=
|
|
7
|
+
shell_scripts/commands/__init__.py,sha256=VoB5ucIdlUmcVdYV1JNgPvGBJU3aKPZMMMmY20Kjf5E,3682
|
|
8
8
|
shell_scripts/commands/_dc_common.py,sha256=kfUn92r6n8F1w27jy5QDJE_6Kvpvzhq6dUGNs0_GO0U,4695
|
|
9
|
-
shell_scripts/commands/
|
|
9
|
+
shell_scripts/commands/agy.py,sha256=L2BFopbNEI40BDrEAs3P6sAJw78U50ZH1SbylkA79hc,2997
|
|
10
10
|
shell_scripts/commands/bin_links.py,sha256=7chuWbk1FdnxH9ak_fATdmUSOyzIbg4WmfRPCOw10-U,2425
|
|
11
11
|
shell_scripts/commands/claude.py,sha256=_X76ygt0jnxZyyNoZ8qVhn6r2C0B9mcNIaKd_hLthl4,2049
|
|
12
12
|
shell_scripts/commands/clean.py,sha256=LOK7bVzqpWDvFBMInlu9COtODVmjwOtwCHyMriq7wIk,2552
|
|
@@ -37,9 +37,9 @@ shell_scripts/commands/video2h265.py,sha256=Sr_UWGz_V77x4anmuy8kiWZv5I_AOFlV0WDn
|
|
|
37
37
|
shell_scripts/commands/view_cmd.py,sha256=qHEivQHZpZCTE3VSFP1ay2SuqgancQlEKxJcKtyeqNA,1827
|
|
38
38
|
shell_scripts/commands/vscode_cmd.py,sha256=Rkcjt5A1HMzqJoh2Yz9VRGoLP-L3qpRO5hkcSrzOmvA,1461
|
|
39
39
|
shell_scripts/commands/vsinsider_cmd.py,sha256=KTTv1cVpJO-u1ktxOE0W_o4AAmz20pAvkDtyhpU9XBg,1548
|
|
40
|
-
shellscripts-0.
|
|
41
|
-
shellscripts-0.
|
|
42
|
-
shellscripts-0.
|
|
43
|
-
shellscripts-0.
|
|
44
|
-
shellscripts-0.
|
|
45
|
-
shellscripts-0.
|
|
40
|
+
shellscripts-0.25.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
41
|
+
shellscripts-0.25.0.dist-info/METADATA,sha256=-3I296fPkLpOPm5hgc1Qez5liP4AU7KfnK0WkkR0rZg,10771
|
|
42
|
+
shellscripts-0.25.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
43
|
+
shellscripts-0.25.0.dist-info/entry_points.txt,sha256=9ICAgH87fxHBzi3f6JXIVcsPWzAKsCh4_1xS8JThQ0M,85
|
|
44
|
+
shellscripts-0.25.0.dist-info/top_level.txt,sha256=7bDVqjcR5CfCCArCP4X4e9gYJ-ua8z-GfQeHbAo8rCY,14
|
|
45
|
+
shellscripts-0.25.0.dist-info/RECORD,,
|
|
@@ -1,453 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""@brief AI CLI installers dispatcher with OS-aware package resolution.
|
|
3
|
-
|
|
4
|
-
@details Provides selector-based installation flows for npm-distributed tools
|
|
5
|
-
and direct-download installers. Npm command prefix and installer payload
|
|
6
|
-
sources are resolved from detected runtime OS. Kiro package resolution is
|
|
7
|
-
manifest-driven on Linux and explicitly unsupported on Windows/macOS. pi.dev
|
|
8
|
-
installation always runs npm global installation first and then installs the
|
|
9
|
-
configured pi package list without any `--extra` selector gate.
|
|
10
|
-
@satisfies PRJ-003, DES-013, REQ-006, REQ-007, REQ-008, REQ-009, REQ-010, REQ-047, REQ-056, REQ-067, REQ-072, REQ-073, REQ-074
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
import json
|
|
14
|
-
import os
|
|
15
|
-
import platform
|
|
16
|
-
import subprocess
|
|
17
|
-
import shutil
|
|
18
|
-
import zipfile
|
|
19
|
-
import tempfile
|
|
20
|
-
from pathlib import Path
|
|
21
|
-
|
|
22
|
-
from shell_scripts.utils import (
|
|
23
|
-
get_runtime_os,
|
|
24
|
-
print_info,
|
|
25
|
-
print_error,
|
|
26
|
-
print_success,
|
|
27
|
-
require_commands,
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
## @var PROGRAM
|
|
31
|
-
# @brief Base CLI program name used in help output.
|
|
32
|
-
# @details Constant identifier for usage-line rendering in command help.
|
|
33
|
-
PROGRAM = "shellscripts"
|
|
34
|
-
|
|
35
|
-
## @var DESCRIPTION
|
|
36
|
-
# @brief One-line command description for dispatcher help surfaces.
|
|
37
|
-
# @details Exposed by command registry introspection (`get_all_commands`).
|
|
38
|
-
DESCRIPTION = "Install AI CLI tools (Codex, Copilot, Gemini, OpenCode, pi.dev, Claude, Kiro)."
|
|
39
|
-
|
|
40
|
-
## @var TOOLS
|
|
41
|
-
# @brief Static npm-installer registry for supported AI CLIs.
|
|
42
|
-
# @details Maps selector tokens to user-facing installer names and exact npm
|
|
43
|
-
# command vectors consumed by `_install_npm_tool(...)`.
|
|
44
|
-
TOOLS = {
|
|
45
|
-
"codex": {
|
|
46
|
-
"name": "OpenAI Codex CLI",
|
|
47
|
-
"install": ["npm", "install", "-g", "@openai/codex"],
|
|
48
|
-
},
|
|
49
|
-
"copilot": {
|
|
50
|
-
"name": "GitHub Copilot CLI",
|
|
51
|
-
"install": ["npm", "install", "-g", "@github/copilot"],
|
|
52
|
-
},
|
|
53
|
-
"gemini": {
|
|
54
|
-
"name": "Google Gemini CLI",
|
|
55
|
-
"install": ["npm", "install", "-g", "@google/gemini-cli"],
|
|
56
|
-
},
|
|
57
|
-
"opencode": {
|
|
58
|
-
"name": "OpenCode CLI",
|
|
59
|
-
"install": ["npm", "install", "-g", "opencode-ai"],
|
|
60
|
-
},
|
|
61
|
-
"pi": {
|
|
62
|
-
"name": "pi.dev CLI",
|
|
63
|
-
"install": ["npm", "install", "-g", "@mariozechner/pi-coding-agent"],
|
|
64
|
-
},
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
## @var PI_PACKAGES
|
|
68
|
-
# @brief Post-install pi package registry executed after pi.dev CLI install.
|
|
69
|
-
# @details Ordered tuple of package specifiers passed to `pi install` after
|
|
70
|
-
# successful npm-based pi.dev CLI installation.
|
|
71
|
-
PI_PACKAGES = ("git:github.com/ferologics/pi-notify",)
|
|
72
|
-
|
|
73
|
-
CLAUDE_BUCKET = (
|
|
74
|
-
"https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819"
|
|
75
|
-
"/claude-code-releases"
|
|
76
|
-
)
|
|
77
|
-
CLAUDE_ARTIFACT_CANDIDATES = {
|
|
78
|
-
"linux": ("linux-x64/claude",),
|
|
79
|
-
"windows": ("windows-x64/claude.exe", "win32-x64/claude.exe"),
|
|
80
|
-
"darwin": ("darwin-arm64/claude", "darwin-x64/claude"),
|
|
81
|
-
}
|
|
82
|
-
KIRO_CHANNEL_BASE_URL = "https://prod.download.cli.kiro.dev/stable"
|
|
83
|
-
KIRO_MANIFEST_URL = f"{KIRO_CHANNEL_BASE_URL}/latest/manifest.json"
|
|
84
|
-
KIRO_LINUX_VARIANT = "headless"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
def print_help(version: str) -> None:
|
|
88
|
-
"""@brief Render command help for `ai-install`.
|
|
89
|
-
|
|
90
|
-
@details Prints supported selectors and execution contract for installer
|
|
91
|
-
dispatch. The selector surface excludes any `--extra` compatibility flag.
|
|
92
|
-
@param version {str} CLI version string appended in usage output.
|
|
93
|
-
@return {None} Writes help text to stdout.
|
|
94
|
-
@satisfies DES-008
|
|
95
|
-
"""
|
|
96
|
-
|
|
97
|
-
print(f"Usage: {PROGRAM} ai-install [options] ({version})")
|
|
98
|
-
print()
|
|
99
|
-
print("ai-install options:")
|
|
100
|
-
print(" --all - Install all AI CLI tools (default).")
|
|
101
|
-
print(" --codex - Install OpenAI Codex CLI only.")
|
|
102
|
-
print(" --copilot - Install GitHub Copilot CLI only.")
|
|
103
|
-
print(" --gemini - Install Google Gemini CLI only.")
|
|
104
|
-
print(" --opencode - Install OpenCode CLI only.")
|
|
105
|
-
print(" --pi - Install pi.dev CLI only.")
|
|
106
|
-
print(" --claude - Install Claude CLI only.")
|
|
107
|
-
print(" --kiro - Install Kiro CLI only.")
|
|
108
|
-
print(" --help - Show this help message.")
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def _install_npm_tool(tool_key):
|
|
112
|
-
"""@brief Execute npm-based installer command for selected tool.
|
|
113
|
-
|
|
114
|
-
@details Resolves base npm command from static tool mapping, omits `sudo`
|
|
115
|
-
on Linux and Windows, prepends `sudo` on other runtimes, and uses resolved
|
|
116
|
-
`npm.cmd` path on Windows when available to avoid process-launch failures.
|
|
117
|
-
For Windows Copilot installs, retries once after a non-zero first attempt
|
|
118
|
-
to mitigate transient file-lock failures during binary replacement.
|
|
119
|
-
@param tool_key {str} Tool identifier key from `TOOLS`.
|
|
120
|
-
@return {bool} `True` when installation succeeds; `False` otherwise.
|
|
121
|
-
@satisfies DES-013, REQ-008, REQ-047, REQ-056, REQ-072
|
|
122
|
-
"""
|
|
123
|
-
|
|
124
|
-
info = TOOLS[tool_key]
|
|
125
|
-
command = list(info["install"])
|
|
126
|
-
runtime_os = get_runtime_os()
|
|
127
|
-
windows_runtime = runtime_os == "windows"
|
|
128
|
-
if windows_runtime:
|
|
129
|
-
npm_cmd_path = shutil.which("npm.cmd")
|
|
130
|
-
if npm_cmd_path:
|
|
131
|
-
command[0] = npm_cmd_path
|
|
132
|
-
elif runtime_os != "linux":
|
|
133
|
-
require_commands("sudo")
|
|
134
|
-
command = ["sudo"] + command
|
|
135
|
-
require_commands(command[0])
|
|
136
|
-
print_info(f"Installing {info['name']}...")
|
|
137
|
-
max_attempts = 2 if windows_runtime and tool_key == "copilot" else 1
|
|
138
|
-
result = None
|
|
139
|
-
for attempt_idx in range(max_attempts):
|
|
140
|
-
result = subprocess.run(command)
|
|
141
|
-
if result.returncode == 0:
|
|
142
|
-
break
|
|
143
|
-
if attempt_idx + 1 < max_attempts:
|
|
144
|
-
print_info(
|
|
145
|
-
"Retrying GitHub Copilot CLI installation after transient Windows file lock..."
|
|
146
|
-
)
|
|
147
|
-
assert result is not None
|
|
148
|
-
if result.returncode != 0:
|
|
149
|
-
print_error(f"Failed to install {info['name']}.")
|
|
150
|
-
print()
|
|
151
|
-
return False
|
|
152
|
-
|
|
153
|
-
print_success(f"{info['name']} installed.")
|
|
154
|
-
print()
|
|
155
|
-
return True
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
def _normalize_kiro_linux_arch(machine_token):
|
|
159
|
-
"""@brief Normalize machine architecture token for Kiro Linux packages.
|
|
160
|
-
|
|
161
|
-
@details Maps runtime machine names into manifest architecture keys accepted
|
|
162
|
-
by Kiro headless Linux ZIP entries. Raises explicit error for unknown
|
|
163
|
-
architecture to avoid ambiguous package selection.
|
|
164
|
-
@param machine_token {str} Raw `platform.machine()` token.
|
|
165
|
-
@return {str} Normalized architecture token (`x86_64` or `aarch64`).
|
|
166
|
-
@throws {RuntimeError} When architecture is not supported by Kiro installer.
|
|
167
|
-
@satisfies REQ-010, REQ-067
|
|
168
|
-
"""
|
|
169
|
-
|
|
170
|
-
normalized = machine_token.strip().lower()
|
|
171
|
-
if normalized in ("x86_64", "amd64"):
|
|
172
|
-
return "x86_64"
|
|
173
|
-
if normalized in ("aarch64", "arm64"):
|
|
174
|
-
return "aarch64"
|
|
175
|
-
raise RuntimeError(
|
|
176
|
-
f"Unsupported Linux architecture for Kiro installer: {machine_token}"
|
|
177
|
-
)
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
def _detect_kiro_linux_libc():
|
|
181
|
-
"""@brief Detect Linux libc class token for Kiro package selection.
|
|
182
|
-
|
|
183
|
-
@details Uses `platform.libc_ver()` to classify runtime libc as `musl` or
|
|
184
|
-
`gnu`. Unknown or empty values default to `gnu` to keep deterministic
|
|
185
|
-
package selection for glibc environments.
|
|
186
|
-
@return {str} libc class token (`musl` or `gnu`).
|
|
187
|
-
@satisfies REQ-010
|
|
188
|
-
"""
|
|
189
|
-
|
|
190
|
-
libc_name, _ = platform.libc_ver()
|
|
191
|
-
if "musl" in libc_name.lower():
|
|
192
|
-
return "musl"
|
|
193
|
-
return "gnu"
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
def _resolve_kiro_linux_download_path(manifest, arch_token, libc_token):
|
|
197
|
-
"""@brief Resolve Kiro Linux ZIP download path from manifest metadata.
|
|
198
|
-
|
|
199
|
-
@details Filters manifest packages by Linux OS, headless ZIP variant,
|
|
200
|
-
runtime architecture, and runtime libc class reflected in target triple.
|
|
201
|
-
Returns first matching `download` path and fails explicitly when no match
|
|
202
|
-
exists.
|
|
203
|
-
@param manifest {dict[str, object]} Parsed Kiro manifest JSON payload.
|
|
204
|
-
@param arch_token {str} Normalized architecture token (`x86_64|aarch64`).
|
|
205
|
-
@param libc_token {str} Normalized libc token (`gnu|musl`).
|
|
206
|
-
@return {str} Relative download path from manifest `packages[].download`.
|
|
207
|
-
@throws {RuntimeError} When no manifest package matches runtime filters.
|
|
208
|
-
@satisfies DES-013, REQ-010
|
|
209
|
-
"""
|
|
210
|
-
|
|
211
|
-
if libc_token not in ("gnu", "musl"):
|
|
212
|
-
raise RuntimeError(f"Unsupported Linux libc class for Kiro installer: {libc_token}")
|
|
213
|
-
|
|
214
|
-
target_suffix = "linux-musl" if libc_token == "musl" else "linux-gnu"
|
|
215
|
-
packages = manifest.get("packages")
|
|
216
|
-
if not isinstance(packages, list):
|
|
217
|
-
raise RuntimeError("Invalid Kiro manifest format: missing packages list")
|
|
218
|
-
|
|
219
|
-
for package in packages:
|
|
220
|
-
if not isinstance(package, dict):
|
|
221
|
-
continue
|
|
222
|
-
if package.get("os") != "linux":
|
|
223
|
-
continue
|
|
224
|
-
if package.get("fileType") != "zip":
|
|
225
|
-
continue
|
|
226
|
-
if package.get("variant") != KIRO_LINUX_VARIANT:
|
|
227
|
-
continue
|
|
228
|
-
if package.get("architecture") != arch_token:
|
|
229
|
-
continue
|
|
230
|
-
target_triple = str(package.get("targetTriple", ""))
|
|
231
|
-
if target_suffix not in target_triple:
|
|
232
|
-
continue
|
|
233
|
-
download_path = package.get("download")
|
|
234
|
-
if isinstance(download_path, str) and download_path:
|
|
235
|
-
return download_path
|
|
236
|
-
|
|
237
|
-
raise RuntimeError(
|
|
238
|
-
"No Kiro Linux package matched runtime architecture/libc in manifest"
|
|
239
|
-
)
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
def _install_claude():
|
|
243
|
-
"""@brief Install Claude CLI by direct binary download.
|
|
244
|
-
|
|
245
|
-
@details Downloads latest version metadata from configured bucket, resolves
|
|
246
|
-
OS-specific Claude artifact candidates from runtime OS token, downloads the
|
|
247
|
-
first available artifact, writes executable into `~/.claude/bin/claude`,
|
|
248
|
-
and sets execute permissions on non-Windows runtimes.
|
|
249
|
-
@return {None} Executes side effects and prints result messages.
|
|
250
|
-
@throws {RuntimeError} When runtime OS has no configured package candidates.
|
|
251
|
-
@throws {urllib.error.URLError} When metadata or artifact download fails.
|
|
252
|
-
@throws {OSError} When destination write or permission update fails.
|
|
253
|
-
@satisfies DES-013, REQ-009
|
|
254
|
-
"""
|
|
255
|
-
|
|
256
|
-
import urllib.error
|
|
257
|
-
import urllib.request
|
|
258
|
-
|
|
259
|
-
print_info("Installing Claude CLI...")
|
|
260
|
-
install_dir = Path.home() / ".claude" / "bin"
|
|
261
|
-
install_dir.mkdir(parents=True, exist_ok=True)
|
|
262
|
-
|
|
263
|
-
try:
|
|
264
|
-
runtime_os = get_runtime_os()
|
|
265
|
-
artifact_candidates = CLAUDE_ARTIFACT_CANDIDATES.get(runtime_os)
|
|
266
|
-
if not artifact_candidates:
|
|
267
|
-
raise RuntimeError(f"Unsupported runtime OS for Claude installer: {runtime_os}")
|
|
268
|
-
|
|
269
|
-
version_url = f"{CLAUDE_BUCKET}/latest"
|
|
270
|
-
with urllib.request.urlopen(version_url, timeout=15) as resp:
|
|
271
|
-
version = resp.read().decode().strip()
|
|
272
|
-
|
|
273
|
-
print_info(f"Downloading Claude CLI version {version}...")
|
|
274
|
-
download_error = None
|
|
275
|
-
dest = install_dir / "claude"
|
|
276
|
-
for artifact_path in artifact_candidates:
|
|
277
|
-
binary_url = f"{CLAUDE_BUCKET}/{version}/{artifact_path}"
|
|
278
|
-
try:
|
|
279
|
-
urllib.request.urlretrieve(binary_url, str(dest))
|
|
280
|
-
break
|
|
281
|
-
except (urllib.error.HTTPError, urllib.error.URLError) as error:
|
|
282
|
-
download_error = error
|
|
283
|
-
else:
|
|
284
|
-
raise RuntimeError(
|
|
285
|
-
f"No Claude artifact candidate was downloadable for OS {runtime_os}"
|
|
286
|
-
) from download_error
|
|
287
|
-
|
|
288
|
-
if runtime_os != "windows":
|
|
289
|
-
dest.chmod(0o755)
|
|
290
|
-
print_success(f"Claude CLI installed to {dest}")
|
|
291
|
-
except (OSError, RuntimeError, urllib.error.HTTPError, urllib.error.URLError) as e:
|
|
292
|
-
print_error(f"Failed to install Claude CLI: {e}")
|
|
293
|
-
print()
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
def _install_pi() -> None:
|
|
297
|
-
"""@brief Install pi.dev CLI and required post-install pi packages.
|
|
298
|
-
|
|
299
|
-
@details Executes npm-based pi.dev CLI installation first. When npm
|
|
300
|
-
installation succeeds, the function resolves the `pi` executable and
|
|
301
|
-
installs each package from `PI_PACKAGES` using `pi install <package>` in
|
|
302
|
-
tuple order. Package installation is skipped only when CLI installation
|
|
303
|
-
fails.
|
|
304
|
-
@return {None} Executes side effects and prints result messages.
|
|
305
|
-
@satisfies DES-013, REQ-072, REQ-073, REQ-074
|
|
306
|
-
"""
|
|
307
|
-
|
|
308
|
-
if not _install_npm_tool("pi"):
|
|
309
|
-
return
|
|
310
|
-
|
|
311
|
-
pi_executable = require_commands("pi")
|
|
312
|
-
print_info("Installing pi.dev packages...")
|
|
313
|
-
for package in PI_PACKAGES:
|
|
314
|
-
result = subprocess.run([pi_executable, "install", package])
|
|
315
|
-
if result.returncode != 0:
|
|
316
|
-
print_error(f"Failed to install pi.dev package: {package}.")
|
|
317
|
-
print()
|
|
318
|
-
return
|
|
319
|
-
|
|
320
|
-
print_success("pi.dev packages installed.")
|
|
321
|
-
print()
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
def _install_kiro():
|
|
325
|
-
"""@brief Install Kiro CLI binaries by ZIP extraction flow.
|
|
326
|
-
|
|
327
|
-
@details Rejects unsupported runtime OS values (`windows`, `darwin`) with
|
|
328
|
-
explicit errors. On Linux, resolves runtime architecture/libc package from
|
|
329
|
-
official stable manifest, downloads selected ZIP archive, extracts
|
|
330
|
-
`kiro-cli*` binaries, and installs them into `~/.local/bin`.
|
|
331
|
-
@return {None} Executes side effects and prints result messages.
|
|
332
|
-
@throws {RuntimeError} When runtime OS is unsupported or manifest has no
|
|
333
|
-
matching package.
|
|
334
|
-
@throws {urllib.error.URLError} When archive download fails.
|
|
335
|
-
@throws {json.JSONDecodeError} When manifest payload is malformed.
|
|
336
|
-
@throws {zipfile.BadZipFile} When downloaded archive is invalid.
|
|
337
|
-
@throws {OSError} When extraction/copy/permission updates fail.
|
|
338
|
-
@satisfies DES-013, REQ-010, REQ-067
|
|
339
|
-
"""
|
|
340
|
-
|
|
341
|
-
import urllib.error
|
|
342
|
-
import urllib.request
|
|
343
|
-
|
|
344
|
-
print_info("Installing Kiro CLI...")
|
|
345
|
-
runtime_os = get_runtime_os()
|
|
346
|
-
if runtime_os == "windows":
|
|
347
|
-
print_error("Failed to install Kiro CLI: unsupported runtime OS windows.")
|
|
348
|
-
print()
|
|
349
|
-
return
|
|
350
|
-
if runtime_os == "darwin":
|
|
351
|
-
print_error("Failed to install Kiro CLI: unsupported runtime OS darwin.")
|
|
352
|
-
print()
|
|
353
|
-
return
|
|
354
|
-
if runtime_os != "linux":
|
|
355
|
-
print_error(f"Failed to install Kiro CLI: unsupported runtime OS {runtime_os}.")
|
|
356
|
-
print()
|
|
357
|
-
return
|
|
358
|
-
|
|
359
|
-
install_dir = Path.home() / ".local" / "bin"
|
|
360
|
-
install_dir.mkdir(parents=True, exist_ok=True)
|
|
361
|
-
|
|
362
|
-
try:
|
|
363
|
-
machine_arch = _normalize_kiro_linux_arch(platform.machine())
|
|
364
|
-
libc_token = _detect_kiro_linux_libc()
|
|
365
|
-
with urllib.request.urlopen(KIRO_MANIFEST_URL, timeout=15) as response:
|
|
366
|
-
manifest_payload = json.loads(response.read().decode())
|
|
367
|
-
download_path = _resolve_kiro_linux_download_path(
|
|
368
|
-
manifest_payload,
|
|
369
|
-
machine_arch,
|
|
370
|
-
libc_token,
|
|
371
|
-
)
|
|
372
|
-
archive_url = f"{KIRO_CHANNEL_BASE_URL}/{download_path}"
|
|
373
|
-
|
|
374
|
-
with tempfile.TemporaryDirectory() as tmpdir:
|
|
375
|
-
zip_path = os.path.join(tmpdir, "kiro.zip")
|
|
376
|
-
print_info("Downloading Kiro CLI...")
|
|
377
|
-
urllib.request.urlretrieve(archive_url, zip_path)
|
|
378
|
-
|
|
379
|
-
with zipfile.ZipFile(zip_path, "r") as zf:
|
|
380
|
-
zf.extractall(tmpdir)
|
|
381
|
-
|
|
382
|
-
copied_binaries = []
|
|
383
|
-
for src in Path(tmpdir).rglob("kiro-cli*"):
|
|
384
|
-
if src.is_file():
|
|
385
|
-
dest = install_dir / src.name
|
|
386
|
-
shutil.copy2(src, str(dest))
|
|
387
|
-
dest.chmod(0o755)
|
|
388
|
-
copied_binaries.append(dest.name)
|
|
389
|
-
|
|
390
|
-
if not copied_binaries:
|
|
391
|
-
raise RuntimeError("No kiro-cli* binaries found in extracted archive")
|
|
392
|
-
|
|
393
|
-
print_success(f"Kiro CLI installed to {install_dir}")
|
|
394
|
-
except (
|
|
395
|
-
OSError,
|
|
396
|
-
RuntimeError,
|
|
397
|
-
urllib.error.HTTPError,
|
|
398
|
-
urllib.error.URLError,
|
|
399
|
-
zipfile.BadZipFile,
|
|
400
|
-
) as e:
|
|
401
|
-
print_error(f"Failed to install Kiro CLI: {e}")
|
|
402
|
-
print()
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
ALL_INSTALLERS = {
|
|
406
|
-
"codex": lambda: _install_npm_tool("codex"),
|
|
407
|
-
"copilot": lambda: _install_npm_tool("copilot"),
|
|
408
|
-
"gemini": lambda: _install_npm_tool("gemini"),
|
|
409
|
-
"opencode": lambda: _install_npm_tool("opencode"),
|
|
410
|
-
"pi": _install_pi,
|
|
411
|
-
"claude": _install_claude,
|
|
412
|
-
"kiro": _install_kiro,
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
def run(args: list[str]) -> int:
|
|
417
|
-
"""@brief Parse selectors and execute selected AI installer routines.
|
|
418
|
-
|
|
419
|
-
@details Accepts explicit selectors or defaults to the full installer set
|
|
420
|
-
when omitted. Unknown selectors are rejected with return code `1`; no
|
|
421
|
-
compatibility parsing exists for removed `--extra` behavior.
|
|
422
|
-
@param args {list[str]} CLI selector tokens for installer filtering.
|
|
423
|
-
@return {int} `0` on successful dispatch; `1` on unknown selector.
|
|
424
|
-
@satisfies REQ-006, REQ-007, REQ-073, REQ-074
|
|
425
|
-
"""
|
|
426
|
-
|
|
427
|
-
selected = []
|
|
428
|
-
include_all = False
|
|
429
|
-
for arg in args:
|
|
430
|
-
key = arg.lstrip("-")
|
|
431
|
-
if key == "all":
|
|
432
|
-
include_all = True
|
|
433
|
-
continue
|
|
434
|
-
if key in ALL_INSTALLERS:
|
|
435
|
-
selected.append(key)
|
|
436
|
-
continue
|
|
437
|
-
print_error(f"Unknown option: {arg}")
|
|
438
|
-
return 1
|
|
439
|
-
|
|
440
|
-
if include_all or not selected:
|
|
441
|
-
selected = list(ALL_INSTALLERS.keys())
|
|
442
|
-
else:
|
|
443
|
-
selected = list(dict.fromkeys(selected))
|
|
444
|
-
|
|
445
|
-
print_info(f"Starting AI CLI tools installation ({len(selected)} tools)...")
|
|
446
|
-
print()
|
|
447
|
-
|
|
448
|
-
for key in selected:
|
|
449
|
-
installer = ALL_INSTALLERS[key]
|
|
450
|
-
installer()
|
|
451
|
-
|
|
452
|
-
print_success("AI CLI tools installation complete.")
|
|
453
|
-
return 0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|