orquesta-cli 0.2.24 → 0.2.26
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/cli.js +8 -3
- package/dist/orquesta/hook-init.d.ts +9 -1
- package/dist/orquesta/hook-init.js +61 -51
- package/dist/setup/first-run-setup.js +17 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -63,12 +63,17 @@ program
|
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
if (options.init) {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
await configManager.initialize();
|
|
67
|
+
const saved = configManager.getOrquestaConfig();
|
|
68
|
+
const token = options.token || saved?.token;
|
|
69
|
+
if (!token) {
|
|
70
|
+
console.error(chalk.red('Error: not connected to Orquesta.'));
|
|
71
|
+
console.error('Run ' + chalk.cyan('orquesta --login') + ' first, or pass ' + chalk.cyan('orquesta --init --token oat_…') + '.');
|
|
68
72
|
process.exit(1);
|
|
69
73
|
}
|
|
70
74
|
const { initHooks } = await import('./orquesta/hook-init.js');
|
|
71
|
-
|
|
75
|
+
const preferredProjectId = options.token ? undefined : saved?.projectId;
|
|
76
|
+
await initHooks(token, undefined, preferredProjectId);
|
|
72
77
|
return;
|
|
73
78
|
}
|
|
74
79
|
await configManager.initialize();
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
export declare function initHooks(token: string, apiUrl?: string): Promise<void>;
|
|
1
|
+
export declare function initHooks(token: string, apiUrl?: string, preferredProjectId?: string): Promise<void>;
|
|
2
|
+
export declare function writeHookFiles(opts: {
|
|
3
|
+
projectId: string;
|
|
4
|
+
token: string;
|
|
5
|
+
apiUrl: string;
|
|
6
|
+
cwd?: string;
|
|
7
|
+
agentBin?: string;
|
|
8
|
+
quiet?: boolean;
|
|
9
|
+
}): boolean;
|
|
2
10
|
//# sourceMappingURL=hook-init.d.ts.map
|
|
@@ -31,8 +31,7 @@ function resolveAgentBin() {
|
|
|
31
31
|
console.warn(' \x1b[33m npm install -g orquesta-agent\x1b[0m\n');
|
|
32
32
|
return 'orquesta-agent';
|
|
33
33
|
}
|
|
34
|
-
export async function initHooks(token, apiUrl = 'https://getorquesta.com') {
|
|
35
|
-
const cwd = process.cwd();
|
|
34
|
+
export async function initHooks(token, apiUrl = 'https://getorquesta.com', preferredProjectId) {
|
|
36
35
|
console.log('\n Initializing Orquesta hook integration...\n');
|
|
37
36
|
const agentBin = resolveAgentBin();
|
|
38
37
|
console.log(' Validating token...');
|
|
@@ -47,14 +46,15 @@ export async function initHooks(token, apiUrl = 'https://getorquesta.com') {
|
|
|
47
46
|
console.error(` Error: Invalid token`);
|
|
48
47
|
process.exit(1);
|
|
49
48
|
}
|
|
50
|
-
const
|
|
51
|
-
|
|
49
|
+
const chosen = (preferredProjectId && data.projects?.find((p) => p.id === preferredProjectId)) ||
|
|
50
|
+
data.projects?.[0];
|
|
51
|
+
if (!chosen) {
|
|
52
52
|
console.error(' Error: No projects found for this token');
|
|
53
53
|
process.exit(1);
|
|
54
54
|
throw new Error();
|
|
55
55
|
}
|
|
56
|
-
projectId =
|
|
57
|
-
projectName =
|
|
56
|
+
projectId = chosen.id;
|
|
57
|
+
projectName = chosen.name;
|
|
58
58
|
console.log(` Connected to: ${projectName}\n`);
|
|
59
59
|
}
|
|
60
60
|
catch (err) {
|
|
@@ -62,51 +62,7 @@ export async function initHooks(token, apiUrl = 'https://getorquesta.com') {
|
|
|
62
62
|
console.error(` Error: Could not reach ${apiUrl} (${msg})`);
|
|
63
63
|
process.exit(1);
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
fs.writeFileSync(configPath, JSON.stringify({ projectId, token, apiUrl }, null, 2) + '\n');
|
|
67
|
-
console.log(' Created .orquesta.json');
|
|
68
|
-
const gitignorePath = path.join(cwd, '.gitignore');
|
|
69
|
-
const entry = '.orquesta.json';
|
|
70
|
-
if (fs.existsSync(gitignorePath)) {
|
|
71
|
-
const content = fs.readFileSync(gitignorePath, 'utf8');
|
|
72
|
-
if (!content.includes(entry)) {
|
|
73
|
-
fs.appendFileSync(gitignorePath, `\n# Orquesta hook config (contains token)\n${entry}\n`);
|
|
74
|
-
console.log(' Added .orquesta.json to .gitignore');
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
fs.writeFileSync(gitignorePath, `# Orquesta hook config (contains token)\n${entry}\n`);
|
|
79
|
-
console.log(' Created .gitignore');
|
|
80
|
-
}
|
|
81
|
-
const claudeDir = path.join(cwd, '.claude');
|
|
82
|
-
const settingsPath = path.join(claudeDir, 'settings.json');
|
|
83
|
-
if (!fs.existsSync(claudeDir)) {
|
|
84
|
-
fs.mkdirSync(claudeDir, { recursive: true });
|
|
85
|
-
}
|
|
86
|
-
let settings = {};
|
|
87
|
-
if (fs.existsSync(settingsPath)) {
|
|
88
|
-
try {
|
|
89
|
-
settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
90
|
-
}
|
|
91
|
-
catch { }
|
|
92
|
-
}
|
|
93
|
-
if (!settings.hooks)
|
|
94
|
-
settings.hooks = {};
|
|
95
|
-
const hooksConfig = buildHooksConfig(agentBin);
|
|
96
|
-
for (const [event, config] of Object.entries(hooksConfig)) {
|
|
97
|
-
if (!settings.hooks[event]) {
|
|
98
|
-
settings.hooks[event] = config;
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
const existing = settings.hooks[event];
|
|
102
|
-
const hasOrquesta = existing.some((e) => e.hooks?.some((h) => h.command?.includes('orquesta-agent hook')));
|
|
103
|
-
if (!hasOrquesta) {
|
|
104
|
-
settings.hooks[event] = [...existing, ...config];
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
|
|
109
|
-
console.log(' Configured .claude/settings.json hooks');
|
|
65
|
+
writeHookFiles({ projectId, token, apiUrl, agentBin });
|
|
110
66
|
console.log(`
|
|
111
67
|
Done! Now run \`claude\` in this directory — all activity will
|
|
112
68
|
be tracked in Orquesta automatically.
|
|
@@ -114,4 +70,58 @@ export async function initHooks(token, apiUrl = 'https://getorquesta.com') {
|
|
|
114
70
|
Dashboard: ${apiUrl}/dashboard/projects/${projectId}
|
|
115
71
|
`);
|
|
116
72
|
}
|
|
73
|
+
export function writeHookFiles(opts) {
|
|
74
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
75
|
+
const log = (m) => { if (!opts.quiet)
|
|
76
|
+
console.log(m); };
|
|
77
|
+
try {
|
|
78
|
+
const agentBin = opts.agentBin ?? resolveAgentBin();
|
|
79
|
+
fs.writeFileSync(path.join(cwd, '.orquesta.json'), JSON.stringify({ projectId: opts.projectId, token: opts.token, apiUrl: opts.apiUrl }, null, 2) + '\n');
|
|
80
|
+
log(' Created .orquesta.json');
|
|
81
|
+
const gitignorePath = path.join(cwd, '.gitignore');
|
|
82
|
+
const entry = '.orquesta.json';
|
|
83
|
+
if (fs.existsSync(gitignorePath)) {
|
|
84
|
+
const content = fs.readFileSync(gitignorePath, 'utf8');
|
|
85
|
+
if (!content.includes(entry)) {
|
|
86
|
+
fs.appendFileSync(gitignorePath, `\n# Orquesta hook config (contains token)\n${entry}\n`);
|
|
87
|
+
log(' Added .orquesta.json to .gitignore');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
fs.writeFileSync(gitignorePath, `# Orquesta hook config (contains token)\n${entry}\n`);
|
|
92
|
+
log(' Created .gitignore');
|
|
93
|
+
}
|
|
94
|
+
const claudeDir = path.join(cwd, '.claude');
|
|
95
|
+
const settingsPath = path.join(claudeDir, 'settings.json');
|
|
96
|
+
if (!fs.existsSync(claudeDir))
|
|
97
|
+
fs.mkdirSync(claudeDir, { recursive: true });
|
|
98
|
+
let settings = {};
|
|
99
|
+
if (fs.existsSync(settingsPath)) {
|
|
100
|
+
try {
|
|
101
|
+
settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
102
|
+
}
|
|
103
|
+
catch { }
|
|
104
|
+
}
|
|
105
|
+
if (!settings.hooks)
|
|
106
|
+
settings.hooks = {};
|
|
107
|
+
const hooksConfig = buildHooksConfig(agentBin);
|
|
108
|
+
for (const [event, config] of Object.entries(hooksConfig)) {
|
|
109
|
+
if (!settings.hooks[event]) {
|
|
110
|
+
settings.hooks[event] = config;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
const existing = settings.hooks[event];
|
|
114
|
+
const hasOrquesta = existing.some((e) => e.hooks?.some((h) => h.command?.includes('orquesta-agent hook')));
|
|
115
|
+
if (!hasOrquesta)
|
|
116
|
+
settings.hooks[event] = [...existing, ...config];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
|
|
120
|
+
log(' Configured .claude/settings.json hooks');
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
117
127
|
//# sourceMappingURL=hook-init.js.map
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import ora from 'ora';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
import * as path from 'path';
|
|
3
5
|
import { configManager } from '../core/config/config-manager.js';
|
|
4
6
|
import { syncOrquestaConfigs, fetchOrquestaProjects } from '../orquesta/config-sync.js';
|
|
7
|
+
import { writeHookFiles } from '../orquesta/hook-init.js';
|
|
5
8
|
import { scanProviders, toEndpointConfig } from '../core/config/auto-detect.js';
|
|
9
|
+
const ORQUESTA_API_URL = process.env['ORQUESTA_API_URL'] || 'https://getorquesta.com';
|
|
6
10
|
export function needsFirstRunSetup() {
|
|
7
11
|
return !configManager.hasEndpoints() && !configManager.hasOrquestaConnection();
|
|
8
12
|
}
|
|
@@ -140,6 +144,19 @@ export async function connectWithToken(token, projectId) {
|
|
|
140
144
|
console.log(chalk.dim(` Project: ${selectedProject.name}`));
|
|
141
145
|
console.log(chalk.dim(` Your prompts and configs will sync with the dashboard.`));
|
|
142
146
|
console.log();
|
|
147
|
+
try {
|
|
148
|
+
const cwd = process.cwd();
|
|
149
|
+
const looksLikeProject = fs.existsSync(path.join(cwd, '.git')) || fs.existsSync(path.join(cwd, 'package.json'));
|
|
150
|
+
const alreadyInit = fs.existsSync(path.join(cwd, '.orquesta.json'));
|
|
151
|
+
if (looksLikeProject && !alreadyInit) {
|
|
152
|
+
const ok = writeHookFiles({ projectId: selectedProject.id, token, apiUrl: ORQUESTA_API_URL, quiet: true });
|
|
153
|
+
if (ok) {
|
|
154
|
+
console.log(chalk.dim(' Installed Claude Code hook for this directory (.claude/settings.json) — claude runs here will report too.'));
|
|
155
|
+
console.log();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch { }
|
|
143
160
|
console.log(chalk.dim(` Use --switch-project to change projects`));
|
|
144
161
|
console.log();
|
|
145
162
|
return {
|