@omnidev-ai/cli 0.8.0 → 0.9.0
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/index.js +45 -37
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -34,6 +34,9 @@ import { existsSync as existsSync4 } from "node:fs";
|
|
|
34
34
|
import { existsSync, mkdirSync } from "node:fs";
|
|
35
35
|
import { readFile, writeFile } from "node:fs/promises";
|
|
36
36
|
import { join } from "node:path";
|
|
37
|
+
import {
|
|
38
|
+
transformHooksConfig
|
|
39
|
+
} from "@omnidev-ai/core";
|
|
37
40
|
var claudeCodeAdapter = {
|
|
38
41
|
id: "claude-code",
|
|
39
42
|
displayName: "Claude Code",
|
|
@@ -50,7 +53,9 @@ var claudeCodeAdapter = {
|
|
|
50
53
|
const claudeMdContent = await generateClaudeMdContent(ctx.projectRoot);
|
|
51
54
|
await writeFile(claudeMdPath, claudeMdContent, "utf-8");
|
|
52
55
|
filesWritten.push("CLAUDE.md");
|
|
53
|
-
const
|
|
56
|
+
const claudeDir = join(ctx.projectRoot, ".claude");
|
|
57
|
+
mkdirSync(claudeDir, { recursive: true });
|
|
58
|
+
const skillsDir = join(claudeDir, "skills");
|
|
54
59
|
mkdirSync(skillsDir, { recursive: true });
|
|
55
60
|
for (const skill of bundle.skills) {
|
|
56
61
|
const skillDir = join(skillsDir, skill.name);
|
|
@@ -65,6 +70,13 @@ ${skill.instructions}`;
|
|
|
65
70
|
await writeFile(skillPath, content, "utf-8");
|
|
66
71
|
filesWritten.push(`.claude/skills/${skill.name}/SKILL.md`);
|
|
67
72
|
}
|
|
73
|
+
if (bundle.hooks) {
|
|
74
|
+
const settingsPath = join(claudeDir, "settings.json");
|
|
75
|
+
const hooksWritten = await writeHooksToSettings(settingsPath, bundle.hooks);
|
|
76
|
+
if (hooksWritten) {
|
|
77
|
+
filesWritten.push(".claude/settings.json");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
68
80
|
return {
|
|
69
81
|
filesWritten,
|
|
70
82
|
filesDeleted
|
|
@@ -86,6 +98,25 @@ async function generateClaudeMdContent(projectRoot) {
|
|
|
86
98
|
`;
|
|
87
99
|
return content;
|
|
88
100
|
}
|
|
101
|
+
async function writeHooksToSettings(settingsPath, hooks) {
|
|
102
|
+
const claudeHooks = transformHooksConfig(hooks, "toClaude");
|
|
103
|
+
let existingSettings = {};
|
|
104
|
+
if (existsSync(settingsPath)) {
|
|
105
|
+
try {
|
|
106
|
+
const content = await readFile(settingsPath, "utf-8");
|
|
107
|
+
existingSettings = JSON.parse(content);
|
|
108
|
+
} catch {
|
|
109
|
+
existingSettings = {};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const newSettings = {
|
|
113
|
+
...existingSettings,
|
|
114
|
+
hooks: claudeHooks
|
|
115
|
+
};
|
|
116
|
+
await writeFile(settingsPath, `${JSON.stringify(newSettings, null, 2)}
|
|
117
|
+
`, "utf-8");
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
89
120
|
// ../adapters/src/codex/index.ts
|
|
90
121
|
import { existsSync as existsSync2 } from "node:fs";
|
|
91
122
|
import { readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
@@ -223,24 +254,12 @@ async function getEnabledAdapters() {
|
|
|
223
254
|
import {
|
|
224
255
|
getActiveProfile,
|
|
225
256
|
loadBaseConfig,
|
|
226
|
-
|
|
227
|
-
|
|
257
|
+
patchAddCapabilitySource,
|
|
258
|
+
patchAddMcp,
|
|
259
|
+
patchAddToProfile,
|
|
260
|
+
syncAgentConfiguration
|
|
228
261
|
} from "@omnidev-ai/core";
|
|
229
262
|
import { buildCommand, buildRouteMap } from "@stricli/core";
|
|
230
|
-
function addToActiveProfile(config, activeProfile, capabilityName) {
|
|
231
|
-
if (!config.profiles) {
|
|
232
|
-
config.profiles = {};
|
|
233
|
-
}
|
|
234
|
-
if (!config.profiles[activeProfile]) {
|
|
235
|
-
config.profiles[activeProfile] = { capabilities: [] };
|
|
236
|
-
}
|
|
237
|
-
if (!config.profiles[activeProfile].capabilities) {
|
|
238
|
-
config.profiles[activeProfile].capabilities = [];
|
|
239
|
-
}
|
|
240
|
-
if (!config.profiles[activeProfile].capabilities.includes(capabilityName)) {
|
|
241
|
-
config.profiles[activeProfile].capabilities.push(capabilityName);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
263
|
async function runAddCap(flags, name) {
|
|
245
264
|
try {
|
|
246
265
|
if (!existsSync4("omni.toml")) {
|
|
@@ -256,25 +275,18 @@ async function runAddCap(flags, name) {
|
|
|
256
275
|
}
|
|
257
276
|
const config = await loadBaseConfig();
|
|
258
277
|
const activeProfile = await getActiveProfile() ?? config.active_profile ?? "default";
|
|
259
|
-
if (
|
|
260
|
-
config.capabilities = {};
|
|
261
|
-
}
|
|
262
|
-
if (!config.capabilities.sources) {
|
|
263
|
-
config.capabilities.sources = {};
|
|
264
|
-
}
|
|
265
|
-
if (config.capabilities.sources[name]) {
|
|
278
|
+
if (config.capabilities?.sources?.[name]) {
|
|
266
279
|
console.error(`✗ Capability source "${name}" already exists`);
|
|
267
280
|
console.log(" Use a different name or remove the existing source first");
|
|
268
281
|
process.exit(1);
|
|
269
282
|
}
|
|
270
283
|
const source = `github:${flags.github}`;
|
|
271
284
|
if (flags.path) {
|
|
272
|
-
|
|
285
|
+
await patchAddCapabilitySource(name, { source, path: flags.path });
|
|
273
286
|
} else {
|
|
274
|
-
|
|
287
|
+
await patchAddCapabilitySource(name, source);
|
|
275
288
|
}
|
|
276
|
-
|
|
277
|
-
await writeConfig(config);
|
|
289
|
+
await patchAddToProfile(activeProfile, name);
|
|
278
290
|
console.log(`✓ Added capability source: ${name}`);
|
|
279
291
|
console.log(` Source: ${source}`);
|
|
280
292
|
if (flags.path) {
|
|
@@ -299,10 +311,7 @@ async function runAddMcp(flags, name) {
|
|
|
299
311
|
}
|
|
300
312
|
const config = await loadBaseConfig();
|
|
301
313
|
const activeProfile = await getActiveProfile() ?? config.active_profile ?? "default";
|
|
302
|
-
if (
|
|
303
|
-
config.mcps = {};
|
|
304
|
-
}
|
|
305
|
-
if (config.mcps[name]) {
|
|
314
|
+
if (config.mcps?.[name]) {
|
|
306
315
|
console.error(`✗ MCP "${name}" already exists`);
|
|
307
316
|
console.log(" Use a different name or remove the existing MCP first");
|
|
308
317
|
process.exit(1);
|
|
@@ -356,9 +365,8 @@ async function runAddMcp(flags, name) {
|
|
|
356
365
|
}
|
|
357
366
|
}
|
|
358
367
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
await writeConfig(config);
|
|
368
|
+
await patchAddMcp(name, mcpConfig);
|
|
369
|
+
await patchAddToProfile(activeProfile, name);
|
|
362
370
|
console.log(`✓ Added MCP: ${name}`);
|
|
363
371
|
console.log(` Transport: ${transport}`);
|
|
364
372
|
if (mcpConfig.url) {
|
|
@@ -868,7 +876,7 @@ import {
|
|
|
868
876
|
loadConfig,
|
|
869
877
|
setActiveProfile,
|
|
870
878
|
syncAgentConfiguration as syncAgentConfiguration3,
|
|
871
|
-
writeConfig
|
|
879
|
+
writeConfig,
|
|
872
880
|
writeEnabledProviders
|
|
873
881
|
} from "@omnidev-ai/core";
|
|
874
882
|
import { buildCommand as buildCommand4 } from "@stricli/core";
|
|
@@ -939,7 +947,7 @@ async function runInit(_flags, providerArg) {
|
|
|
939
947
|
}
|
|
940
948
|
await writeEnabledProviders(providerIds);
|
|
941
949
|
if (!existsSync6("omni.toml")) {
|
|
942
|
-
await
|
|
950
|
+
await writeConfig({
|
|
943
951
|
profiles: {
|
|
944
952
|
default: {
|
|
945
953
|
capabilities: []
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnidev-ai/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@inquirer/prompts": "^8.1.0",
|
|
31
|
-
"@omnidev-ai/core": "0.
|
|
31
|
+
"@omnidev-ai/core": "0.9.0",
|
|
32
32
|
"@stricli/core": "^1.2.5"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@omnidev-ai/adapters": "0.0.
|
|
35
|
+
"@omnidev-ai/adapters": "0.0.11",
|
|
36
36
|
"bunup": "^0.16.20"
|
|
37
37
|
}
|
|
38
38
|
}
|