spin-up-dev-project 0.1.0__tar.gz → 0.2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: spin-up-dev-project
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Spin up a new project: directory, README, git repo, private GitHub repo, then launch your coding agent.
5
5
  Project-URL: Homepage, https://github.com/lorenzowood/spin-up
6
6
  Project-URL: Issues, https://github.com/lorenzowood/spin-up/issues
@@ -56,7 +56,7 @@ cursor: cursor-agent
56
56
  ## Usage
57
57
 
58
58
  ```
59
- spin-up [-y] [--owner OWNER] <agent> <directory> [<name>]
59
+ spin-up [-y] [-q] [--owner OWNER] <agent> <directory> [<name>]
60
60
  ```
61
61
 
62
62
  | Argument | Meaning |
@@ -65,6 +65,7 @@ spin-up [-y] [--owner OWNER] <agent> <directory> [<name>]
65
65
  | `directory` | The directory to create. It **must not already exist**. Its basename is the repo name. |
66
66
  | `name` | Optional title for the README's `# H1`. Defaults to the directory name. |
67
67
  | `--owner` | GitHub owner for the new repo. Defaults to the user `gh` is logged in as. |
68
+ | `-q`, `--quiet` | Don't print progress messages. |
68
69
  | `-y`, `--yes` | Don't ask for confirmation when possibly-related repos are found. |
69
70
 
70
71
  What it does, in order:
@@ -75,7 +76,10 @@ What it does, in order:
75
76
  If any are found it prints them and asks `Continue with spin-up of <directory>?`.
76
77
  3. Creates the directory and `README.md`, runs `git init -b main`, and commits.
77
78
  4. Creates the **private** repo `<owner>/<directory-name>` and pushes.
