devlaunch 0.0.14__tar.gz → 0.0.15__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.
Files changed (26) hide show
  1. {devlaunch-0.0.14 → devlaunch-0.0.15}/PKG-INFO +15 -2
  2. {devlaunch-0.0.14 → devlaunch-0.0.15}/README.md +14 -1
  3. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/aid.py +43 -12
  4. devlaunch-0.0.15/devlaunch/devpod_provider.py +116 -0
  5. {devlaunch-0.0.14 → devlaunch-0.0.15}/pyproject.toml +2 -2
  6. {devlaunch-0.0.14 → devlaunch-0.0.15}/.gitignore +0 -0
  7. {devlaunch-0.0.14 → devlaunch-0.0.15}/LICENSE +0 -0
  8. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/__init__.py +0 -0
  9. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/completion.py +0 -0
  10. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/completion_loader.py +0 -0
  11. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/completions/__init__.py +0 -0
  12. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/completions/dl.bash +0 -0
  13. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/devpod_ssh.py +0 -0
  14. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/dl.py +0 -0
  15. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/gh_auth.py +0 -0
  16. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/tools.py +0 -0
  17. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/tty_session.py +0 -0
  18. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/workspace_id.py +0 -0
  19. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/worktree/__init__.py +0 -0
  20. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/worktree/branch_manager.py +0 -0
  21. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/worktree/config.py +0 -0
  22. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/worktree/migration.py +0 -0
  23. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/worktree/models.py +0 -0
  24. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/worktree/repo_manager.py +0 -0
  25. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/worktree/storage.py +0 -0
  26. {devlaunch-0.0.14 → devlaunch-0.0.15}/devlaunch/worktree/workspace_clone.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: devlaunch
3
- Version: 0.0.14
3
+ Version: 0.0.15
4
4
  Summary: DevLaunch - A streamlined CLI for devpod workspaces
5
5
  Project-URL: Source, https://github.com/blooop/devlaunch
6
6
  Project-URL: Home, https://github.com/blooop/devlaunch
@@ -105,13 +105,26 @@ aid blooop/devlaunch@fix/42 fix the flaky test
105
105
  is exactly
106
106
 
107
107
  ```bash
108
- dl blooop/devlaunch@fix/42 -- claude 'fix the flaky test'
108
+ dl blooop/devlaunch@fix/42 -- IS_SANDBOX=1 claude --dangerously-skip-permissions 'fix the flaky test'
109
109
  ```
110
110
 
111
111
  That means an `aid` workspace *is* the `dl` workspace: same clone, same workspace
112
112
  id, same container — started if stopped, attached to if already running, and never
113
113
  rebuilt just because `aid` asked for it. Anything `dl` learns, `aid` gets.
114
114
 
115
+ `claude` is started with `--dangerously-skip-permissions`. The agent is already
116
+ inside a disposable container holding only this repo, so the per-tool prompts it
117
+ would ask on the host protect nothing here and would stall an unattended run.
118
+ `IS_SANDBOX=1` rides along because `claude` otherwise refuses that flag outright
119
+ under `uid 0`, and devcontainers that run as root are ordinary. The variable is
120
+ scoped to the agent process, not exported into your shell.
121
+
122
+ The trade is worth stating plainly: an agent started this way edits, runs and
123
+ deletes inside the container without asking. It cannot reach your host, but it can
124
+ rewrite the checkout it is in, so review an `aid` workspace before pushing rather
125
+ than treating it as a sandbox that will stop it for you. `--codex` and `--gemini`
126
+ are unaffected, and `dl <ws> -- claude` still runs exactly what you typed.
127
+
115
128
  | Option | Description |
116
129
  |--------|-------------|
117
130
  | `--claude`, `--codex`, `--gemini` | Pick the agent (default: `claude`) |
@@ -83,13 +83,26 @@ aid blooop/devlaunch@fix/42 fix the flaky test
83
83
  is exactly
84
84
 
