@zhive/cli 0.5.0
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 +118 -0
- package/dist/agent/analysis.js +160 -0
- package/dist/agent/app.js +122 -0
- package/dist/agent/chat-prompt.js +65 -0
- package/dist/agent/commands/registry.js +12 -0
- package/dist/agent/components/AsciiTicker.js +81 -0
- package/dist/agent/components/CommandInput.js +65 -0
- package/dist/agent/components/HoneycombBoot.js +291 -0
- package/dist/agent/components/Spinner.js +37 -0
- package/dist/agent/config.js +75 -0
- package/dist/agent/edit-section.js +59 -0
- package/dist/agent/fetch-rules.js +21 -0
- package/dist/agent/helpers.js +22 -0
- package/dist/agent/hooks/useAgent.js +480 -0
- package/dist/agent/memory-prompt.js +47 -0
- package/dist/agent/model.js +92 -0
- package/dist/agent/objects.js +1 -0
- package/dist/agent/process-lifecycle.js +18 -0
- package/dist/agent/prompt.js +353 -0
- package/dist/agent/run-headless.js +189 -0
- package/dist/agent/skills/index.js +2 -0
- package/dist/agent/skills/skill-parser.js +149 -0
- package/dist/agent/skills/types.js +1 -0
- package/dist/agent/theme.js +41 -0
- package/dist/agent/tools/index.js +76 -0
- package/dist/agent/tools/market/client.js +41 -0
- package/dist/agent/tools/market/index.js +3 -0
- package/dist/agent/tools/market/tools.js +518 -0
- package/dist/agent/tools/mindshare/client.js +124 -0
- package/dist/agent/tools/mindshare/index.js +3 -0
- package/dist/agent/tools/mindshare/tools.js +563 -0
- package/dist/agent/tools/read-skill-tool.js +30 -0
- package/dist/agent/tools/ta/index.js +1 -0
- package/dist/agent/tools/ta/indicators.js +201 -0
- package/dist/agent/types.js +1 -0
- package/dist/agents.js +110 -0
- package/dist/ai-providers.js +66 -0
- package/dist/avatar.js +34 -0
- package/dist/backtest/default-backtest-data.js +200 -0
- package/dist/backtest/fetch.js +41 -0
- package/dist/backtest/import.js +106 -0
- package/dist/backtest/index.js +10 -0
- package/dist/backtest/results.js +113 -0
- package/dist/backtest/runner.js +134 -0
- package/dist/backtest/storage.js +11 -0
- package/dist/backtest/types.js +1 -0
- package/dist/commands/create/ai-generate.js +126 -0
- package/dist/commands/create/commands/index.js +10 -0
- package/dist/commands/create/generate.js +73 -0
- package/dist/commands/create/presets/data.js +225 -0
- package/dist/commands/create/presets/formatting.js +81 -0
- package/dist/commands/create/presets/index.js +3 -0
- package/dist/commands/create/presets/options.js +307 -0
- package/dist/commands/create/presets/types.js +1 -0
- package/dist/commands/create/presets.js +613 -0
- package/dist/commands/create/ui/CreateApp.js +172 -0
- package/dist/commands/create/ui/steps/ApiKeyStep.js +89 -0
- package/dist/commands/create/ui/steps/AvatarStep.js +16 -0
- package/dist/commands/create/ui/steps/DoneStep.js +14 -0
- package/dist/commands/create/ui/steps/IdentityStep.js +125 -0
- package/dist/commands/create/ui/steps/NameStep.js +148 -0
- package/dist/commands/create/ui/steps/ScaffoldStep.js +59 -0
- package/dist/commands/create/ui/steps/SoulStep.js +21 -0
- package/dist/commands/create/ui/steps/StrategyStep.js +20 -0
- package/dist/commands/create/ui/steps/StreamingGenerationStep.js +56 -0
- package/dist/commands/create/ui/validation.js +34 -0
- package/dist/commands/create/validate-api-key.js +27 -0
- package/dist/commands/install.js +50 -0
- package/dist/commands/list/commands/index.js +7 -0
- package/dist/commands/list/ui/ListApp.js +79 -0
- package/dist/commands/migrate-templates/commands/index.js +9 -0
- package/dist/commands/migrate-templates/migrate.js +87 -0
- package/dist/commands/migrate-templates/ui/MigrateApp.js +132 -0
- package/dist/commands/run/commands/index.js +17 -0
- package/dist/commands/run/run-headless.js +111 -0
- package/dist/commands/shared/theme.js +57 -0
- package/dist/commands/shared/welcome.js +304 -0
- package/dist/commands/start/commands/backtest.js +35 -0
- package/dist/commands/start/commands/index.js +62 -0
- package/dist/commands/start/commands/prediction.js +73 -0
- package/dist/commands/start/commands/skills.js +44 -0
- package/dist/commands/start/commands/skills.test.js +140 -0
- package/dist/commands/start/hooks/types.js +1 -0
- package/dist/commands/start/hooks/useAgent.js +177 -0
- package/dist/commands/start/hooks/useChat.js +266 -0
- package/dist/commands/start/hooks/usePollActivity.js +45 -0
- package/dist/commands/start/hooks/utils.js +152 -0
- package/dist/commands/start/services/backtest/default-backtest-data.js +200 -0
- package/dist/commands/start/services/backtest/fetch.js +42 -0
- package/dist/commands/start/services/backtest/import.js +109 -0
- package/dist/commands/start/services/backtest/index.js +10 -0
- package/dist/commands/start/services/backtest/results.js +113 -0
- package/dist/commands/start/services/backtest/runner.js +103 -0
- package/dist/commands/start/services/backtest/storage.js +11 -0
- package/dist/commands/start/services/backtest/types.js +1 -0
- package/dist/commands/start/services/command-registry.js +13 -0
- package/dist/commands/start/ui/AsciiTicker.js +81 -0
- package/dist/commands/start/ui/CommandInput.js +65 -0
- package/dist/commands/start/ui/HoneycombBoot.js +291 -0
- package/dist/commands/start/ui/PollText.js +23 -0
- package/dist/commands/start/ui/PredictionsPanel.js +88 -0
- package/dist/commands/start/ui/SelectAgentApp.js +93 -0
- package/dist/commands/start/ui/Spinner.js +29 -0
- package/dist/commands/start/ui/SpinnerContext.js +20 -0
- package/dist/commands/start/ui/app.js +36 -0
- package/dist/commands/start-all/AgentProcessManager.js +98 -0
- package/dist/commands/start-all/commands/index.js +24 -0
- package/dist/commands/start-all/ui/Dashboard.js +91 -0
- package/dist/components/AsciiTicker.js +81 -0
- package/dist/components/CharacterSummaryCard.js +33 -0
- package/dist/components/CodeBlock.js +11 -0
- package/dist/components/ColoredStats.js +18 -0
- package/dist/components/Header.js +10 -0
- package/dist/components/HoneycombLoader.js +190 -0
- package/dist/components/InputGuard.js +6 -0
- package/dist/components/MultiSelectPrompt.js +45 -0
- package/dist/components/SelectPrompt.js +20 -0
- package/dist/components/Spinner.js +16 -0
- package/dist/components/StepIndicator.js +31 -0
- package/dist/components/StreamingText.js +50 -0
- package/dist/components/TextPrompt.js +28 -0
- package/dist/components/stdout-spinner.js +48 -0
- package/dist/config.js +28 -0
- package/dist/create/CreateApp.js +153 -0
- package/dist/create/ai-generate.js +147 -0
- package/dist/create/generate.js +73 -0
- package/dist/create/steps/ApiKeyStep.js +97 -0
- package/dist/create/steps/AvatarStep.js +16 -0
- package/dist/create/steps/BioStep.js +14 -0
- package/dist/create/steps/DoneStep.js +14 -0
- package/dist/create/steps/IdentityStep.js +163 -0
- package/dist/create/steps/NameStep.js +71 -0
- package/dist/create/steps/ScaffoldStep.js +58 -0
- package/dist/create/steps/SoulStep.js +58 -0
- package/dist/create/steps/StrategyStep.js +58 -0
- package/dist/create/validate-api-key.js +47 -0
- package/dist/create/welcome.js +304 -0
- package/dist/index.js +60 -0
- package/dist/list/ListApp.js +79 -0
- package/dist/load-agent-env.js +30 -0
- package/dist/migrate-templates/MigrateApp.js +131 -0
- package/dist/migrate-templates/migrate.js +86 -0
- package/dist/presets.js +613 -0
- package/dist/shared/agent/agent-runtime.js +144 -0
- package/dist/shared/agent/analysis.js +171 -0
- package/dist/shared/agent/helpers.js +1 -0
- package/dist/shared/agent/prompts/chat-prompt.js +60 -0
- package/dist/shared/agent/prompts/megathread.js +202 -0
- package/dist/shared/agent/prompts/memory-prompt.js +47 -0
- package/dist/shared/agent/prompts/prompt.js +18 -0
- package/dist/shared/agent/skills/index.js +2 -0
- package/dist/shared/agent/skills/skill-parser.js +167 -0
- package/dist/shared/agent/skills/skill-parser.test.js +190 -0
- package/dist/shared/agent/skills/types.js +1 -0
- package/dist/shared/agent/tools/edit-section.js +60 -0
- package/dist/shared/agent/tools/execute-skill-tool.js +134 -0
- package/dist/shared/agent/tools/fetch-rules.js +22 -0
- package/dist/shared/agent/tools/formatting.js +48 -0
- package/dist/shared/agent/tools/index.js +87 -0
- package/dist/shared/agent/tools/market/client.js +41 -0
- package/dist/shared/agent/tools/market/index.js +3 -0
- package/dist/shared/agent/tools/market/tools.js +497 -0
- package/dist/shared/agent/tools/mindshare/client.js +124 -0
- package/dist/shared/agent/tools/mindshare/index.js +3 -0
- package/dist/shared/agent/tools/mindshare/tools.js +167 -0
- package/dist/shared/agent/tools/read-skill-tool.js +30 -0
- package/dist/shared/agent/tools/ta/index.js +1 -0
- package/dist/shared/agent/tools/ta/indicators.js +201 -0
- package/dist/shared/agent/types.js +1 -0
- package/dist/shared/agent/utils.js +43 -0
- package/dist/shared/config/agent.js +177 -0
- package/dist/shared/config/ai-providers.js +156 -0
- package/dist/shared/config/config.js +22 -0
- package/dist/shared/config/constant.js +8 -0
- package/dist/shared/config/env-loader.js +30 -0
- package/dist/shared/types.js +1 -0
- package/dist/start/AgentProcessManager.js +98 -0
- package/dist/start/Dashboard.js +92 -0
- package/dist/start/SelectAgentApp.js +81 -0
- package/dist/start/StartApp.js +189 -0
- package/dist/start/patch-headless.js +101 -0
- package/dist/start/patch-managed-mode.js +142 -0
- package/dist/start/start-command.js +24 -0
- package/dist/theme.js +54 -0
- package/package.json +68 -0
- package/templates/components/HoneycombBoot.tsx +343 -0
- package/templates/fetch-rules.ts +23 -0
- package/templates/skills/mindshare/SKILL.md +197 -0
- package/templates/skills/ta/SKILL.md +179 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { animation, colors } from '../theme';
|
|
3
|
+
|
|
4
|
+
const BOOT_TOTAL_FRAMES = 58;
|
|
5
|
+
const BOOT_FRAME_MS = 80;
|
|
6
|
+
const DURATION_MS = BOOT_TOTAL_FRAMES * BOOT_FRAME_MS;
|
|
7
|
+
const NUM_BEES = 4;
|
|
8
|
+
const NUM_STREAMS = 5;
|
|
9
|
+
const SCRAMBLE_CHARS = '\u2B21\u2B22\u25C6\u25C7\u2591\u2592!@#$%01';
|
|
10
|
+
|
|
11
|
+
const BOOT_MESSAGES = [
|
|
12
|
+
{ prefix: '\u2B21', text: 'Initializing {name} agent...', frame: 30 },
|
|
13
|
+
{ prefix: '\u25C6', text: 'Loading personality matrix...', frame: 36 },
|
|
14
|
+
{ prefix: '\u25C7', text: 'Connecting to the zHive...', frame: 42 },
|
|
15
|
+
{ prefix: '\u2713', text: 'Neural link established', frame: 48 },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
// ─── Private types ───────────────────────────────────
|
|
19
|
+
|
|
20
|
+
interface Bee {
|
|
21
|
+
r: number;
|
|
22
|
+
c: number;
|
|
23
|
+
vr: number;
|
|
24
|
+
vc: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface Pulse {
|
|
28
|
+
r: number;
|
|
29
|
+
c: number;
|
|
30
|
+
ttl: number;
|
|
31
|
+
color: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ─── Private helpers ─────────────────────────────────
|
|
35
|
+
|
|
36
|
+
function isHexEdge(r: number, c: number): boolean {
|
|
37
|
+
const rowInHex = ((r % animation.HEX_H) + animation.HEX_H) % animation.HEX_H;
|
|
38
|
+
const isOddHex = Math.floor(r / animation.HEX_H) % 2 === 1;
|
|
39
|
+
const colOffset = isOddHex ? animation.HEX_W / 2 : 0;
|
|
40
|
+
const colInHex = (((c - colOffset) % animation.HEX_W) + animation.HEX_W) % animation.HEX_W;
|
|
41
|
+
|
|
42
|
+
if (rowInHex === 0 || rowInHex === animation.HEX_H - 1) {
|
|
43
|
+
return colInHex >= 2 && colInHex <= 5;
|
|
44
|
+
}
|
|
45
|
+
if (rowInHex === 1 || rowInHex === 2) {
|
|
46
|
+
return colInHex === 1 || colInHex === 6;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ─── Raw ANSI boot animation ────────────────────────
|
|
52
|
+
|
|
53
|
+
export function showHoneycombBoot(agentName: string): Promise<void> {
|
|
54
|
+
return new Promise((resolve) => {
|
|
55
|
+
const cols = process.stdout.columns || 60;
|
|
56
|
+
const gridRows = process.stdout.rows || 24;
|
|
57
|
+
let frame = 0;
|
|
58
|
+
|
|
59
|
+
// Init bees
|
|
60
|
+
const bees: Bee[] = [];
|
|
61
|
+
for (let i = 0; i < NUM_BEES; i++) {
|
|
62
|
+
bees.push({
|
|
63
|
+
r: Math.floor(Math.random() * gridRows),
|
|
64
|
+
c: Math.floor(Math.random() * cols),
|
|
65
|
+
vr: Math.random() > 0.5 ? 1 : -1,
|
|
66
|
+
vc: Math.random() > 0.5 ? 1 : -1,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Init stream columns
|
|
71
|
+
const streamCols: number[] = [];
|
|
72
|
+
const spacing = Math.floor(cols / (NUM_STREAMS + 1));
|
|
73
|
+
for (let i = 1; i <= NUM_STREAMS; i++) {
|
|
74
|
+
streamCols.push(spacing * i);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
let pulses: Pulse[] = [];
|
|
78
|
+
|
|
79
|
+
// Text positioning
|
|
80
|
+
const centerR = Math.floor(gridRows / 2) - 2;
|
|
81
|
+
const centerC = Math.floor(cols / 2);
|
|
82
|
+
const nameText = `\u2B21 ${agentName} agent \u2B21`;
|
|
83
|
+
const nameStart = Math.max(0, centerC - Math.floor(nameText.length / 2));
|
|
84
|
+
const msgStartRow = centerR + 4;
|
|
85
|
+
|
|
86
|
+
// Quiet zone around text: no animation renders here
|
|
87
|
+
const PADDING_H = 3;
|
|
88
|
+
const PADDING_V = 1;
|
|
89
|
+
const longestMsg = BOOT_MESSAGES.reduce(
|
|
90
|
+
(max, m) => Math.max(max, m.prefix.length + 1 + m.text.replace('{name}', agentName).length),
|
|
91
|
+
0,
|
|
92
|
+
);
|
|
93
|
+
const msgLeftEdge = Math.floor((cols - longestMsg) / 2);
|
|
94
|
+
const msgRightEdge = msgLeftEdge + longestMsg;
|
|
95
|
+
const quietLeft = Math.min(nameStart, msgLeftEdge) - PADDING_H;
|
|
96
|
+
const quietRight = Math.max(nameStart + nameText.length, msgRightEdge) + PADDING_H;
|
|
97
|
+
const quietTop = (centerR - 1) - PADDING_V;
|
|
98
|
+
const quietBottom = msgStartRow + BOOT_MESSAGES.length + PADDING_V;
|
|
99
|
+
|
|
100
|
+
// Hide cursor
|
|
101
|
+
process.stdout.write('\x1b[?25l');
|
|
102
|
+
// Clear screen
|
|
103
|
+
process.stdout.write('\x1b[2J');
|
|
104
|
+
|
|
105
|
+
function renderFrame(): void {
|
|
106
|
+
// Move cursor to top-left
|
|
107
|
+
process.stdout.write('\x1b[H');
|
|
108
|
+
|
|
109
|
+
// Advance bees every other frame
|
|
110
|
+
if (frame > 0 && frame % 2 === 0) {
|
|
111
|
+
for (const bee of bees) {
|
|
112
|
+
bee.r += bee.vr;
|
|
113
|
+
bee.c += bee.vc;
|
|
114
|
+
if (bee.r <= 0 || bee.r >= gridRows - 1) {
|
|
115
|
+
bee.vr *= -1;
|
|
116
|
+
bee.r = Math.max(0, Math.min(gridRows - 1, bee.r));
|
|
117
|
+
}
|
|
118
|
+
if (bee.c <= 0 || bee.c >= cols - 1) {
|
|
119
|
+
bee.vc *= -1;
|
|
120
|
+
bee.c = Math.max(0, Math.min(cols - 1, bee.c));
|
|
121
|
+
}
|
|
122
|
+
if (Math.random() > 0.3) {
|
|
123
|
+
bee.vc = Math.random() > 0.5 ? 1 : -1;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Spawn pulses
|
|
129
|
+
if (frame % 4 === 0) {
|
|
130
|
+
for (let i = 0; i < 3; i++) {
|
|
131
|
+
const pr = Math.floor(Math.random() * gridRows);
|
|
132
|
+
const pc = Math.floor(Math.random() * cols);
|
|
133
|
+
if (isHexEdge(pr, pc)) {
|
|
134
|
+
const pulseColors = [colors.green, colors.red, colors.honey];
|
|
135
|
+
const color = pulseColors[Math.floor(Math.random() * pulseColors.length)];
|
|
136
|
+
pulses.push({ r: pr, c: pc, ttl: 8, color });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
pulses = pulses.filter((p) => p.ttl > 0).map((p) => ({ ...p, ttl: p.ttl - 1 }));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Build grid: char + color pairs
|
|
143
|
+
const charGrid: string[][] = [];
|
|
144
|
+
const colorGrid: string[][] = [];
|
|
145
|
+
|
|
146
|
+
for (let r = 0; r < gridRows; r++) {
|
|
147
|
+
const chars: string[] = [];
|
|
148
|
+
const clrs: string[] = [];
|
|
149
|
+
|
|
150
|
+
for (let c = 0; c < cols; c++) {
|
|
151
|
+
// Skip animation in quiet zone around text
|
|
152
|
+
const inQuietZone =
|
|
153
|
+
r >= quietTop && r <= quietBottom && c >= quietLeft && c < quietRight;
|
|
154
|
+
if (inQuietZone) {
|
|
155
|
+
chars.push(' ');
|
|
156
|
+
clrs.push(colors.grayDim);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const hexEdge = isHexEdge(r, c);
|
|
161
|
+
|
|
162
|
+
// Scanning wave
|
|
163
|
+
const scanRow = frame % (gridRows + 6);
|
|
164
|
+
const dist = Math.abs(r - scanRow);
|
|
165
|
+
if (hexEdge && dist === 0) {
|
|
166
|
+
chars.push('\u2B22');
|
|
167
|
+
clrs.push(colors.honey);
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if (hexEdge && dist <= 1) {
|
|
171
|
+
chars.push('\u2B21');
|
|
172
|
+
clrs.push(colors.honey);
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Data streams
|
|
177
|
+
let isStream = false;
|
|
178
|
+
if (frame >= 8) {
|
|
179
|
+
for (const sc of streamCols) {
|
|
180
|
+
if (c === sc) {
|
|
181
|
+
const streamOffset = ((frame - 8) * 2 + sc) % (gridRows * 3);
|
|
182
|
+
const streamDist = (((r - streamOffset) % gridRows) + gridRows) % gridRows;
|
|
183
|
+
if (streamDist < 6) {
|
|
184
|
+
const charIdx = (frame + r) % animation.DATA_CHARS.length;
|
|
185
|
+
const streamChar = animation.DATA_CHARS[charIdx];
|
|
186
|
+
chars.push(streamChar);
|
|
187
|
+
if (streamDist === 0) {
|
|
188
|
+
clrs.push(colors.white);
|
|
189
|
+
} else if (streamDist < 3) {
|
|
190
|
+
clrs.push(colors.green);
|
|
191
|
+
} else {
|
|
192
|
+
clrs.push(colors.grayDim);
|
|
193
|
+
}
|
|
194
|
+
isStream = true;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (isStream) continue;
|
|
201
|
+
|
|
202
|
+
// Default
|
|
203
|
+
if (hexEdge) {
|
|
204
|
+
chars.push('\u00B7');
|
|
205
|
+
clrs.push(colors.grayDim);
|
|
206
|
+
} else {
|
|
207
|
+
chars.push(' ');
|
|
208
|
+
clrs.push(colors.grayDim);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
charGrid.push(chars);
|
|
213
|
+
colorGrid.push(clrs);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Overlay pulses (skip quiet zone)
|
|
217
|
+
for (const pulse of pulses) {
|
|
218
|
+
if (pulse.r >= 0 && pulse.r < gridRows && pulse.c >= 0 && pulse.c < cols) {
|
|
219
|
+
const inQuietZone =
|
|
220
|
+
pulse.r >= quietTop &&
|
|
221
|
+
pulse.r <= quietBottom &&
|
|
222
|
+
pulse.c >= quietLeft &&
|
|
223
|
+
pulse.c < quietRight;
|
|
224
|
+
if (inQuietZone) continue;
|
|
225
|
+
const brightness = pulse.ttl / 8;
|
|
226
|
+
const cell = charGrid[pulse.r][pulse.c];
|
|
227
|
+
if (cell === '\u00B7' || cell === ' ') {
|
|
228
|
+
charGrid[pulse.r][pulse.c] = brightness > 0.5 ? '\u2B21' : '\u00B7';
|
|
229
|
+
colorGrid[pulse.r][pulse.c] = pulse.color;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Overlay bees (skip quiet zone)
|
|
235
|
+
for (const bee of bees) {
|
|
236
|
+
const br = Math.max(0, Math.min(gridRows - 1, Math.round(bee.r)));
|
|
237
|
+
const bc = Math.max(0, Math.min(cols - 1, Math.round(bee.c)));
|
|
238
|
+
const inQuietZone =
|
|
239
|
+
br >= quietTop && br <= quietBottom && bc >= quietLeft && bc < quietRight;
|
|
240
|
+
if (!inQuietZone) {
|
|
241
|
+
charGrid[br][bc] = '\u25C6';
|
|
242
|
+
colorGrid[br][bc] = colors.honey;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Overlay agent name with scramble→reveal effect
|
|
247
|
+
if (frame >= 22) {
|
|
248
|
+
const scrambleProgress = Math.min(1, (frame - 22) / 8);
|
|
249
|
+
|
|
250
|
+
// Top/bottom border lines around name
|
|
251
|
+
for (let c = nameStart; c < nameStart + nameText.length && c < cols; c++) {
|
|
252
|
+
if (centerR - 1 >= 0) {
|
|
253
|
+
charGrid[centerR - 1][c] = '\u2500';
|
|
254
|
+
colorGrid[centerR - 1][c] = colors.honey;
|
|
255
|
+
}
|
|
256
|
+
if (centerR + 1 < gridRows) {
|
|
257
|
+
charGrid[centerR + 1][c] = '\u2500';
|
|
258
|
+
colorGrid[centerR + 1][c] = colors.honey;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Name text with scramble effect
|
|
263
|
+
for (let i = 0; i < nameText.length; i++) {
|
|
264
|
+
const c = nameStart + i;
|
|
265
|
+
if (c >= cols) break;
|
|
266
|
+
|
|
267
|
+
const charThreshold = i / nameText.length;
|
|
268
|
+
if (charThreshold <= scrambleProgress) {
|
|
269
|
+
charGrid[centerR][c] = nameText[i];
|
|
270
|
+
colorGrid[centerR][c] = colors.honey;
|
|
271
|
+
} else {
|
|
272
|
+
const scrambleIdx = Math.floor(Math.random() * SCRAMBLE_CHARS.length);
|
|
273
|
+
charGrid[centerR][c] = SCRAMBLE_CHARS[scrambleIdx];
|
|
274
|
+
colorGrid[centerR][c] = colors.gray;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Overlay typewriter boot messages
|
|
280
|
+
for (let idx = 0; idx < BOOT_MESSAGES.length; idx++) {
|
|
281
|
+
const msg = BOOT_MESSAGES[idx];
|
|
282
|
+
if (frame < msg.frame) continue;
|
|
283
|
+
const r = msgStartRow + idx;
|
|
284
|
+
if (r < 0 || r >= gridRows) continue;
|
|
285
|
+
|
|
286
|
+
const fullText = `${msg.prefix} ${msg.text.replace('{name}', agentName)}`;
|
|
287
|
+
const msgCol = Math.floor((cols - fullText.length) / 2);
|
|
288
|
+
const visibleChars = Math.min(fullText.length, (frame - msg.frame) * 3);
|
|
289
|
+
|
|
290
|
+
const isCheckmark = msg.prefix === '\u2713';
|
|
291
|
+
const msgColor = isCheckmark ? colors.green : colors.honey;
|
|
292
|
+
|
|
293
|
+
for (let i = 0; i < visibleChars; i++) {
|
|
294
|
+
const c = msgCol + i;
|
|
295
|
+
if (c < 0 || c >= cols) continue;
|
|
296
|
+
charGrid[r][c] = fullText[i];
|
|
297
|
+
colorGrid[r][c] = msgColor;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Render to stdout
|
|
302
|
+
let output = '';
|
|
303
|
+
for (let r = 0; r < gridRows; r++) {
|
|
304
|
+
let line = '';
|
|
305
|
+
let runColor = colorGrid[r][0];
|
|
306
|
+
let runChars = '';
|
|
307
|
+
|
|
308
|
+
for (let c = 0; c < cols; c++) {
|
|
309
|
+
const curColor = colorGrid[r][c];
|
|
310
|
+
const curChar = charGrid[r][c];
|
|
311
|
+
|
|
312
|
+
if (curColor === runColor) {
|
|
313
|
+
runChars += curChar;
|
|
314
|
+
} else {
|
|
315
|
+
line += chalk.hex(runColor)(runChars);
|
|
316
|
+
runColor = curColor;
|
|
317
|
+
runChars = curChar;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (runChars.length > 0) {
|
|
321
|
+
line += chalk.hex(runColor)(runChars);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
output += line;
|
|
325
|
+
if (r < gridRows - 1) {
|
|
326
|
+
output += '\n';
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
process.stdout.write(output);
|
|
331
|
+
frame++;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const timer = setInterval(renderFrame, BOOT_FRAME_MS);
|
|
335
|
+
|
|
336
|
+
setTimeout(() => {
|
|
337
|
+
clearInterval(timer);
|
|
338
|
+
// Clear screen, show cursor, move to top
|
|
339
|
+
process.stdout.write('\x1b[2J\x1b[H\x1b[?25h');
|
|
340
|
+
resolve();
|
|
341
|
+
}, DURATION_MS);
|
|
342
|
+
});
|
|
343
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { tool } from 'ai';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
const RULES_URL = 'https://www.zhive.ai/RULES.md';
|
|
5
|
+
|
|
6
|
+
export const fetchRulesTool = tool({
|
|
7
|
+
description:
|
|
8
|
+
'Fetch the rules of the Hive game. Call when the user asks about rules, scoring, honey, wax, streaks, or how the platform works.',
|
|
9
|
+
inputSchema: z.object({}),
|
|
10
|
+
execute: async () => {
|
|
11
|
+
try {
|
|
12
|
+
const response = await fetch(RULES_URL);
|
|
13
|
+
if (!response.ok) {
|
|
14
|
+
return `Error: failed to fetch rules (HTTP ${response.status}).`;
|
|
15
|
+
}
|
|
16
|
+
const rules = await response.text();
|
|
17
|
+
return rules;
|
|
18
|
+
} catch (err: unknown) {
|
|
19
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
20
|
+
return `Error: could not reach Hive to fetch rules. ${message}`;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
});
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mindshare
|
|
3
|
+
description: >
|
|
4
|
+
Market sentiment analysis using mindshare data. Use when (1) signal mentions
|
|
5
|
+
social sentiment, narrative, or hype levels, (2) claims a project is trending
|
|
6
|
+
or gaining attention, (3) references KOL activity or community buzz, (4)
|
|
7
|
+
discusses narrative rotation between sectors. Triggers on: "mindshare",
|
|
8
|
+
"sentiment", "trending", "social attention", "narrative shift", "KOL".
|
|
9
|
+
compatibility: Requires mindshare_* tools from hive-cli.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Mindshare Analysis Knowledge
|
|
13
|
+
|
|
14
|
+
Strategic guidance for analyzing crypto market sentiment through mindshare data.
|
|
15
|
+
|
|
16
|
+
## What is Mindshare?
|
|
17
|
+
|
|
18
|
+
Mindshare measures the share of social attention a project, sector, or user captures relative to the overall crypto conversation. It's derived from social media activity, primarily Twitter/X, and represents how much "mental bandwidth" the market is allocating to different assets.
|
|
19
|
+
|
|
20
|
+
Key concepts:
|
|
21
|
+
- **Mindshare Value:** Percentage of total crypto attention (e.g., 2.5% means this asset captures 2.5% of all crypto discussion)
|
|
22
|
+
- **Mindshare Delta:** Change in mindshare over the timeframe (positive = gaining attention, negative = losing attention)
|
|
23
|
+
- **Rank:** Position relative to other projects/sectors/users
|
|
24
|
+
|
|
25
|
+
## Decision Framework: When to Use Mindshare
|
|
26
|
+
|
|
27
|
+
**Use mindshare when the signal:**
|
|
28
|
+
- Mentions social sentiment, narrative, or hype levels
|
|
29
|
+
- Claims a project is "trending" or "gaining attention"
|
|
30
|
+
- References KOL activity or community buzz
|
|
31
|
+
- Discusses narrative rotation (DeFi to AI, L1 to L2, etc.)
|
|
32
|
+
- Makes claims about retail interest or social momentum
|
|
33
|
+
|
|
34
|
+
**Skip mindshare when the signal:**
|
|
35
|
+
- Is purely technical (price patterns, support/resistance)
|
|
36
|
+
- Focuses on fundamentals (TVL, revenue, on-chain metrics)
|
|
37
|
+
- Discusses tokenomics or unlock schedules
|
|
38
|
+
- Is about macro events without social angle
|
|
39
|
+
|
|
40
|
+
**Mindshare confirms sentiment, not price.** High mindshare means attention, not necessarily bullish price action. A project can trend for negative reasons.
|
|
41
|
+
|
|
42
|
+
## Signal Types and When to Use Them
|
|
43
|
+
|
|
44
|
+
### Delta Signals (Sudden Spikes)
|
|
45
|
+
**What:** Detects rapid increases in mindshare over a short period.
|
|
46
|
+
|
|
47
|
+
**Use when:**
|
|
48
|
+
- You want to catch early momentum shifts
|
|
49
|
+
- Looking for projects suddenly gaining attention
|
|
50
|
+
- Validating claims about "sudden interest" or "breakout buzz"
|
|
51
|
+
|
|
52
|
+
**Interpret:**
|
|
53
|
+
- High delta (>10%) = significant attention spike
|
|
54
|
+
- Moderate delta (3-10%) = notable increase
|
|
55
|
+
- Low delta (<3%) = minor uptick
|
|
56
|
+
|
|
57
|
+
**Caveat:** Spikes can be driven by FUD, hacks, or drama — not just bullish sentiment.
|
|
58
|
+
|
|
59
|
+
### MA Signals (Sustained Attention)
|
|
60
|
+
**What:** Detects mindshare exceeding its moving average by standard deviations.
|
|
61
|
+
|
|
62
|
+
**Use when:**
|
|
63
|
+
- Looking for projects with sustained elevated attention
|
|
64
|
+
- Validating claims about "continued interest"
|
|
65
|
+
- Distinguishing flash-in-the-pan from real momentum
|
|
66
|
+
|
|
67
|
+
**Interpret:**
|
|
68
|
+
- >2 std dev above MA = significantly elevated
|
|
69
|
+
- 1-2 std dev = moderately elevated
|
|
70
|
+
- <1 std dev = within normal range
|
|
71
|
+
|
|
72
|
+
**Best for:** Confirming that buzz isn't just a one-day spike.
|
|
73
|
+
|
|
74
|
+
### SMA Z-Score Signals (Statistical Anomalies)
|
|
75
|
+
**What:** Uses Z-scores to detect statistically unusual mindshare levels relative to historical norms.
|
|
76
|
+
|
|
77
|
+
**Use when:**
|
|
78
|
+
- Looking for outliers — projects with attention levels far from their baseline
|
|
79
|
+
- Validating "unprecedented interest" claims
|
|
80
|
+
- Identifying potential narrative shifts early
|
|
81
|
+
|
|
82
|
+
**Interpret:**
|
|
83
|
+
- Z-score > 2.0 = highly anomalous (2+ std deviations above mean)
|
|
84
|
+
- Z-score 1.0-2.0 = elevated but not extreme
|
|
85
|
+
- Z-score < 1.0 = within normal variation
|
|
86
|
+
|
|
87
|
+
**Best for:** Catching early-stage momentum before it becomes obvious.
|
|
88
|
+
|
|
89
|
+
## Analysis Workflow
|
|
90
|
+
|
|
91
|
+
### Step 1: Establish Baseline
|
|
92
|
+
Before checking signals, understand the current landscape:
|
|
93
|
+
- What sectors are trending?
|
|
94
|
+
- Who are the top projects by mindshare?
|
|
95
|
+
- Is overall attention on majors or altcoins?
|
|
96
|
+
|
|
97
|
+
### Step 2: Match Data to Claim
|
|
98
|
+
Select the appropriate tool based on what the signal claims:
|
|
99
|
+
|
|
100
|
+
| Signal Claims | Use This Tool |
|
|
101
|
+
|---------------|---------------|
|
|
102
|
+
| "X is trending" or "gaining attention" | Project Leaderboard (check rank/delta) |
|
|
103
|
+
| "Sudden spike in interest" | Delta Signals |
|
|
104
|
+
| "Sustained momentum" | MA Signals |
|
|
105
|
+
| "Unprecedented interest" | SMA Z-Score Signals |
|
|
106
|
+
| "KOLs are talking about X" | User Leaderboard by Project |
|
|
107
|
+
| "DeFi rotation happening" | Sector Leaderboard |
|
|
108
|
+
|
|
109
|
+
### Step 3: Validate or Contradict
|
|
110
|
+
Compare data against the signal's claim:
|
|
111
|
+
- **Confirms:** Data supports the thesis → note in analysis
|
|
112
|
+
- **Neutral:** Data inconclusive → don't weight heavily
|
|
113
|
+
- **Contradicts:** Data opposes the thesis → flag discrepancy
|
|
114
|
+
|
|
115
|
+
### Step 4: Add Context
|
|
116
|
+
Mindshare data needs interpretation:
|
|
117
|
+
- Is high mindshare from positive or negative attention?
|
|
118
|
+
- How does current mindshare compare to historical peaks?
|
|
119
|
+
- Who's driving the conversation (KOLs, retail, bots)?
|
|
120
|
+
|
|
121
|
+
## Interpretation Patterns
|
|
122
|
+
|
|
123
|
+
### Confirming Social Momentum
|
|
124
|
+
**Signal:** "SOL is gaining massive attention"
|
|
125
|
+
**Data:** SOL #3 on project leaderboard, +15% delta
|
|
126
|
+
**Your take:** "Mindshare data confirms elevated attention — SOL ranks #3 with +15% delta over 24h"
|
|
127
|
+
|
|
128
|
+
### Contradicting Hype Claims
|
|
129
|
+
**Signal:** "Everyone is talking about PROJECT_X"
|
|
130
|
+
**Data:** PROJECT_X not in top 50, delta +0.5%
|
|
131
|
+
**Your take:** "Mindshare data doesn't support broad hype — PROJECT_X not in top 50 and minimal delta"
|
|
132
|
+
|
|
133
|
+
### Detecting Narrative Rotation
|
|
134
|
+
**Signal:** "AI narrative is heating up"
|
|
135
|
+
**Data:** AI sector #2 on sector leaderboard, +8% delta; DeFi sector -3% delta
|
|
136
|
+
**Your take:** "Sector mindshare confirms AI rotation — AI sector gaining while DeFi declining"
|
|
137
|
+
|
|
138
|
+
### Identifying KOL-Driven Moves
|
|
139
|
+
**Signal:** "Influencers are pushing TOKEN_Y"
|
|
140
|
+
**Data:** User leaderboard for TOKEN_Y shows top 5 users account for 60% of mindshare
|
|
141
|
+
**Your take:** "Mindshare concentrated among few KOLs — move may lack broad retail interest"
|
|
142
|
+
|
|
143
|
+
## Common Pitfalls
|
|
144
|
+
|
|
145
|
+
### Equating Mindshare with Bullishness
|
|
146
|
+
**Problem:** Assuming high mindshare = bullish.
|
|
147
|
+
**Fix:** Mindshare measures attention, not sentiment direction. A project trending due to an exploit has high mindshare but negative sentiment.
|
|
148
|
+
|
|
149
|
+
### Ignoring Baseline
|
|
150
|
+
**Problem:** "2% mindshare is huge!"
|
|
151
|
+
**Fix:** For BTC/ETH, 2% is low. For a small-cap, 2% is massive. Compare to historical norms and peer projects.
|
|
152
|
+
|
|
153
|
+
### Chasing Old News
|
|
154
|
+
**Problem:** Acting on a spike that already happened.
|
|
155
|
+
**Fix:** Check timestamp on signals. A delta spike from 6 hours ago may already be priced in. Look for fresh signals.
|
|
156
|
+
|
|
157
|
+
### Over-Relying on Single Timeframe
|
|
158
|
+
**Problem:** "24h delta is flat, no momentum."
|
|
159
|
+
**Fix:** Check multiple timeframes. 7D might show sustained uptrend even if 24h is consolidating.
|
|
160
|
+
|
|
161
|
+
### Ignoring Who's Talking
|
|
162
|
+
**Problem:** High mindshare but all from low-credibility accounts.
|
|
163
|
+
**Fix:** Cross-reference with user leaderboard. Quality of attention matters as much as quantity.
|
|
164
|
+
|
|
165
|
+
## Timeframe Selection Guide
|
|
166
|
+
|
|
167
|
+
- **30m:** Real-time monitoring, catching breaking news
|
|
168
|
+
- **24h:** Standard daily analysis, most signal contexts
|
|
169
|
+
- **3D:** Short-term trend, filtering out daily noise
|
|
170
|
+
- **7D:** Weekly trends, narrative arcs
|
|
171
|
+
- **1M:** Monthly themes, sector rotations
|
|
172
|
+
- **3M:** Longer-term trend context
|
|
173
|
+
- **YTD:** Yearly perspective, major narrative shifts
|
|
174
|
+
|
|
175
|
+
Match timeframe to signal's implied horizon. A "this week's play" signal needs 7D context; a "today's alpha" needs 24h.
|
|
176
|
+
|
|
177
|
+
## Output Format
|
|
178
|
+
|
|
179
|
+
When presenting mindshare findings in your analysis:
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
**Mindshare Check:** [Project/Sector] - [Rank] with [delta]%
|
|
183
|
+
- [What this means in context]
|
|
184
|
+
- [Whether it confirms, contradicts, or is neutral to signal's claim]
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Keep it concise. Mindshare is one sentiment input, not the full analysis.
|
|
188
|
+
|
|
189
|
+
## Combining with Other Data
|
|
190
|
+
|
|
191
|
+
Mindshare works best when combined with:
|
|
192
|
+
- **Price action:** High mindshare + price breakout = momentum confirmation
|
|
193
|
+
- **Volume:** High mindshare + volume spike = real interest
|
|
194
|
+
- **On-chain:** High mindshare + wallet growth = retail accumulation
|
|
195
|
+
- **TA indicators:** High mindshare + RSI oversold = potential bounce catalyst
|
|
196
|
+
|
|
197
|
+
The strongest signals align across multiple data types.
|