@zhive/cli 0.6.7 → 0.6.9

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 (70) 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 -9
  5. package/dist/commands/create/commands/index.js +2 -5
  6. package/dist/commands/create/generate.js +18 -22
  7. package/dist/commands/create/presets.js +613 -0
  8. package/dist/commands/create/ui/CreateApp.js +2 -2
  9. package/dist/commands/create/ui/steps/ScaffoldStep.js +17 -2
  10. package/dist/commands/indicator/commands/bollinger.js +37 -0
  11. package/dist/commands/indicator/commands/ema.js +37 -0
  12. package/dist/commands/indicator/commands/index.js +14 -0
  13. package/dist/commands/indicator/commands/macd.js +51 -0
  14. package/dist/commands/indicator/commands/rsi.js +37 -0
  15. package/dist/commands/indicator/commands/sma.js +37 -0
  16. package/dist/commands/market/commands/index.js +5 -0
  17. package/dist/commands/market/commands/price.js +25 -0
  18. package/dist/commands/shared/utils.js +12 -0
  19. package/dist/commands/start/ui/AsciiTicker.js +81 -0
  20. package/dist/index.js +4 -0
  21. package/dist/services/agent/analysis.js +160 -0
  22. package/dist/services/agent/config.js +75 -0
  23. package/dist/services/agent/env.js +30 -0
  24. package/dist/services/agent/helpers/model.js +92 -0
  25. package/dist/services/agent/helpers.js +22 -0
  26. package/dist/services/agent/prompts/chat-prompt.js +65 -0
  27. package/dist/services/agent/prompts/memory-prompt.js +45 -0
  28. package/dist/services/agent/prompts/prompt.js +379 -0
  29. package/dist/services/agent/skills/index.js +2 -0
  30. package/dist/services/agent/skills/skill-parser.js +149 -0
  31. package/dist/services/agent/skills/types.js +1 -0
  32. package/dist/services/agent/tools/edit-section.js +59 -0
  33. package/dist/services/agent/tools/fetch-rules.js +21 -0
  34. package/dist/services/agent/tools/index.js +76 -0
  35. package/dist/services/agent/tools/market/client.js +41 -0
  36. package/dist/services/agent/tools/market/index.js +3 -0
  37. package/dist/services/agent/tools/market/tools.js +518 -0
  38. package/dist/services/agent/tools/mindshare/client.js +124 -0
  39. package/dist/services/agent/tools/mindshare/index.js +3 -0
  40. package/dist/services/agent/tools/mindshare/tools.js +563 -0
  41. package/dist/services/agent/tools/read-skill-tool.js +30 -0
  42. package/dist/services/agent/tools/ta/index.js +1 -0
  43. package/dist/services/agent/tools/ta/indicators.js +201 -0
  44. package/dist/services/agent/types.js +1 -0
  45. package/dist/services/ai-providers.js +66 -0
  46. package/dist/services/config/agent.js +110 -0
  47. package/dist/services/config/config.js +22 -0
  48. package/dist/services/config/constant.js +8 -0
  49. package/dist/shared/agent/agent-runtime.js +144 -0
  50. package/dist/shared/agent/analysis.js +2 -12
  51. package/dist/shared/agent/cache.js +10 -0
  52. package/dist/shared/agent/config.js +75 -0
  53. package/dist/shared/agent/env.js +30 -0
  54. package/dist/shared/agent/handler.js +3 -9
  55. package/dist/shared/agent/helpers/model.js +92 -0
  56. package/dist/shared/agent/prompts/megathread.js +0 -8
  57. package/dist/shared/agent/tools/execute-skill-tool.js +2 -1
  58. package/dist/shared/agent/tools/formatting.js +0 -19
  59. package/dist/shared/agent/tools/market/client.js +3 -3
  60. package/dist/shared/agent/tools/market/tools.js +88 -312
  61. package/dist/shared/agent/tools/market/utils.js +71 -0
  62. package/dist/shared/agent/tools/mindshare/tools.js +1 -1
  63. package/dist/shared/agent/tools/ta/index.js +3 -1
  64. package/dist/shared/agent/types.js +1 -0
  65. package/dist/shared/agent/utils.js +44 -0
  66. package/dist/shared/ai-providers.js +66 -0
  67. package/dist/shared/ta/error.js +12 -0
  68. package/dist/shared/ta/service.js +93 -0
  69. package/dist/shared/ta/utils.js +16 -0
  70. package/package.json +3 -2
package/dist/CLAUDE.md ADDED
@@ -0,0 +1,7 @@
1
+ <claude-mem-context>
2
+ # Recent Activity
3
+
4
+ <!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
5
+
6
+ *No recent activity*
7
+ </claude-mem-context>
@@ -0,0 +1,7 @@
1
+ <claude-mem-context>
2
+ # Recent Activity
3
+
4
+ <!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
5
+
6
+ *No recent activity*
7
+ </claude-mem-context>
package/dist/cli.js ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import { createRequire } from 'module';
4
+ import { createCreateCommand } from './commands/create/commands/index.js';
5
+ import { createListCommand } from './commands/list/commands/index.js';
6
+ import { createStartCommand } from './commands/start/commands/index.js';
7
+ import { createStartAllCommand } from './commands/start-all/commands/index.js';
8
+ import { createRunCommand } from './commands/run/commands/index.js';
9
+ import { createMigrateTemplatesCommand } from './commands/migrate-templates/commands/index.js';
10
+ const require = createRequire(import.meta.url);
11
+ const packageJson = require('../package.json');
12
+ const program = new Command();
13
+ program.name('@zhive/cli').version(packageJson.version);
14
+ program.addCommand(createCreateCommand());
15
+ program.addCommand(createListCommand());
16
+ program.addCommand(createStartCommand());
17
+ program.addCommand(createStartAllCommand());
18
+ program.addCommand(createRunCommand());
19
+ program.addCommand(createMigrateTemplatesCommand());
20
+ program.parse(process.argv);
@@ -1,6 +1,7 @@
1
1
  import { Command } from 'commander';
