orquesta-cli 0.1.17 → 0.1.19

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 CHANGED
@@ -38,11 +38,21 @@ program
38
38
  .option('--sync', 'Sync configurations with Orquesta and exit')
39
39
  .option('--scan', 'Scan for available LLM providers (env vars + local ports)')
40
40
  .option('--add-provider <providerId>', 'Add a specific provider by ID (e.g., openai, anthropic, ollama)')
41
+ .option('--init', 'Initialize Claude Code hook integration for this project (requires --token)')
41
42
  .action(async (options) => {
42
43
  if (options.eval) {
43
44
  await runEvalMode();
44
45
  return;
45
46
  }
47
+ if (options.init) {
48
+ if (!options.token) {
49
+ console.error('Error: --init requires --token. Usage: orquesta --init --token <token>');
50
+ process.exit(1);
51
+ }
52
+ const { initHooks } = await import('./orquesta/hook-init.js');
53
+ await initHooks(options.token);
54
+ return;
55
+ }
46
56
  await configManager.initialize();
47
57
  if (options.status) {
48
58
  showConnectionStatus();
@@ -0,0 +1,2 @@
1
+ export declare function initHooks(token: string, apiUrl?: string): Promise<void>;
2
+ //# sourceMappingURL=hook-init.d.ts.map
@@ -0,0 +1,117 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { execSync } from 'child_process';
4
+ function buildHooksConfig(bin) {
5
+ return {
6
+ UserPromptSubmit: [{
7
+ hooks: [{ type: 'command', command: `${bin} hook prompt-submit` }],
8
+ }],
9
+ PostToolUse: [{
10
+ matcher: 'Edit|Write|Bash|Read|Glob|Grep',
11
+ hooks: [{ type: 'command', command: `${bin} hook tool-use`, async: true }],
12
+ }],
13
+ Stop: [{
14
+ hooks: [{ type: 'command', command: `${bin} hook stop` }],
15
+ }],
16
+ };
17
+ }
18
+ function resolveAgentBin() {
19
+ try {
20
+ const globalPrefix = execSync('npm prefix -g', { encoding: 'utf8' }).trim();
21
+ const binName = process.platform === 'win32' ? 'orquesta-agent.cmd' : 'orquesta-agent';
22
+ const candidate = path.join(globalPrefix, 'bin', binName);
23
+ if (fs.existsSync(candidate)) {
24
+ console.log(` Agent binary: ${candidate}`);
25
+ return candidate;
26
+ }
27
+ }
28
+ catch { }
29
+ console.warn(' \x1b[33m⚠ orquesta-agent not found globally.\x1b[0m');
30
+ console.warn(' \x1b[33m Hooks may fail. Install it:\x1b[0m');
31
+ console.warn(' \x1b[33m npm install -g orquesta-agent\x1b[0m\n');
32
+ return 'orquesta-agent';
33
+ }
34
+ export async function initHooks(token, apiUrl = 'https://orquesta.live') {
35
+ const cwd = process.cwd();
36
+ console.log('\n Initializing Orquesta hook integration...\n');
37
+ const agentBin = resolveAgentBin();
38
+ console.log(' Validating token...');
39
+ let projectId;
40
+ let projectName;
41
+ try {
42
+ const res = await fetch(`${apiUrl}/api/orquesta-cli/projects`, {
43
+ headers: { 'Authorization': `Bearer ${token}` },
44
+ });
45
+ const data = await res.json();
46
+ if (!res.ok || !data.organization) {
47
+ console.error(` Error: Invalid token`);
48
+ process.exit(1);
49
+ }
50
+ const firstProject = data.projects?.[0];
51
+ if (!firstProject) {
52
+ console.error(' Error: No projects found for this token');
53
+ process.exit(1);
54
+ throw new Error();
55
+ }
56
+ projectId = firstProject.id;
57
+ projectName = firstProject.name;
58
+ console.log(` Connected to: ${projectName}\n`);
59
+ }
60
+ catch (err) {
61
+ const msg = err instanceof Error ? err.message : 'Unknown error';
62
+ console.error(` Error: Could not reach ${apiUrl} (${msg})`);
63
+ process.exit(1);
64
+ }
65
+ const configPath = path.join(cwd, '.orquesta.json');
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');
110
+ console.log(`
111
+ Done! Now run \`claude\` in this directory — all activity will
112
+ be tracked in Orquesta automatically.
113
+
114
+ Dashboard: ${apiUrl}/dashboard/projects/${projectId}
115
+ `);
116
+ }
117
+ //# sourceMappingURL=hook-init.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orquesta-cli",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "Orquesta CLI - AI-powered coding assistant with team collaboration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",