@zhive/cli 0.6.3 → 0.6.4

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 (101) hide show
  1. package/dist/CLAUDE.md +7 -0
  2. package/dist/backtest/CLAUDE.md +7 -0
  3. package/dist/cli.js +20 -0
  4. package/dist/commands/agent/commands/profile.js +3 -2
  5. package/dist/commands/agent/commands/profile.test.js +10 -12
  6. package/dist/commands/doctor/commands/index.js +93 -0
  7. package/dist/commands/megathread/commands/create-comment.js +4 -9
  8. package/dist/commands/megathread/commands/create-comment.test.js +15 -173
  9. package/dist/commands/megathread/commands/list.js +5 -5
  10. package/dist/commands/megathread/commands/list.test.js +14 -14
  11. package/dist/commands/start/commands/prediction.js +3 -4
  12. package/dist/commands/start/hooks/useChat.js +40 -41
  13. package/dist/commands/start/services/command-registry.js +1 -1
  14. package/dist/index.js +2 -0
  15. package/dist/{agent → services/agent}/analysis.js +5 -5
  16. package/dist/{load-agent-env.js → services/agent/env.js} +1 -1
  17. package/dist/{agent → services/agent/helpers}/model.js +2 -2
  18. package/dist/{agent → services/agent/prompts}/memory-prompt.js +20 -22
  19. package/dist/{agent → services/agent/prompts}/prompt.js +80 -54
  20. package/dist/{agent → services/agent}/tools/market/client.js +1 -1
  21. package/dist/{agent → services/agent}/tools/mindshare/client.js +1 -1
  22. package/dist/{agents.js → services/config/agent.js} +2 -2
  23. package/dist/{config.js → services/config/config.js} +1 -7
  24. package/dist/services/config/constant.js +8 -0
  25. package/dist/shared/agent/config.js +75 -0
  26. package/dist/shared/agent/env.js +30 -0
  27. package/dist/shared/agent/helpers/model.js +92 -0
  28. package/dist/shared/ai-providers.js +66 -0
  29. package/dist/shared/config/agent.js +0 -11
  30. package/dist/shared/config/agent.test.js +4 -35
  31. package/package.json +2 -2
  32. package/dist/agent/app.js +0 -122
  33. package/dist/agent/commands/registry.js +0 -12
  34. package/dist/agent/components/AsciiTicker.js +0 -81
  35. package/dist/agent/components/CommandInput.js +0 -65
  36. package/dist/agent/components/HoneycombBoot.js +0 -291
  37. package/dist/agent/components/Spinner.js +0 -37
  38. package/dist/agent/hooks/useAgent.js +0 -480
  39. package/dist/agent/objects.js +0 -1
  40. package/dist/agent/process-lifecycle.js +0 -18
  41. package/dist/agent/run-headless.js +0 -189
  42. package/dist/agent/theme.js +0 -41
  43. package/dist/avatar.js +0 -34
  44. package/dist/backtest/default-backtest-data.js +0 -200
  45. package/dist/backtest/fetch.js +0 -41
  46. package/dist/backtest/import.js +0 -106
  47. package/dist/backtest/index.js +0 -10
  48. package/dist/backtest/results.js +0 -113
  49. package/dist/backtest/runner.js +0 -134
  50. package/dist/backtest/storage.js +0 -11
  51. package/dist/backtest/types.js +0 -1
  52. package/dist/commands/install.js +0 -50
  53. package/dist/commands/start/ui/PollText.js +0 -23
  54. package/dist/commands/start/ui/PredictionsPanel.js +0 -88
  55. package/dist/commands/start/ui/SpinnerContext.js +0 -20
  56. package/dist/components/InputGuard.js +0 -6
  57. package/dist/components/stdout-spinner.js +0 -48
  58. package/dist/create/CreateApp.js +0 -153
  59. package/dist/create/ai-generate.js +0 -147
  60. package/dist/create/generate.js +0 -73
  61. package/dist/create/steps/ApiKeyStep.js +0 -97
  62. package/dist/create/steps/AvatarStep.js +0 -16
  63. package/dist/create/steps/BioStep.js +0 -14
  64. package/dist/create/steps/DoneStep.js +0 -14
  65. package/dist/create/steps/IdentityStep.js +0 -163
  66. package/dist/create/steps/NameStep.js +0 -71
  67. package/dist/create/steps/ScaffoldStep.js +0 -58
  68. package/dist/create/steps/SoulStep.js +0 -58
  69. package/dist/create/steps/StrategyStep.js +0 -58
  70. package/dist/create/validate-api-key.js +0 -47
  71. package/dist/create/welcome.js +0 -304
  72. package/dist/list/ListApp.js +0 -79
  73. package/dist/migrate-templates/MigrateApp.js +0 -131
  74. package/dist/migrate-templates/migrate.js +0 -86
  75. package/dist/presets.js +0 -613
  76. package/dist/start/AgentProcessManager.js +0 -98
  77. package/dist/start/Dashboard.js +0 -92
  78. package/dist/start/SelectAgentApp.js +0 -81
  79. package/dist/start/StartApp.js +0 -189
  80. package/dist/start/patch-headless.js +0 -101
  81. package/dist/start/patch-managed-mode.js +0 -142
  82. package/dist/start/start-command.js +0 -24
  83. package/dist/theme.js +0 -54
  84. /package/dist/{agent → services/agent}/config.js +0 -0
  85. /package/dist/{agent → services/agent}/helpers.js +0 -0
  86. /package/dist/{agent → services/agent/prompts}/chat-prompt.js +0 -0
  87. /package/dist/{agent → services/agent}/skills/index.js +0 -0
  88. /package/dist/{agent → services/agent}/skills/skill-parser.js +0 -0
  89. /package/dist/{agent → services/agent}/skills/types.js +0 -0
  90. /package/dist/{agent → services/agent/tools}/edit-section.js +0 -0
  91. /package/dist/{agent → services/agent/tools}/fetch-rules.js +0 -0
  92. /package/dist/{agent → services/agent}/tools/index.js +0 -0
  93. /package/dist/{agent → services/agent}/tools/market/index.js +0 -0
  94. /package/dist/{agent → services/agent}/tools/market/tools.js +0 -0
  95. /package/dist/{agent → services/agent}/tools/mindshare/index.js +0 -0
  96. /package/dist/{agent → services/agent}/tools/mindshare/tools.js +0 -0
  97. /package/dist/{agent → services/agent}/tools/read-skill-tool.js +0 -0
  98. /package/dist/{agent → services/agent}/tools/ta/index.js +0 -0
  99. /package/dist/{agent → services/agent}/tools/ta/indicators.js +0 -0
  100. /package/dist/{agent → services/agent}/types.js +0 -0
  101. /package/dist/{ai-providers.js → services/ai-providers.js} +0 -0
