shellscripts 0.25.1__py3-none-any.whl → 0.26.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 +0 -3
- shell_scripts/commands/_yolo_common.py +184 -0
- shell_scripts/commands/agy.py +26 -57
- shell_scripts/commands/claude.py +27 -33
- shell_scripts/commands/codex.py +26 -83
- shell_scripts/commands/copilot.py +28 -31
- shell_scripts/commands/opencode.py +26 -31
- shell_scripts/commands/req_cmd.py +2 -2
- shell_scripts/config_cli.py +2341 -0
- shell_scripts/core.py +48 -10
- shell_scripts/version_check.py +43 -14
- {shellscripts-0.25.1.dist-info → shellscripts-0.26.0.dist-info}/METADATA +10 -19
- {shellscripts-0.25.1.dist-info → shellscripts-0.26.0.dist-info}/RECORD +18 -19
- shell_scripts/commands/gemini.py +0 -54
- shell_scripts/commands/kiro.py +0 -54
- shell_scripts/commands/pi.py +0 -61
- {shellscripts-0.25.1.dist-info → shellscripts-0.26.0.dist-info}/WHEEL +0 -0
- {shellscripts-0.25.1.dist-info → shellscripts-0.26.0.dist-info}/entry_points.txt +0 -0
- {shellscripts-0.25.1.dist-info → shellscripts-0.26.0.dist-info}/licenses/LICENSE +0 -0
- {shellscripts-0.25.1.dist-info → shellscripts-0.26.0.dist-info}/top_level.txt +0 -0
shell_scripts/__init__.py
CHANGED
|
@@ -20,10 +20,7 @@ _COMMAND_MODULES = {
|
|
|
20
20
|
"claude": "shell_scripts.commands.claude",
|
|
21
21
|
"codex": "shell_scripts.commands.codex",
|
|
22
22
|
"copilot": "shell_scripts.commands.copilot",
|
|
23
|
-
"gemini": "shell_scripts.commands.gemini",
|
|
24
|
-
"kiro": "shell_scripts.commands.kiro",
|
|
25
23
|
"opencode": "shell_scripts.commands.opencode",
|
|
26
|
-
"pi": "shell_scripts.commands.pi",
|
|
27
24
|
"dicom2jpg": "shell_scripts.commands.dicom2jpg",
|
|
28
25
|
"dicomviewer": "shell_scripts.commands.dicomviewer",
|
|
29
26
|
"diff": "shell_scripts.commands.diff_cmd",
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""@brief Shared registry-based launcher for YOLO-mode external AI CLIs.
|
|
3
|
+
|
|
4
|
+
@details Defines the declarative `YoloCliSpec` registry plus the shared inline
|
|
5
|
+
help renderer and subprocess runner consumed by thin YOLO command modules.
|
|
6
|
+
Adding a new YOLO CLI requires exactly one `YoloCliSpec` record plus one thin
|
|
7
|
+
command module exposing `DESCRIPTION`, `print_help(version)`, and `run(args)`.
|
|
8
|
+
@satisfies DES-030, DES-031, REQ-055, REQ-056, REQ-064
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import subprocess
|
|
14
|
+
from dataclasses import dataclass
|
|
15
|
+
|
|
16
|
+
from shell_scripts.utils import require_commands
|
|
17
|
+
|
|
18
|
+
## @var PROGRAM
|
|
19
|
+
# @brief Base CLI program name used in help output.
|
|
20
|
+
# @details Constant identifier for usage-line rendering in command help.
|
|
21
|
+
PROGRAM = "shellscripts"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass(frozen=True)
|
|
25
|
+
class YoloCliSpec:
|
|
26
|
+
"""@brief Declarative definition of one YOLO-mode external AI CLI.
|
|
27
|
+
|
|
28
|
+
@details Immutable registry record; a command module becomes a YOLO
|
|
29
|
+
launcher by binding exactly one instance of this record.
|
|
30
|
+
@satisfies DES-030
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
## @var command
|
|
34
|
+
# @brief Dispatcher command token exposed by the CLI registry.
|
|
35
|
+
command: str
|
|
36
|
+
## @var executable
|
|
37
|
+
# @brief External executable token resolved and validated before launch.
|
|
38
|
+
executable: str
|
|
39
|
+
## @var option
|
|
40
|
+
# @brief YOLO-mode option inserted immediately after the executable.
|
|
41
|
+
option: str
|
|
42
|
+
## @var note
|
|
43
|
+
# @brief Behavioral note rendered in inline help for `option`.
|
|
44
|
+
note: str
|
|
45
|
+
## @var alternative
|
|
46
|
+
# @brief Documented-but-not-executed alternative option; empty when none.
|
|
47
|
+
alternative: str = ""
|
|
48
|
+
## @var alternative_note
|
|
49
|
+
# @brief Behavioral note rendered in inline help for `alternative`.
|
|
50
|
+
alternative_note: str = ""
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## @var YOLO_CLI_REGISTRY
|
|
54
|
+
# @brief Alphabetically ordered registry of YOLO-mode AI CLI definitions.
|
|
55
|
+
# @details Rendered verbatim in every YOLO command inline help in this order;
|
|
56
|
+
# appending one record extends the registry and every help surface.
|
|
57
|
+
# @satisfies DES-030, REQ-086
|
|
58
|
+
YOLO_CLI_REGISTRY: tuple[YoloCliSpec, ...] = (
|
|
59
|
+
YoloCliSpec(
|
|
60
|
+
command="agy",
|
|
61
|
+
executable="agy",
|
|
62
|
+
option="--dangerously-skip-permissions",
|
|
63
|
+
note="Official Antigravity flag used instead of --yolo.",
|
|
64
|
+
),
|
|
65
|
+
YoloCliSpec(
|
|
66
|
+
command="claude",
|
|
67
|
+
executable="claude",
|
|
68
|
+
option="--dangerously-skip-permissions",
|
|
69
|
+
note=(
|
|
70
|
+
"Ignores all approval, policy, and rule prompts"
|
|
71
|
+
" for the entire session."
|
|
72
|
+
),
|
|
73
|
+
),
|
|
74
|
+
YoloCliSpec(
|
|
75
|
+
command="codex",
|
|
76
|
+
executable="codex",
|
|
77
|
+
option="--yolo",
|
|
78
|
+
note=(
|
|
79
|
+
"Skips confirmation prompts and entirely disables"
|
|
80
|
+
" the security sandbox."
|
|
81
|
+
),
|
|
82
|
+
),
|
|
83
|
+
YoloCliSpec(
|
|
84
|
+
command="copilot",
|
|
85
|
+
executable="copilot",
|
|
86
|
+
option="--yolo",
|
|
87
|
+
note="Skips confirmation prompts for the entire session.",
|
|
88
|
+
alternative="--allow-all",
|
|
89
|
+
alternative_note=(
|
|
90
|
+
"Accepted alternative granting access to all paths and tools."
|
|
91
|
+
),
|
|
92
|
+
),
|
|
93
|
+
YoloCliSpec(
|
|
94
|
+
command="opencode",
|
|
95
|
+
executable="opencode",
|
|
96
|
+
option="--auto",
|
|
97
|
+
note=(
|
|
98
|
+
"Approves every request that is not explicitly denied; "
|
|
99
|
+
"no formal --yolo flag exists."
|
|
100
|
+
),
|
|
101
|
+
),
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
## @var YOLO_CLI_INDEX
|
|
105
|
+
# @brief O(1) command-token lookup index over `YOLO_CLI_REGISTRY`.
|
|
106
|
+
# @satisfies DES-030
|
|
107
|
+
YOLO_CLI_INDEX: dict[str, YoloCliSpec] = {
|
|
108
|
+
spec.command: spec for spec in YOLO_CLI_REGISTRY
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def get_yolo_spec(command: str) -> YoloCliSpec:
|
|
113
|
+
"""@brief Resolve the declarative YOLO CLI record for one command token.
|
|
114
|
+
|
|
115
|
+
@details Performs O(1) dictionary lookup on `YOLO_CLI_INDEX`.
|
|
116
|
+
Time complexity O(1).
|
|
117
|
+
@param command {str} Dispatcher command token (for example `codex`).
|
|
118
|
+
@return {YoloCliSpec} Registry record bound to the command token.
|
|
119
|
+
@throws {KeyError} If the command token is not registered.
|
|
120
|
+
@satisfies DES-030
|
|
121
|
+
"""
|
|
122
|
+
return YOLO_CLI_INDEX[command]
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def print_yolo_help(command: str, version: str, description: str) -> None:
|
|
126
|
+
"""@brief Render YOLO command help documenting the full YOLO CLI registry.
|
|
127
|
+
|
|
128
|
+
@details Emits the command description, usage line, executed YOLO option
|
|
129
|
+
with its behavioral note, optional documented alternative option, and the
|
|
130
|
+
complete registry listing with every executed option and note in ascending
|
|
131
|
+
alphabetical command order; does not mutate process state.
|
|
132
|
+
Time complexity O(n) over registered YOLO CLI record count.
|
|
133
|
+
@param command {str} Dispatcher command token whose help is rendered.
|
|
134
|
+
@param version {str} CLI version string propagated by dispatcher.
|
|
135
|
+
@param description {str} One-line command description for the help header.
|
|
136
|
+
@return {None} Writes help text to stdout.
|
|
137
|
+
@satisfies DES-008, REQ-086, REQ-092, REQ-093
|
|
138
|
+
"""
|
|
139
|
+
spec = get_yolo_spec(command)
|
|
140
|
+
print(description)
|
|
141
|
+
print(f"Usage: {PROGRAM} {spec.command} [args...] ({version})")
|
|
142
|
+
print()
|
|
143
|
+
print(f"{spec.command} YOLO mode:")
|
|
144
|
+
print(f" Executed command: {spec.executable} {spec.option} [args...]")
|
|
145
|
+
print(f" {spec.option} - {spec.note}")
|
|
146
|
+
if spec.alternative:
|
|
147
|
+
print(
|
|
148
|
+
f" {spec.alternative} - {spec.alternative_note}"
|
|
149
|
+
" (accepted alternative; never appended automatically)."
|
|
150
|
+
)
|
|
151
|
+
print(" --help - Show this help message.")
|
|
152
|
+
print()
|
|
153
|
+
print("Registered YOLO CLIs (alphabetical order):")
|
|
154
|
+
for entry in YOLO_CLI_REGISTRY:
|
|
155
|
+
print(f" {entry.command:<9} {entry.executable} {entry.option}")
|
|
156
|
+
print(f" {entry.note}")
|
|
157
|
+
if entry.alternative:
|
|
158
|
+
print(
|
|
159
|
+
f" Alternative: {entry.alternative}"
|
|
160
|
+
f" - {entry.alternative_note}"
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def run_yolo_cli(command: str, args: list[str]) -> int:
|
|
165
|
+
"""@brief Launch one registered YOLO CLI after executable validation.
|
|
166
|
+
|
|
167
|
+
@details Resolves the registry record, validates executable availability
|
|
168
|
+
for the record executable, builds the command vector
|
|
169
|
+
`[resolved_executable, option] + args`, then executes it through blocking
|
|
170
|
+
`subprocess.run` with inherited stdio. Performs no Git repository root
|
|
171
|
+
validation and emits no project-root error output. Time complexity O(n)
|
|
172
|
+
over forwarded argument count.
|
|
173
|
+
@param command {str} Registered dispatcher command token.
|
|
174
|
+
@param args {list[str]} Additional CLI args forwarded to the external CLI.
|
|
175
|
+
@return {int} Child process return code.
|
|
176
|
+
@throws {KeyError} If the command token is not registered.
|
|
177
|
+
@satisfies REQ-014, REQ-015, REQ-017, REQ-018, REQ-085,
|
|
178
|
+
REQ-055, REQ-056, REQ-064
|
|
179
|
+
"""
|
|
180
|
+
spec = get_yolo_spec(command)
|
|
181
|
+
cmd = [spec.executable, spec.option] + args
|
|
182
|
+
cmd[0] = require_commands(cmd[0])
|
|
183
|
+
result = subprocess.run(cmd)
|
|
184
|
+
return result.returncode
|
shell_scripts/commands/agy.py
CHANGED
|
@@ -1,81 +1,50 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""@brief Antigravity CLI launcher in
|
|
2
|
+
"""@brief Antigravity CLI launcher in YOLO mode via the shared registry launcher.
|
|
3
3
|
|
|
4
|
-
@details
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@satisfies REQ-085, REQ-086, REQ-055, REQ-056, REQ-064
|
|
4
|
+
@details Thin YOLO command module binding the `agy` registry record and
|
|
5
|
+
delegating project-root enforcement, executable validation, inline help
|
|
6
|
+
rendering, and blocking subprocess invocation to `_yolo_common`.
|
|
7
|
+
@satisfies REQ-085, DES-030, DES-031, DES-008
|
|
9
8
|
"""
|
|
10
9
|
|
|
11
|
-
import
|
|
10
|
+
from shell_scripts.commands._yolo_common import (
|
|
11
|
+
get_yolo_spec,
|
|
12
|
+
print_yolo_help,
|
|
13
|
+
run_yolo_cli,
|
|
14
|
+
)
|
|
12
15
|
|
|
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
16
|
## @var DESCRIPTION
|
|
20
17
|
# @brief One-line command description for dispatcher help surfaces.
|
|
21
18
|
# @details Exposed by command registry introspection (`get_all_commands`).
|
|
22
19
|
DESCRIPTION = "Launch Antigravity CLI in the project context."
|
|
23
|
-
## @var
|
|
24
|
-
# @brief
|
|
25
|
-
# @
|
|
26
|
-
|
|
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
|
-
)))
|
|
20
|
+
## @var SPEC
|
|
21
|
+
# @brief Declarative YOLO CLI record bound to the `agy` command token.
|
|
22
|
+
# @satisfies DES-030, REQ-085
|
|
23
|
+
SPEC = get_yolo_spec("agy")
|
|
39
24
|
|
|
40
25
|
|
|
41
|
-
def print_help(version):
|
|
26
|
+
def print_help(version: str) -> None:
|
|
42
27
|
"""@brief Print command-specific help for `agy`.
|
|
43
28
|
|
|
44
|
-
@details
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
Time complexity O(n) over registered AI CLI token count.
|
|
29
|
+
@details Delegates to the shared YOLO help renderer, which emits the
|
|
30
|
+
executed option documentation and the alphabetical YOLO CLI registry.
|
|
31
|
+
Time complexity O(n) over registered YOLO CLI record count.
|
|
48
32
|
@param version {str} CLI version string propagated by dispatcher.
|
|
49
33
|
@return {None} Writes help text to stdout.
|
|
50
|
-
@satisfies DES-008, REQ-086
|
|
34
|
+
@satisfies DES-008, REQ-086, REQ-092
|
|
51
35
|
"""
|
|
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}")
|
|
36
|
+
print_yolo_help(SPEC.command, version, DESCRIPTION)
|
|
62
37
|
|
|
63
38
|
|
|
64
|
-
def run(args):
|
|
39
|
+
def run(args: list[str]) -> int:
|
|
65
40
|
"""@brief Launch Antigravity CLI in YOLO mode after executable validation.
|
|
66
41
|
|
|
67
|
-
@details
|
|
68
|
-
`
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
argument count.
|
|
42
|
+
@details Delegates to the shared YOLO runner executing
|
|
43
|
+
`agy --dangerously-skip-permissions` plus pass-through args through
|
|
44
|
+
blocking subprocess run with inherited stdio. Time complexity O(n) over
|
|
45
|
+
forwarded argument count.
|
|
72
46
|
@param args {list[str]} Additional CLI args forwarded to Antigravity.
|
|
73
47
|
@return {int} Child process return code.
|
|
74
48
|
@satisfies REQ-085, REQ-055, REQ-056, REQ-064
|
|
75
49
|
"""
|
|
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
|
|
50
|
+
return run_yolo_cli(SPEC.command, args)
|
shell_scripts/commands/claude.py
CHANGED
|
@@ -1,56 +1,50 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""@brief Claude CLI launcher in
|
|
2
|
+
"""@brief Claude CLI launcher in YOLO mode via the shared registry launcher.
|
|
3
3
|
|
|
4
|
-
@details
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
@details Thin YOLO command module binding the `claude` registry record and
|
|
5
|
+
delegating project-root enforcement, PATH-based executable validation, inline
|
|
6
|
+
help rendering, and blocking subprocess invocation to `_yolo_common`.
|
|
7
|
+
@satisfies REQ-017, DES-030, DES-031, DES-008
|
|
7
8
|
"""
|
|
8
9
|
|
|
9
|
-
import
|
|
10
|
-
|
|
10
|
+
from shell_scripts.commands._yolo_common import (
|
|
11
|
+
get_yolo_spec,
|
|
12
|
+
print_yolo_help,
|
|
13
|
+
run_yolo_cli,
|
|
14
|
+
)
|
|
11
15
|
|
|
12
|
-
from shell_scripts.utils import require_project_root, require_commands
|
|
13
|
-
|
|
14
|
-
## @var PROGRAM
|
|
15
|
-
# @brief Base CLI program name used in help output.
|
|
16
|
-
# @details Constant identifier for usage-line rendering in command help.
|
|
17
|
-
PROGRAM = "shellscripts"
|
|
18
16
|
## @var DESCRIPTION
|
|
19
17
|
# @brief One-line command description for dispatcher help surfaces.
|
|
20
18
|
# @details Exposed by command registry introspection (`get_all_commands`).
|
|
21
19
|
DESCRIPTION = "Launch Claude CLI with skip-permissions in the project context."
|
|
20
|
+
## @var SPEC
|
|
21
|
+
# @brief Declarative YOLO CLI record bound to the `claude` command token.
|
|
22
|
+
# @satisfies DES-030, REQ-017
|
|
23
|
+
SPEC = get_yolo_spec("claude")
|
|
22
24
|
|
|
23
25
|
|
|
24
|
-
def print_help(version):
|
|
26
|
+
def print_help(version: str) -> None:
|
|
25
27
|
"""@brief Print command-specific help for `claude`.
|
|
26
28
|
|
|
27
|
-
@details
|
|
28
|
-
|
|
29
|
+
@details Delegates to the shared YOLO help renderer, which emits the
|
|
30
|
+
executed option documentation and the alphabetical YOLO CLI registry.
|
|
31
|
+
Time complexity O(n) over registered YOLO CLI record count.
|
|
29
32
|
@param version {str} CLI version string propagated by dispatcher.
|
|
30
33
|
@return {None} Writes help text to stdout.
|
|
31
|
-
@satisfies DES-008
|
|
34
|
+
@satisfies DES-008, REQ-086, REQ-092
|
|
32
35
|
"""
|
|
33
|
-
|
|
34
|
-
print(f"Usage: {PROGRAM} claude [args...] ({version})")
|
|
35
|
-
print()
|
|
36
|
-
print("claude options:")
|
|
37
|
-
print(" All arguments are passed through to the Claude CLI.")
|
|
38
|
-
print(" --help - Show this help message.")
|
|
36
|
+
print_yolo_help(SPEC.command, version, DESCRIPTION)
|
|
39
37
|
|
|
40
38
|
|
|
41
|
-
def run(args):
|
|
42
|
-
"""@brief Launch Claude CLI after
|
|
39
|
+
def run(args: list[str]) -> int:
|
|
40
|
+
"""@brief Launch Claude CLI in YOLO mode after executable validation.
|
|
43
41
|
|
|
44
|
-
@details
|
|
45
|
-
|
|
42
|
+
@details Delegates to the shared YOLO runner executing the PATH-resolved
|
|
43
|
+
`claude --dangerously-skip-permissions` plus pass-through args through
|
|
44
|
+
blocking subprocess run with inherited stdio. Time complexity O(n) over
|
|
45
|
+
forwarded argument count.
|
|
46
46
|
@param args {list[str]} Additional CLI args forwarded to Claude.
|
|
47
47
|
@return {int} Child process return code.
|
|
48
48
|
@satisfies REQ-017, REQ-055, REQ-056, REQ-064
|
|
49
49
|
"""
|
|
50
|
-
|
|
51
|
-
require_project_root()
|
|
52
|
-
claude_bin = Path.home() / ".claude" / "bin" / "claude"
|
|
53
|
-
cmd = [str(claude_bin), "--dangerously-skip-permissions"] + args
|
|
54
|
-
cmd[0] = require_commands(cmd[0])
|
|
55
|
-
result = subprocess.run(cmd)
|
|
56
|
-
return result.returncode
|
|
50
|
+
return run_yolo_cli(SPEC.command, args)
|
shell_scripts/commands/codex.py
CHANGED
|
@@ -1,107 +1,50 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""@brief Codex CLI launcher
|
|
2
|
+
"""@brief Codex CLI launcher in YOLO mode via the shared registry launcher.
|
|
3
3
|
|
|
4
|
-
@details
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
informational output line for each copy direction.
|
|
10
|
-
@satisfies REQ-014, REQ-043, REQ-044, REQ-064
|
|
4
|
+
@details Thin YOLO command module binding the `codex` registry record and
|
|
5
|
+
delegating project-root enforcement, executable validation, inline help
|
|
6
|
+
rendering, and blocking subprocess invocation to `_yolo_common`. Performs no
|
|
7
|
+
auth-file synchronization and no `CODEX_HOME` environment mutation.
|
|
8
|
+
@satisfies REQ-014, DES-030, DES-031, DES-008
|
|
11
9
|
"""
|
|
12
10
|
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
from shell_scripts.commands._yolo_common import (
|
|
12
|
+
get_yolo_spec,
|
|
13
|
+
print_yolo_help,
|
|
14
|
+
run_yolo_cli,
|
|
15
|
+
)
|
|
17
16
|
|
|
18
|
-
from shell_scripts.utils import print_info, require_project_root, require_commands
|
|
19
|
-
|
|
20
|
-
## @var PROGRAM
|
|
21
|
-
# @brief Base CLI program name used in help output.
|
|
22
|
-
# @details Constant identifier for usage-line rendering in command help.
|
|
23
|
-
PROGRAM = "shellscripts"
|
|
24
17
|
## @var DESCRIPTION
|
|
25
18
|
# @brief One-line command description for dispatcher help surfaces.
|
|
26
19
|
# @details Exposed by command registry introspection (`get_all_commands`).
|
|
27
20
|
DESCRIPTION = "Launch OpenAI Codex CLI in the project context."
|
|
21
|
+
## @var SPEC
|
|
22
|
+
# @brief Declarative YOLO CLI record bound to the `codex` command token.
|
|
23
|
+
# @satisfies DES-030, REQ-014
|
|
24
|
+
SPEC = get_yolo_spec("codex")
|
|
28
25
|
|
|
29
26
|
|
|
30
27
|
def print_help(version: str) -> None:
|
|
31
28
|
"""@brief Print command-specific help for `codex`.
|
|
32
29
|
|
|
33
|
-
@details
|
|
34
|
-
|
|
30
|
+
@details Delegates to the shared YOLO help renderer, which emits the
|
|
31
|
+
executed option documentation and the alphabetical YOLO CLI registry.
|
|
32
|
+
Time complexity O(n) over registered YOLO CLI record count.
|
|
35
33
|
@param version {str} CLI version string propagated by dispatcher.
|
|
36
34
|
@return {None} Writes help text to stdout.
|
|
37
|
-
@satisfies DES-008
|
|
38
|
-
"""
|
|
39
|
-
print(f"Usage: {PROGRAM} codex [args...] ({version})")
|
|
40
|
-
print()
|
|
41
|
-
print("codex options:")
|
|
42
|
-
print(" All arguments are passed through to the Codex CLI.")
|
|
43
|
-
print(" --help - Show this help message.")
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def _copy_auth_file(
|
|
47
|
-
source_path: Path,
|
|
48
|
-
destination_path: Path,
|
|
49
|
-
direction_label: str,
|
|
50
|
-
) -> None:
|
|
51
|
-
"""@brief Copy Codex auth file while replacing destination file or symlink.
|
|
52
|
-
|
|
53
|
-
@details Ensures destination parent directory exists, removes an existing
|
|
54
|
-
destination entry when it is a file or symbolic link, then copies source
|
|
55
|
-
bytes to destination preserving metadata with `shutil.copy2`, then emits
|
|
56
|
-
one informational output line for copy evidence. Time complexity O(n) where
|
|
57
|
-
n is auth file size.
|
|
58
|
-
@param source_path {Path} Existing auth file source path.
|
|
59
|
-
@param destination_path {Path} Auth file destination path to overwrite.
|
|
60
|
-
@param direction_label {str} Copy direction descriptor shown in info output.
|
|
61
|
-
@return {None} Applies destination filesystem mutation.
|
|
62
|
-
@throws {OSError} If source read, destination unlink, or copy operation fails.
|
|
63
|
-
@satisfies REQ-043, REQ-044
|
|
35
|
+
@satisfies DES-008, REQ-086, REQ-092
|
|
64
36
|
"""
|
|
65
|
-
|
|
66
|
-
if destination_path.exists() or destination_path.is_symlink():
|
|
67
|
-
destination_path.unlink()
|
|
68
|
-
shutil.copy2(source_path, destination_path)
|
|
69
|
-
print_info(
|
|
70
|
-
f"Copied auth.json ({direction_label}): {source_path} -> {destination_path}"
|
|
71
|
-
)
|
|
37
|
+
print_yolo_help(SPEC.command, version, DESCRIPTION)
|
|
72
38
|
|
|
73
39
|
|
|
74
40
|
def run(args: list[str]) -> int:
|
|
75
|
-
"""@brief Launch Codex CLI
|
|
41
|
+
"""@brief Launch Codex CLI in YOLO mode after executable validation.
|
|
76
42
|
|
|
77
|
-
@details
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
run, then copies project auth back to home path in a `finally` block with
|
|
81
|
-
reverse-direction copy evidence output.
|
|
43
|
+
@details Delegates to the shared YOLO runner executing
|
|
44
|
+
`codex --yolo` plus pass-through args through blocking subprocess run
|
|
45
|
+
with inherited stdio. Time complexity O(n) over forwarded argument count.
|
|
82
46
|
@param args {list[str]} Additional CLI args forwarded to Codex.
|
|
83
47
|
@return {int} Child process return code.
|
|
84
|
-
@
|
|
85
|
-
@satisfies REQ-014, REQ-043, REQ-044, REQ-064
|
|
48
|
+
@satisfies REQ-014, REQ-055, REQ-056, REQ-064
|
|
86
49
|
"""
|
|
87
|
-
|
|
88
|
-
project_auth_path = project_root / ".codex" / "auth.json"
|
|
89
|
-
home_auth_path = Path.home() / ".codex" / "auth.json"
|
|
90
|
-
_copy_auth_file(
|
|
91
|
-
home_auth_path,
|
|
92
|
-
project_auth_path,
|
|
93
|
-
"global config -> project config",
|
|
94
|
-
)
|
|
95
|
-
codex_home = str(project_root / ".codex")
|
|
96
|
-
os.environ["CODEX_HOME"] = codex_home
|
|
97
|
-
cmd = ["codex", "--yolo"] + args
|
|
98
|
-
cmd[0] = require_commands(cmd[0])
|
|
99
|
-
try:
|
|
100
|
-
result = subprocess.run(cmd)
|
|
101
|
-
finally:
|
|
102
|
-
_copy_auth_file(
|
|
103
|
-
project_auth_path,
|
|
104
|
-
home_auth_path,
|
|
105
|
-
"project config -> global config",
|
|
106
|
-
)
|
|
107
|
-
return result.returncode
|
|
50
|
+
return run_yolo_cli(SPEC.command, args)
|
|
@@ -1,54 +1,51 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""@brief GitHub Copilot CLI launcher in
|
|
2
|
+
"""@brief GitHub Copilot CLI launcher in YOLO mode via the shared launcher.
|
|
3
3
|
|
|
4
|
-
@details
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
@details Thin YOLO command module binding the `copilot` registry record and
|
|
5
|
+
delegating project-root enforcement, executable validation, inline help
|
|
6
|
+
rendering, and blocking subprocess invocation to `_yolo_common`. The accepted
|
|
7
|
+
alternative `--allow-all` option is documented in inline help only.
|
|
8
|
+
@satisfies REQ-015, REQ-093, DES-030, DES-031, DES-008
|
|
7
9
|
"""
|
|
8
10
|
|
|
9
|
-
import
|
|
11
|
+
from shell_scripts.commands._yolo_common import (
|
|
12
|
+
get_yolo_spec,
|
|
13
|
+
print_yolo_help,
|
|
14
|
+
run_yolo_cli,
|
|
15
|
+
)
|
|
10
16
|
|
|
11
|
-
from shell_scripts.utils import require_project_root, require_commands
|
|
12
|
-
|
|
13
|
-
## @var PROGRAM
|
|
14
|
-
# @brief Base CLI program name used in help output.
|
|
15
|
-
# @details Constant identifier for usage-line rendering in command help.
|
|
16
|
-
PROGRAM = "shellscripts"
|
|
17
17
|
## @var DESCRIPTION
|
|
18
18
|
# @brief One-line command description for dispatcher help surfaces.
|
|
19
19
|
# @details Exposed by command registry introspection (`get_all_commands`).
|
|
20
20
|
DESCRIPTION = "Launch GitHub Copilot CLI in the project context."
|
|
21
|
+
## @var SPEC
|
|
22
|
+
# @brief Declarative YOLO CLI record bound to the `copilot` command token.
|
|
23
|
+
# @satisfies DES-030, REQ-015, REQ-093
|
|
24
|
+
SPEC = get_yolo_spec("copilot")
|
|
21
25
|
|
|
22
26
|
|
|
23
|
-
def print_help(version):
|
|
27
|
+
def print_help(version: str) -> None:
|
|
24
28
|
"""@brief Print command-specific help for `copilot`.
|
|
25
29
|
|
|
26
|
-
@details
|
|
27
|
-
|
|
30
|
+
@details Delegates to the shared YOLO help renderer, which emits the
|
|
31
|
+
executed option documentation, the accepted `--allow-all` alternative,
|
|
32
|
+
and the alphabetical YOLO CLI registry.
|
|
33
|
+
Time complexity O(n) over registered YOLO CLI record count.
|
|
28
34
|
@param version {str} CLI version string propagated by dispatcher.
|
|
29
35
|
@return {None} Writes help text to stdout.
|
|
30
|
-
@satisfies DES-008
|
|
36
|
+
@satisfies DES-008, REQ-086, REQ-092, REQ-093
|
|
31
37
|
"""
|
|
32
|
-
|
|
33
|
-
print(f"Usage: {PROGRAM} copilot [args...] ({version})")
|
|
34
|
-
print()
|
|
35
|
-
print("copilot options:")
|
|
36
|
-
print(" All arguments are passed through to the Copilot CLI.")
|
|
37
|
-
print(" --help - Show this help message.")
|
|
38
|
+
print_yolo_help(SPEC.command, version, DESCRIPTION)
|
|
38
39
|
|
|
39
40
|
|
|
40
|
-
def run(args):
|
|
41
|
-
"""@brief Launch Copilot CLI after
|
|
41
|
+
def run(args: list[str]) -> int:
|
|
42
|
+
"""@brief Launch Copilot CLI in YOLO mode after executable validation.
|
|
42
43
|
|
|
43
|
-
@details
|
|
44
|
-
`copilot
|
|
44
|
+
@details Delegates to the shared YOLO runner executing
|
|
45
|
+
`copilot --yolo` plus pass-through args through blocking subprocess run
|
|
46
|
+
with inherited stdio. Time complexity O(n) over forwarded argument count.
|
|
45
47
|
@param args {list[str]} Additional CLI args forwarded to Copilot.
|
|
46
48
|
@return {int} Child process return code.
|
|
47
49
|
@satisfies REQ-015, REQ-055, REQ-056, REQ-064
|
|
48
50
|
"""
|
|
49
|
-
|
|
50
|
-
require_project_root()
|
|
51
|
-
cmd = ["copilot", "--yolo", "--allow-all-tools", "--no-auto-update"] + args
|
|
52
|
-
cmd[0] = require_commands(cmd[0])
|
|
53
|
-
result = subprocess.run(cmd)
|
|
54
|
-
return result.returncode
|
|
51
|
+
return run_yolo_cli(SPEC.command, args)
|