orquesta-cli 0.1.17 → 0.1.18

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,103 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { execSync } from 'child_process';
4
+ const HOOKS_CONFIG = {
5
+ UserPromptSubmit: [{
6
+ hooks: [{ type: 'command', command: 'orquesta-agent hook prompt-submit' }],
7
+ }],
8
+ PostToolUse: [{
9
+ matcher: 'Edit|Write|Bash|Read|Glob|Grep',
10
+ hooks: [{ type: 'command', command: 'orquesta-agent hook tool-use', async: true }],
11
+ }],
12
+ Stop: [{
13
+ hooks: [{ type: 'command', command: 'orquesta-agent hook stop' }],
14
+ }],
15
+ };
16
+ export async function initHooks(token, apiUrl = 'https://orquesta.live') {
17
+ const cwd = process.cwd();
18
+ try {
19
+ execSync('orquesta-agent --version', { stdio: 'ignore' });
20
+ }
21
+ catch {
22
+ console.warn('\n Warning: orquesta-agent is not installed globally.');
23
+ console.warn(' Hooks require it. Install with: npm install -g orquesta-agent\n');
24
+ }
25
+ console.log('\n Initializing Orquesta hook integration...\n');
26
+ console.log(' Validating token...');
27
+ let projectId;
28
+ let projectName;
29
+ try {
30
+ const res = await fetch(`${apiUrl}/api/orquesta-cli/projects`, {
31
+ headers: { 'Authorization': `Bearer ${token}` },
32
+ });
33
+ const data = await res.json();
34
+ if (!res.ok || !data.organization) {
35
+ console.error(` Error: Invalid token`);
36
+ process.exit(1);
37
+ }
38
+ const firstProject = data.projects?.[0];
39
+ if (!firstProject) {
40
+ console.error(' Error: No projects found for this token');
41
+ process.exit(1);
42
+ throw new Error();
43
+ }
44
+ projectId = firstProject.id;
45
+ projectName = firstProject.name;
46
+ console.log(` Connected to: ${projectName}\n`);
47
+ }
48
+ catch (err) {
49
+ console.error(` Error: Could not reach ${apiUrl}`);
50
+ process.exit(1);
51
+ }
52
+ const configPath = path.join(cwd, '.orquesta.json');
53
+ fs.writeFileSync(configPath, JSON.stringify({ projectId, token, apiUrl }, null, 2) + '\n');
54
+ console.log(' Created .orquesta.json');
55
+ const gitignorePath = path.join(cwd, '.gitignore');
56
+ const entry = '.orquesta.json';
57
+ if (fs.existsSync(gitignorePath)) {
58
+ const content = fs.readFileSync(gitignorePath, 'utf8');
59
+ if (!content.includes(entry)) {
60
+ fs.appendFileSync(gitignorePath, `\n# Orquesta hook config (contains token)\n${entry}\n`);
61
+ console.log(' Added .orquesta.json to .gitignore');
62
+ }
63
+ }
64
+ else {
65
+ fs.writeFileSync(gitignorePath, `# Orquesta hook config (contains token)\n${entry}\n`);
66
+ console.log(' Created .gitignore');
67
+ }
68
+ const claudeDir = path.join(cwd, '.claude');
69
+ const settingsPath = path.join(claudeDir, 'settings.json');
70
+ if (!fs.existsSync(claudeDir)) {
71
+ fs.mkdirSync(claudeDir, { recursive: true });
72
+ }
73
+ let settings = {};
74
+ if (fs.existsSync(settingsPath)) {
75
+ try {
76
+ settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
77
+ }
78
+ catch { }
79
+ }
80
+ if (!settings.hooks)
81
+ settings.hooks = {};
82
+ for (const [event, config] of Object.entries(HOOKS_CONFIG)) {
83
+ if (!settings.hooks[event]) {
84
+ settings.hooks[event] = config;
85
+ }
86
+ else {
87
+ const existing = settings.hooks[event];
88
+ const hasOrquesta = existing.some((e) => e.hooks?.some((h) => h.command?.includes('orquesta-agent hook')));
89
+ if (!hasOrquesta) {
90
+ settings.hooks[event] = [...existing, ...config];
91
+ }
92
+ }
93
+ }
94
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
95
+ console.log(' Configured .claude/settings.json hooks');
96
+ console.log(`
97
+ Done! Now run \`claude\` in this directory — all activity will
98
+ be tracked in Orquesta automatically.
99
+
100
+ Dashboard: ${apiUrl}/dashboard/projects/${projectId}
101
+ `);
102
+ }
103
+ //# 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.18",
4
4
  "description": "Orquesta CLI - AI-powered coding assistant with team collaboration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",