78
- 5. Replaces itself with the agent command, running in the new directory.
79
+ 5. If run inside [herdr](https://herdr.dev) (`HERDR_WORKSPACE_ID` is set), renames the
80
+ current workspace to `<name>` if given, else the directory name. A failure here is
81
+ only a warning.
82
+ 6. Replaces itself with the agent command, running in the new directory.
79
83
 
80
84
  ### Related-repo check
81
85
 
@@ -40,7 +40,7 @@ cursor: cursor-agent
40
40
  ## Usage
41
41
 
42
42
  ```
43
- spin-up [-y] [--owner OWNER] <agent> <directory> [<name>]
43
+ spin-up [-y] [-q] [--owner OWNER] <agent> <directory> [<name>]
44
44
  ```
45
45
 
46
46
  | Argument | Meaning |
@@ -49,6 +49,7 @@ spin-up [-y] [--owner OWNER] <agent> <directory> [<name>]
49
49
  | `directory` | The directory to create. It **must not already exist**. Its basename is the repo name. |
50
50
  | `name` | Optional title for the README's `# H1`. Defaults to the directory name. |
51
51
  | `--owner` | GitHub owner for the new repo. Defaults to the user `gh` is logged in as. |
52
+ | `-q`, `--quiet` | Don't print progress messages. |
52
53
  | `-y`, `--yes` | Don't ask for confirmation when possibly-related repos are found. |
53
54
 
54
55
  What it does, in order:
@@ -59,7 +60,10 @@ What it does, in order:
59
60
  If any are found it prints them and asks `Continue with spin-up of <directory>?`.
60
61
  3. Creates the directory and `README.md`, runs `git init -b main`, and commits.
61
62
  4. Creates the **private** repo `<owner>/<directory-name>` and pushes.
62
- 5. Replaces itself with the agent command, running in the new directory.
63
+ 5. If run inside [herdr](https://herdr.dev) (`HERDR_WORKSPACE_ID` is set), renames the
64
+ current workspace to `<name>` if given, else the directory name. A failure here is
65
+ only a warning.
66
+ 6. Replaces itself with the agent command, running in the new directory.
63
67
 
64
68
  ### Related-repo check
65
69
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "spin-up-dev-project"
7
- version = "0.1.0"
7
+ version = "0.2.0"
8
8
  description = "Spin up a new project: directory, README, git repo, private GitHub repo, then launch your coding agent."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -1,3 +1,3 @@
1
1
  """spin-up: scaffold a project, create its private GitHub repo, launch an agent."""
2
2
 
3
- __version__ = "0.1.0"
3
+ __version__ = "0.2.0"
@@ -56,13 +56,30 @@ def launch_agent(argv: list[str], cwd: Path) -> None:
56
56
  os.execvp(argv[0], argv)
57
57
 
58
58
 
59
+ def rename_herdr_workspace(label: str, say=print) -> None:
60
+ """If running inside herdr, label the current workspace (best effort)."""
61
+ workspace = os.environ.get("HERDR_WORKSPACE_ID")
62
+ if not workspace or shutil.which("herdr") is None:
63
+ return
64
+ say(f"Renaming herdr workspace {workspace} to {label!r}")
65
+ try:
66
+ run(["herdr", "workspace", "rename", workspace, label])
67
+ except SpinUpError as exc:
68
+ print(f"spin-up: warning: could not rename herdr workspace: {exc}", file=sys.stderr)
69
+
70
+
59
71
  def spin_up(
60
72
  agent: str,
61
73
  directory: str,
62
74
  title: str | None = None,
63
75
  owner: str | None = None,
64
76
  assume_yes: bool = False,
77
+ quiet: bool = False,
65
78
  ) -> None:
79
+ def say(msg: str) -> None:
80
+ if not quiet:
81
+ print(msg, flush=True)
82
+
66
83
  agents = load_agents()
67
84
  if agent not in agents:
68
85
  known = ", ".join(sorted(agents)) or "none"
@@ -81,8 +98,10 @@ def spin_up(
81
98
  if shutil.which(tool) is None:
82
99
  raise SpinUpError(f"{tool!r} not found on PATH")
83
100
 
101
+ say("Checking GitHub authentication...")
84
102
  check_gh_auth()
85
103
  owner = owner or github_user()
104
+ say(f"Looking for related repositories under {owner}...")
86
105
  related = find_related(name, list_repo_names(owner))
87
106
  if related:
88
107
  print("The following may be related:")
@@ -91,18 +110,25 @@ def spin_up(
91
110
  if not assume_yes and not confirm(f"Continue with spin-up of {directory}?"):
92
111
  print("Aborted.")
93
112
  raise SystemExit(1)
113
+ else:
114
+ say("None found.")
94
115
 
116
+ say(f"Creating {path} with README.md")
95
117
  path.mkdir(parents=True)
96
118
  (path / "README.md").write_text(f"# {title or name}\n\nPlaceholder.\n")
119
+ say("Initialising git repository and committing...")
97
120
  run(["git", "init", "-b", "main"], cwd=path)
98
121
  run(["git", "add", "README.md"], cwd=path)
99
122
  run(["git", "commit", "-m", "Add placeholder README"], cwd=path)
123
+ say(f"Creating private GitHub repository {owner}/{name} and pushing...")
100
124
  run(
101
125
  ["gh", "repo", "create", f"{owner}/{name}", "--private",
102
126
  "--source=.", "--remote=origin", "--push"],
103
127
  cwd=path,
104
128
  )
105
- print(f"Created https://github.com/{owner}/{name} (private)")
129
+ say(f"Created https://github.com/{owner}/{name} (private)")
130
+ rename_herdr_workspace(title or name, say)
131
+ say(f"Launching: {' '.join(agent_argv)}")
106
132
  launch_agent(agent_argv, path)
107
133
 
108
134
 
@@ -118,10 +144,11 @@ def main(argv: list[str] | None = None) -> int:
118
144
  parser.add_argument("--owner", help="GitHub owner (default: the authenticated gh user)")
119
145
  parser.add_argument("-y", "--yes", action="store_true",
120
146
  help="don't prompt when possibly-related repos are found")
147
+ parser.add_argument("-q", "--quiet", action="store_true", help="don't print progress messages")
121
148
  parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
122
149
  args = parser.parse_args(argv)
123
150
  try:
124
- spin_up(args.agent, args.directory, args.name, args.owner, args.yes)
151
+ spin_up(args.agent, args.directory, args.name, args.owner, args.yes, args.quiet)
125
152
  except SpinUpError as exc:
126
153
  print(f"spin-up: {exc}", file=sys.stderr)
127
154
  return 1
@@ -29,6 +29,11 @@ def env(tmp_path, monkeypatch):
29
29
  fake_agent.write_text("#!/bin/sh\n")
30
30
  fake_agent.chmod(fake_agent.stat().st_mode | stat.S_IEXEC)
31
31
 
32
+ herdr = bindir / "herdr"
33
+ herdr.write_text('#!/bin/sh\necho "$@" >> "$FAKE_HERDR_LOG"\n[ -z "$FAKE_HERDR_FAIL" ] || exit 1\n')
34
+ herdr.chmod(herdr.stat().st_mode | stat.S_IEXEC)
35
+ monkeypatch.setenv("FAKE_HERDR_LOG", str(tmp_path / "herdr.log"))
36
+
32
37
  log = tmp_path / "gh.log"
33
38
  repos = tmp_path / "repos.json"
34
39
  repos.write_text("[]")
@@ -42,6 +47,8 @@ def env(tmp_path, monkeypatch):
42
47
  monkeypatch.setenv(f"GIT_AUTHOR_{var}", val)
43
48
  monkeypatch.setenv(f"GIT_COMMITTER_{var}", val)
44
49
  monkeypatch.setattr(config, "CONFIG_PATH", cfg)
50
+ # Tests may themselves run inside herdr: never touch the real workspace.
51
+ monkeypatch.delenv("HERDR_WORKSPACE_ID", raising=False)
45
52
 
46
53
  launched = []
47
54
  monkeypatch.setattr(cli, "launch_agent", lambda argv, cwd: launched.append((argv, cwd)))
@@ -51,6 +58,7 @@ def env(tmp_path, monkeypatch):
51
58
 
52
59
  e = Env()
53
60
  e.tmp, e.log, e.launched = tmp_path, log, launched
61
+ e.herdr_calls = lambda: (tmp_path / "herdr.log").read_text().splitlines() if (tmp_path / "herdr.log").exists() else []
54
62
  e.set_repos = lambda names: repos.write_text(json.dumps([{"name": n} for n in names]))
55
63
  e.gh_calls = lambda: log.read_text().splitlines() if log.exists() else []
56
64
  return e
@@ -172,3 +180,38 @@ def test_owner_is_taken_from_authenticated_user_not_hardcoded(env, monkeypatch):
172
180
  import pathlib, spin_up
173
181
  src = "".join(p.read_text() for p in pathlib.Path(spin_up.__file__).parent.glob("*.py"))
174
182
  assert "lorenzowood" not in src
183
+
184
+
185
+ def test_not_in_herdr_no_rename(env):
186
+ assert cli.main(["fake", str(env.tmp / "thing")]) == 0
187
+ assert env.herdr_calls() == []
188
+
189
+
190
+ def test_herdr_workspace_renamed_to_directory_name(env, monkeypatch):
191
+ monkeypatch.setenv("HERDR_WORKSPACE_ID", "w9")
192
+ assert cli.main(["fake", str(env.tmp / "thing")]) == 0
193
+ assert env.herdr_calls() == ["workspace rename w9 thing"]
194
+
195
+
196
+ def test_herdr_workspace_renamed_to_name_argument_when_given(env, monkeypatch):
197
+ monkeypatch.setenv("HERDR_WORKSPACE_ID", "w9")
198
+ assert cli.main(["fake", str(env.tmp / "thing"), "My Fancy Thing"]) == 0
199
+ assert env.herdr_calls() == ["workspace rename w9 My Fancy Thing"]
200
+
201
+
202
+ def test_herdr_rename_failure_is_only_a_warning(env, monkeypatch, capsys):
203
+ monkeypatch.setenv("HERDR_WORKSPACE_ID", "w9")
204
+ monkeypatch.setenv("FAKE_HERDR_FAIL", "1")
205
+ assert cli.main(["fake", str(env.tmp / "thing")]) == 0
206
+ assert "could not rename herdr workspace" in capsys.readouterr().err
207
+ assert env.launched
208
+
209
+
210
+ def test_progress_messages_by_default_and_quiet_suppresses(env, capsys):
211
+ assert cli.main(["fake", str(env.tmp / "a")]) == 0
212
+ out = capsys.readouterr().out
213
+ for step in ("Checking GitHub authentication", "Looking for related repositories",
214
+ "Creating private GitHub repository lorenzowood/a", "Launching: fakeagent --flag"):
215
+ assert step in out
216
+ assert cli.main(["fake", str(env.tmp / "b"), "--quiet"]) == 0
217
+ assert capsys.readouterr().out == ""
@@ -4,5 +4,5 @@ requires-python = ">=3.10"
4
4
 
5
5
  [[package]]
6
6
  name = "spin-up-dev-project"
7
- version = "0.1.0"
7
+ version = "0.2.0"
8
8
  source = { editable = "." }