packleader 0.0.1__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 (35) hide show
  1. packleader-0.0.1/LICENSE +21 -0
  2. packleader-0.0.1/PKG-INFO +16 -0
  3. packleader-0.0.1/README.md +6 -0
  4. packleader-0.0.1/packleader/__init__.py +3 -0
  5. packleader-0.0.1/packleader/__main__.py +8 -0
  6. packleader-0.0.1/packleader/_jobrun.py +49 -0
  7. packleader-0.0.1/packleader/banner.py +127 -0
  8. packleader-0.0.1/packleader/cli.py +172 -0
  9. packleader-0.0.1/packleader/config.py +291 -0
  10. packleader-0.0.1/packleader/install_check.py +81 -0
  11. packleader-0.0.1/packleader/jobs.py +445 -0
  12. packleader-0.0.1/packleader/locks.py +230 -0
  13. packleader-0.0.1/packleader/product.py +134 -0
  14. packleader-0.0.1/packleader/runners/__init__.py +0 -0
  15. packleader-0.0.1/packleader/runners/base.py +27 -0
  16. packleader-0.0.1/packleader/runners/local.py +134 -0
  17. packleader-0.0.1/packleader.egg-info/PKG-INFO +16 -0
  18. packleader-0.0.1/packleader.egg-info/SOURCES.txt +33 -0
  19. packleader-0.0.1/packleader.egg-info/dependency_links.txt +1 -0
  20. packleader-0.0.1/packleader.egg-info/entry_points.txt +3 -0
  21. packleader-0.0.1/packleader.egg-info/top_level.txt +1 -0
  22. packleader-0.0.1/pyproject.toml +20 -0
  23. packleader-0.0.1/setup.cfg +4 -0
  24. packleader-0.0.1/tests/test_banner.py +59 -0
  25. packleader-0.0.1/tests/test_cli.py +227 -0
  26. packleader-0.0.1/tests/test_config.py +204 -0
  27. packleader-0.0.1/tests/test_install_check.py +140 -0
  28. packleader-0.0.1/tests/test_jobs.py +327 -0
  29. packleader-0.0.1/tests/test_locks.py +186 -0
  30. packleader-0.0.1/tests/test_privacy.py +459 -0
  31. packleader-0.0.1/tests/test_product.py +95 -0
  32. packleader-0.0.1/tests/test_release_workflow.py +43 -0
  33. packleader-0.0.1/tests/test_runner_local.py +129 -0
  34. packleader-0.0.1/tests/test_scripts.py +159 -0
  35. packleader-0.0.1/tests/test_watch.py +271 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mohammedsaif Kordia
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.
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: packleader
3
+ Version: 0.0.1
4
+ Summary: Packleader: a delivery pipeline for Claude Code
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.12
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Dynamic: license-file
10
+
11
+ # Packleader
12
+
13
+ A delivery pipeline for Claude Code: an Opus brain plans and verifies, a judge scores every plan and brief,
14
+ the AI agent you choose implements, gates prove it, and every outward step waits for you.
15
+
16
+ **Status: pre-alpha, under construction.**
@@ -0,0 +1,6 @@
1
+ # Packleader
2
+
3
+ A delivery pipeline for Claude Code: an Opus brain plans and verifies, a judge scores every plan and brief,
4
+ the AI agent you choose implements, gates prove it, and every outward step waits for you.
5
+
6
+ **Status: pre-alpha, under construction.**
@@ -0,0 +1,3 @@
1
+ """Packleader: a delivery pipeline for Claude Code."""
2
+
3
+ __version__ = "0.0.1"
@@ -0,0 +1,8 @@
1
+ """Run Packleader with ``python -m packleader``."""
2
+
3
+ import sys
4
+
5
+ from .cli import main
6
+
7
+ if __name__ == "__main__":
8
+ sys.exit(main())
@@ -0,0 +1,49 @@
1
+ """Runner entry point for a detached job (B2)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import os
7
+ import subprocess
8
+ import sys
9
+ from pathlib import Path
10
+
11
+
12
+ def main(argv=None) -> int:
13
+ if argv is None:
14
+ argv = sys.argv[1:]
15
+ jobs_dir = Path(argv[0])
16
+ job_id = argv[1]
17
+ with open(jobs_dir / (job_id + ".json"), encoding="utf-8") as handle:
18
+ data = json.load(handle)
19
+ command = data["argv"]
20
+ cwd = data.get("cwd")
21
+ out_path = jobs_dir / (job_id + ".out")
22
+ rc = 0
23
+ with open(out_path, "ab") as out:
24
+ run_kwargs: dict = {
25
+ "cwd": cwd,
26
+ "stdin": subprocess.DEVNULL,
27
+ "stdout": out,
28
+ "stderr": subprocess.STDOUT,
29
+ }
30
+ if os.name == "nt":
31
+ run_kwargs["creationflags"] = getattr(
32
+ subprocess, "CREATE_NO_WINDOW", 0
33
+ )
34
+ try:
35
+ proc = subprocess.run(command, **run_kwargs)
36
+ except OSError as exc:
37
+ out.write(("cannot run: %s\n" % type(exc).__name__).encode("utf-8"))
38
+ rc = 127
39
+ else:
40
+ rc = proc.returncode
41
+ with open(jobs_dir / (job_id + ".rc"), "w", encoding="utf-8") as handle:
42
+ handle.write("%d\n" % rc)
43
+ with open(jobs_dir / (job_id + ".done"), "w", encoding="utf-8") as handle:
44
+ handle.write("done\n")
45
+ return 0
46
+
47
+
48
+ if __name__ == "__main__":
49
+ sys.exit(main())
@@ -0,0 +1,127 @@
1
+ """The welcome banner and terminal colour helpers for ``pl``.
2
+
3
+ Colour is used only on an interactive terminal that is not asked to stay
4
+ plain (``NO_COLOR``, ``TERM=dumb``). Block glyphs fall back to ``#`` when
5
+ the output encoding cannot carry them (a pipe on an old Windows code page).
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import os
11
+ import sys
12
+
13
+ from . import __version__
14
+
15
+ # 5 x 5 letters; "#" is a filled cell.
16
+ _LETTERS = {
17
+ "P": ["#### ", "# #", "#### ", "# ", "# "],
18
+ "A": [" ### ", "# #", "#####", "# #", "# #"],
19
+ "C": [" ####", "# ", "# ", "# ", " ####"],
20
+ "K": ["# #", "# # ", "### ", "# # ", "# #"],
21
+ "L": ["# ", "# ", "# ", "# ", "#####"],
22
+ "E": ["#####", "# ", "#### ", "# ", "#####"],
23
+ "D": ["#### ", "# #", "# #", "# #", "#### "],
24
+ "R": ["#### ", "# #", "#### ", "# # ", "# #"],
25
+ }
26
+
27
+ WORD = "PACKLEADER"
28
+
29
+ # One 256-colour code per letter: amber to purple.
30
+ _GRADIENT = [214, 208, 202, 196, 197, 198, 199, 163, 127, 91]
31
+
32
+ TAGLINE = "plan. judge. build. prove."
33
+
34
+
35
+ def _enable_windows_vt(stream):
36
+ """Turn on ANSI escape handling for a Windows console. True when on."""
37
+ if os.name != "nt":
38
+ return True
39
+ try:
40
+ import ctypes
41
+ import msvcrt
42
+
43
+ kernel32 = ctypes.windll.kernel32
44
+ handle = msvcrt.get_osfhandle(stream.fileno())
45
+ mode = ctypes.c_uint32()
46
+ if not kernel32.GetConsoleMode(handle, ctypes.byref(mode)):
47
+ return False
48
+ enable_vt = 0x0004
49
+ if mode.value & enable_vt:
50
+ return True
51
+ return bool(kernel32.SetConsoleMode(handle, mode.value | enable_vt))
52
+ except Exception:
53
+ return False
54
+
55
+
56
+ def use_colour(stream=None):
57
+ """True when ``stream`` is a terminal that should get colour."""
58
+ stream = stream or sys.stdout
59
+ if os.environ.get("NO_COLOR"):
60
+ return False
61
+ if os.environ.get("TERM") == "dumb":
62
+ return False
63
+ try:
64
+ if not stream.isatty():
65
+ return False
66
+ except Exception:
67
+ return False
68
+ return _enable_windows_vt(stream)
69
+
70
+
71
+ def can_encode(text, stream=None):
72
+ stream = stream or sys.stdout
73
+ encoding = getattr(stream, "encoding", None) or "ascii"
74
+ try:
75
+ text.encode(encoding)
76
+ except (UnicodeEncodeError, LookupError):
77
+ return False
78
+ return True
79
+
80
+
81
+ def paint(text, code, colour):
82
+ """Wrap ``text`` in a 256-colour escape when ``colour`` is on."""
83
+ if not colour:
84
+ return text
85
+ return "\033[1;38;5;%dm%s\033[0m" % (code, text)
86
+
87
+
88
+ def dim(text, colour):
89
+ return "\033[2m%s\033[0m" % text if colour else text
90
+
91
+
92
+ #: Columns the double-width banner needs (10 letters of 10, gaps, margin).
93
+ WIDE_COLUMNS = 2 + len(WORD) * 10 + (len(WORD) - 1) + 2
94
+
95
+
96
+ def render(colour=False, block=True, wide=False):
97
+ """Return the banner text; ``wide`` draws every cell two columns wide."""
98
+ fill = "█" if block else "#"
99
+ scale = 2 if wide else 1
100
+ rows = []
101
+ for row in range(5):
102
+ cells = []
103
+ for index, letter in enumerate(WORD):
104
+ pattern = "".join(
105
+ (fill if cell == "#" else " ") * scale
106
+ for cell in _LETTERS[letter][row])
107
+ cells.append(paint(pattern, _GRADIENT[index], colour))
108
+ rows.append(" " + " ".join(cells).rstrip())
109
+ rows.append("")
110
+ rows.append(" " + dim("v%s %s" % (__version__, TAGLINE), colour))
111
+ return "\n".join(rows) + "\n"
112
+
113
+
114
+ def show(stream=None):
115
+ """Print the banner to ``stream`` (default stdout)."""
116
+ stream = stream or sys.stdout
117
+ colour = use_colour(stream)
118
+ block = can_encode("█", stream)
119
+ wide = colour and _columns() >= WIDE_COLUMNS
120
+ stream.write("\n" + render(colour=colour, block=block, wide=wide) + "\n")
121
+ stream.flush()
122
+
123
+
124
+ def _columns():
125
+ import shutil
126
+
127
+ return shutil.get_terminal_size((80, 24)).columns
@@ -0,0 +1,172 @@
1
+ """Command line interface for Packleader."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import sys
7
+
8
+ from . import __version__, banner, config, install_check
9
+ from . import jobs
10
+ from .product import Product
11
+
12
+
13
+ def _build_parser() -> argparse.ArgumentParser:
14
+ parser = argparse.ArgumentParser(
15
+ prog="pl",
16
+ description="Packleader: a delivery pipeline for Claude Code",
17
+ )
18
+ parser.add_argument(
19
+ "--version",
20
+ action="version",
21
+ version="packleader " + __version__,
22
+ )
23
+ sub = parser.add_subparsers(dest="command")
24
+ config_parser = sub.add_parser("config", help="inspect the pack configuration")
25
+ config_sub = config_parser.add_subparsers(dest="config_command")
26
+ config_sub.required = True
27
+ check_parser = config_sub.add_parser("check", help="validate product.toml")
28
+ check_parser.add_argument(
29
+ "--root",
30
+ default=".",
31
+ help="project root holding .packleader/product.toml",
32
+ )
33
+ job_parser = sub.add_parser("job", help="manage background jobs")
34
+ job_sub = job_parser.add_subparsers(dest="job_command")
35
+ job_sub.required = True
36
+ job_start = job_sub.add_parser("start", help="start a background job")
37
+ job_start.add_argument("--root", default=".", help="project root")
38
+ job_start.add_argument("--cwd", default=None, help="working directory")
39
+ job_start.add_argument("--tag", default="job", help="job tag")
40
+ job_start.add_argument(
41
+ "cmd", nargs=argparse.REMAINDER, default=[], help="command to run"
42
+ )
43
+ job_state = job_sub.add_parser("state", help="show job state")
44
+ job_state.add_argument("job_id", help="job id")
45
+ job_state.add_argument("--root", default=".", help="project root")
46
+ job_stop = job_sub.add_parser("stop", help="stop a running job")
47
+ job_stop.add_argument("job_id", help="job id")
48
+ job_stop.add_argument("--root", default=".", help="project root")
49
+ watch_parser = sub.add_parser("watch", help="watch a job until it ends")
50
+ watch_parser.add_argument("job_id", help="job id")
51
+ watch_parser.add_argument("--root", default=".", help="project root")
52
+ watch_parser.add_argument("--report", default=None, help="report file")
53
+ watch_parser.add_argument(
54
+ "--poll", type=float, default=60.0, help="poll interval in seconds"
55
+ )
56
+ watch_parser.add_argument(
57
+ "--silent-min",
58
+ type=float,
59
+ default=12.0,
60
+ help="minutes without change before SILENT",
61
+ )
62
+ watch_parser.add_argument(
63
+ "--activity",
64
+ action="append",
65
+ default=[],
66
+ dest="activity",
67
+ help="activity glob relative to root",
68
+ )
69
+ wait_parser = sub.add_parser("wait", help="wait for a job to finish")
70
+ wait_parser.add_argument("job_id", help="job id")
71
+ wait_parser.add_argument("--root", default=".", help="project root")
72
+ wait_parser.add_argument(
73
+ "--poll", type=float, default=60.0, help="poll interval in seconds"
74
+ )
75
+ return parser
76
+
77
+
78
+ def main(argv=None) -> int:
79
+ """Run the CLI; return the process exit code."""
80
+ parser = _build_parser()
81
+ args = parser.parse_args(argv)
82
+ if args.command is None:
83
+ banner.show(sys.stdout)
84
+ parser.print_help(sys.stdout)
85
+ return 0
86
+ if args.command == "config" and args.config_command == "check":
87
+ loaded = config.load(args.root)
88
+ version = loaded.data.get("version")
89
+ if isinstance(version, str):
90
+ for warning in install_check.warnings(version):
91
+ print("packleader: warning: %s" % warning, file=sys.stderr)
92
+ for warning in loaded.warnings:
93
+ print("packleader: warning: %s" % warning, file=sys.stderr)
94
+ if loaded.errors:
95
+ for error in loaded.errors:
96
+ print("packleader: error: %s" % error, file=sys.stderr)
97
+ return 1
98
+ product = Product.from_config(loaded.data)
99
+ print(
100
+ "ok: product %s, %d member(s), %d host(s)"
101
+ % (product.name, len(product.members), len(product.hosts))
102
+ )
103
+ return 0
104
+ if args.command == "job":
105
+ try:
106
+ if args.job_command == "start":
107
+ cmd = list(args.cmd)
108
+ if cmd[:1] == ["--"]:
109
+ cmd = cmd[1:]
110
+ if not cmd:
111
+ parser.error("CMD is required")
112
+ job_id = jobs.start(
113
+ args.root, cmd, cwd=args.cwd, tag=args.tag
114
+ )
115
+ print("job=%s" % job_id)
116
+ return 0
117
+ if args.job_command == "state":
118
+ current = jobs.state(args.root, args.job_id)
119
+ line = "%s rc=%s" % (
120
+ current.name,
121
+ current.rc if current.rc is not None else "-",
122
+ )
123
+ if current.detail:
124
+ line += " %s" % current.detail
125
+ print(line)
126
+ return 0
127
+ if args.job_command == "stop":
128
+ print(
129
+ "stopped"
130
+ if jobs.stop(args.root, args.job_id)
131
+ else "not running"
132
+ )
133
+ return 0
134
+ except jobs.JobError as exc:
135
+ print("packleader: error: %s" % exc, file=sys.stderr)
136
+ return 2
137
+ if args.command == "watch":
138
+ try:
139
+ last = None
140
+ for event in jobs.watch(
141
+ args.root,
142
+ args.job_id,
143
+ report=args.report,
144
+ poll_s=args.poll,
145
+ silent_min=args.silent_min,
146
+ activity=tuple(args.activity or ()),
147
+ ):
148
+ print(event.line, flush=True)
149
+ last = event
150
+ if last is None:
151
+ return 0
152
+ return jobs.EXIT_CODES[last.kind]
153
+ except jobs.JobError as exc:
154
+ print("packleader: error: %s" % exc, file=sys.stderr)
155
+ return 2
156
+ if args.command == "wait":
157
+ try:
158
+ last = None
159
+ for event in jobs.watch(
160
+ args.root, args.job_id, poll_s=args.poll,
161
+ silent_min=float("inf"),
162
+ ):
163
+ last = event
164
+ if last is None:
165
+ return 0
166
+ print(last.line, flush=True)
167
+ return jobs.EXIT_CODES[last.kind]
168
+ except jobs.JobError as exc:
169
+ print("packleader: error: %s" % exc, file=sys.stderr)
170
+ return 2
171
+ parser.print_help(sys.stdout)
172
+ return 0