spin-up-dev-project 0.1.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.
spin_up/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """spin-up: scaffold a project, create its private GitHub repo, launch an agent."""
2
+
3
+ __version__ = "0.1.0"
spin_up/cli.py ADDED
@@ -0,0 +1,132 @@
1
+ """The ``spin-up`` command."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import json
7
+ import os
8
+ import shutil
9
+ import subprocess
10
+ import sys
11
+ from pathlib import Path
12
+
13
+ from . import __version__
14
+ from .config import SpinUpError, load_agents
15
+ from .related import find_related
16
+
17
+
18
+ def run(cmd: list[str], cwd: Path | None = None) -> str:
19
+ """Run a command, returning stdout; raise SpinUpError with stderr on failure."""
20
+ try:
21
+ proc = subprocess.run(cmd, cwd=cwd, capture_output=True, text=True)
22
+ except FileNotFoundError:
23
+ raise SpinUpError(f"{cmd[0]!r} not found on PATH") from None
24
+ if proc.returncode != 0:
25
+ detail = (proc.stderr or proc.stdout).strip()
26
+ raise SpinUpError(f"{' '.join(cmd)} failed:\n{detail}")
27
+ return proc.stdout
28
+
29
+
30
+ def check_gh_auth() -> None:
31
+ try:
32
+ run(["gh", "auth", "status"])
33
+ except SpinUpError:
34
+ raise SpinUpError("gh is not authenticated; run `gh auth login` first") from None
35
+
36
+
37
+ def github_user() -> str:
38
+ return run(["gh", "api", "user", "--jq", ".login"]).strip()
39
+
40
+
41
+ def list_repo_names(owner: str) -> list[str]:
42
+ out = run(["gh", "repo", "list", owner, "--limit", "1000", "--json", "name"])
43
+ return [r["name"] for r in json.loads(out or "[]")]
44
+
45
+
46
+ def confirm(question: str) -> bool:
47
+ try:
48
+ return input(question + " [y/N] ").strip().lower() in ("y", "yes")
49
+ except EOFError:
50
+ return False
51
+
52
+
53
+ def launch_agent(argv: list[str], cwd: Path) -> None:
54
+ """Replace this process with the agent, running in the new project directory."""
55
+ os.chdir(cwd)
56
+ os.execvp(argv[0], argv)
57
+
58
+
59
+ def spin_up(
60
+ agent: str,
61
+ directory: str,
62
+ title: str | None = None,
63
+ owner: str | None = None,
64
+ assume_yes: bool = False,
65
+ ) -> None:
66
+ agents = load_agents()
67
+ if agent not in agents:
68
+ known = ", ".join(sorted(agents)) or "none"
69
+ raise SpinUpError(f"unknown agent {agent!r} (configured: {known})")
70
+ agent_argv = agents[agent]
71
+ if shutil.which(agent_argv[0]) is None:
72
+ raise SpinUpError(f"agent command {agent_argv[0]!r} not found on PATH")
73
+
74
+ path = Path(directory).expanduser()
75
+ if path.exists():
76
+ raise SpinUpError(f"{path} already exists")
77
+ name = path.name
78
+ if not name:
79
+ raise SpinUpError(f"cannot derive a repository name from {directory!r}")
80
+ for tool in ("git", "gh"):
81
+ if shutil.which(tool) is None:
82
+ raise SpinUpError(f"{tool!r} not found on PATH")
83
+
84
+ check_gh_auth()
85
+ owner = owner or github_user()
86
+ related = find_related(name, list_repo_names(owner))
87
+ if related:
88
+ print("The following may be related:")
89
+ for repo in related:
90
+ print(f" {owner}/{repo}")
91
+ if not assume_yes and not confirm(f"Continue with spin-up of {directory}?"):
92
+ print("Aborted.")
93
+ raise SystemExit(1)
94
+
95
+ path.mkdir(parents=True)
96
+ (path / "README.md").write_text(f"# {title or name}\n\nPlaceholder.\n")
97
+ run(["git", "init", "-b", "main"], cwd=path)
98
+ run(["git", "add", "README.md"], cwd=path)
99
+ run(["git", "commit", "-m", "Add placeholder README"], cwd=path)
100
+ run(
101
+ ["gh", "repo", "create", f"{owner}/{name}", "--private",
102
+ "--source=.", "--remote=origin", "--push"],
103
+ cwd=path,
104
+ )
105
+ print(f"Created https://github.com/{owner}/{name} (private)")
106
+ launch_agent(agent_argv, path)
107
+
108
+
109
+ def main(argv: list[str] | None = None) -> int:
110
+ parser = argparse.ArgumentParser(
111
+ prog="spin-up",
112
+ description="Create a directory, placeholder README, git repo and private "
113
+ "GitHub repo, then launch a coding agent in it.",
114
+ )
115
+ parser.add_argument("agent", help="agent key from ~/.config/spin-up")
116
+ parser.add_argument("directory", help="new directory to create (must not exist)")
117
+ parser.add_argument("name", nargs="?", help="title for the README's H1 (default: directory name)")
118
+ parser.add_argument("--owner", help="GitHub owner (default: the authenticated gh user)")
119
+ parser.add_argument("-y", "--yes", action="store_true",
120
+ help="don't prompt when possibly-related repos are found")
121
+ parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
122
+ args = parser.parse_args(argv)
123
+ try:
124
+ spin_up(args.agent, args.directory, args.name, args.owner, args.yes)
125
+ except SpinUpError as exc:
126
+ print(f"spin-up: {exc}", file=sys.stderr)
127
+ return 1
128
+ return 0
129
+
130
+
131
+ if __name__ == "__main__":
132
+ sys.exit(main())
spin_up/config.py ADDED
@@ -0,0 +1,50 @@
1
+ """Agent configuration: ``~/.config/spin-up`` maps agent keys to commands.
2
+
3
+ Format, one agent per line (blank lines and ``#`` comments are ignored)::
4
+
5
+ claude: claude --dangerously-skip-permissions
6
+ cursor: cursor-agent
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import shlex
12
+ from pathlib import Path
13
+
14
+ CONFIG_PATH = Path("~/.config/spin-up").expanduser()
15
+
16
+
17
+ class SpinUpError(Exception):
18
+ """A user-facing error: printed without a traceback."""
19
+
20
+
21
+ def parse_config(text: str) -> dict[str, list[str]]:
22
+ """Parse config text into ``{agent: argv}``."""
23
+ agents: dict[str, list[str]] = {}
24
+ for lineno, raw in enumerate(text.splitlines(), start=1):
25
+ line = raw.strip()
26
+ if not line or line.startswith("#"):
27
+ continue
28
+ key, sep, command = line.partition(":")
29
+ key, command = key.strip(), command.strip()
30
+ if not sep or not key or not command:
31
+ raise SpinUpError(f"config line {lineno}: expected 'agent: command', got {raw!r}")
32
+ try:
33
+ argv = shlex.split(command)
34
+ except ValueError as exc:
35
+ raise SpinUpError(f"config line {lineno}: {exc}") from exc
36
+ agents[key] = argv
37
+ return agents
38
+
39
+
40
+ def load_agents(path: Path | None = None) -> dict[str, list[str]]:
41
+ path = path or CONFIG_PATH
42
+ try:
43
+ text = path.read_text()
44
+ except FileNotFoundError:
45
+ raise SpinUpError(
46
+ f"no config file at {path}. Create it with lines like:\n"
47
+ " claude: claude --dangerously-skip-permissions\n"
48
+ " cursor: cursor-agent"
49
+ ) from None
50
+ return parse_config(text)
spin_up/related.py ADDED
@@ -0,0 +1,54 @@
1
+ """Find existing repos whose names look related to a new project's name."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+
7
+ STOP_WORDS = frozenset(
8
+ """a an the and or but of for to in on at by with from into over as is it
9
+ my your our their this that""".split()
10
+ )
11
+
12
+ _IRREGULAR = {
13
+ "people": "person",
14
+ "children": "child",
15
+ "men": "man",
16
+ "women": "woman",
17
+ "mice": "mouse",
18
+ "indices": "index",
19
+ "analyses": "analysis",
20
+ }
21
+
22
+
23
+ def singularize(word: str) -> str:
24
+ """Rule-based English singularisation (good enough for matching names)."""
25
+ w = word.lower()
26
+ if w in _IRREGULAR:
27
+ return _IRREGULAR[w]
28
+ if len(w) <= 3 or w.endswith(("ss", "us", "is")):
29
+ return w
30
+ if w.endswith("ies") and len(w) > 4:
31
+ return w[:-3] + "y"
32
+ if w.endswith(("sses", "xes", "ches", "shes", "zes")):
33
+ return w[:-2]
34
+ if w.endswith("s"):
35
+ return w[:-1]
36
+ return w
37
+
38
+
39
+ def keywords(name: str) -> set[str]:
40
+ """Split a hyphen/underscore/space separated name into singular, non-stop words."""
41
+ words = (w for w in re.split(r"[-_.\s]+", name.lower()) if w)
42
+ return {singularize(w) for w in words if w not in STOP_WORDS}
43
+
44
+
45
+ def find_related(name: str, repo_names: list[str]) -> list[str]:
46
+ """Repos sharing at least one keyword with ``name`` (excluding an exact match)."""
47
+ wanted = keywords(name)
48
+ if not wanted:
49
+ return []
50
+ return [
51
+ repo
52
+ for repo in repo_names
53
+ if repo.lower() != name.lower() and wanted & keywords(repo)
54
+ ]
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.5
2
+ Name: spin-up-dev-project
3
+ Version: 0.1.0
4
+ Summary: Spin up a new project: directory, README, git repo, private GitHub repo, then launch your coding agent.
5
+ Project-URL: Homepage, https://github.com/lorenzowood/spin-up
6
+ Project-URL: Issues, https://github.com/lorenzowood/spin-up/issues
7
+ Author: Lorenzo Wood
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: cli,coding-agent,git,github,scaffold
11
+ Classifier: Environment :: Console
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Software Development :: Version Control :: Git
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+
17
+ # spin-up
18
+
19
+ Start a new project in one command: create the directory, drop in a placeholder
20
+ `README.md`, `git init`, commit, create a **private** GitHub repo, push, and then
21
+ launch your coding agent inside it.
22
+
23
+ ```console
24
+ $ spin-up claude ~/Projects/local-ai-library
25
+ Created https://github.com/you/local-ai-library (private)
26
+ # ...and Claude Code starts in ~/Projects/local-ai-library
27
+ ```
28
+
29
+ ## Requirements
30
+
31
+ - Python 3.10+
32
+ - [`git`](https://git-scm.com/)
33
+ - the [GitHub CLI](https://cli.github.com/) (`gh`), authenticated (`gh auth login`).
34
+ spin-up checks this on every run, and creates repos under the account `gh` is
35
+ logged in as, so there is no owner to configure
36
+ - whichever coding agent(s) you want to launch
37
+
38
+ ## Install
39
+
40
+ The PyPI package is `spin-up-dev-project`; the command it installs is `spin-up`.
41
+
42
+ ```console
43
+ uv tool install spin-up-dev-project # or: pipx install spin-up-dev-project
44
+ ```
45
+
46
+ ## Configure agents
47
+
48
+ Create `~/.config/spin-up` mapping a key to the command that starts your agent,
49
+ one per line (blank lines and `#` comments are ignored):
50
+
51
+ ```
52
+ claude: claude --dangerously-skip-permissions
53
+ cursor: cursor-agent
54
+ ```
55
+
56
+ ## Usage
57
+
58
+ ```
59
+ spin-up [-y] [--owner OWNER] <agent> <directory> [<name>]
60
+ ```
61
+
62
+ | Argument | Meaning |
63
+ | --- | --- |
64
+ | `agent` | A key from `~/.config/spin-up`. |
65
+ | `directory` | The directory to create. It **must not already exist**. Its basename is the repo name. |
66
+ | `name` | Optional title for the README's `# H1`. Defaults to the directory name. |
67
+ | `--owner` | GitHub owner for the new repo. Defaults to the user `gh` is logged in as. |
68
+ | `-y`, `--yes` | Don't ask for confirmation when possibly-related repos are found. |
69
+
70
+ What it does, in order:
71
+
72
+ 1. Checks the agent is configured and its command is on `PATH`, that the
73
+ directory doesn't exist, and that `gh` is authenticated. Nothing is created if any check fails.
74
+ 2. Lists your GitHub repos and looks for ones that might be related (see below).
75
+ If any are found it prints them and asks `Continue with spin-up of <directory>?`.
76
+ 3. Creates the directory and `README.md`, runs `git init -b main`, and commits.
77
+ 4. Creates the **private** repo `<owner>/<directory-name>` and pushes.
78
+ 5. Replaces itself with the agent command, running in the new directory.
79
+
80
+ ### Related-repo check
81
+
82
+ To avoid starting a project you already have, the directory name is split on
83
+ `-`, `_`, `.` and spaces; words are lower-cased and singularised
84
+ (`libraries` → `library`); common stop words (`the`, `a`, `of`, `and`, …) are
85
+ dropped. Any existing repo whose name shares at least one remaining word is
86
+ listed as possibly related. Only repo *names* are compared, and singularisation
87
+ is a small rule-based English heuristic rather than a full dictionary.
88
+
89
+ ## Development
90
+
91
+ ```console
92
+ uv run --with pytest --with-editable . pytest
93
+ ```
94
+
95
+ The tests use real `git` and a fake `gh` on `PATH`, so they never touch GitHub.
96
+
97
+ ## Licence
98
+
99
+ MIT
@@ -0,0 +1,9 @@
1
+ spin_up/__init__.py,sha256=5CynZ_fecAecpbECHg9vmE2THqnI_08F32EAXskCLdE,107
2
+ spin_up/cli.py,sha256=MvRecr7fHvXj7yJ2updxOrExVoMlQZ8EZ-dt_6oDjbU,4500
3
+ spin_up/config.py,sha256=l1iK5qqX3jZG0oDx8arf4LXa5lnTevp-f1iR-2swWKw,1614
4
+ spin_up/related.py,sha256=OOw4O5CUAJZjGceEQ-ckDqv33JhIG3jmosT1GYuO_t4,1530
5
+ spin_up_dev_project-0.1.0.dist-info/METADATA,sha256=qsf7amKzPzHp0oy2Z0YC7mKPf8pWuMYljSBFKl-nvW4,3541
6
+ spin_up_dev_project-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
7
+ spin_up_dev_project-0.1.0.dist-info/entry_points.txt,sha256=hceQp1ma1ClxMS6O7uyPVEWZ5hRJcInVmxR6Twk3_AQ,45
8
+ spin_up_dev_project-0.1.0.dist-info/licenses/LICENSE,sha256=OdCXbARczOFlDfOieHpc2HyGJowzn4Nn-4trki-F1QE,1069
9
+ spin_up_dev_project-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ spin-up = spin_up.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lorenzo Wood
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.