hive-swarm 2.0.0 → 2.1.1
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/.codex-plugin/plugin.json +1 -1
- package/README.md +3 -3
- package/board.css +391 -186
- package/board.html +136 -44
- package/board.js +1203 -122
- package/codex.mjs +44 -13
- package/core.mjs +154 -6
- package/engine.mjs +188 -9
- package/hive-bees.js +110 -64
- package/hive-gif.js +756 -0
- package/hive-graph.js +1421 -383
- package/installer.mjs +36 -16
- package/package.json +2 -1
- package/server.mjs +59 -14
- package/skills/swarm/SKILL.md +7 -6
- package/worktrees.mjs +167 -98
package/hive-bees.js
CHANGED
|
@@ -1,64 +1,110 @@
|
|
|
1
|
-
(() => {
|
|
2
|
-
'use strict';
|
|
3
|
-
const palette=[
|
|
4
|
-
['#efac37','#ffe18d','#bb641d'],
|
|
5
|
-
['#75baef','#cdefff','#3974bb'],
|
|
6
|
-
['#55cbb2','#b8f8df','#268c7d'],
|
|
7
|
-
['#e68db3','#ffcee2','#a24275'],
|
|
8
|
-
['#b3ce64','#e9f6a1','#6c9137'],
|
|
9
|
-
['#ad9ce8','#e3d4ff','#6d58af'],
|
|
10
|
-
['#f09a71','#ffd3b7','#af5833'],
|
|
11
|
-
['#95cbd1','#defbfa','#4a8d9d'],
|
|
12
|
-
['#d1a76a','#ffe2a9','#987044'],
|
|
13
|
-
];
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return palette[
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
1
|
+
(() => {
|
|
2
|
+
'use strict';
|
|
3
|
+
const palette = [
|
|
4
|
+
['#efac37', '#ffe18d', '#bb641d'],
|
|
5
|
+
['#75baef', '#cdefff', '#3974bb'],
|
|
6
|
+
['#55cbb2', '#b8f8df', '#268c7d'],
|
|
7
|
+
['#e68db3', '#ffcee2', '#a24275'],
|
|
8
|
+
['#b3ce64', '#e9f6a1', '#6c9137'],
|
|
9
|
+
['#ad9ce8', '#e3d4ff', '#6d58af'],
|
|
10
|
+
['#f09a71', '#ffd3b7', '#af5833'],
|
|
11
|
+
['#95cbd1', '#defbfa', '#4a8d9d'],
|
|
12
|
+
['#d1a76a', '#ffe2a9', '#987044'],
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const mutedPalette = ['#aaafb6', '#d6dae0', '#848991'];
|
|
16
|
+
|
|
17
|
+
function colors(name, coordinator, tint) {
|
|
18
|
+
if (coordinator) return palette[0];
|
|
19
|
+
if (Number.isInteger(tint)) return palette[1 + (Math.abs(tint) % (palette.length - 1))];
|
|
20
|
+
const hash = [...String(name ?? '')].reduce((sum, letter) => sum * 31 + letter.charCodeAt(0), 0) >>> 0;
|
|
21
|
+
return palette[hash % palette.length];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function hexRgb(hex) {
|
|
25
|
+
const clean = String(hex).replace('#', '');
|
|
26
|
+
const value = Number.parseInt(clean, 16);
|
|
27
|
+
return [(value >> 16) & 255, (value >> 8) & 255, value & 255];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function tintStyle(name, coordinator, tint) {
|
|
31
|
+
const [base, highlight, shade] = colors(name, coordinator, tint);
|
|
32
|
+
const [r, g, b] = hexRgb(base);
|
|
33
|
+
const [sr, sg, sb] = hexRgb(shade);
|
|
34
|
+
const tr = Math.round(sr * 0.78);
|
|
35
|
+
const tg = Math.round(sg * 0.78);
|
|
36
|
+
const tb = Math.round(sb * 0.78);
|
|
37
|
+
const text = '#' + [tr, tg, tb].map(c => c.toString(16).padStart(2, '0')).join('');
|
|
38
|
+
return {
|
|
39
|
+
base,
|
|
40
|
+
highlight,
|
|
41
|
+
shade,
|
|
42
|
+
bg: `rgba(${r}, ${g}, ${b}, 0.14)`,
|
|
43
|
+
border: `rgba(${r}, ${g}, ${b}, 0.42)`,
|
|
44
|
+
text,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function paintRects(ctx, color, rects, ox = 0, oy = 0, scale = 1) {
|
|
49
|
+
ctx.fillStyle = color;
|
|
50
|
+
for (const [rx, ry, rw, rh] of rects) {
|
|
51
|
+
if (ox === 0 && oy === 0 && scale === 1) ctx.fillRect(rx, ry, rw, rh);
|
|
52
|
+
else ctx.fillRect(ox + rx * scale, oy + ry * scale, rw * scale, rh * scale);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function drawSprite(ctx, x, y, name, { status = 'working', coordinator = false, tint, muted = false, scale = 1 } = {}) {
|
|
57
|
+
if (!ctx) return;
|
|
58
|
+
const [base, highlight, shade] = muted ? mutedPalette : colors(name, coordinator, tint);
|
|
59
|
+
const asleep = !muted && ['waiting', 'quota', 'retired', 'done'].includes(status);
|
|
60
|
+
|
|
61
|
+
const outline = muted ? '#727880' : '#201915';
|
|
62
|
+
const wingRim = muted ? '#828a94' : '#24313d';
|
|
63
|
+
const wingFill = muted ? '#ced3d9' : '#a9c6db';
|
|
64
|
+
const wingLight = muted ? '#eef1f4' : '#e7f2fa';
|
|
65
|
+
const stripe = muted ? '#767c84' : '#2c221c';
|
|
66
|
+
|
|
67
|
+
paintRects(ctx, outline, [[3, 2, 1, 3], [6, 3, 1, 2], [5, 1, 2, 1], [2, 3, 1, 1], [5, 5, 10, 8], [3, 7, 13, 5],
|
|
68
|
+
[4, 12, 11, 2], [6, 14, 7, 1], [16, 9, 2, 2], [7, 14, 1, 2], [12, 14, 1, 2]], x, y, scale);
|
|
69
|
+
paintRects(ctx, wingRim, [[7, 3, 6, 4], [8, 2, 4, 6], [12, 3, 4, 4], [13, 2, 2, 1]], x, y, scale);
|
|
70
|
+
paintRects(ctx, wingFill, [[8, 3, 3, 4], [12, 4, 3, 2], [9, 7, 2, 1]], x, y, scale);
|
|
71
|
+
paintRects(ctx, wingLight, [[9, 3, 2, 2], [12, 4, 2, 1], [8, 4, 1, 2]], x, y, scale);
|
|
72
|
+
paintRects(ctx, base, [[4, 7, 8, 5], [5, 6, 6, 7], [12, 7, 3, 5], [13, 12, 1, 1], [6, 13, 1, 1]], x, y, scale);
|
|
73
|
+
paintRects(ctx, highlight, [[5, 7, 3, 1], [4, 9, 2, 2], [10, 7, 2, 1], [13, 8, 1, 2], [5, 12, 2, 1]], x, y, scale);
|
|
74
|
+
paintRects(ctx, shade, [[6, 12, 7, 1], [12, 11, 3, 1], [13, 12, 1, 1]], x, y, scale);
|
|
75
|
+
paintRects(ctx, stripe, [[8, 6, 2, 7], [12, 7, 1, 6], [15, 9, 2, 1]], x, y, scale);
|
|
76
|
+
|
|
77
|
+
if (asleep) {
|
|
78
|
+
paintRects(ctx, outline, [[4, 10, 2, 1]], x, y, scale);
|
|
79
|
+
paintRects(ctx, '#d7dcff', coordinator
|
|
80
|
+
? [[0, 0, 2, 1], [1, 1, 1, 1], [0, 2, 2, 1], [15, 0, 4, 1], [17, 1, 1, 2], [15, 3, 4, 1]]
|
|
81
|
+
: [[1, 1, 3, 1], [2, 2, 1, 1], [1, 3, 3, 1], [15, 0, 4, 1], [17, 1, 1, 2], [15, 3, 4, 1]], x, y, scale);
|
|
82
|
+
} else {
|
|
83
|
+
paintRects(ctx, muted ? '#555b63' : '#201915', [[5, 8, 1, 2]], x, y, scale);
|
|
84
|
+
paintRects(ctx, muted ? '#e5e8ec' : '#fff6d7', [[5, 8, 1, 1]], x, y, scale);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (coordinator) {
|
|
88
|
+
paintRects(ctx, muted ? '#727880' : '#6d4219', [[2, 1, 1, 4], [8, 1, 1, 4], [2, 4, 7, 1]], x, y, scale);
|
|
89
|
+
paintRects(ctx, muted ? '#c7cbd1' : '#ffd86b', [[2, 0, 1, 2], [5, 0, 1, 3], [8, 0, 1, 2], [3, 2, 5, 2], [4, 1, 3, 1]], x, y, scale);
|
|
90
|
+
paintRects(ctx, muted ? '#9da3ab' : '#e7a52f', [[3, 4, 5, 1], [3, 3, 5, 1]], x, y, scale);
|
|
91
|
+
paintRects(ctx, muted ? '#eceef1' : '#fff3bf', [[3, 2, 1, 1], [7, 2, 1, 1], [5, 3, 1, 1]], x, y, scale);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function sprite(name, { status = 'working', coordinator = false, tint, muted = false } = {}) {
|
|
96
|
+
const canvas = document.createElement('canvas');
|
|
97
|
+
canvas.className = 'bee-pixel';
|
|
98
|
+
canvas.width = 20;
|
|
99
|
+
canvas.height = 18;
|
|
100
|
+
canvas.setAttribute('aria-hidden', 'true');
|
|
101
|
+
const asleep = !muted && ['waiting', 'quota', 'retired', 'done'].includes(status);
|
|
102
|
+
canvas.dataset.pose = muted ? 'muted' : (asleep ? 'sleeping' : 'awake');
|
|
103
|
+
if (muted) canvas.dataset.muted = 'true';
|
|
104
|
+
const ctx = canvas.getContext('2d');
|
|
105
|
+
drawSprite(ctx, 0, 0, name, { status, coordinator, tint, muted, scale: 1 });
|
|
106
|
+
return canvas;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
globalThis.HiveBee = Object.freeze({ sprite, colors, tintStyle, drawSprite });
|
|
110
|
+
})();
|