@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.
- package/dist/CLAUDE.md +7 -0
- package/dist/backtest/CLAUDE.md +7 -0
- package/dist/cli.js +20 -0
- package/dist/commands/agent/commands/profile.js +3 -9
- package/dist/commands/create/commands/index.js +2 -5
- package/dist/commands/create/generate.js +18 -22
- package/dist/commands/create/presets.js +613 -0
- package/dist/commands/create/ui/CreateApp.js +2 -2
- package/dist/commands/create/ui/steps/ScaffoldStep.js +17 -2
- package/dist/commands/indicator/commands/bollinger.js +37 -0
- package/dist/commands/indicator/commands/ema.js +37 -0
- package/dist/commands/indicator/commands/index.js +14 -0
- package/dist/commands/indicator/commands/macd.js +51 -0
- package/dist/commands/indicator/commands/rsi.js +37 -0
- package/dist/commands/indicator/commands/sma.js +37 -0
- package/dist/commands/market/commands/index.js +5 -0
- package/dist/commands/market/commands/price.js +25 -0
- package/dist/commands/shared/utils.js +12 -0
- package/dist/commands/start/ui/AsciiTicker.js +81 -0
- package/dist/index.js +4 -0
- package/dist/services/agent/analysis.js +160 -0
- package/dist/services/agent/config.js +75 -0
- package/dist/services/agent/env.js +30 -0
- package/dist/services/agent/helpers/model.js +92 -0
- package/dist/services/agent/helpers.js +22 -0
- package/dist/services/agent/prompts/chat-prompt.js +65 -0
- package/dist/services/agent/prompts/memory-prompt.js +45 -0
- package/dist/services/agent/prompts/prompt.js +379 -0
- package/dist/services/agent/skills/index.js +2 -0
- package/dist/services/agent/skills/skill-parser.js +149 -0
- package/dist/services/agent/skills/types.js +1 -0
- package/dist/services/agent/tools/edit-section.js +59 -0
- package/dist/services/agent/tools/fetch-rules.js +21 -0
- package/dist/services/agent/tools/index.js +76 -0
- package/dist/services/agent/tools/market/client.js +41 -0
- package/dist/services/agent/tools/market/index.js +3 -0
- package/dist/services/agent/tools/market/tools.js +518 -0
- package/dist/services/agent/tools/mindshare/client.js +124 -0
- package/dist/services/agent/tools/mindshare/index.js +3 -0
- package/dist/services/agent/tools/mindshare/tools.js +563 -0
- package/dist/services/agent/tools/read-skill-tool.js +30 -0
- package/dist/services/agent/tools/ta/index.js +1 -0
- package/dist/services/agent/tools/ta/indicators.js +201 -0
- package/dist/services/agent/types.js +1 -0
- package/dist/services/ai-providers.js +66 -0
- package/dist/services/config/agent.js +110 -0
- package/dist/services/config/config.js +22 -0
- package/dist/services/config/constant.js +8 -0
- package/dist/shared/agent/agent-runtime.js +144 -0
- package/dist/shared/agent/analysis.js +2 -12
- package/dist/shared/agent/cache.js +10 -0
- package/dist/shared/agent/config.js +75 -0
- package/dist/shared/agent/env.js +30 -0
- package/dist/shared/agent/handler.js +3 -9
- package/dist/shared/agent/helpers/model.js +92 -0
- package/dist/shared/agent/prompts/megathread.js +0 -8
- package/dist/shared/agent/tools/execute-skill-tool.js +2 -1
- package/dist/shared/agent/tools/formatting.js +0 -19
- package/dist/shared/agent/tools/market/client.js +3 -3
- package/dist/shared/agent/tools/market/tools.js +88 -312
- package/dist/shared/agent/tools/market/utils.js +71 -0
- package/dist/shared/agent/tools/mindshare/tools.js +1 -1
- package/dist/shared/agent/tools/ta/index.js +3 -1
- package/dist/shared/agent/types.js +1 -0
- package/dist/shared/agent/utils.js +44 -0
- package/dist/shared/ai-providers.js +66 -0
- package/dist/shared/ta/error.js +12 -0
- package/dist/shared/ta/service.js +93 -0
- package/dist/shared/ta/utils.js +16 -0
- package/package.json +3 -2
package/dist/CLAUDE.md
ADDED
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
|
|
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
|
-
|
|
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
|
|
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(
|
|
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(
|
|
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,
|
|
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.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
}
|