@zhive/cli 0.6.3 → 0.6.5

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 (103) 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/create-comments.js +83 -0
  10. package/dist/commands/megathread/commands/index.js +2 -0
  11. package/dist/commands/megathread/commands/list.js +5 -5
  12. package/dist/commands/megathread/commands/list.test.js +14 -14
  13. package/dist/commands/start/commands/prediction.js +3 -4
  14. package/dist/commands/start/hooks/useChat.js +40 -41
  15. package/dist/commands/start/services/command-registry.js +1 -1
  16. package/dist/index.js +2 -0
  17. package/dist/{agent → services/agent}/analysis.js +5 -5
  18. package/dist/{load-agent-env.js → services/agent/env.js} +1 -1
  19. package/dist/{agent → services/agent/helpers}/model.js +2 -2
  20. package/dist/{agent → services/agent/prompts}/memory-prompt.js +20 -22
  21. package/dist/{agent → services/agent/prompts}/prompt.js +80 -54
  22. package/dist/{agent → services/agent}/tools/market/client.js +1 -1
  23. package/dist/{agent → services/agent}/tools/mindshare/client.js +1 -1
  24. package/dist/{agents.js → services/config/agent.js} +2 -2
  25. package/dist/{config.js → services/config/config.js} +1 -7
  26. package/dist/services/config/constant.js +8 -0
  27. package/dist/shared/agent/config.js +75 -0
  28. package/dist/shared/agent/env.js +30 -0
  29. package/dist/shared/agent/helpers/model.js +92 -0
  30. package/dist/shared/ai-providers.js +66 -0
  31. package/dist/shared/config/agent.js +0 -11
  32. package/dist/shared/config/agent.test.js +4 -35
  33. package/package.json +2 -2
  34. package/dist/agent/app.js +0 -122
  35. package/dist/agent/commands/registry.js +0 -12
  36. package/dist/agent/components/AsciiTicker.js +0 -81
  37. package/dist/agent/components/CommandInput.js +0 -65
  38. package/dist/agent/components/HoneycombBoot.js +0 -291
  39. package/dist/agent/components/Spinner.js +0 -37
  40. package/dist/agent/hooks/useAgent.js +0 -480
  41. package/dist/agent/objects.js +0 -1
  42. package/dist/agent/process-lifecycle.js +0 -18
  43. package/dist/agent/run-headless.js +0 -189
  44. package/dist/agent/theme.js +0 -41
  45. package/dist/avatar.js +0 -34
  46. package/dist/backtest/default-backtest-data.js +0 -200
  47. package/dist/backtest/fetch.js +0 -41
  48. package/dist/backtest/import.js +0 -106
  49. package/dist/backtest/index.js +0 -10
  50. package/dist/backtest/results.js +0 -113
  51. package/dist/backtest/runner.js +0 -134
  52. package/dist/backtest/storage.js +0 -11
  53. package/dist/backtest/types.js +0 -1
  54. package/dist/commands/install.js +0 -50
  55. package/dist/commands/start/ui/PollText.js +0 -23
  56. package/dist/commands/start/ui/PredictionsPanel.js +0 -88
  57. package/dist/commands/start/ui/SpinnerContext.js +0 -20
  58. package/dist/components/InputGuard.js +0 -6
  59. package/dist/components/stdout-spinner.js +0 -48
  60. package/dist/create/CreateApp.js +0 -153
  61. package/dist/create/ai-generate.js +0 -147
  62. package/dist/create/generate.js +0 -73
  63. package/dist/create/steps/ApiKeyStep.js +0 -97
  64. package/dist/create/steps/AvatarStep.js +0 -16
  65. package/dist/create/steps/BioStep.js +0 -14
  66. package/dist/create/steps/DoneStep.js +0 -14
  67. package/dist/create/steps/IdentityStep.js +0 -163
  68. package/dist/create/steps/NameStep.js +0 -71
  69. package/dist/create/steps/ScaffoldStep.js +0 -58
  70. package/dist/create/steps/SoulStep.js +0 -58
  71. package/dist/create/steps/StrategyStep.js +0 -58
  72. package/dist/create/validate-api-key.js +0 -47
  73. package/dist/create/welcome.js +0 -304
  74. package/dist/list/ListApp.js +0 -79
  75. package/dist/migrate-templates/MigrateApp.js +0 -131
  76. package/dist/migrate-templates/migrate.js +0 -86
  77. package/dist/presets.js +0 -613
  78. package/dist/start/AgentProcessManager.js +0 -98
  79. package/dist/start/Dashboard.js +0 -92
  80. package/dist/start/SelectAgentApp.js +0 -81
  81. package/dist/start/StartApp.js +0 -189
  82. package/dist/start/patch-headless.js +0 -101
  83. package/dist/start/patch-managed-mode.js +0 -142
  84. package/dist/start/start-command.js +0 -24
  85. package/dist/theme.js +0 -54
  86. /package/dist/{agent → services/agent}/config.js +0 -0
  87. /package/dist/{agent → services/agent}/helpers.js +0 -0
  88. /package/dist/{agent → services/agent/prompts}/chat-prompt.js +0 -0
  89. /package/dist/{agent → services/agent}/skills/index.js +0 -0
  90. /package/dist/{agent → services/agent}/skills/skill-parser.js +0 -0
  91. /package/dist/{agent → services/agent}/skills/types.js +0 -0
  92. /package/dist/{agent → services/agent/tools}/edit-section.js +0 -0
  93. /package/dist/{agent → services/agent/tools}/fetch-rules.js +0 -0
  94. /package/dist/{agent → services/agent}/tools/index.js +0 -0
  95. /package/dist/{agent → services/agent}/tools/market/index.js +0 -0
  96. /package/dist/{agent → services/agent}/tools/market/tools.js +0 -0
  97. /package/dist/{agent → services/agent}/tools/mindshare/index.js +0 -0
  98. /package/dist/{agent → services/agent}/tools/mindshare/tools.js +0 -0
  99. /package/dist/{agent → services/agent}/tools/read-skill-tool.js +0 -0
  100. /package/dist/{agent → services/agent}/tools/ta/index.js +0 -0
  101. /package/dist/{agent → services/agent}/tools/ta/indicators.js +0 -0
  102. /package/dist/{agent → services/agent}/types.js +0 -0
  103. /package/dist/{ai-providers.js → services/ai-providers.js} +0 -0
