@eve-horizon/cli 0.2.11 → 0.2.13

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.
@@ -1,290 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.handleInit = handleInit;
37
- const fs = __importStar(require("node:fs"));
38
- const path = __importStar(require("node:path"));
39
- const os = __importStar(require("node:os"));
40
- const node_child_process_1 = require("node:child_process");
41
- const args_1 = require("../lib/args");
42
- // ============================================================================
43
- // Constants
44
- // ============================================================================
45
- const DEFAULT_TEMPLATE = 'https://github.com/incept5/eve-horizon-starter';
46
- const DEFAULT_BRANCH = 'main';
47
- // ============================================================================
48
- // Main Handler
49
- // ============================================================================
50
- /**
51
- * eve init [directory] [--template <url>] [--branch <branch>]
52
- *
53
- * Initialize a new Eve Horizon project from a template.
54
- * Downloads the template, strips git history, and sets up a fresh project.
55
- */
56
- async function handleInit(positionals, flags) {
57
- const targetDir = positionals[0] || '.';
58
- const template = (0, args_1.getStringFlag)(flags, ['template', 't']) || DEFAULT_TEMPLATE;
59
- const branch = (0, args_1.getStringFlag)(flags, ['branch', 'b']) || DEFAULT_BRANCH;
60
- const skipSkills = Boolean(flags['skip-skills']);
61
- // Resolve target directory
62
- const resolvedTarget = path.resolve(targetDir);
63
- const targetName = path.basename(resolvedTarget);
64
- const isCurrentDir = targetDir === '.';
65
- // Validate target directory
66
- if (isCurrentDir) {
67
- // Current directory must be empty or not exist
68
- if (fs.existsSync(resolvedTarget)) {
69
- const entries = fs.readdirSync(resolvedTarget);
70
- // Allow hidden files like .git, but fail if there's substantial content
71
- const nonHiddenEntries = entries.filter(e => !e.startsWith('.'));
72
- if (nonHiddenEntries.length > 0) {
73
- throw new Error(`Current directory is not empty. Remove existing files or specify a new directory name:\n` +
74
- ` eve init my-project`);
75
- }
76
- }
77
- }
78
- else {
79
- // Named directory must not exist or be empty
80
- if (fs.existsSync(resolvedTarget)) {
81
- const entries = fs.readdirSync(resolvedTarget);
82
- if (entries.length > 0) {
83
- throw new Error(`Directory '${targetDir}' already exists and is not empty.`);
84
- }
85
- }
86
- }
87
- console.log(`Initializing Eve Horizon project${isCurrentDir ? '' : ` in '${targetName}'`}...`);
88
- console.log(`Template: ${template}`);
89
- console.log(`Branch: ${branch}`);
90
- console.log('');
91
- // Create temp directory for clone
92
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'eve-init-'));
93
- try {
94
- // Clone template
95
- console.log('Downloading template...');
96
- const cloneResult = (0, node_child_process_1.spawnSync)('git', ['clone', '--depth=1', `--branch=${branch}`, template, tempDir], {
97
- encoding: 'utf8',
98
- stdio: ['pipe', 'pipe', 'pipe'],
99
- });
100
- if (cloneResult.status !== 0) {
101
- throw new Error(`Failed to clone template:\n${cloneResult.stderr || cloneResult.stdout}`);
102
- }
103
- // Remove .git from cloned template
104
- const gitDir = path.join(tempDir, '.git');
105
- if (fs.existsSync(gitDir)) {
106
- fs.rmSync(gitDir, { recursive: true, force: true });
107
- }
108
- // Create target directory if needed
109
- if (!fs.existsSync(resolvedTarget)) {
110
- fs.mkdirSync(resolvedTarget, { recursive: true });
111
- }
112
- // Copy template contents to target
113
- console.log('Setting up project...');
114
- copyDirRecursive(tempDir, resolvedTarget);
115
- // Initialize git
116
- console.log('Initializing git repository...');
117
- (0, node_child_process_1.execSync)('git init', { cwd: resolvedTarget, stdio: 'pipe' });
118
- (0, node_child_process_1.execSync)('git add -A', { cwd: resolvedTarget, stdio: 'pipe' });
119
- (0, node_child_process_1.execSync)('git commit -m "Initial commit from eve-horizon-starter"', {
120
- cwd: resolvedTarget,
121
- stdio: 'pipe',
122
- });
123
- // Install skills
124
- if (!skipSkills) {
125
- console.log('');
126
- console.log('Installing skills...');
127
- await installSkills(resolvedTarget);
128
- }
129
- // Success message
130
- console.log('');
131
- console.log('Project initialized successfully!');
132
- console.log('');
133
- console.log('Next steps:');
134
- if (!isCurrentDir) {
135
- console.log(` 1. cd ${targetName}`);
136
- console.log(' 2. Start your AI coding agent (e.g., claude, cursor)');
137
- console.log(' 3. Ask: "Run the eve-new-project-setup skill"');
138
- }
139
- else {
140
- console.log(' 1. Start your AI coding agent (e.g., claude, cursor)');
141
- console.log(' 2. Ask: "Run the eve-new-project-setup skill"');
142
- }
143
- console.log('');
144
- console.log('The setup skill will:');
145
- console.log(' - Install the Eve CLI if needed');
146
- console.log(' - Configure your profile and authentication');
147
- console.log(' - Set up your project manifest');
148
- console.log(' - Help you set up your own Git remote');
149
- }
150
- finally {
151
- // Clean up temp directory
152
- if (fs.existsSync(tempDir)) {
153
- fs.rmSync(tempDir, { recursive: true, force: true });
154
- }
155
- }
156
- }
157
- // ============================================================================
158
- // Helper Functions
159
- // ============================================================================
160
- /**
161
- * Recursively copy directory contents
162
- */
163
- function copyDirRecursive(src, dest) {
164
- const entries = fs.readdirSync(src, { withFileTypes: true });
165
- for (const entry of entries) {
166
- const srcPath = path.join(src, entry.name);
167
- const destPath = path.join(dest, entry.name);
168
- if (entry.isDirectory()) {
169
- if (!fs.existsSync(destPath)) {
170
- fs.mkdirSync(destPath, { recursive: true });
171
- }
172
- copyDirRecursive(srcPath, destPath);
173
- }
174
- else if (entry.isSymbolicLink()) {
175
- const linkTarget = fs.readlinkSync(srcPath);
176
- if (!fs.existsSync(destPath)) {
177
- fs.symlinkSync(linkTarget, destPath);
178
- }
179
- }
180
- else {
181
- fs.copyFileSync(srcPath, destPath);
182
- }
183
- }
184
- }
185
- /**
186
- * Install skills from skills.txt
187
- * This reuses the logic from the skills command
188
- */
189
- async function installSkills(projectRoot) {
190
- const skillsTxt = path.join(projectRoot, 'skills.txt');
191
- if (!fs.existsSync(skillsTxt)) {
192
- console.log('No skills.txt found, skipping skill installation');
193
- return;
194
- }
195
- // Check if openskills is available
196
- const result = (0, node_child_process_1.spawnSync)('which', ['openskills'], { encoding: 'utf8' });
197
- if (result.status !== 0) {
198
- console.log('openskills CLI not found. Skills will be installed when you run:');
199
- console.log(' npm install -g @anthropic/openskills');
200
- console.log(' eve skills install');
201
- return;
202
- }
203
- // Import and call the skills install logic
204
- // We directly call the openskills commands here for simplicity
205
- try {
206
- const content = fs.readFileSync(skillsTxt, 'utf-8');
207
- const lines = content.split('\n')
208
- .map(line => line.split('#')[0].trim())
209
- .filter(line => line.length > 0);
210
- for (const source of lines) {
211
- console.log(` Installing: ${source}`);
212
- try {
213
- (0, node_child_process_1.execSync)(`openskills install ${JSON.stringify(source)} --universal --yes`, {
214
- cwd: projectRoot,
215
- stdio: 'inherit',
216
- timeout: 120000,
217
- });
218
- }
219
- catch {
220
- console.log(` Warning: Failed to install ${source}`);
221
- }
222
- }
223
- // Ensure symlink
224
- ensureSkillsSymlink(projectRoot);
225
- // Sync AGENTS.md
226
- try {
227
- (0, node_child_process_1.execSync)('openskills sync --yes', {
228
- cwd: projectRoot,
229
- stdio: 'inherit',
230
- timeout: 30000,
231
- });
232
- }
233
- catch {
234
- console.log('Warning: Failed to sync AGENTS.md');
235
- }
236
- // Commit skill changes
237
- try {
238
- (0, node_child_process_1.execSync)('git add -A', { cwd: projectRoot, stdio: 'pipe' });
239
- const hasChanges = (0, node_child_process_1.spawnSync)('git', ['diff', '--cached', '--quiet'], {
240
- cwd: projectRoot,
241
- encoding: 'utf8',
242
- });
243
- if (hasChanges.status !== 0) {
244
- (0, node_child_process_1.execSync)('git commit -m "chore: install skills from skills.txt"', {
245
- cwd: projectRoot,
246
- stdio: 'pipe',
247
- });
248
- }
249
- }
250
- catch {
251
- // Ignore commit failures
252
- }
253
- }
254
- catch (err) {
255
- console.log('Warning: Failed to install some skills');
256
- }
257
- }
258
- /**
259
- * Ensure .claude/skills symlink points to .agent/skills
260
- */
261
- function ensureSkillsSymlink(projectRoot) {
262
- const agentSkills = path.join(projectRoot, '.agent', 'skills');
263
- const claudeDir = path.join(projectRoot, '.claude');
264
- const claudeSkills = path.join(claudeDir, 'skills');
265
- if (!fs.existsSync(agentSkills)) {
266
- fs.mkdirSync(agentSkills, { recursive: true });
267
- }
268
- if (!fs.existsSync(claudeDir)) {
269
- fs.mkdirSync(claudeDir, { recursive: true });
270
- }
271
- if (fs.existsSync(claudeSkills)) {
272
- const stat = fs.lstatSync(claudeSkills);
273
- if (stat.isSymbolicLink()) {
274
- const target = fs.readlinkSync(claudeSkills);
275
- if (target === '../.agent/skills' || target === agentSkills) {
276
- return;
277
- }
278
- fs.unlinkSync(claudeSkills);
279
- }
280
- else {
281
- return;
282
- }
283
- }
284
- try {
285
- fs.symlinkSync('../.agent/skills', claudeSkills);
286
- }
287
- catch {
288
- // Ignore symlink failures
289
- }
290
- }
@@ -1,73 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleIntegrations = handleIntegrations;
4
- const args_1 = require("../lib/args");
5
- const client_1 = require("../lib/client");
6
- const output_1 = require("../lib/output");
7
- async function handleIntegrations(subcommand, positionals, flags, context) {
8
- const json = Boolean(flags.json);
9
- const orgId = (0, args_1.getStringFlag)(flags, ['org']) ?? context.orgId;
10
- switch (subcommand) {
11
- case 'list': {
12
- if (!orgId) {
13
- throw new Error('Usage: eve integrations list --org <org_id>');
14
- }
15
- const response = await (0, client_1.requestJson)(context, `/orgs/${orgId}/integrations`);
16
- (0, output_1.outputJson)(response, json);
17
- return;
18
- }
19
- case 'slack': {
20
- const action = positionals[0];
21
- if (action !== 'connect') {
22
- throw new Error('Usage: eve integrations slack connect --org <org_id> --team-id <team_id> [--token <token>]');
23
- }
24
- if (!orgId) {
25
- throw new Error('Missing org id. Provide --org or set a profile default.');
26
- }
27
- const teamId = (0, args_1.getStringFlag)(flags, ['team-id']);
28
- if (!teamId) {
29
- throw new Error('Missing --team-id');
30
- }
31
- const token = (0, args_1.getStringFlag)(flags, ['token']);
32
- const tokensJsonFlag = (0, args_1.getStringFlag)(flags, ['tokens-json']);
33
- const status = (0, args_1.getStringFlag)(flags, ['status']);
34
- let tokensJson;
35
- if (tokensJsonFlag) {
36
- try {
37
- const parsed = JSON.parse(tokensJsonFlag);
38
- if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
39
- tokensJson = parsed;
40
- }
41
- }
42
- catch (error) {
43
- throw new Error('Invalid --tokens-json (must be JSON object)');
44
- }
45
- }
46
- if (!tokensJson && token) {
47
- tokensJson = { access_token: token };
48
- }
49
- const body = { team_id: teamId };
50
- if (tokensJson)
51
- body.tokens_json = tokensJson;
52
- if (status)
53
- body.status = status;
54
- const response = await (0, client_1.requestJson)(context, `/orgs/${orgId}/integrations/slack/connect`, { method: 'POST', body });
55
- (0, output_1.outputJson)(response, json, `✓ Slack integration connected: ${response.id}`);
56
- return;
57
- }
58
- case 'test': {
59
- const integrationId = positionals[0];
60
- if (!integrationId) {
61
- throw new Error('Usage: eve integrations test <integration_id>');
62
- }
63
- if (!orgId) {
64
- throw new Error('Missing org id. Provide --org or set a profile default.');
65
- }
66
- const response = await (0, client_1.requestJson)(context, `/orgs/${orgId}/integrations/${integrationId}/test`, { method: 'POST' });
67
- (0, output_1.outputJson)(response, json, response.ok ? '✓ Integration test ok' : 'Integration test failed');
68
- return;
69
- }
70
- default:
71
- throw new Error('Usage: eve integrations <list|slack|test>');
72
- }
73
- }