ccgarden 0.1.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.
@@ -0,0 +1,38 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v7
13
+
14
+ - name: Install uv
15
+ uses: astral-sh/setup-uv@v9.0.0
16
+
17
+ - name: Build
18
+ run: uv build
19
+
20
+ - uses: actions/upload-artifact@v4
21
+ with:
22
+ name: dist
23
+ path: dist/
24
+
25
+ publish:
26
+ needs: build
27
+ runs-on: ubuntu-latest
28
+ environment: pypi
29
+ permissions:
30
+ id-token: write
31
+ steps:
32
+ - uses: actions/download-artifact@v4
33
+ with:
34
+ name: dist
35
+ path: dist/
36
+
37
+ - name: Publish to PyPI
38
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,10 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
@@ -0,0 +1,25 @@
1
+ repos:
2
+ # ruff and pytest live in git-a-grip so every repo shares one copy, rather
3
+ # than each keeping its own `bash -c '... && git add "$@"'` wrapper.
4
+ - repo: https://github.com/dannybrown37/git-a-grip
5
+ rev: v0.2.0
6
+ hooks:
7
+ - id: ruff-check
8
+ - id: ruff-format
9
+ - id: pytest
10
+ args: [-q]
11
+
12
+ - repo: https://github.com/pre-commit/pre-commit-hooks
13
+ rev: v4.6.0
14
+ hooks:
15
+ - id: end-of-file-fixer
16
+ - id: trailing-whitespace
17
+ - id: check-merge-conflict
18
+ - id: check-toml
19
+ - id: check-yaml
20
+ - id: check-added-large-files
21
+
22
+ - repo: https://github.com/gitleaks/gitleaks
23
+ rev: v8.30.1
24
+ hooks:
25
+ - id: gitleaks
@@ -0,0 +1 @@
1
+ 3.12
ccgarden-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Danny Brown
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,107 @@
1
+ Metadata-Version: 2.4
2
+ Name: ccgarden
3
+ Version: 0.1.0
4
+ Summary: Grow a tree/garden visualization from ccstats.db session history
5
+ Project-URL: Homepage, https://github.com/dannybrown37/ccgarden
6
+ Project-URL: Repository, https://github.com/dannybrown37/ccgarden
7
+ Project-URL: Issues, https://github.com/dannybrown37/ccgarden/issues
8
+ Author-email: Danny Brown <dannybrown37@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: claude,claude-code,stats,svg,visualization
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Utilities
18
+ Requires-Python: >=3.12
19
+ Description-Content-Type: text/markdown
20
+
21
+ # ccgarden
22
+
23
+ Grow a garden from your local Claude Code session history.
24
+
25
+ `ccgarden` reads the JSONL transcripts under `~/.claude/projects`, rolls
26
+ them up into a small sqlite history db, and renders the result as an SVG
27
+ tree: one growing organism that represents everything you've built with
28
+ Claude Code on this machine.
29
+
30
+ ![Example garden, rendered from synthetic sample data](docs/images/garden-example.png)
31
+
32
+ *(This is a dummied-up example with a few months of synthetic data across
33
+ five repos, several models, and a handful of tools — enough to show every
34
+ shape the renderer draws. Your own garden will look sparser at first and
35
+ fill in as you work.)*
36
+
37
+ ## What each shape means
38
+
39
+ | Shape | Grows with |
40
+ |---|---|
41
+ | **Trunk** | Total sessions, across all repos |
42
+ | **Rings** | One per day worked; bolder rings mean busier days |
43
+ | **Branches** | One per repo — longer branches mean more lines changed, thicker branches mean more tokens |
44
+ | **Leaves** | One per session; more leaves means a busier repo, bigger leaves mean deeper (more turns/session) sessions |
45
+ | **Flowers** | One per whole ratio of cache reads to cache writes |
46
+ | **Clouds** | One per model + reasoning-effort combination used; bigger and darker clouds mean more tokens and heavier thinking |
47
+ | **Sun** | Rises and brightens with your all-in token total (output + input + cache read + cache write) |
48
+ | **Bushes** | One per tool (Bash, Edit, Read, ...); bigger bushes mean more calls |
49
+ | **Sunflowers** | One per repo; taller stalks mean more prompts |
50
+ | **Birds** | One per `cartoon` adapter that saved tokens; bigger birds mean more tokens saved. Only appears if `cartoon` is installed |
51
+
52
+ Hover (or tap, on mobile) any shape for the exact numbers behind it.
53
+
54
+ ## Install
55
+
56
+ ```sh
57
+ uv tool install ccgarden
58
+ ```
59
+
60
+ (or `pipx install ccgarden`). This installs two commands: `ccgarden` and
61
+ `ccstats`.
62
+
63
+ To hack on it instead, clone the repo and run `uv sync`, which puts the
64
+ same two commands in the project's virtualenv.
65
+
66
+ ## Usage
67
+
68
+ ```sh
69
+ uv run ccgarden
70
+ ```
71
+
72
+ This will:
73
+
74
+ 1. Scan `~/.claude/projects` and record today's snapshot into
75
+ `~/.claude/ccstats.db` (same as running `ccstats` — see below).
76
+ 2. Replay the full day-by-day history from that db into an animated
77
+ SVG timelapse of the garden growing.
78
+ 3. Write it to `~/.claude/ccgarden.svg` and open it in your browser
79
+ (add `--no-open` to skip that last step).
80
+
81
+ Run it again any day and the garden picks up where it left off — new
82
+ rings, longer branches, bigger clouds, more leaves.
83
+
84
+ ### `ccstats`
85
+
86
+ The underlying stats engine can also be run on its own, for a
87
+ terminal-native usage report instead of (or before) rendering a garden:
88
+
89
+ ```sh
90
+ uv run ccstats # summarize all local session logs
91
+ uv run ccstats --since 2026-06-01 # limit the window
92
+ uv run ccstats --json # machine-readable output
93
+ uv run ccstats --record --since 2026-01-01 --until 2026-07-01 # backfill history
94
+ ```
95
+
96
+ Run `uv run ccstats --help` for the full list of flags.
97
+
98
+ ## Development
99
+
100
+ ```sh
101
+ uv run pytest
102
+ uv run ruff check .
103
+ ```
104
+
105
+ ## License
106
+
107
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,87 @@
1
+ # ccgarden
2
+
3
+ Grow a garden from your local Claude Code session history.
4
+
5
+ `ccgarden` reads the JSONL transcripts under `~/.claude/projects`, rolls
6
+ them up into a small sqlite history db, and renders the result as an SVG
7
+ tree: one growing organism that represents everything you've built with
8
+ Claude Code on this machine.
9
+
10
+ ![Example garden, rendered from synthetic sample data](docs/images/garden-example.png)
11
+
12
+ *(This is a dummied-up example with a few months of synthetic data across
13
+ five repos, several models, and a handful of tools — enough to show every
14
+ shape the renderer draws. Your own garden will look sparser at first and
15
+ fill in as you work.)*
16
+
17
+ ## What each shape means
18
+
19
+ | Shape | Grows with |
20
+ |---|---|
21
+ | **Trunk** | Total sessions, across all repos |
22
+ | **Rings** | One per day worked; bolder rings mean busier days |
23
+ | **Branches** | One per repo — longer branches mean more lines changed, thicker branches mean more tokens |
24
+ | **Leaves** | One per session; more leaves means a busier repo, bigger leaves mean deeper (more turns/session) sessions |
25
+ | **Flowers** | One per whole ratio of cache reads to cache writes |
26
+ | **Clouds** | One per model + reasoning-effort combination used; bigger and darker clouds mean more tokens and heavier thinking |
27
+ | **Sun** | Rises and brightens with your all-in token total (output + input + cache read + cache write) |
28
+ | **Bushes** | One per tool (Bash, Edit, Read, ...); bigger bushes mean more calls |
29
+ | **Sunflowers** | One per repo; taller stalks mean more prompts |
30
+ | **Birds** | One per `cartoon` adapter that saved tokens; bigger birds mean more tokens saved. Only appears if `cartoon` is installed |
31
+
32
+ Hover (or tap, on mobile) any shape for the exact numbers behind it.
33
+
34
+ ## Install
35
+
36
+ ```sh
37
+ uv tool install ccgarden
38
+ ```
39
+
40
+ (or `pipx install ccgarden`). This installs two commands: `ccgarden` and
41
+ `ccstats`.
42
+
43
+ To hack on it instead, clone the repo and run `uv sync`, which puts the
44
+ same two commands in the project's virtualenv.
45
+
46
+ ## Usage
47
+
48
+ ```sh
49
+ uv run ccgarden
50
+ ```
51
+
52
+ This will:
53
+
54
+ 1. Scan `~/.claude/projects` and record today's snapshot into
55
+ `~/.claude/ccstats.db` (same as running `ccstats` — see below).
56
+ 2. Replay the full day-by-day history from that db into an animated
57
+ SVG timelapse of the garden growing.
58
+ 3. Write it to `~/.claude/ccgarden.svg` and open it in your browser
59
+ (add `--no-open` to skip that last step).
60
+
61
+ Run it again any day and the garden picks up where it left off — new
62
+ rings, longer branches, bigger clouds, more leaves.
63
+
64
+ ### `ccstats`
65
+
66
+ The underlying stats engine can also be run on its own, for a
67
+ terminal-native usage report instead of (or before) rendering a garden:
68
+
69
+ ```sh
70
+ uv run ccstats # summarize all local session logs
71
+ uv run ccstats --since 2026-06-01 # limit the window
72
+ uv run ccstats --json # machine-readable output
73
+ uv run ccstats --record --since 2026-01-01 --until 2026-07-01 # backfill history
74
+ ```
75
+
76
+ Run `uv run ccstats --help` for the full list of flags.
77
+
78
+ ## Development
79
+
80
+ ```sh
81
+ uv run pytest
82
+ uv run ruff check .
83
+ ```
84
+
85
+ ## License
86
+
87
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,74 @@
1
+ [project]
2
+ name = "ccgarden"
3
+ version = "0.1.0"
4
+ description = "Grow a tree/garden visualization from ccstats.db session history"
5
+ authors = [
6
+ { name = "Danny Brown", email = "dannybrown37@gmail.com" }
7
+ ]
8
+ requires-python = ">=3.12"
9
+ dependencies = []
10
+ readme = "README.md"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ keywords = ["claude", "claude-code", "visualization", "svg", "stats"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Environment :: Console",
17
+ "Intended Audience :: Developers",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Topic :: Utilities",
21
+ ]
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/dannybrown37/ccgarden"
25
+ Repository = "https://github.com/dannybrown37/ccgarden"
26
+ Issues = "https://github.com/dannybrown37/ccgarden/issues"
27
+
28
+ [project.scripts]
29
+ ccgarden = "ccgarden:main"
30
+ ccstats = "ccgarden.claude_stats:main"
31
+
32
+ [build-system]
33
+ requires = ["hatchling"]
34
+ build-backend = "hatchling.build"
35
+
36
+ [tool.ruff]
37
+ line-length = 79
38
+ show-fixes = true
39
+ target-version = "py312"
40
+
41
+ [tool.ruff.lint]
42
+ select = [
43
+ "A", "ANN", "ARG", "B", "C4", "COM", "C90",
44
+ "D200", "D201", "D202", "D205", "D212",
45
+ "E", "EM", "ERA", "EXE", "F", "FBT", "G", "I", "ICN", "ISC", "N",
46
+ "PGH", "PIE", "PL", "PLE", "PLR", "PLW", "PT", "PTH", "PYI", "Q",
47
+ "RET", "RSE", "RUF", "S", "SLF", "SIM", "TCH", "TID", "TRY", "W",
48
+ "UP", "YTT",
49
+ ]
50
+ ignore = [
51
+ "S311",
52
+ "S101",
53
+ "I001",
54
+ "S113",
55
+ "PLR0913",
56
+ "PLC0415",
57
+ "COM812", # conflicts with formatter
58
+ ]
59
+
60
+ [tool.ruff.lint.flake8-quotes]
61
+ inline-quotes = "single"
62
+
63
+ [tool.ruff.lint.per-file-ignores]
64
+ "tests/**" = ["ANN201", "PLR2004", "ANN001", "ANN003", "ARG002", "PT019"]
65
+
66
+ [tool.ruff.format]
67
+ quote-style = "single"
68
+ docstring-code-format = true
69
+
70
+ [dependency-groups]
71
+ dev = [
72
+ "pytest>=9.1.1",
73
+ "ruff>=0.16.0",
74
+ ]
@@ -0,0 +1,61 @@
1
+ import argparse
2
+ import subprocess
3
+ import webbrowser
4
+ from pathlib import Path
5
+
6
+ from ccgarden.claude_stats import DEFAULT_LOG_ROOT, print_report
7
+ from ccgarden.data import load_garden_timeline
8
+ from ccgarden.render import render_timeline_svg
9
+
10
+ DEFAULT_DB_PATH = Path.home() / '.claude' / 'ccstats.db'
11
+ DEFAULT_OUTPUT_PATH = Path.home() / '.claude' / 'ccgarden.svg'
12
+
13
+
14
+ def _is_wsl() -> bool:
15
+ try:
16
+ return 'microsoft' in Path('/proc/version').read_text().lower()
17
+ except OSError:
18
+ return False
19
+
20
+
21
+ def _open_in_browser(path: Path) -> None:
22
+ if _is_wsl():
23
+ windows_path = subprocess.run( # noqa: S603
24
+ ['wslpath', '-w', str(path)], # noqa: S607
25
+ capture_output=True,
26
+ text=True,
27
+ check=True,
28
+ ).stdout.strip()
29
+ # explorer.exe always exits 1 on success, so don't check the code.
30
+ subprocess.run( # noqa: S603
31
+ ['explorer.exe', windows_path], # noqa: S607
32
+ check=False,
33
+ )
34
+ else:
35
+ webbrowser.open(path.as_uri())
36
+
37
+
38
+ def build_parser() -> argparse.ArgumentParser:
39
+ parser = argparse.ArgumentParser(
40
+ prog='ccgarden',
41
+ description='Grow a garden from local Claude Code session history.',
42
+ )
43
+ parser.add_argument(
44
+ '--no-open',
45
+ action='store_true',
46
+ help='write the SVG without opening it in a browser',
47
+ )
48
+ return parser
49
+
50
+
51
+ def main(argv: list[str] | None = None) -> None:
52
+ args = build_parser().parse_args(argv)
53
+ # print_report also records today's snapshot -- must run before the
54
+ # timeline is loaded, or the garden it renders is one day stale.
55
+ print_report([DEFAULT_LOG_ROOT], db_path=DEFAULT_DB_PATH)
56
+ timeline = load_garden_timeline(str(DEFAULT_DB_PATH))
57
+ svg = render_timeline_svg(timeline)
58
+ DEFAULT_OUTPUT_PATH.write_text(svg)
59
+ if not args.no_open:
60
+ _open_in_browser(DEFAULT_OUTPUT_PATH)
61
+ print(f'wrote {DEFAULT_OUTPUT_PATH}')