@@ -1,142 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
- import { fileURLToPath } from 'url';
4
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
5
- const TEMPLATES_DIR = path.resolve(__dirname, '../../templates');
6
- const MANAGED_MARKER = 'HIVE_MANAGED';
7
- const INTERACTIVE_GUARD_MARKER = 'Input Bar — only when stdin is a real TTY';
8
- /**
9
- * Patches an existing agent to support:
10
- * 1. Headless mode — skip TextInput when stdin is not a TTY (piped by dashboard)
11
- * 2. Managed mode — Escape exits back to dashboard when HIVE_MANAGED=1
12
- *
13
- * Idempotent — skips if already patched.
14
- */
15
- export async function ensureManagedMode(agentDir) {
16
- await patchProcessLifecycle(agentDir);
17
- await patchIndexTsx(agentDir);
18
- }
19
- async function patchProcessLifecycle(agentDir) {
20
- const filePath = path.join(agentDir, 'process-lifecycle.ts');
21
- const exists = await fs.pathExists(filePath);
22
- if (!exists) {
23
- return;
24
- }
25
- const content = await fs.readFile(filePath, 'utf-8');
26
- // Already patched if gracefulShutdown is exported
27
- if (content.includes('export const gracefulShutdown')) {
28
- return;
29
- }
30
- // Copy the template version (it has the export + exitCode param)
31
- const templatePath = path.join(TEMPLATES_DIR, 'process-lifecycle.ts');
32
- const templateExists = await fs.pathExists(templatePath);
33
- if (!templateExists) {
34
- return;
35
- }
36
- await fs.copyFile(templatePath, filePath);
37
- }
38
- async function patchIndexTsx(agentDir) {
39
- const filePath = path.join(agentDir, 'index.tsx');
40
- const exists = await fs.pathExists(filePath);
41
- if (!exists) {
42
- return;
43
- }
44
- let content = await fs.readFile(filePath, 'utf-8');
45
- // Already fully patched
46
- if (content.includes(MANAGED_MARKER) && content.includes(INTERACTIVE_GUARD_MARKER)) {
47
- return;
48
- }
49
- // 1. Add useInput to ink import if not present
50
- // Existing pattern: "import { render, Box, Text } from 'ink';"
51
- // Target: "import { render, Box, Text, useInput } from 'ink';"
52
- if (!content.includes('useInput')) {
53
- content = content.replace(/\s*}\s*from\s*'ink'/, ", useInput } from 'ink'");
54
- }
55
- // 2. Add gracefulShutdown import from process-lifecycle if not present
56
- if (!content.includes('gracefulShutdown')) {
57
- content = content.replace(/import\s*\{\s*setupProcessLifecycle\s*\}\s*from\s*'\.\/process-lifecycle'/, "import { setupProcessLifecycle, gracefulShutdown } from './process-lifecycle'");
58
- }
59
- // 3. Add isInteractive + managed mode hooks after useAgent() destructuring
60
- if (!content.includes(MANAGED_MARKER)) {
61
- const useAgentClose = '} = useAgent();';
62
- const hookInsertIndex = content.indexOf(useAgentClose);
63
- if (hookInsertIndex === -1) {
64
- return;
65
- }
66
- const insertAfter = hookInsertIndex + useAgentClose.length;
67
- const hooks = `
68
-
69
- // When stdin is not a TTY (piped by hive-cli start), skip interactive input
70
- const isInteractive = process.stdin.isTTY === true;
71
-
72
- // When managed by hive-cli start, Escape exits back to dashboard
73
- const isManaged = process.env.HIVE_MANAGED === '1';
74
-
75
- useInput((_input, key) => {
76
- if (isManaged && key.escape) {
77
- void gracefulShutdown(0);
78
- }
79
- }, { isActive: isManaged });`;
80
- content = content.slice(0, insertAfter) + hooks + content.slice(insertAfter);
81
- }
82
- // 4. Wrap TextInput in isInteractive guard
83
- // Replace the input bar section to conditionally render TextInput
84
- if (!content.includes(INTERACTIVE_GUARD_MARKER) && content.includes('<TextInput')) {
85
- // Find the Input Bar comment and replace the entire block
86
- const inputBarStart = content.indexOf('{/* Input Bar */}');
87
- if (inputBarStart === -1) {
88
- // Fallback: just wrap the TextInput line
89
- await fs.writeFile(filePath, content, 'utf-8');
90
- return;
91
- }
92
- // Find the closing </Box> of the bottom border (3 Box elements after Input Bar comment)
93
- // Pattern: <Box> separator </Box> <Box> TextInput </Box> <Box> bottom border </Box>
94
- let pos = inputBarStart;
95
- let boxCloseCount = 0;
96
- const boxCloseTag = '</Box>';
97
- while (boxCloseCount < 3 && pos < content.length) {
98
- const nextClose = content.indexOf(boxCloseTag, pos);
99
- if (nextClose === -1) {
100
- break;
101
- }
102
- pos = nextClose + boxCloseTag.length;
103
- boxCloseCount++;
104
- }
105
- if (boxCloseCount === 3) {
106
- const inputBarEnd = pos;
107
- const replacement = `{/* Input Bar — only when stdin is a real TTY */}
108
- <Box>
109
- <Text color="gray">
110
- {isInteractive ? border.teeLeft : border.bottomLeft}
111
- {border.horizontal.repeat(boxWidth - 2)}
112
- {isInteractive ? border.teeRight : border.bottomRight}
113
- </Text>
114
- </Box>
115
- {isInteractive && (
116
- <>
117
- <Box paddingLeft={1}>
118
- <Text color={colors.honey}>{symbols.arrow} </Text>
119
- <TextInput
120
- value={input}
121
- onChange={setInput}
122
- onSubmit={(val) => {
123
- setInput('');
124
- void handleChatSubmit(val);
125
- }}
126
- placeholder={chatStreaming ? 'thinking...' : \`chat with \${agentName} agent...\`}
127
- />
128
- </Box>
129
- <Box>
130
- <Text color="gray">
131
- {border.bottomLeft}
132
- {border.horizontal.repeat(boxWidth - 2)}
133
- {border.bottomRight}
134
- </Text>
135
- </Box>
136
- </>
137
- )}`;
138
- content = content.slice(0, inputBarStart) + replacement + content.slice(inputBarEnd);
139
- }
140
- }
141
- await fs.writeFile(filePath, content, 'utf-8');
142
- }
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import { render } from 'ink';
3
- import { showWelcome } from '../create/welcome.js';
4
- import { scanAgents, fetchBulkStats, sortAgentsByHoney } from '../agents.js';
5
- import { symbols, styled } from '../theme.js';
6
- import { AgentProcessManager } from './AgentProcessManager.js';
7
- import { Dashboard } from './Dashboard.js';
8
- export async function startCommand() {
9
- // Run welcome animation and scan agents in parallel
10
- const results = await Promise.all([showWelcome(), scanAgents()]);
11
- const discovered = results[1];
12
- if (discovered.length === 0) {
13
- console.log(`\n ${styled.honey(symbols.hive)} ${styled.red('No agents found in ~/.hive/agents/')}\n`);
14
- console.log(` ${styled.gray('Create agents with:')} ${styled.white('npx @hive-org/cli@latest create')}\n`);
15
- return;
16
- }
17
- const names = discovered.map((a) => a.name);
18
- const statsMap = await fetchBulkStats(names);
19
- const sortedDiscovered = sortAgentsByHoney(discovered, statsMap);
20
- const manager = new AgentProcessManager();
21
- manager.spawnAll(sortedDiscovered);
22
- const { waitUntilExit } = render(React.createElement(Dashboard, { manager, statsMap }));
23
- await waitUntilExit();
24
- }
package/dist/theme.js DELETED
@@ -1,54 +0,0 @@
1
- import chalk from 'chalk';
2
- export const colors = {
3
- honey: '#F5A623',
4
- honeyDark: '#D4891A',
5
- honeyBright: '#FFD700',
6
- white: '#FFFFFF',
7
- gray: '#A6A6A6',
8
- grayDim: '#555555',
9
- green: '#27C587',
10
- red: '#E14B4B',
11
- wax: '#C45C5C',
12
- cyan: '#22D3EE',
13
- hot: '#FB923C',
14
- controversial: '#C084FC',
15
- };
16
- export const symbols = {
17
- hive: '\u2B21', // ⬡
18
- diamond: '\u25C6', // ◆
19
- diamondOpen: '\u25C7', // ◇
20
- dot: '\u25CF', // ●
21
- spinner: ['\u25D0', '\u25D3', '\u25D1', '\u25D2'], // ◐ ◓ ◑ ◒
22
- check: '\u2713', // ✓
23
- cross: '\u2717', // ✗
24
- arrow: '\u203A', // ›
25
- };
26
- export const border = {
27
- horizontal: '\u2500', // ─
28
- vertical: '\u2502', // │
29
- topLeft: '\u250C', // ┌
30
- topRight: '\u2510', // ┐
31
- bottomLeft: '\u2514', // └
32
- bottomRight: '\u2518', // ┘
33
- teeLeft: '\u251C', // ├
34
- teeRight: '\u2524', // ┤
35
- };
36
- export const animation = {
37
- DATA_CHARS: '01▪▫░▒',
38
- HEX_CHARS: '⬡⬢',
39
- TICK_MS: 120,
40
- };
41
- export const styled = {
42
- honey: (text) => chalk.hex(colors.honey)(text),
43
- honeyBold: (text) => chalk.hex(colors.honey).bold(text),
44
- white: (text) => chalk.white(text),
45
- whiteBold: (text) => chalk.bold.white(text),
46
- gray: (text) => chalk.gray(text),
47
- dim: (text) => chalk.hex(colors.grayDim)(text),
48
- green: (text) => chalk.hex(colors.green)(text),
49
- red: (text) => chalk.hex(colors.red)(text),
50
- wax: (text) => chalk.hex(colors.wax)(text),
51
- cyan: (text) => chalk.hex(colors.cyan)(text),
52
- hot: (text) => chalk.hex(colors.hot)(text),
53
- controversial: (text) => chalk.hex(colors.controversial)(text),
54
- };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes