honeytree 1.0.5 → 1.0.7
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.
- package/README.md +22 -169
- package/bin/honeydew.js +9 -12
- package/package.json +15 -8
- package/src/badge.js +42 -68
- package/src/commands/export.js +23 -0
- package/src/commands/init.js +54 -0
- package/src/commands/plant.js +12 -0
- package/src/commands/stats.js +48 -0
- package/src/commands/watch.js +117 -0
- package/src/core/animation.js +135 -0
- package/src/core/environment.js +324 -0
- package/src/core/progression.js +129 -0
- package/src/core/sprites.js +388 -0
- package/src/core/state.js +173 -0
- package/src/markdown.js +13 -44
- package/src/renderers/terminal.js +225 -0
- package/src/tracker/activity.js +43 -0
- package/src/tracker/files.js +44 -0
- package/src/tracker/git.js +77 -0
- package/src/init.js +0 -86
- package/src/plant.js +0 -101
- package/src/renderer.js +0 -302
- package/src/sprites.js +0 -245
- package/src/state.js +0 -53
- package/src/viewer.js +0 -169
package/README.md
CHANGED
|
@@ -1,192 +1,45 @@
|
|
|
1
1
|
# Honeytree
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://github.com/Varun2009178/honeytree/blob/main/LICENSE)
|
|
3
|
+
Honeytree is a living pixel-art forest for developers. It tracks git commits, file saves, and active coding time, then renders the result as a shared forest in the terminal and the VS Code sidebar.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Each prompt plants a new tree. Each tree grows over time. Your forest evolves from a quiet clearing into an ancient woodland — and it never resets.
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## Quick Start
|
|
5
|
+
## Install
|
|
13
6
|
|
|
14
7
|
```bash
|
|
15
8
|
npm install -g honeytree
|
|
16
9
|
honeytree init
|
|
17
|
-
honeytree
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
That's it. Three commands:
|
|
21
|
-
|
|
22
|
-
1. **Install** the CLI globally
|
|
23
|
-
2. **Init** creates your forest file and registers a Claude Code hook
|
|
24
|
-
3. **Run the viewer** in a separate terminal to watch your forest grow
|
|
25
|
-
|
|
26
|
-
After setup, trees are planted automatically after every Claude Code response. No manual steps needed.
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## How It Works
|
|
31
|
-
|
|
32
|
-
When you run `honeytree init`, it does two things:
|
|
33
|
-
|
|
34
|
-
- Creates `~/.honeydew/forest.json` to store your forest state
|
|
35
|
-
- Adds a `Stop` hook to `~/.claude/settings.json` that runs after every Claude Code response
|
|
36
|
-
|
|
37
|
-
From then on, every time Claude Code responds to a prompt, a new tree is planted in your forest automatically. Open the viewer in a second terminal to watch them grow in real time.
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
## Streaks
|
|
42
|
-
|
|
43
|
-
Honeytree tracks your coding streak — consecutive days where you use Claude Code.
|
|
44
|
-
|
|
45
|
-
- **Active streak**: The viewer and badge show your current streak count (e.g. `7-day streak`)
|
|
46
|
-
- **Broken streak**: Miss a day and your forest starts **wilting** — trees desaturate toward brown, and fog rolls in across the scene
|
|
47
|
-
- **Recovery**: Your next prompt resets the streak to 1 and clears the wilting immediately
|
|
48
|
-
|
|
49
|
-
The longer you go without coding, the worse it gets:
|
|
50
|
-
|
|
51
|
-
| Days idle | Effect |
|
|
52
|
-
|----------:|--------|
|
|
53
|
-
| 1 | Light desaturation, sparse fog |
|
|
54
|
-
| 2 | Noticeable browning, moderate fog |
|
|
55
|
-
| 3 | Heavy browning, dense fog |
|
|
56
|
-
| 4+ | Near-dead forest, thick fog |
|
|
57
|
-
|
|
58
|
-
Plant a tree to bring it all back to life.
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
|
|
62
|
-
## Badge
|
|
63
|
-
|
|
64
|
-
Generate a badge for your GitHub README that shows your forest stats and links back to [Honeytree](https://github.com/Varun2009178/honeytree):
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
honeytree badge
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
This creates a `honeytree-badge.svg` file in your current directory and prints the markdown to embed it:
|
|
71
|
-
|
|
72
|
-
```markdown
|
|
73
|
-
[](https://github.com/Varun2009178/honeytree)
|
|
74
10
|
```
|
|
75
11
|
|
|
76
|
-
|
|
12
|
+
Run `honeytree` to open the forest. `honeydew watch` is kept as the explicit watch alias.
|
|
77
13
|
|
|
78
|
-
|
|
79
|
-
|-------|-------------|---------|
|
|
80
|
-
| Active streak | Green | `42 trees · 7d streak` |
|
|
81
|
-
| Wilting | Orange-red | `42 trees · wilting` |
|
|
82
|
-
| No streak data | Grey | `42 trees` |
|
|
14
|
+
## Commands
|
|
83
15
|
|
|
84
|
-
|
|
16
|
+
| Command | What it does |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| `honeytree init` | Creates `~/.honeytree/state.json`, migrates old `~/.honeydew/forest.json`, and prepares the forest project |
|
|
19
|
+
| `honeytree` | Opens the animated terminal forest |
|
|
20
|
+
| `honeydew watch` | Explicit watch alias for the same forest view |
|
|
85
21
|
|
|
86
|
-
|
|
22
|
+
Internal compatibility commands such as `plant`, `stats`, `badge`, and `md` still exist for integration flows, but they are not part of the primary public workflow.
|
|
87
23
|
|
|
88
|
-
##
|
|
24
|
+
## What Grows
|
|
89
25
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
26
|
+
- Git commits plant trees.
|
|
27
|
+
- Every 50 file saves adds a ground element.
|
|
28
|
+
- Every 30 active coding minutes adds an animal.
|
|
29
|
+
- Your streak drives weather effects.
|
|
30
|
+
- The current month drives the season.
|
|
95
31
|
|
|
96
|
-
|
|
32
|
+
## Visual System
|
|
97
33
|
|
|
98
|
-
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
101
|
-
-
|
|
102
|
-
|
|
103
|
-
Commit `FOREST.md` to your repo root so your team can see the forest. When teammates see it, they can install Honeytree themselves — one install spreads to the whole team.
|
|
104
|
-
|
|
105
|
-
Run `honeytree badge` first to generate the SVG, then `honeytree md` to generate the markdown that embeds it.
|
|
106
|
-
|
|
107
|
-
---
|
|
108
|
-
|
|
109
|
-
## Biomes
|
|
110
|
-
|
|
111
|
-
Your forest evolves visually as it grows — the sky, ground, and atmosphere all change:
|
|
112
|
-
|
|
113
|
-
| Trees | Biome | What changes |
|
|
114
|
-
|------:|-------|-------------|
|
|
115
|
-
| 0–9 | Clearing | Sparse stars, light ground |
|
|
116
|
-
| 10–24 | Grove | More stars, richer ground |
|
|
117
|
-
| 25–49 | Woodland | Dense canopy, varied starlight |
|
|
118
|
-
| 50–99 | Old Growth | Deep greens, warm starlight |
|
|
119
|
-
| 100+ | Ancient Forest | Richest palette, brightest sky |
|
|
120
|
-
|
|
121
|
-
Trees are never deleted. The forest only grows.
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
## Tree Species
|
|
126
|
-
|
|
127
|
-
Five species are randomly assigned when a tree is planted:
|
|
128
|
-
|
|
129
|
-
| Species | Look |
|
|
130
|
-
|---------|------|
|
|
131
|
-
| Oak | Wide, rounded canopy |
|
|
132
|
-
| Pine | Tall, triangular shape |
|
|
133
|
-
| Birch | Light trunk, bright leaves |
|
|
134
|
-
| Willow | Drooping canopy |
|
|
135
|
-
| Cherry | Pink blossoms |
|
|
136
|
-
|
|
137
|
-
Each species has 4 growth stages (seed, sapling, young, full). Existing trees grow a little with each new prompt.
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
## CLI Reference
|
|
142
|
-
|
|
143
|
-
| Command | Description |
|
|
144
|
-
|---------|-------------|
|
|
145
|
-
| `honeytree init` | Create forest and register Claude Code hook |
|
|
146
|
-
| `honeytree` | Launch the live viewer |
|
|
147
|
-
| `honeytree plant` | Plant a tree manually (normally runs via hook) |
|
|
148
|
-
| `honeytree badge` | Generate `honeytree-badge.svg` in current directory |
|
|
149
|
-
| `honeytree md` | Generate `FOREST.md` in current directory |
|
|
150
|
-
|
|
151
|
-
---
|
|
152
|
-
|
|
153
|
-
## Viewer
|
|
154
|
-
|
|
155
|
-
The viewer adapts to your terminal width — expand your terminal and new trees will spread across the full width.
|
|
156
|
-
|
|
157
|
-
Press `Ctrl+C` to exit. The viewer shows a summary of your forest when you close it.
|
|
158
|
-
|
|
159
|
-
### Reading the Stats Bar
|
|
160
|
-
|
|
161
|
-
Below your forest you'll see a stats bar like this:
|
|
162
|
-
|
|
163
|
-
```
|
|
164
|
-
honeytree · 42 trees · 7-day streak · ████████░░░░ next: oak [woodland]
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
Here's what each part means:
|
|
168
|
-
|
|
169
|
-
| Segment | What it tells you |
|
|
170
|
-
|---------|-------------------|
|
|
171
|
-
| `42 trees` | Total trees in your forest — one planted per prompt, never deleted |
|
|
172
|
-
| `7-day streak` | Consecutive days you've used Claude Code. Resets to 1 if you skip a day |
|
|
173
|
-
| `wilting (2d idle)` | Appears instead of streak when you've been inactive — your forest is dying |
|
|
174
|
-
| `████████░░░░` | Progress bar toward the next milestone (10, 25, 50, 100, 250, 500, 1000 trees) |
|
|
175
|
-
| `next: oak` | The species of the next tree that will be planted |
|
|
176
|
-
| `[woodland]` | Your current biome — evolves as your tree count grows |
|
|
177
|
-
|
|
178
|
-
---
|
|
34
|
+
- Time of day changes the sky between sunrise, day, sunset, and night.
|
|
35
|
+
- Seasons recolor the same pixel sprites for spring, summer, autumn, and winter.
|
|
36
|
+
- Weather escalates from clear to rain, rainbow, golden hour, and aurora.
|
|
37
|
+
- The terminal uses Unicode pixel blocks, while the VS Code extension uses an animated canvas renderer.
|
|
179
38
|
|
|
180
39
|
## Requirements
|
|
181
40
|
|
|
182
41
|
- Node.js 18+
|
|
183
|
-
-
|
|
184
|
-
|
|
185
|
-
## Links
|
|
186
|
-
|
|
187
|
-
- **npm**: [npmjs.com/package/honeytree](https://www.npmjs.com/package/honeytree)
|
|
188
|
-
- **GitHub**: [github.com/Varun2009178/honeytree](https://github.com/Varun2009178/honeytree)
|
|
189
|
-
- **Issues**: [github.com/Varun2009178/honeytree/issues](https://github.com/Varun2009178/honeytree/issues)
|
|
42
|
+
- VS Code 1.85+ for the bundled extension
|
|
190
43
|
|
|
191
44
|
## License
|
|
192
45
|
|
package/bin/honeydew.js
CHANGED
|
@@ -3,22 +3,19 @@
|
|
|
3
3
|
const command = process.argv[2];
|
|
4
4
|
|
|
5
5
|
if (command === "init") {
|
|
6
|
-
const { init } = await import("../src/init.js");
|
|
6
|
+
const { init } = await import("../src/commands/init.js");
|
|
7
7
|
await init();
|
|
8
|
+
} else if (command === "export") {
|
|
9
|
+
const { exportForest } = await import("../src/commands/export.js");
|
|
10
|
+
await exportForest();
|
|
11
|
+
} else if (command === "watch" || !command) {
|
|
12
|
+
const { watch } = await import("../src/commands/watch.js");
|
|
13
|
+
await watch();
|
|
8
14
|
} else if (command === "plant") {
|
|
9
|
-
const { plant } = await import("../src/plant.js");
|
|
15
|
+
const { plant } = await import("../src/commands/plant.js");
|
|
10
16
|
await plant();
|
|
11
|
-
} else if (command === "badge") {
|
|
12
|
-
const { badge } = await import("../src/badge.js");
|
|
13
|
-
await badge();
|
|
14
|
-
} else if (command === "md") {
|
|
15
|
-
const { generateForestMd } = await import("../src/markdown.js");
|
|
16
|
-
await generateForestMd();
|
|
17
|
-
} else if (!command) {
|
|
18
|
-
const { viewer } = await import("../src/viewer.js");
|
|
19
|
-
await viewer();
|
|
20
17
|
} else {
|
|
21
18
|
console.error(`Unknown command: ${command}`);
|
|
22
|
-
console.error("Usage: honeytree [init|
|
|
19
|
+
console.error("Usage: honeytree [init | export | watch]");
|
|
23
20
|
process.exit(1);
|
|
24
21
|
}
|
package/package.json
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "honeytree",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.7",
|
|
4
|
+
"description": "A living pixel art forest that grows while you code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"honeytree": "./bin/honeydew.js"
|
|
7
|
+
"honeytree": "./bin/honeydew.js",
|
|
8
|
+
"honeydew": "./bin/honeydew.js"
|
|
8
9
|
},
|
|
9
10
|
"files": [
|
|
10
11
|
"bin",
|
|
11
12
|
"src"
|
|
12
13
|
],
|
|
13
14
|
"scripts": {
|
|
14
|
-
"test": "node --test test
|
|
15
|
+
"test": "node --test test/**/*.test.js",
|
|
16
|
+
"postinstall": "echo \"🌳 Thanks for planting! Star us: https://github.com/Varun2009178/honeytree\""
|
|
15
17
|
},
|
|
16
18
|
"keywords": [
|
|
17
19
|
"cli",
|
|
18
20
|
"terminal",
|
|
19
21
|
"forest",
|
|
20
|
-
"claude-code",
|
|
21
22
|
"pixel-art",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
23
|
+
"git",
|
|
24
|
+
"developer-tools",
|
|
25
|
+
"ascii-art"
|
|
24
26
|
],
|
|
25
27
|
"repository": {
|
|
26
28
|
"type": "git",
|
|
@@ -33,7 +35,12 @@
|
|
|
33
35
|
"author": "Varun Nukala",
|
|
34
36
|
"license": "MIT",
|
|
35
37
|
"dependencies": {
|
|
36
|
-
"chalk": "^5.4.1"
|
|
38
|
+
"chalk": "^5.4.1",
|
|
39
|
+
"chokidar": "^4.0.3",
|
|
40
|
+
"date-fns": "^4.1.0",
|
|
41
|
+
"ink": "^5.2.1",
|
|
42
|
+
"react": "^18.3.1",
|
|
43
|
+
"simple-git": "^3.36.0"
|
|
37
44
|
},
|
|
38
45
|
"engines": {
|
|
39
46
|
"node": ">=18"
|
package/src/badge.js
CHANGED
|
@@ -1,92 +1,66 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { readState } from "./core/state.js";
|
|
5
|
+
import { buildTerminalScene } from "./renderers/terminal.js";
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const CELL = 6;
|
|
8
|
+
const BG = "#0d1117";
|
|
9
|
+
const TEXT_PAD = 18;
|
|
9
10
|
|
|
10
|
-
function
|
|
11
|
-
return
|
|
11
|
+
function escapeXml(value) {
|
|
12
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
function
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const treePart = `${count} tree${count === 1 ? "" : "s"}`;
|
|
15
|
+
function generateForestSVG(state) {
|
|
16
|
+
const cols = 80;
|
|
17
|
+
const { buffer, statsLine } = buildTerminalScene(state, cols, 0, { color: false });
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
const artW = cols * CELL;
|
|
20
|
+
const artH = buffer.length * CELL;
|
|
21
|
+
const totalW = artW;
|
|
22
|
+
const totalH = artH + TEXT_PAD;
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
let rects = "";
|
|
25
|
+
for (let y = 0; y < buffer.length; y += 1) {
|
|
26
|
+
for (let x = 0; x < cols; x += 1) {
|
|
27
|
+
const cell = buffer[y][x];
|
|
28
|
+
if (!cell.color) continue;
|
|
29
|
+
rects += `<rect x="${x * CELL}" y="${y * CELL}" width="${CELL}" height="${CELL}" fill="${cell.color}"/>`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${totalW}" height="${totalH}" viewBox="0 0 ${totalW} ${totalH}">
|
|
34
|
+
<rect width="${totalW}" height="${totalH}" fill="${BG}" rx="6"/>
|
|
35
|
+
${rects}
|
|
36
|
+
<text x="${totalW / 2}" y="${artH + 13}" text-anchor="middle" fill="#8e8a84" font-family="monospace" font-size="10">${escapeXml(statsLine.trim())}</text>
|
|
37
|
+
</svg>`;
|
|
29
38
|
}
|
|
30
39
|
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
const today = new Date().toISOString().slice(0, 10);
|
|
34
|
-
const a = new Date(forest.lastActiveDate + "T00:00:00");
|
|
35
|
-
const b = new Date(today + "T00:00:00");
|
|
36
|
-
const idle = Math.round((b - a) / (24 * 60 * 60 * 1000));
|
|
37
|
-
if (idle > 0) return "#c4653a";
|
|
38
|
-
return "#2ea043";
|
|
40
|
+
export function writeBadgeSVG(state, outPath) {
|
|
41
|
+
fs.writeFileSync(outPath, generateForestSVG(state));
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<linearGradient id="s" x2="0" y2="100%">
|
|
51
|
-
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
|
52
|
-
<stop offset="1" stop-opacity=".1"/>
|
|
53
|
-
</linearGradient>
|
|
54
|
-
<clipPath id="r"><rect width="${tw}" height="${HEIGHT}" rx="3" fill="#fff"/></clipPath>
|
|
55
|
-
<g clip-path="url(#r)">
|
|
56
|
-
<rect width="${lw}" height="${HEIGHT}" fill="#555"/>
|
|
57
|
-
<rect x="${lw}" width="${mw}" height="${HEIGHT}" fill="${color}"/>
|
|
58
|
-
<rect width="${tw}" height="${HEIGHT}" fill="url(#s)"/>
|
|
59
|
-
</g>
|
|
60
|
-
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="11">
|
|
61
|
-
<text aria-hidden="true" x="${lx}" y="15" fill="#010101" fill-opacity=".3">${label}</text>
|
|
62
|
-
<text x="${lx}" y="14">${label}</text>
|
|
63
|
-
<text aria-hidden="true" x="${mx}" y="15" fill="#010101" fill-opacity=".3">${message}</text>
|
|
64
|
-
<text x="${mx}" y="14">${message}</text>
|
|
65
|
-
</g>
|
|
66
|
-
</svg>`;
|
|
44
|
+
export function findBadgeFile() {
|
|
45
|
+
let dir = process.cwd();
|
|
46
|
+
const root = path.parse(dir).root;
|
|
47
|
+
while (dir !== root) {
|
|
48
|
+
const candidate = path.join(dir, "honeytree-badge.svg");
|
|
49
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
50
|
+
dir = path.dirname(dir);
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
67
53
|
}
|
|
68
54
|
|
|
69
55
|
export async function badge() {
|
|
70
|
-
const
|
|
71
|
-
if (!
|
|
72
|
-
console.error('No
|
|
56
|
+
const state = readState();
|
|
57
|
+
if (!state) {
|
|
58
|
+
console.error('No Honeytree state found. Run "honeytree init" first.');
|
|
73
59
|
process.exit(1);
|
|
74
60
|
}
|
|
75
61
|
|
|
76
|
-
const label = "honeytree";
|
|
77
|
-
const message = buildMessage(forest);
|
|
78
|
-
const color = badgeColor(forest);
|
|
79
|
-
const svg = generateSVG(label, message, color);
|
|
80
|
-
|
|
81
62
|
const outPath = path.resolve("honeytree-badge.svg");
|
|
82
|
-
|
|
63
|
+
writeBadgeSVG(state, outPath);
|
|
83
64
|
|
|
84
65
|
console.log(`Badge written to ${outPath}`);
|
|
85
|
-
console.log("");
|
|
86
|
-
console.log("Add this to your README to show your Honeytree stats.");
|
|
87
|
-
console.log("The badge links to https://github.com/Varun2009178/honeytree");
|
|
88
|
-
console.log("");
|
|
89
|
-
console.log(
|
|
90
|
-
`[](https://github.com/Varun2009178/honeytree)`,
|
|
91
|
-
);
|
|
92
66
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
import { writeBadgeSVG } from "../badge.js";
|
|
4
|
+
import { buildMarkdown } from "../markdown.js";
|
|
5
|
+
import { readState } from "../core/state.js";
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
|
|
8
|
+
export async function exportForest() {
|
|
9
|
+
const state = readState();
|
|
10
|
+
if (!state) {
|
|
11
|
+
console.error('No Honeytree state found. Run "honeytree init" first.');
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const badgePath = path.resolve("honeytree-badge.svg");
|
|
16
|
+
writeBadgeSVG(state, badgePath);
|
|
17
|
+
|
|
18
|
+
const md = buildMarkdown(state);
|
|
19
|
+
const mdPath = path.resolve("FOREST.md");
|
|
20
|
+
fs.writeFileSync(mdPath, md);
|
|
21
|
+
|
|
22
|
+
console.log("Exported honeytree-badge.svg and FOREST.md");
|
|
23
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
import { ensureState, getStateFile } from "../core/state.js";
|
|
6
|
+
|
|
7
|
+
function getClaudeSettingsPath() {
|
|
8
|
+
const root = process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), ".claude");
|
|
9
|
+
return path.join(root, "settings.json");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function hasClaudeHook(settings) {
|
|
13
|
+
return (
|
|
14
|
+
settings?.hooks?.Stop?.some((entry) =>
|
|
15
|
+
entry?.hooks?.some((hook) => hook?.command === "honeytree plant"),
|
|
16
|
+
) ?? false
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function installClaudeHook() {
|
|
21
|
+
const settingsPath = getClaudeSettingsPath();
|
|
22
|
+
fs.mkdirSync(path.dirname(settingsPath), { recursive: true });
|
|
23
|
+
|
|
24
|
+
let settings = {};
|
|
25
|
+
try {
|
|
26
|
+
settings = JSON.parse(fs.readFileSync(settingsPath, "utf8"));
|
|
27
|
+
} catch {
|
|
28
|
+
settings = {};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
settings.hooks ??= {};
|
|
32
|
+
settings.hooks.Stop ??= [];
|
|
33
|
+
|
|
34
|
+
if (!hasClaudeHook(settings)) {
|
|
35
|
+
settings.hooks.Stop.push({
|
|
36
|
+
matcher: "",
|
|
37
|
+
hooks: [{ type: "command", command: "honeytree plant" }],
|
|
38
|
+
});
|
|
39
|
+
fs.writeFileSync(settingsPath, `${JSON.stringify(settings, null, 2)}\n`);
|
|
40
|
+
return settingsPath;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function init() {
|
|
47
|
+
ensureState();
|
|
48
|
+
|
|
49
|
+
const hook = process.argv.includes("--hook") || process.env.HONEYTREE_ENABLE_CLAUDE_HOOK === "1";
|
|
50
|
+
if (hook) installClaudeHook();
|
|
51
|
+
|
|
52
|
+
const suffix = hook ? " (Claude hook installed)" : "";
|
|
53
|
+
console.log(`🌳 Forest planted at ${getStateFile()}${suffix}`);
|
|
54
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { applyCommit } from "../core/progression.js";
|
|
2
|
+
import { updateState } from "../core/state.js";
|
|
3
|
+
|
|
4
|
+
export async function plant() {
|
|
5
|
+
const width = Number.parseInt(process.env.HONEYTREE_WIDTH ?? "80", 10) || 80;
|
|
6
|
+
const now = new Date();
|
|
7
|
+
const nextState = updateState((state) => applyCommit(state, { now, width }));
|
|
8
|
+
console.log(
|
|
9
|
+
`Planted ${nextState.trees.at(-1)?.species ?? "tree"} #${nextState.total_commits} (${nextState.trees.length} total trees)`,
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { getEnvironmentSnapshot } from "../core/environment.js";
|
|
2
|
+
import { getNextMinuteCheckpoint } from "../core/progression.js";
|
|
3
|
+
import { getTreeSpeciesForCommit } from "../core/sprites.js";
|
|
4
|
+
import { readState } from "../core/state.js";
|
|
5
|
+
|
|
6
|
+
function formatPlural(count, singular) {
|
|
7
|
+
return `${count} ${singular}${count === 1 ? "" : "s"}`;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function getNextTreeCommit(totalCommits) {
|
|
11
|
+
return totalCommits + 1;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getNextGroundUnlock(totalFileSaves) {
|
|
15
|
+
return Math.ceil((totalFileSaves + 1) / 50) * 50;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function buildStatsReport(state, now = new Date()) {
|
|
19
|
+
const environment = getEnvironmentSnapshot(now, state.current_streak);
|
|
20
|
+
const nextTreeCommit = getNextTreeCommit(state.total_commits);
|
|
21
|
+
const nextGroundUnlock = getNextGroundUnlock(state.total_file_saves);
|
|
22
|
+
const nextMinuteUnlock = getNextMinuteCheckpoint(state.total_minutes_coded);
|
|
23
|
+
|
|
24
|
+
return [
|
|
25
|
+
"Honeytree",
|
|
26
|
+
`Trees: ${formatPlural(state.trees.length, "tree")} (${state.total_commits} commits)`,
|
|
27
|
+
`Animals: ${formatPlural(state.animals.length, "animal")} (${state.total_minutes_coded} active minutes)`,
|
|
28
|
+
`Ground: ${formatPlural(state.ground_elements.length, "element")} (${state.total_file_saves} file saves)`,
|
|
29
|
+
`Streak: ${state.current_streak} day${state.current_streak === 1 ? "" : "s"}`,
|
|
30
|
+
`Season: ${environment.season.label}`,
|
|
31
|
+
`Weather: ${environment.weather.label}`,
|
|
32
|
+
`Sky: ${environment.sky.label}`,
|
|
33
|
+
`Next tree: commit ${nextTreeCommit} → ${getTreeSpeciesForCommit(nextTreeCommit)}`,
|
|
34
|
+
`Next ground element: ${Math.max(0, nextGroundUnlock - state.total_file_saves)} saves`,
|
|
35
|
+
`Next animal: ${Math.max(0, nextMinuteUnlock - state.total_minutes_coded)} minutes`,
|
|
36
|
+
].join("\n");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function stats() {
|
|
40
|
+
const state = readState();
|
|
41
|
+
if (!state) {
|
|
42
|
+
console.error('No Honeytree state found. Run "honeytree init" first.');
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
console.log(buildStatsReport(state));
|
|
47
|
+
}
|
|
48
|
+
|