orquesta-cli 0.1.18 → 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/orquesta/hook-init.js +35 -21
- package/package.json +1 -1
|
@@ -1,28 +1,40 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import { execSync } from 'child_process';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
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() {
|
|
18
19
|
try {
|
|
19
|
-
execSync('
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
+
}
|
|
24
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();
|
|
25
36
|
console.log('\n Initializing Orquesta hook integration...\n');
|
|
37
|
+
const agentBin = resolveAgentBin();
|
|
26
38
|
console.log(' Validating token...');
|
|
27
39
|
let projectId;
|
|
28
40
|
let projectName;
|
|
@@ -46,7 +58,8 @@ export async function initHooks(token, apiUrl = 'https://orquesta.live') {
|
|
|
46
58
|
console.log(` Connected to: ${projectName}\n`);
|
|
47
59
|
}
|
|
48
60
|
catch (err) {
|
|
49
|
-
|
|
61
|
+
const msg = err instanceof Error ? err.message : 'Unknown error';
|
|
62
|
+
console.error(` Error: Could not reach ${apiUrl} (${msg})`);
|
|
50
63
|
process.exit(1);
|
|
51
64
|
}
|
|
52
65
|
const configPath = path.join(cwd, '.orquesta.json');
|
|
@@ -79,7 +92,8 @@ export async function initHooks(token, apiUrl = 'https://orquesta.live') {
|
|
|
79
92
|
}
|
|
80
93
|
if (!settings.hooks)
|
|
81
94
|
settings.hooks = {};
|
|
82
|
-
|
|
95
|
+
const hooksConfig = buildHooksConfig(agentBin);
|
|
96
|
+
for (const [event, config] of Object.entries(hooksConfig)) {
|
|
83
97
|
if (!settings.hooks[event]) {
|
|
84
98
|
settings.hooks[event] = config;
|
|
85
99
|
}
|