@@ -1,131 +0,0 @@
1
- import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useState, useEffect, useCallback } from 'react';
3
- import { Box, Text, useInput, useApp } from 'ink';
4
- import { scanAgents } from '../agents.js';
5
- import { colors, symbols, styled, border } from '../theme.js';
6
- import { isOldStyleAgent, migrateAgent } from './migrate.js';
7
- export function MigrateApp() {
8
- const { exit } = useApp();
9
- const [phase, setPhase] = useState('scanning');
10
- const [agents, setAgents] = useState([]);
11
- const [cursor, setCursor] = useState(0);
12
- const [results, setResults] = useState([]);
13
- const [currentStep, setCurrentStep] = useState('');
14
- const [currentAgent, setCurrentAgent] = useState('');
15
- // ─── Scan phase ────────────────────────────────────
16
- useEffect(() => {
17
- const scan = async () => {
18
- const discovered = await scanAgents();
19
- if (discovered.length === 0) {
20
- setPhase('done');
21
- return;
22
- }
23
- const selectableAgents = discovered.map((info) => {
24
- const oldStyle = isOldStyleAgent(info.dir);
25
- return {
26
- info,
27
- selected: oldStyle,
28
- isOldStyle: oldStyle,
29
- };
30
- });
31
- const hasOldStyle = selectableAgents.some((a) => a.isOldStyle);
32
- if (!hasOldStyle) {
33
- setResults(selectableAgents.map((a) => ({
34
- name: a.info.name,
35
- success: true,
36
- error: 'Already migrated',
37
- })));
38
- setPhase('done');
39
- return;
40
- }
41
- setAgents(selectableAgents);
42
- setPhase('selecting');
43
- };
44
- scan().catch((err) => {
45
- const message = err instanceof Error ? err.message : String(err);
46
- setResults([{ name: 'scan', success: false, error: message }]);
47
- setPhase('done');
48
- });
49
- }, []);
50
- // ─── Keyboard input (selecting phase) ──────────────
51
- useInput((input, key) => {
52
- if (phase !== 'selecting')
53
- return;
54
- const oldStyleAgents = agents.filter((a) => a.isOldStyle);
55
- if (key.upArrow) {
56
- setCursor((prev) => Math.max(0, prev - 1));
57
- }
58
- else if (key.downArrow) {
59
- setCursor((prev) => Math.min(oldStyleAgents.length - 1, prev + 1));
60
- }
61
- else if (input === ' ') {
62
- // Toggle selection
63
- const targetName = oldStyleAgents[cursor]?.info.name;
64
- if (targetName) {
65
- setAgents((prev) => prev.map((a) => a.info.name === targetName ? { ...a, selected: !a.selected } : a));
66
- }
67
- }
68
- else if (key.return) {
69
- const selected = agents.filter((a) => a.selected && a.isOldStyle);
70
- if (selected.length > 0) {
71
- setPhase('migrating');
72
- runMigrations(selected);
73
- }
74
- }
75
- else if (input === 'q' || key.escape) {
76
- exit();
77
- }
78
- }, { isActive: phase === 'selecting' });
79
- // ─── Migrate phase ─────────────────────────────────
80
- const runMigrations = useCallback(async (selected) => {
81
- const migrateResults = [];
82
- for (const agent of selected) {
83
- setCurrentAgent(agent.info.name);
84
- setCurrentStep('Starting migration');
85
- const result = await migrateAgent(agent.info.dir, agent.info.name, (step) => {
86
- setCurrentStep(step);
87
- });
88
- migrateResults.push(result);
89
- setResults([...migrateResults]);
90
- }
91
- setCurrentAgent('');
92
- setCurrentStep('');
93
- setPhase('done');
94
- }, []);
95
- // ─── Done phase — exit after a short delay ─────────
96
- useEffect(() => {
97
- if (phase === 'done') {
98
- const timer = setTimeout(() => {
99
- exit();
100
- }, 1500);
101
- return () => {
102
- clearTimeout(timer);
103
- };
104
- }
105
- }, [phase, exit]);
106
- // ─── Render ────────────────────────────────────────
107
- const termWidth = process.stdout.columns || 60;
108
- if (phase === 'scanning') {
109
- return (_jsx(Box, { flexDirection: "column", paddingLeft: 1, children: _jsxs(Text, { color: colors.honey, children: [symbols.hive, " Scanning agents..."] }) }));
110
- }
111
- if (phase === 'selecting') {
112
- const oldStyleAgents = agents.filter((a) => a.isOldStyle);
113
- const newStyleAgents = agents.filter((a) => !a.isOldStyle);
114
- return (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [_jsxs(Text, { color: colors.honey, bold: true, children: [symbols.hive, " Migrate agents to @hive-org/cli"] }), _jsx(Text, { color: colors.gray, children: border.horizontal.repeat(termWidth - 4) }), _jsxs(Text, { color: colors.gray, children: ["Use ", styled.white('↑↓'), " to navigate, ", styled.white('space'), " to toggle, ", styled.white('enter'), " to confirm"] }), _jsx(Text, { children: " " }), oldStyleAgents.map((agent, i) => {
115
- const isCursor = i === cursor;
116
- const prefix = agent.selected ? symbols.check : symbols.diamondOpen;
117
- const prefixColor = agent.selected ? colors.green : colors.gray;
118
- const nameColor = isCursor ? colors.white : colors.gray;
119
- const cursorChar = isCursor ? symbols.arrow : ' ';
120
- return (_jsxs(Box, { children: [_jsxs(Text, { color: colors.honey, children: [cursorChar, " "] }), _jsxs(Text, { color: prefixColor, children: [prefix, " "] }), _jsx(Text, { color: nameColor, bold: isCursor, children: agent.info.name }), _jsxs(Text, { color: colors.gray, children: [" (", agent.info.provider, ")"] })] }, agent.info.name));
121
- }), newStyleAgents.length > 0 && (_jsxs(_Fragment, { children: [_jsx(Text, { children: " " }), _jsx(Text, { color: colors.gray, children: "Already migrated:" }), newStyleAgents.map((agent) => (_jsx(Box, { children: _jsxs(Text, { color: colors.gray, children: [' ', symbols.check, " ", agent.info.name] }) }, agent.info.name)))] })), _jsx(Text, { children: " " }), _jsx(Text, { color: colors.gray, children: styled.dim('q/esc to cancel') })] }));
122
- }
123
- if (phase === 'migrating') {
124
- return (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [_jsxs(Text, { color: colors.honey, bold: true, children: [symbols.hive, " Migrating agents..."] }), _jsx(Text, { color: colors.gray, children: border.horizontal.repeat(termWidth - 4) }), results.map((r) => (_jsx(Box, { children: _jsxs(Text, { color: r.success ? colors.green : colors.red, children: [r.success ? symbols.check : symbols.cross, " ", r.name] }) }, r.name))), currentAgent && (_jsx(Box, { children: _jsxs(Text, { color: colors.honey, children: [symbols.diamond, " ", currentAgent, ": ", currentStep] }) }))] }));
125
- }
126
- // phase === 'done'
127
- const successCount = results.filter((r) => r.success && !r.error).length;
128
- const alreadyNew = results.filter((r) => r.error === 'Already migrated').length;
129
- const failCount = results.filter((r) => !r.success).length;
130
- return (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [_jsxs(Text, { color: colors.honey, bold: true, children: [symbols.hive, " Migration complete"] }), _jsx(Text, { color: colors.gray, children: border.horizontal.repeat(termWidth - 4) }), results.map((r) => (_jsxs(Box, { children: [r.success && !r.error && (_jsxs(Text, { color: colors.green, children: [symbols.check, " ", r.name, " \u2014 migrated"] })), r.error === 'Already migrated' && (_jsxs(Text, { color: colors.gray, children: [symbols.check, " ", r.name, " \u2014 already migrated"] })), !r.success && r.error !== 'Already migrated' && (_jsxs(Text, { color: colors.red, children: [symbols.cross, " ", r.name, " \u2014 ", r.error] }))] }, r.name))), agents.length === 0 && results.length === 0 && (_jsx(Text, { color: colors.gray, children: "No agents found in ~/.hive/agents/" })), _jsx(Text, { children: " " }), successCount > 0 && (_jsxs(Text, { color: colors.gray, children: ["Agents now run via @hive-org/cli. ", styled.white('npx @hive-org/cli@latest start'), " always uses the latest version."] }))] }));
131
- }
@@ -1,86 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
- /** Files scaffolded by the old `hive create` that are now in @hive-org/cli */
4
- const OLD_FILES = [
5
- 'index.tsx',
6
- 'analysis.ts',
7
- 'prompt.ts',
8
- 'chat-prompt.ts',
9
- 'memory-prompt.ts',
10
- 'edit-section.ts',
11
- 'fetch-rules.ts',
12
- 'helpers.ts',
13
- 'theme.ts',
14
- 'types.ts',
15
- 'process-lifecycle.ts',
16
- 'tsconfig.json',
17
- ];
18
- /** Directories scaffolded by the old `hive create` */
19
- const OLD_DIRS = ['hooks', 'components', 'hive'];
20
- export function isOldStyleAgent(agentDir) {
21
- const indexPath = path.join(agentDir, 'index.tsx');
22
- return fs.pathExistsSync(indexPath);
23
- }
24
- export async function migrateAgent(agentDir, name, onStep) {
25
- try {
26
- // 1. Verify it's a valid agent
27
- const soulPath = path.join(agentDir, 'SOUL.md');
28
- const soulExists = await fs.pathExists(soulPath);
29
- if (!soulExists) {
30
- return { name, success: false, error: 'No SOUL.md found — not a valid agent' };
31
- }
32
- // 2. Delete old scaffolded files
33
- onStep('Removing old runtime files');
34
- for (const file of OLD_FILES) {
35
- const filePath = path.join(agentDir, file);
36
- const exists = await fs.pathExists(filePath);
37
- if (exists) {
38
- await fs.remove(filePath);
39
- }
40
- }
41
- // 3. Delete old directories
42
- onStep('Removing old directories');
43
- for (const dir of OLD_DIRS) {
44
- const dirPath = path.join(agentDir, dir);
45
- const exists = await fs.pathExists(dirPath);
46
- if (exists) {
47
- await fs.remove(dirPath);
48
- }
49
- }
50
- // 4. Rewrite package.json
51
- onStep('Rewriting package.json');
52
- const pkgPath = path.join(agentDir, 'package.json');
53
- const pkgExists = await fs.pathExists(pkgPath);
54
- let pkgName = `hive-agent-${name}`;
55
- if (pkgExists) {
56
- const oldPkg = await fs.readJson(pkgPath);
57
- pkgName = oldPkg.name ?? pkgName;
58
- }
59
- const newPkg = {
60
- name: pkgName,
61
- private: true,
62
- type: 'module',
63
- scripts: {
64
- start: 'npx @hive-org/cli@latest start',
65
- },
66
- };
67
- await fs.writeJson(pkgPath, newPkg, { spaces: 2 });
68
- // 5. Remove old node_modules and lock files (no longer needed)
69
- onStep('Cleaning up old dependencies');
70
- const nodeModulesPath = path.join(agentDir, 'node_modules');
71
- const nodeModulesExists = await fs.pathExists(nodeModulesPath);
72
- if (nodeModulesExists) {
73
- await fs.remove(nodeModulesPath);
74
- }
75
- const lockPath = path.join(agentDir, 'package-lock.json');
76
- const lockExists = await fs.pathExists(lockPath);
77
- if (lockExists) {
78
- await fs.remove(lockPath);
79
- }
80
- return { name, success: true };
81
- }
82
- catch (err) {
83
- const message = err instanceof Error ? err.message : String(err);
84
- return { name, success: false, error: message.slice(0, 200) };
85
- }
86
- }