85
85
  ```bash
86
- dl blooop/devlaunch@fix/42 -- claude 'fix the flaky test'
86
+ dl blooop/devlaunch@fix/42 -- IS_SANDBOX=1 claude --dangerously-skip-permissions 'fix the flaky test'
87
87
  ```
88
88
 
89
89
  That means an `aid` workspace *is* the `dl` workspace: same clone, same workspace
90
90
  id, same container — started if stopped, attached to if already running, and never
91
91
  rebuilt just because `aid` asked for it. Anything `dl` learns, `aid` gets.
92
92
 
93
+ `claude` is started with `--dangerously-skip-permissions`. The agent is already
94
+ inside a disposable container holding only this repo, so the per-tool prompts it
95
+ would ask on the host protect nothing here and would stall an unattended run.
96
+ `IS_SANDBOX=1` rides along because `claude` otherwise refuses that flag outright
97
+ under `uid 0`, and devcontainers that run as root are ordinary. The variable is
98
+ scoped to the agent process, not exported into your shell.
99
+
100
+ The trade is worth stating plainly: an agent started this way edits, runs and
101
+ deletes inside the container without asking. It cannot reach your host, but it can
102
+ rewrite the checkout it is in, so review an `aid` workspace before pushing rather
103
+ than treating it as a sandbox that will stop it for you. `--codex` and `--gemini`
104
+ are unaffected, and `dl <ws> -- claude` still runs exactly what you typed.
105
+
93
106
  | Option | Description |
94
107
  |--------|-------------|
95
108
  | `--claude`, `--codex`, `--gemini` | Pick the agent (default: `claude`) |
@@ -7,7 +7,7 @@ a `dl` one and hands that to :func:`devlaunch.dl.main`, so:
7
7
 
8
8
  is exactly
9
9
 
10
- dl owner/repo@branch -- claude 'fix the flaky test'
10
+ dl owner/repo@branch -- claude --dangerously-skip-permissions 'fix the flaky test'
11
11
 
12
12
  Everything that decides how a workspace is obtained — the bare repo cache, the
13
13
  worktree clone, the workspace id, the devpod container, the fast attach to one
@@ -27,13 +27,41 @@ from typing import Dict, List, Optional
27
27
 
28
28
  from . import dl
29
29
 
30
+
31
+ @dataclass(frozen=True)
32
+ class Agent:
33
+ """How one coding agent is started inside the workspace.
34
+
35
+ Split three ways because not every part of the line belongs everywhere:
36
+ `env` and `command` always run, while `prompt_flags` only joins them when
37
+ there is a prompt — gemini's way of taking an initial prompt is a flag that
38
+ is a syntax error without one.
39
+ """
40
+
41
+ command: List[str]
42
+ prompt_flags: List[str] = field(default_factory=list)
43
+ env: Dict[str, str] = field(default_factory=dict)
44
+
45
+
30
46
  # Base command per agent. The prompt, when there is one, is appended as a single
31
47
  # quoted argument; each of these CLIs takes an initial prompt that way and then
32
48
  # drops into its interactive session.