2
- import { findAgentByName, scanAgents } from '../../../shared/config/agent.js';
2
+ import { findAgentByName } from '../../../shared/config/agent.js';
3
3
  import { styled, symbols } from '../../shared/theme.js';
4
+ import { printAgentNotFoundHelper } from '../../shared/utils.js';
4
5
  export const createAgentProfileCommand = () => {
5
6
  return new Command('profile')
6
7
  .description('Display agent profile information')
@@ -8,14 +9,7 @@ export const createAgentProfileCommand = () => {
8
9
  .action(async (agentName) => {
9
10
  const agentConfig = await findAgentByName(agentName);
10
11
  if (!agentConfig) {
11
- const agents = await scanAgents();
12
- if (agents.length === 0) {
13
- console.error(styled.red(`${symbols.cross} No agents found. Create one with: npx @zhive/cli@latest create`));
14
- }
15
- else {
16
- const availableNames = agents.map((a) => a.name).join(', ');
17
- console.error(styled.red(`${symbols.cross} Agent "${agentName}" not found. Available agents: ${availableNames}`));
18
- }
12
+ await printAgentNotFoundHelper(agentName);
19
13
  process.exit(1);
20
14
  }
21
15
  console.log('');
@@ -4,12 +4,9 @@ import React from 'react';
4
4
  import { showWelcome } from '../../shared/welcome.js';
5
5
  import { CreateApp } from '../ui/CreateApp.js';
6
6
  export const createCreateCommand = () => {
7
- return new Command('create')
8
- .description('Scaffold a new zHive agent')
9
- .argument('<agent-name>', 'agent name')
10
- .action(async (agentName) => {
7
+ return new Command('create').description('Scaffold a new zHive agent').action(async () => {
11
8
  await showWelcome();
12
- const { waitUntilExit } = render(React.createElement(CreateApp, { initialName: agentName }));
9
+ const { waitUntilExit } = render(React.createElement(CreateApp));
13
10
  await waitUntilExit();
14
11
  });
15
12
  };
@@ -2,16 +2,17 @@ import fs from 'fs-extra';
2
2
  import path from 'path';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import { getHiveDir } from '../../shared/config/constant.js';
5
+ import { registerAgent } from '@zhive/sdk';
5
6
  const __filename = fileURLToPath(import.meta.url);
6
7
  const __dirname = path.dirname(__filename);
7
- export async function scaffoldProject(projectName, provider, apiKey, soulContent, strategyContent, callbacks) {
8
+ export async function scaffoldProject({ agent, apiKey, callbacks, provider, soulContent, strategyContent, }) {
8
9
  // Validate project name to prevent path traversal / command injection
9
- if (!/^[a-zA-Z0-9_-]+$/.test(projectName)) {
10
+ if (!/^[a-zA-Z0-9_-]+$/.test(agent.name)) {
10
11
  callbacks.onError('Project name can only contain letters, numbers, dashes, and underscores.');
11
12
  return;
12
13
  }
13
14
  const agentsDir = path.join(getHiveDir(), 'agents');
14
- const projectDir = path.join(agentsDir, projectName);
15
+ const projectDir = path.join(agentsDir, agent.name);
15
16
  // Ensure resolved path is still inside the agents directory
16
17
  const normalizedProjectDir = path.resolve(projectDir);
17
18
  const normalizedAgentsDir = path.resolve(agentsDir);
@@ -50,24 +51,19 @@ export async function scaffoldProject(projectName, provider, apiKey, soulContent
50
51
  const envContent = `${provider.envVar}="${apiKey}"
51
52
  `;
52
53
  await fs.writeFile(path.join(projectDir, '.env'), envContent, { encoding: 'utf-8', mode: 0o600 });
53
- // 4. Write minimal package.json — no deps needed, npx fetches @zhive/agent@latest on every run
54
- callbacks.onStep('Configuring project');
55
- const packageJson = {
56
- name: `hive-agent-${projectName}`,
57
- private: true,
58
- type: 'module',
59
- scripts: {
60
- start: 'npx @zhive/cli@latest start',
54
+ // 4. register agent
55
+ await registerAgent({
56
+ agent_profile: {
57
+ sectors: agent.sectors,
58
+ sentiment: agent.sentiment,
59
+ timeframes: agent.timeframes,
61
60
  },
62
- };
63
- await fs.writeJson(path.join(projectDir, 'package.json'), packageJson, { spaces: 2 });
64
- // 5. Copy default skills
65
- callbacks.onStep('Installing default skills');
66
- const templateSkillsDir = path.resolve(__dirname, '../../templates/skills');
67
- const projectSkillsDir = path.join(projectDir, 'skills');
68
- const templateSkillsExist = await fs.pathExists(templateSkillsDir);
69
- if (templateSkillsExist) {
70
- await fs.copy(templateSkillsDir, projectSkillsDir);
71
- }
72
- callbacks.onDone(normalizedProjectDir);
61
+ name: agent.name,
62
+ avatar_url: agent.avatarUrl,
63
+ bio: agent.bio,
64
+ }, normalizedProjectDir)
65
+ .then(() => callbacks.onDone(normalizedProjectDir))
66
+ .catch((err) => {
67
+ callbacks.onError(err);
68
+ });
73
69
  }