@hive-org/cli 0.0.7 → 0.0.8
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/agent/hooks/useAgent.js +2 -1
- package/dist/config.js +1 -0
- package/dist/create/generate.js +2 -3
- package/dist/create/steps/DoneStep.js +1 -1
- package/dist/create/steps/NameStep.js +2 -1
- package/dist/index.js +23 -18
- package/dist/migrate-templates/MigrateApp.js +1 -1
- package/dist/migrate-templates/migrate.js +1 -1
- package/dist/start/SelectAgentApp.js +58 -0
- package/package.json +1 -1
|
@@ -93,7 +93,8 @@ export function useAgent() {
|
|
|
93
93
|
// ─── Agent lifecycle ────────────────────────────────
|
|
94
94
|
useEffect(() => {
|
|
95
95
|
const start = async () => {
|
|
96
|
-
const
|
|
96
|
+
const { HIVE_API_URL } = await import('../../config.js');
|
|
97
|
+
const baseUrl = HIVE_API_URL;
|
|
97
98
|
const config = await loadAgentConfig();
|
|
98
99
|
setAgentName(config.name);
|
|
99
100
|
setAgentBio(config.bio ?? '');
|
package/dist/config.js
CHANGED
package/dist/create/generate.js
CHANGED
|
@@ -44,8 +44,7 @@ export async function scaffoldProject(projectName, provider, apiKey, soulContent
|
|
|
44
44
|
await fs.writeFile(path.join(projectDir, 'MEMORY.md'), seedMemory, 'utf-8');
|
|
45
45
|
// 3. Write .env
|
|
46
46
|
callbacks.onStep('Writing environment file');
|
|
47
|
-
const envContent =
|
|
48
|
-
${provider.envVar}="${apiKey}"
|
|
47
|
+
const envContent = `${provider.envVar}="${apiKey}"
|
|
49
48
|
`;
|
|
50
49
|
await fs.writeFile(path.join(projectDir, '.env'), envContent, { encoding: 'utf-8', mode: 0o600 });
|
|
51
50
|
// 4. Write minimal package.json — no deps needed, npx fetches @hive-org/agent@latest on every run
|
|
@@ -55,7 +54,7 @@ ${provider.envVar}="${apiKey}"
|
|
|
55
54
|
private: true,
|
|
56
55
|
type: 'module',
|
|
57
56
|
scripts: {
|
|
58
|
-
start: 'npx @hive-org/cli@latest
|
|
57
|
+
start: 'npx @hive-org/cli@latest start',
|
|
59
58
|
},
|
|
60
59
|
};
|
|
61
60
|
await fs.writeJson(path.join(projectDir, 'package.json'), packageJson, { spaces: 2 });
|
|
@@ -10,5 +10,5 @@ export function DoneStep({ projectDir }) {
|
|
|
10
10
|
const termWidth = process.stdout.columns || 60;
|
|
11
11
|
const boxWidth = Math.min(termWidth - 4, 60);
|
|
12
12
|
const line = border.horizontal.repeat(boxWidth - 2);
|
|
13
|
-
return (_jsxs(Box, { flexDirection: "column", marginLeft: 2, children: [_jsx(Box, { children: _jsxs(Text, { color: colors.honey, children: [border.topLeft, line, border.topRight] }) }), _jsxs(Box, { children: [_jsx(Text, { color: colors.honey, children: border.vertical }), _jsx(Text, { children: " " }), _jsxs(Text, { color: colors.honey, bold: true, children: [symbols.hive, " Agent created successfully!"] }), _jsx(Text, { children: ' '.repeat(Math.max(0, boxWidth - 32)) }), _jsx(Text, { color: colors.honey, children: border.vertical })] }), _jsx(Box, { children: _jsxs(Text, { color: colors.honey, children: [border.bottomLeft, line, border.bottomRight] }) }), _jsxs(Box, { flexDirection: "column", marginTop: 1, marginLeft: 1, children: [_jsx(Text, { color: colors.white, bold: true, children: "Next steps:" }),
|
|
13
|
+
return (_jsxs(Box, { flexDirection: "column", marginLeft: 2, children: [_jsx(Box, { children: _jsxs(Text, { color: colors.honey, children: [border.topLeft, line, border.topRight] }) }), _jsxs(Box, { children: [_jsx(Text, { color: colors.honey, children: border.vertical }), _jsx(Text, { children: " " }), _jsxs(Text, { color: colors.honey, bold: true, children: [symbols.hive, " Agent created successfully!"] }), _jsx(Text, { children: ' '.repeat(Math.max(0, boxWidth - 32)) }), _jsx(Text, { color: colors.honey, children: border.vertical })] }), _jsx(Box, { children: _jsxs(Text, { color: colors.honey, children: [border.bottomLeft, line, border.bottomRight] }) }), _jsxs(Box, { flexDirection: "column", marginTop: 1, marginLeft: 1, children: [_jsx(Text, { color: colors.white, bold: true, children: "Next steps:" }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: _jsxs(Text, { color: colors.gray, children: [" 1. ", _jsx(Text, { color: colors.white, children: "npx @hive-org/cli@latest start" })] }) }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: colors.grayDim, children: " Edit SOUL.md and STRATEGY.md to fine-tune your agent." }) })] })] }));
|
|
14
14
|
}
|
|
@@ -5,6 +5,7 @@ import axios from 'axios';
|
|
|
5
5
|
import { TextPrompt } from '../../components/TextPrompt.js';
|
|
6
6
|
import { Spinner } from '../../components/Spinner.js';
|
|
7
7
|
import { colors, symbols } from '../../theme.js';
|
|
8
|
+
import { HIVE_API_URL } from '../../config.js';
|
|
8
9
|
const ADJECTIVES = [
|
|
9
10
|
'royal', 'golden', 'buzzy', 'honey', 'sweet', 'stung', 'waxed', 'bold',
|
|
10
11
|
'swift', 'wild', 'keen', 'warm', 'hazy', 'calm', 'busy', 'amber',
|
|
@@ -38,7 +39,7 @@ export function NameStep({ onComplete }) {
|
|
|
38
39
|
setChecking(true);
|
|
39
40
|
setError('');
|
|
40
41
|
try {
|
|
41
|
-
const apiUrl =
|
|
42
|
+
const apiUrl = HIVE_API_URL;
|
|
42
43
|
const response = await axios.get(`${apiUrl}/agent/check-name`, {
|
|
43
44
|
params: { name },
|
|
44
45
|
timeout: 3000,
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { render } from 'ink';
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { CreateApp } from './create/CreateApp.js';
|
|
6
6
|
import { ListApp } from './list/ListApp.js';
|
|
7
|
+
import { SelectAgentApp } from './start/SelectAgentApp.js';
|
|
7
8
|
import { startCommand } from './start/start-command.js';
|
|
8
9
|
import { showWelcome } from './create/welcome.js';
|
|
9
10
|
const require = createRequire(import.meta.url);
|
|
@@ -13,8 +14,8 @@ const HELP_TEXT = `@hive-org/cli v${pkg.version}
|
|
|
13
14
|
Usage:
|
|
14
15
|
npx @hive-org/cli@latest create [agent-name] Scaffold a new Hive agent
|
|
15
16
|
npx @hive-org/cli@latest list List existing agents
|
|
16
|
-
npx @hive-org/cli@latest start
|
|
17
|
-
npx @hive-org/cli@latest
|
|
17
|
+
npx @hive-org/cli@latest start Select and start an agent
|
|
18
|
+
npx @hive-org/cli@latest start-all Start all agents
|
|
18
19
|
npx @hive-org/cli@latest migrate-templates Migrate old-style agents
|
|
19
20
|
npx @hive-org/cli@latest --help Show this help message
|
|
20
21
|
npx @hive-org/cli@latest --version Print version
|
|
@@ -23,8 +24,8 @@ Examples:
|
|
|
23
24
|
npx @hive-org/cli@latest create alpha Creates ~/.hive/agents/alpha/
|
|
24
25
|
npx @hive-org/cli@latest create Interactive setup
|
|
25
26
|
npx @hive-org/cli@latest list Show all agents
|
|
26
|
-
npx @hive-org/cli@latest start
|
|
27
|
-
npx @hive-org/cli@latest
|
|
27
|
+
npx @hive-org/cli@latest start Pick an agent and run it
|
|
28
|
+
npx @hive-org/cli@latest start-all Launch all agents as child processes`;
|
|
28
29
|
const command = process.argv[2];
|
|
29
30
|
const arg = process.argv[3];
|
|
30
31
|
if (command === '--version' || command === '-v') {
|
|
@@ -39,7 +40,7 @@ if (command === 'list') {
|
|
|
39
40
|
const { waitUntilExit } = render(React.createElement(ListApp));
|
|
40
41
|
await waitUntilExit();
|
|
41
42
|
}
|
|
42
|
-
else if (command === 'start') {
|
|
43
|
+
else if (command === 'start-all') {
|
|
43
44
|
await startCommand();
|
|
44
45
|
}
|
|
45
46
|
else if (command === 'create') {
|
|
@@ -54,20 +55,24 @@ else if (command === 'migrate-templates') {
|
|
|
54
55
|
const { waitUntilExit } = render(React.createElement(MigrateApp));
|
|
55
56
|
await waitUntilExit();
|
|
56
57
|
}
|
|
57
|
-
else if (command === '
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
else if (command === 'start') {
|
|
59
|
+
let selectedAgent = null;
|
|
60
|
+
const { waitUntilExit: waitForSelect } = render(React.createElement(SelectAgentApp, {
|
|
61
|
+
onSelect: (agent) => {
|
|
62
|
+
selectedAgent = agent;
|
|
63
|
+
},
|
|
64
|
+
}));
|
|
65
|
+
await waitForSelect();
|
|
66
|
+
if (selectedAgent) {
|
|
67
|
+
const picked = selectedAgent;
|
|
68
|
+
process.chdir(picked.dir);
|
|
69
|
+
await import('dotenv/config');
|
|
70
|
+
const { setupProcessLifecycle } = await import('./agent/process-lifecycle.js');
|
|
71
|
+
const { App } = await import('./agent/app.js');
|
|
72
|
+
setupProcessLifecycle();
|
|
73
|
+
const { waitUntilExit } = render(React.createElement(App));
|
|
74
|
+
await waitUntilExit();
|
|
64
75
|
}
|
|
65
|
-
await import('dotenv/config');
|
|
66
|
-
const { setupProcessLifecycle } = await import('./agent/process-lifecycle.js');
|
|
67
|
-
const { App } = await import('./agent/app.js');
|
|
68
|
-
setupProcessLifecycle();
|
|
69
|
-
const { waitUntilExit } = render(React.createElement(App));
|
|
70
|
-
await waitUntilExit();
|
|
71
76
|
}
|
|
72
77
|
else {
|
|
73
78
|
console.error(`Unknown command: ${command}\n`);
|
|
@@ -127,5 +127,5 @@ export function MigrateApp() {
|
|
|
127
127
|
const successCount = results.filter((r) => r.success && !r.error).length;
|
|
128
128
|
const alreadyNew = results.filter((r) => r.error === 'Already migrated').length;
|
|
129
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: "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: "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: "gray", children: "No agents found in ~/.hive/agents/" })), _jsx(Text, { children: " " }), successCount > 0 && (_jsxs(Text, { color: "gray", children: ["Agents now run via @hive-org/cli. ", styled.white('npx @hive-org/cli@latest
|
|
130
|
+
return (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [_jsxs(Text, { color: colors.honey, bold: true, children: [symbols.hive, " Migration complete"] }), _jsx(Text, { color: "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: "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: "gray", children: "No agents found in ~/.hive/agents/" })), _jsx(Text, { children: " " }), successCount > 0 && (_jsxs(Text, { color: "gray", children: ["Agents now run via @hive-org/cli. ", styled.white('npx @hive-org/cli@latest start'), " always uses the latest version."] }))] }));
|
|
131
131
|
}
|
|
@@ -61,7 +61,7 @@ export async function migrateAgent(agentDir, name, onStep) {
|
|
|
61
61
|
private: true,
|
|
62
62
|
type: 'module',
|
|
63
63
|
scripts: {
|
|
64
|
-
start: 'npx @hive-org/cli@latest
|
|
64
|
+
start: 'npx @hive-org/cli@latest start',
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
67
|
await fs.writeJson(pkgPath, newPkg, { spaces: 2 });
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { Box, Text, useApp, useInput } from 'ink';
|
|
4
|
+
import { colors, symbols } from '../theme.js';
|
|
5
|
+
import { scanAgents } from '../agents.js';
|
|
6
|
+
export function SelectAgentApp({ onSelect }) {
|
|
7
|
+
const { exit } = useApp();
|
|
8
|
+
const [agents, setAgents] = useState(null);
|
|
9
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const load = async () => {
|
|
12
|
+
const results = await scanAgents();
|
|
13
|
+
setAgents(results);
|
|
14
|
+
if (results.length === 0) {
|
|
15
|
+
exit();
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
void load();
|
|
19
|
+
}, []);
|
|
20
|
+
useInput((_input, key) => {
|
|
21
|
+
if (agents === null || agents.length === 0) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (key.upArrow) {
|
|
25
|
+
setSelectedIndex((prev) => {
|
|
26
|
+
const max = agents.length - 1;
|
|
27
|
+
return prev > 0 ? prev - 1 : max;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
else if (key.downArrow) {
|
|
31
|
+
setSelectedIndex((prev) => {
|
|
32
|
+
const max = agents.length - 1;
|
|
33
|
+
return prev < max ? prev + 1 : 0;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
else if (key.return) {
|
|
37
|
+
const agent = agents[selectedIndex];
|
|
38
|
+
if (agent) {
|
|
39
|
+
onSelect(agent);
|
|
40
|
+
exit();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else if (key.ctrl && _input === 'c') {
|
|
44
|
+
exit();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
if (agents === null) {
|
|
48
|
+
return (_jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: colors.gray, children: "Scanning agents..." }) }));
|
|
49
|
+
}
|
|
50
|
+
if (agents.length === 0) {
|
|
51
|
+
return (_jsxs(Box, { flexDirection: "column", marginLeft: 2, children: [_jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { color: colors.honey, children: [symbols.hive, " "] }), _jsx(Text, { color: colors.white, bold: true, children: "No agents found" })] }), _jsxs(Text, { color: colors.gray, children: ["Create one with: ", _jsx(Text, { color: colors.white, children: "npx @hive-org/cli@latest create" })] })] }));
|
|
52
|
+
}
|
|
53
|
+
const nameWidth = Math.max(6, ...agents.map((a) => a.name.length)) + 2;
|
|
54
|
+
return (_jsxs(Box, { flexDirection: "column", marginLeft: 2, children: [_jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { color: colors.honey, children: [symbols.hive, " "] }), _jsx(Text, { color: colors.white, bold: true, children: "Select an agent to start" }), _jsxs(Text, { color: colors.grayDim, children: [" (", agents.length, ")"] })] }), agents.map((agent, index) => {
|
|
55
|
+
const isSelected = index === selectedIndex;
|
|
56
|
+
return (_jsxs(Box, { children: [_jsx(Text, { color: isSelected ? colors.honey : colors.grayDim, children: isSelected ? `${symbols.diamond} ` : ' ' }), _jsx(Text, { color: isSelected ? colors.white : colors.gray, bold: isSelected, children: agent.name.padEnd(nameWidth) }), _jsx(Text, { color: colors.grayDim, children: agent.provider })] }, agent.name));
|
|
57
|
+
}), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: colors.grayDim, children: [symbols.arrow, " ", '\u2191\u2193', " navigate ", ' ', " enter select ", ' ', " ctrl+c quit"] }) })] }));
|
|
58
|
+
}
|