33
- AGENT_COMMANDS: Dict[str, List[str]] = {
34
- "claude": ["claude"],
35
- "codex": ["codex"],
36
- "gemini": ["gemini", "--prompt-interactive"],
49
+ #
50
+ # claude is started with --dangerously-skip-permissions: the whole point of a dl
51
+ # workspace is that the agent is already inside a disposable container with only
52
+ # this repo in it, so the per-tool prompts it would otherwise ask on the host buy
53
+ # nothing and stop an unattended `aid owner/repo fix the bug` dead.
54
+ #
55
+ # IS_SANDBOX=1 is what makes that flag usable at all here. claude refuses it
56
+ # outright under uid 0 -- "cannot be used with root/sudo privileges", exit 1 --
57
+ # and plenty of devcontainers run as root, so without this aid would not start
58
+ # in them at all. The variable is claude's own way of being told the refusal is
59
+ # answering for a machine that isn't there, which is exactly a dl workspace: a
60
+ # disposable container holding one repo.
61
+ AGENT_COMMANDS: Dict[str, Agent] = {
62
+ "claude": Agent(["claude", "--dangerously-skip-permissions"], env={"IS_SANDBOX": "1"}),
63
+ "codex": Agent(["codex"]),
64
+ "gemini": Agent(["gemini"], prompt_flags=["--prompt-interactive"]),
37
65
  }
38
66
 
39
67
  # Flags that pick the agent, e.g. `aid --gemini owner/repo ...`.
@@ -122,18 +150,21 @@ def build_agent_command(agent: str, prompt: str = "") -> str:
122
150
  takes. The prompt is quoted here rather than reassembled by the caller, so
123
151
  the words the user typed reach the agent as the single argument they meant.
124
152
  """
153
+ # Named for the agent, not `spec`, which is the workspace everywhere else here.
125
154
  try:
126
- command = list(AGENT_COMMANDS[agent])
155
+ started = AGENT_COMMANDS[agent]
127
156
  except KeyError:
128
157
  raise UsageError(
129
158
  f"Unknown agent {agent!r}. Choose one of: {', '.join(sorted(AGENT_COMMANDS))}."
130
159
  ) from None
131
- if not prompt:
132
- # No prompt to be interactive about: start the agent's plain session.
133
- # gemini's --prompt-interactive would be a syntax error without one.
134
- return shlex.quote(command[0])
135
- command.append(prompt)
136
- return shlex.join(command)
160
+ # No prompt to be interactive about: start the agent's plain session, without
161
+ # the flags that only make sense alongside one.
162
+ words = [*started.command, *started.prompt_flags, prompt] if prompt else list(started.command)
163
+ # Assignments prefixing a command set the variables for that command only, so
164
+ # the agent is the one process that sees them and nothing in the login shell
165
+ # dl runs this under is changed.
166
+ assignments = [f"{name}={shlex.quote(value)}" for name, value in sorted(started.env.items())]
167
+ return " ".join([*assignments, shlex.join(words)])
137
168
 
138
169
 
139
170
  def build_dl_args(parsed: AidArgs) -> List[str]:
@@ -0,0 +1,116 @@
1
+ """Answer "is this devpod provider already registered?" from devpod itself.
2
+
3
+ The question used to be asked by grepping devpod's human-facing table:
4
+
5
+ devpod provider list | grep -qw docker || devpod provider add docker
6
+
7
+ devpod v0.26.1 colourises that table unconditionally and emits the reset
8
+ sequence ``ESC[m`` immediately before each cell, so the character preceding
9
+ ``docker`` is the letter ``m``, ``grep -w``'s left word boundary never matches,
10
+ and the guard reported "absent" on every machine that had already registered the
11
+ provider. ``NO_COLOR=1`` does not help.
12
+
13
+ Dropping ``-w`` would have fixed today's rendering and left us reading a table
14
+ devpod is free to re-render tomorrow. ``provider list --output json`` is the
15
+ same information in a form that has no rendering to change: an object keyed by
16
+ provider name.
17
+
18
+ The other half of the old guard's failure is the part worth keeping out on
19
+ purpose. Output it could not read came back as an empty set of providers, and an
20
+ empty set of providers means "go add one" -- so an unreadable answer turned into
21
+ an action. Here, unreadable is its own outcome: `UnreadableProviderList`. The
22
+ caller finds out, rather than being told something false.
23
+ """
24
+
25
+ import json
26
+ import subprocess
27
+ from typing import Callable, Optional, Sequence, Set
28
+
29
+
30
+ class UnreadableProviderList(RuntimeError):
31
+ """devpod's provider listing could not be read.
32
+
33
+ Distinct from "no providers are registered", which is a listing that reads
34
+ fine and is empty.
35
+ """
36
+
37
+
38
+ def parse_provider_names(listing: str) -> Set[str]:
39
+ """The names of every registered provider in a `--output json` listing."""
40
+ try:
41
+ parsed = json.loads(listing)
42
+ except json.JSONDecodeError as exc:
43
+ raise UnreadableProviderList(
44
+ f"devpod's provider listing is not JSON: {listing[:120]!r}"
45
+ ) from exc
46
+ if not isinstance(parsed, dict):
47
+ raise UnreadableProviderList(
48
+ f"expected devpod to list providers by name, got {type(parsed).__name__}"
49
+ )
50
+ return set(parsed)
51
+
52
+
53
+ def list_provider_names(
54
+ run: Callable[..., subprocess.CompletedProcess] = subprocess.run,
55
+ ) -> Set[str]:
56
+ """Ask devpod which providers are registered."""
57
+ result = run(
58
+ ["devpod", "provider", "list", "--output", "json"],
59
+ capture_output=True,
60
+ text=True,
61
+ check=False,
62
+ )
63
+ if result.returncode != 0:
64
+ raise UnreadableProviderList(
65
+ f"`devpod provider list` exited {result.returncode}: {(result.stderr or '').strip()[:200]}"
66
+ )
67
+ return parse_provider_names(result.stdout or "")
68
+
69
+
70
+ def ensure_provider(
71
+ name: str, run: Callable[..., subprocess.CompletedProcess] = subprocess.run
72
+ ) -> bool:
73
+ """Register `name` with devpod unless it is already registered.
74
+
75
+ Returns True if it had to be added, False if it was already there. Raises
76
+ `UnreadableProviderList` rather than guessing when devpod's answer cannot
77
+ be read.
78
+ """
79
+ if name in list_provider_names(run=run):
80
+ return False
81
+ result = run(["devpod", "provider", "add", name], check=False)
82
+ if result.returncode != 0:
83
+ raise RuntimeError(f"`devpod provider add {name}` exited {result.returncode}")
84
+ return True
85
+
86
+
87
+ def main(
88
+ argv: Optional[Sequence[str]] = None,
89
+ run: Callable[..., subprocess.CompletedProcess] = subprocess.run,
90
+ ) -> int:
91
+ """CLI entry point: `python -m devlaunch.devpod_provider <name>`.
92
+
93
+ This is what the `dev-add-docker` pixi task runs, so a devpod that cannot be
94
+ read has to stop the task rather than let it carry on as if the provider
95
+ were missing.
96
+ """
97
+ import argparse # pylint: disable=import-outside-toplevel
98
+
99
+ parser = argparse.ArgumentParser(
100
+ prog="python -m devlaunch.devpod_provider",
101
+ description="Register a devpod provider unless it is already registered.",
102
+ )
103
+ parser.add_argument("name", help="provider name, e.g. docker")
104
+ args = parser.parse_args(argv)
105
+
106
+ try:
107
+ added = ensure_provider(args.name, run=run)
108
+ except (UnreadableProviderList, RuntimeError) as exc:
109
+ print(f"error: {exc}")
110
+ return 1
111
+ print(f"devpod provider {args.name}: {'added' if added else 'already registered'}")
112
+ return 0
113
+
114
+
115
+ if __name__ == "__main__":
116
+ raise SystemExit(main())
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "devlaunch"
3
- version = "0.0.14"
3
+ version = "0.0.15"
4
4
  authors = [{ name = "Austin Gregg-Smith", email = "blooop@gmail.com" }]
5
5
  description = "DevLaunch - A streamlined CLI for devpod workspaces"
6
6
  readme = "README.md"
@@ -74,7 +74,7 @@ py312 = ["py312", "test"]
74
74
  py313 = ["py313", "test"]
75
75
 
76
76
  [tool.pixi.tasks]
77
- dev-add-docker = "devpod provider list | grep -qw docker || devpod provider add docker"
77
+ dev-add-docker = "python -m devlaunch.devpod_provider docker"
78
78
  dev = { cmd = "devpod up . --ide none && ssh pythontemplate.devpod", depends-on = ["dev-add-docker"] }
79
79
  dev-vs = { cmd = "devpod up . --ide vscode", depends-on = ["dev-add-docker"] }
80
80
  dev-restart = { cmd = "devpod up . --recreate --ide none && ssh pythontemplate.devpod", depends-on = ["dev-add-docker"] }
File without changes
File without changes
File without changes