@omnidev-ai/cli 0.4.0 → 0.5.1
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 +986 -696
- package/dist/shared/chunk-7txw9v1e.js +3017 -0
- package/package.json +35 -36
package/dist/index.js
CHANGED
|
@@ -1,772 +1,1062 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
__require,
|
|
4
|
+
__toESM,
|
|
5
|
+
debug,
|
|
6
|
+
disableCapability,
|
|
7
|
+
disableProvider,
|
|
8
|
+
discoverCapabilities,
|
|
9
|
+
enableCapability,
|
|
10
|
+
enableProvider,
|
|
11
|
+
generateInstructionsTemplate,
|
|
12
|
+
getActiveProfile,
|
|
13
|
+
getEnabledCapabilities,
|
|
14
|
+
loadCapabilityConfig,
|
|
15
|
+
loadConfig,
|
|
16
|
+
readEnabledProviders,
|
|
17
|
+
resolveEnabledCapabilities,
|
|
18
|
+
setActiveProfile,
|
|
19
|
+
syncAgentConfiguration,
|
|
20
|
+
writeConfig,
|
|
21
|
+
writeEnabledProviders
|
|
22
|
+
} from "./shared/chunk-7txw9v1e.js";
|
|
23
|
+
|
|
24
|
+
// src/index.ts
|
|
25
|
+
import { run } from "@stricli/core";
|
|
26
|
+
|
|
27
|
+
// src/lib/dynamic-app.ts
|
|
28
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
29
|
+
import { join as join5 } from "node:path";
|
|
30
|
+
import { buildApplication, buildRouteMap as buildRouteMap4 } from "@stricli/core";
|
|
31
|
+
|
|
32
|
+
// ../adapters/src/claude-code/index.ts
|
|
3
33
|
import { existsSync, mkdirSync } from "node:fs";
|
|
4
34
|
import { join } from "node:path";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
35
|
+
var claudeCodeAdapter = {
|
|
36
|
+
id: "claude-code",
|
|
37
|
+
displayName: "Claude Code",
|
|
38
|
+
async init(ctx) {
|
|
39
|
+
const claudeMdPath = join(ctx.projectRoot, "CLAUDE.md");
|
|
40
|
+
const filesCreated = [];
|
|
41
|
+
if (!existsSync(claudeMdPath)) {
|
|
42
|
+
await Bun.write(claudeMdPath, generateClaudeTemplate());
|
|
43
|
+
filesCreated.push("CLAUDE.md");
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
filesCreated,
|
|
47
|
+
message: filesCreated.length > 0 ? `Created ${filesCreated.join(", ")}` : "CLAUDE.md already exists"
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
async sync(bundle, ctx) {
|
|
51
|
+
const filesWritten = [];
|
|
52
|
+
const filesDeleted = [];
|
|
53
|
+
const skillsDir = join(ctx.projectRoot, ".claude", "skills");
|
|
54
|
+
mkdirSync(skillsDir, { recursive: true });
|
|
55
|
+
for (const skill of bundle.skills) {
|
|
56
|
+
const skillDir = join(skillsDir, skill.name);
|
|
57
|
+
mkdirSync(skillDir, { recursive: true });
|
|
58
|
+
const skillPath = join(skillDir, "SKILL.md");
|
|
59
|
+
const content = `---
|
|
60
|
+
name: ${skill.name}
|
|
61
|
+
description: "${skill.description}"
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
${skill.instructions}`;
|
|
65
|
+
await Bun.write(skillPath, content);
|
|
66
|
+
filesWritten.push(`.claude/skills/${skill.name}/SKILL.md`);
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
filesWritten,
|
|
70
|
+
filesDeleted
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
function generateClaudeTemplate() {
|
|
75
|
+
return `# Project Instructions
|
|
76
|
+
|
|
77
|
+
<!-- Add your project-specific instructions here -->
|
|
78
|
+
|
|
79
|
+
## OmniDev
|
|
80
|
+
|
|
81
|
+
@import .omni/instructions.md
|
|
82
|
+
`;
|
|
83
|
+
}
|
|
84
|
+
// ../adapters/src/codex/index.ts
|
|
85
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
86
|
+
import { join as join2 } from "node:path";
|
|
87
|
+
var codexAdapter = {
|
|
88
|
+
id: "codex",
|
|
89
|
+
displayName: "Codex",
|
|
90
|
+
async init(ctx) {
|
|
91
|
+
const agentsMdPath = join2(ctx.projectRoot, "AGENTS.md");
|
|
92
|
+
const filesCreated = [];
|
|
93
|
+
if (!existsSync2(agentsMdPath)) {
|
|
94
|
+
await Bun.write(agentsMdPath, generateAgentsTemplate());
|
|
95
|
+
filesCreated.push("AGENTS.md");
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
filesCreated,
|
|
99
|
+
message: filesCreated.length > 0 ? `Created ${filesCreated.join(", ")}` : "AGENTS.md already exists"
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
async sync(_bundle, _ctx) {
|
|
103
|
+
return {
|
|
104
|
+
filesWritten: [],
|
|
105
|
+
filesDeleted: []
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
function generateAgentsTemplate() {
|
|
110
|
+
return `# Project Instructions
|
|
111
|
+
|
|
112
|
+
<!-- Add your project-specific instructions here -->
|
|
113
|
+
|
|
114
|
+
## OmniDev
|
|
8
115
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
116
|
+
@import .omni/instructions.md
|
|
117
|
+
`;
|
|
118
|
+
}
|
|
119
|
+
// ../adapters/src/cursor/index.ts
|
|
120
|
+
import { mkdirSync as mkdirSync2 } from "node:fs";
|
|
121
|
+
import { join as join3 } from "node:path";
|
|
122
|
+
var cursorAdapter = {
|
|
123
|
+
id: "cursor",
|
|
124
|
+
displayName: "Cursor",
|
|
125
|
+
async init(ctx) {
|
|
126
|
+
const rulesDir = join3(ctx.projectRoot, ".cursor", "rules");
|
|
127
|
+
mkdirSync2(rulesDir, { recursive: true });
|
|
128
|
+
return {
|
|
129
|
+
filesCreated: [".cursor/rules/"],
|
|
130
|
+
message: "Created .cursor/rules/ directory"
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
async sync(bundle, ctx) {
|
|
134
|
+
const filesWritten = [];
|
|
135
|
+
const filesDeleted = [];
|
|
136
|
+
const rulesDir = join3(ctx.projectRoot, ".cursor", "rules");
|
|
137
|
+
mkdirSync2(rulesDir, { recursive: true });
|
|
138
|
+
for (const rule of bundle.rules) {
|
|
139
|
+
const rulePath = join3(rulesDir, `omnidev-${rule.name}.mdc`);
|
|
140
|
+
await Bun.write(rulePath, rule.content);
|
|
141
|
+
filesWritten.push(`.cursor/rules/omnidev-${rule.name}.mdc`);
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
filesWritten,
|
|
145
|
+
filesDeleted
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
// ../adapters/src/opencode/index.ts
|
|
150
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3 } from "node:fs";
|
|
151
|
+
import { join as join4 } from "node:path";
|
|
152
|
+
var opencodeAdapter = {
|
|
153
|
+
id: "opencode",
|
|
154
|
+
displayName: "OpenCode",
|
|
155
|
+
async init(ctx) {
|
|
156
|
+
const opencodeDir = join4(ctx.projectRoot, ".opencode");
|
|
157
|
+
mkdirSync3(opencodeDir, { recursive: true });
|
|
158
|
+
const instructionsPath = join4(opencodeDir, "instructions.md");
|
|
159
|
+
const filesCreated = [];
|
|
160
|
+
if (!existsSync3(instructionsPath)) {
|
|
161
|
+
await Bun.write(instructionsPath, generateOpencodeTemplate());
|
|
162
|
+
filesCreated.push(".opencode/instructions.md");
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
filesCreated,
|
|
166
|
+
message: filesCreated.length > 0 ? `Created ${filesCreated.join(", ")}` : ".opencode/instructions.md already exists"
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
async sync(_bundle, _ctx) {
|
|
170
|
+
return {
|
|
171
|
+
filesWritten: [],
|
|
172
|
+
filesDeleted: []
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
function generateOpencodeTemplate() {
|
|
177
|
+
return `# OpenCode Instructions
|
|
178
|
+
|
|
179
|
+
<!-- Add your project-specific instructions here -->
|
|
180
|
+
|
|
181
|
+
## OmniDev
|
|
182
|
+
|
|
183
|
+
@import ../.omni/instructions.md
|
|
184
|
+
`;
|
|
185
|
+
}
|
|
186
|
+
// ../adapters/src/registry.ts
|
|
187
|
+
var builtInAdapters = [
|
|
188
|
+
claudeCodeAdapter,
|
|
189
|
+
codexAdapter,
|
|
190
|
+
cursorAdapter,
|
|
191
|
+
opencodeAdapter
|
|
192
|
+
];
|
|
193
|
+
var adapterMap = new Map(builtInAdapters.map((adapter) => [adapter.id, adapter]));
|
|
194
|
+
function getAllAdapters() {
|
|
195
|
+
return builtInAdapters;
|
|
196
|
+
}
|
|
197
|
+
async function getEnabledAdapters() {
|
|
198
|
+
const enabledIds = await readEnabledProviders();
|
|
199
|
+
return enabledIds.map((id) => adapterMap.get(id)).filter((a) => a != null);
|
|
200
|
+
}
|
|
201
|
+
// src/commands/capability.ts
|
|
202
|
+
import { buildCommand, buildRouteMap } from "@stricli/core";
|
|
13
203
|
async function runCapabilityList() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
204
|
+
try {
|
|
205
|
+
const enabledIds = await getEnabledCapabilities();
|
|
206
|
+
const capabilityPaths = await discoverCapabilities();
|
|
207
|
+
if (capabilityPaths.length === 0) {
|
|
208
|
+
console.log("No capabilities found.");
|
|
209
|
+
console.log("");
|
|
210
|
+
console.log("To add capabilities, create directories in omni/capabilities/");
|
|
211
|
+
console.log("Each capability must have a capability.toml file.");
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
console.log("Capabilities:");
|
|
215
|
+
console.log("");
|
|
216
|
+
for (const path of capabilityPaths) {
|
|
217
|
+
try {
|
|
218
|
+
const capConfig = await loadCapabilityConfig(path);
|
|
219
|
+
const isEnabled = enabledIds.includes(capConfig.capability.id);
|
|
220
|
+
const status = isEnabled ? "✓ enabled" : "✗ disabled";
|
|
221
|
+
const { id, name, version } = capConfig.capability;
|
|
222
|
+
console.log(` ${status} ${name}`);
|
|
223
|
+
console.log(` ID: ${id}`);
|
|
224
|
+
console.log(` Version: ${version}`);
|
|
225
|
+
console.log("");
|
|
226
|
+
} catch (error) {
|
|
227
|
+
console.error(` ✗ Failed to load capability at ${path}:`, error);
|
|
228
|
+
console.log("");
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
} catch (error) {
|
|
232
|
+
console.error("Error listing capabilities:", error);
|
|
233
|
+
process.exit(1);
|
|
234
|
+
}
|
|
43
235
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Run the capability enable command.
|
|
46
|
-
*/
|
|
47
236
|
async function runCapabilityEnable(_flags, name) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
237
|
+
try {
|
|
238
|
+
const capabilityPaths = await discoverCapabilities();
|
|
239
|
+
const capabilityExists = capabilityPaths.some(async (path) => {
|
|
240
|
+
const config = await loadCapabilityConfig(path);
|
|
241
|
+
return config.capability.id === name;
|
|
242
|
+
});
|
|
243
|
+
if (!capabilityExists) {
|
|
244
|
+
console.error(`Error: Capability '${name}' not found`);
|
|
245
|
+
console.log("");
|
|
246
|
+
console.log("Run 'dev capability list' to see available capabilities");
|
|
247
|
+
process.exit(1);
|
|
248
|
+
}
|
|
249
|
+
await enableCapability(name);
|
|
250
|
+
console.log(`✓ Enabled capability: ${name}`);
|
|
251
|
+
console.log("");
|
|
252
|
+
const adapters = await getEnabledAdapters();
|
|
253
|
+
await syncAgentConfiguration({ adapters });
|
|
254
|
+
} catch (error) {
|
|
255
|
+
console.error("Error enabling capability:", error);
|
|
256
|
+
process.exit(1);
|
|
257
|
+
}
|
|
69
258
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Run the capability disable command.
|
|
72
|
-
*/
|
|
73
259
|
async function runCapabilityDisable(_flags, name) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
260
|
+
try {
|
|
261
|
+
await disableCapability(name);
|
|
262
|
+
console.log(`✓ Disabled capability: ${name}`);
|
|
263
|
+
console.log("");
|
|
264
|
+
const adapters = await getEnabledAdapters();
|
|
265
|
+
await syncAgentConfiguration({ adapters });
|
|
266
|
+
} catch (error) {
|
|
267
|
+
console.error("Error disabling capability:", error);
|
|
268
|
+
process.exit(1);
|
|
269
|
+
}
|
|
84
270
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
271
|
+
var listCommand = buildCommand({
|
|
272
|
+
docs: {
|
|
273
|
+
brief: "List all discovered capabilities"
|
|
274
|
+
},
|
|
275
|
+
parameters: {},
|
|
276
|
+
async func() {
|
|
277
|
+
await runCapabilityList();
|
|
278
|
+
}
|
|
91
279
|
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
280
|
+
var enableCommand = buildCommand({
|
|
281
|
+
docs: {
|
|
282
|
+
brief: "Enable a capability"
|
|
283
|
+
},
|
|
284
|
+
parameters: {
|
|
285
|
+
flags: {},
|
|
286
|
+
positional: {
|
|
287
|
+
kind: "tuple",
|
|
288
|
+
parameters: [
|
|
289
|
+
{
|
|
290
|
+
brief: "Capability name to enable",
|
|
291
|
+
parse: String
|
|
292
|
+
}
|
|
293
|
+
]
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
func: runCapabilityEnable
|
|
105
297
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
298
|
+
var disableCommand = buildCommand({
|
|
299
|
+
docs: {
|
|
300
|
+
brief: "Disable a capability"
|
|
301
|
+
},
|
|
302
|
+
parameters: {
|
|
303
|
+
flags: {},
|
|
304
|
+
positional: {
|
|
305
|
+
kind: "tuple",
|
|
306
|
+
parameters: [
|
|
307
|
+
{
|
|
308
|
+
brief: "Capability name to disable",
|
|
309
|
+
parse: String
|
|
310
|
+
}
|
|
311
|
+
]
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
func: runCapabilityDisable
|
|
119
315
|
});
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
316
|
+
var capabilityRoutes = buildRouteMap({
|
|
317
|
+
routes: {
|
|
318
|
+
list: listCommand,
|
|
319
|
+
enable: enableCommand,
|
|
320
|
+
disable: disableCommand
|
|
321
|
+
},
|
|
322
|
+
docs: {
|
|
323
|
+
brief: "Manage capabilities"
|
|
324
|
+
}
|
|
127
325
|
});
|
|
128
326
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
327
|
+
// src/commands/doctor.ts
|
|
328
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
329
|
+
import { buildCommand as buildCommand2 } from "@stricli/core";
|
|
330
|
+
var doctorCommand = buildCommand2({
|
|
331
|
+
docs: {
|
|
332
|
+
brief: "Check OmniDev setup and dependencies"
|
|
333
|
+
},
|
|
334
|
+
parameters: {},
|
|
335
|
+
async func() {
|
|
336
|
+
return await runDoctor();
|
|
337
|
+
}
|
|
137
338
|
});
|
|
138
339
|
async function runDoctor() {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
340
|
+
console.log("OmniDev Doctor");
|
|
341
|
+
console.log("==============");
|
|
342
|
+
console.log("");
|
|
343
|
+
const checks = [
|
|
344
|
+
checkBunVersion(),
|
|
345
|
+
checkOmniLocalDir(),
|
|
346
|
+
checkConfig(),
|
|
347
|
+
checkRootGitignore(),
|
|
348
|
+
checkCapabilitiesDir()
|
|
349
|
+
];
|
|
350
|
+
let allPassed = true;
|
|
351
|
+
for (const check of checks) {
|
|
352
|
+
const { name, passed, message, fix } = await check;
|
|
353
|
+
const icon = passed ? "✓" : "✗";
|
|
354
|
+
console.log(`${icon} ${name}: ${message}`);
|
|
355
|
+
if (!passed && fix) {
|
|
356
|
+
console.log(` Fix: ${fix}`);
|
|
357
|
+
}
|
|
358
|
+
if (!passed)
|
|
359
|
+
allPassed = false;
|
|
360
|
+
}
|
|
361
|
+
console.log("");
|
|
362
|
+
if (allPassed) {
|
|
363
|
+
console.log("All checks passed!");
|
|
364
|
+
} else {
|
|
365
|
+
console.log("Some checks failed. Please fix the issues above.");
|
|
366
|
+
process.exit(1);
|
|
367
|
+
}
|
|
163
368
|
}
|
|
164
369
|
async function checkBunVersion() {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
370
|
+
const version = Bun.version;
|
|
371
|
+
const parts = version.split(".");
|
|
372
|
+
const firstPart = parts[0];
|
|
373
|
+
if (!firstPart) {
|
|
374
|
+
return {
|
|
375
|
+
name: "Bun Version",
|
|
376
|
+
passed: false,
|
|
377
|
+
message: `Invalid version format: ${version}`,
|
|
378
|
+
fix: "Reinstall Bun: curl -fsSL https://bun.sh/install | bash"
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
const major = Number.parseInt(firstPart, 10);
|
|
382
|
+
if (major < 1) {
|
|
383
|
+
return {
|
|
384
|
+
name: "Bun Version",
|
|
385
|
+
passed: false,
|
|
386
|
+
message: `v${version}`,
|
|
387
|
+
fix: "Upgrade Bun: curl -fsSL https://bun.sh/install | bash"
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
return {
|
|
391
|
+
name: "Bun Version",
|
|
392
|
+
passed: true,
|
|
393
|
+
message: `v${version}`
|
|
394
|
+
};
|
|
186
395
|
}
|
|
187
396
|
async function checkOmniLocalDir() {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
397
|
+
const exists = existsSync4(".omni");
|
|
398
|
+
if (!exists) {
|
|
399
|
+
return {
|
|
400
|
+
name: ".omni/ directory",
|
|
401
|
+
passed: false,
|
|
402
|
+
message: "Not found",
|
|
403
|
+
fix: "Run: omnidev init"
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
return {
|
|
407
|
+
name: ".omni/ directory",
|
|
408
|
+
passed: true,
|
|
409
|
+
message: "Found"
|
|
410
|
+
};
|
|
200
411
|
}
|
|
201
412
|
async function checkConfig() {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
413
|
+
const configPath = "omni.toml";
|
|
414
|
+
if (!existsSync4(configPath)) {
|
|
415
|
+
return {
|
|
416
|
+
name: "Configuration",
|
|
417
|
+
passed: false,
|
|
418
|
+
message: "omni.toml not found",
|
|
419
|
+
fix: "Run: omnidev init"
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
try {
|
|
423
|
+
const { loadConfig: loadConfig2 } = await import("./shared/chunk-7txw9v1e.js");
|
|
424
|
+
await loadConfig2();
|
|
425
|
+
return {
|
|
426
|
+
name: "Configuration",
|
|
427
|
+
passed: true,
|
|
428
|
+
message: "Valid"
|
|
429
|
+
};
|
|
430
|
+
} catch (error) {
|
|
431
|
+
return {
|
|
432
|
+
name: "Configuration",
|
|
433
|
+
passed: false,
|
|
434
|
+
message: `Invalid: ${error instanceof Error ? error.message : String(error)}`,
|
|
435
|
+
fix: "Check omni.toml syntax"
|
|
436
|
+
};
|
|
437
|
+
}
|
|
225
438
|
}
|
|
226
439
|
async function checkRootGitignore() {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
440
|
+
const gitignorePath = ".gitignore";
|
|
441
|
+
if (!existsSync4(gitignorePath)) {
|
|
442
|
+
return {
|
|
443
|
+
name: "Root .gitignore",
|
|
444
|
+
passed: false,
|
|
445
|
+
message: ".gitignore not found",
|
|
446
|
+
fix: "Run: omnidev init"
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
const content = await Bun.file(gitignorePath).text();
|
|
450
|
+
const lines = content.split(`
|
|
451
|
+
`).map((line) => line.trim());
|
|
452
|
+
const hasOmniDir = lines.includes(".omni/");
|
|
453
|
+
const hasLocalToml = lines.includes("omni.local.toml");
|
|
454
|
+
if (!hasOmniDir || !hasLocalToml) {
|
|
455
|
+
const missing = [];
|
|
456
|
+
if (!hasOmniDir)
|
|
457
|
+
missing.push(".omni/");
|
|
458
|
+
if (!hasLocalToml)
|
|
459
|
+
missing.push("omni.local.toml");
|
|
460
|
+
return {
|
|
461
|
+
name: "Root .gitignore",
|
|
462
|
+
passed: false,
|
|
463
|
+
message: `Missing entries: ${missing.join(", ")}`,
|
|
464
|
+
fix: "Run: omnidev init"
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
return {
|
|
468
|
+
name: "Root .gitignore",
|
|
469
|
+
passed: true,
|
|
470
|
+
message: "Found with OmniDev entries"
|
|
471
|
+
};
|
|
254
472
|
}
|
|
255
473
|
async function checkCapabilitiesDir() {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
474
|
+
const capabilitiesDirPath = ".omni/capabilities";
|
|
475
|
+
if (!existsSync4(capabilitiesDirPath)) {
|
|
476
|
+
return {
|
|
477
|
+
name: "Capabilities Directory",
|
|
478
|
+
passed: true,
|
|
479
|
+
message: "Not found (no custom capabilities)"
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
return {
|
|
483
|
+
name: "Capabilities Directory",
|
|
484
|
+
passed: true,
|
|
485
|
+
message: "Found"
|
|
486
|
+
};
|
|
267
487
|
}
|
|
268
488
|
|
|
269
|
-
|
|
270
|
-
|
|
489
|
+
// src/commands/init.ts
|
|
490
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync4 } from "node:fs";
|
|
491
|
+
import { buildCommand as buildCommand3 } from "@stricli/core";
|
|
492
|
+
|
|
493
|
+
// src/prompts/provider.ts
|
|
494
|
+
import { checkbox } from "@inquirer/prompts";
|
|
271
495
|
async function promptForProviders() {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
checked: false
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
name: "Codex",
|
|
287
|
-
value: "codex",
|
|
288
|
-
checked: false
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
name: "OpenCode",
|
|
292
|
-
value: "opencode",
|
|
293
|
-
checked: false
|
|
294
|
-
}
|
|
295
|
-
],
|
|
296
|
-
required: true
|
|
297
|
-
});
|
|
298
|
-
return answers;
|
|
496
|
+
const answers = await checkbox({
|
|
497
|
+
message: "Select your AI provider(s):",
|
|
498
|
+
choices: [
|
|
499
|
+
{ name: "Claude Code (Claude CLI)", value: "claude-code", checked: true },
|
|
500
|
+
{ name: "Cursor", value: "cursor", checked: false },
|
|
501
|
+
{ name: "Codex", value: "codex", checked: false },
|
|
502
|
+
{ name: "OpenCode", value: "opencode", checked: false }
|
|
503
|
+
],
|
|
504
|
+
required: true
|
|
505
|
+
});
|
|
506
|
+
return answers;
|
|
299
507
|
}
|
|
300
508
|
|
|
301
|
-
|
|
302
|
-
//#region src/commands/init.ts
|
|
509
|
+
// src/commands/init.ts
|
|
303
510
|
async function runInit(_flags, providerArg) {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
511
|
+
console.log("Initializing OmniDev...");
|
|
512
|
+
mkdirSync4(".omni", { recursive: true });
|
|
513
|
+
mkdirSync4(".omni/capabilities", { recursive: true });
|
|
514
|
+
mkdirSync4(".omni/state", { recursive: true });
|
|
515
|
+
await updateRootGitignore();
|
|
516
|
+
let providerIds;
|
|
517
|
+
if (providerArg) {
|
|
518
|
+
providerIds = parseProviderArg(providerArg);
|
|
519
|
+
} else {
|
|
520
|
+
providerIds = await promptForProviders();
|
|
521
|
+
}
|
|
522
|
+
await writeEnabledProviders(providerIds);
|
|
523
|
+
if (!existsSync5("omni.toml")) {
|
|
524
|
+
await writeConfig({
|
|
525
|
+
project: "my-project",
|
|
526
|
+
profiles: {
|
|
527
|
+
default: {
|
|
528
|
+
capabilities: []
|
|
529
|
+
},
|
|
530
|
+
planning: {
|
|
531
|
+
capabilities: []
|
|
532
|
+
},
|
|
533
|
+
coding: {
|
|
534
|
+
capabilities: []
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
await setActiveProfile("default");
|
|
539
|
+
}
|
|
540
|
+
if (!existsSync5(".omni/instructions.md")) {
|
|
541
|
+
await Bun.write(".omni/instructions.md", generateInstructionsTemplate());
|
|
542
|
+
}
|
|
543
|
+
const config = await loadConfig();
|
|
544
|
+
const ctx = {
|
|
545
|
+
projectRoot: process.cwd(),
|
|
546
|
+
config
|
|
547
|
+
};
|
|
548
|
+
const allAdapters = getAllAdapters();
|
|
549
|
+
const selectedAdapters = allAdapters.filter((a) => providerIds.includes(a.id));
|
|
550
|
+
const filesCreated = [];
|
|
551
|
+
const filesExisting = [];
|
|
552
|
+
for (const adapter of selectedAdapters) {
|
|
553
|
+
if (adapter.init) {
|
|
554
|
+
const result = await adapter.init(ctx);
|
|
555
|
+
if (result.filesCreated) {
|
|
556
|
+
filesCreated.push(...result.filesCreated);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
const enabledAdapters = await getEnabledAdapters();
|
|
561
|
+
await syncAgentConfiguration({ silent: true, adapters: enabledAdapters });
|
|
562
|
+
console.log("");
|
|
563
|
+
console.log(`✓ OmniDev initialized for ${selectedAdapters.map((a) => a.displayName).join(" and ")}!`);
|
|
564
|
+
console.log("");
|
|
565
|
+
if (filesCreated.length > 0) {
|
|
566
|
+
console.log("\uD83D\uDCDD Don't forget to add your project description to:");
|
|
567
|
+
console.log(" • .omni/instructions.md");
|
|
568
|
+
}
|
|
569
|
+
if (filesExisting.length > 0) {
|
|
570
|
+
console.log("\uD83D\uDCDD Add this line to your existing file(s):");
|
|
571
|
+
for (const file of filesExisting) {
|
|
572
|
+
console.log(` • ${file}: @import .omni/instructions.md`);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
console.log("");
|
|
576
|
+
console.log("\uD83D\uDCA1 Recommendation:");
|
|
577
|
+
console.log(" Add provider-specific files to .gitignore:");
|
|
578
|
+
console.log(" CLAUDE.md, .claude/, AGENTS.md, .cursor/, .mcp.json");
|
|
579
|
+
console.log("");
|
|
580
|
+
console.log(" Run 'omnidev capability list' to see available capabilities.");
|
|
360
581
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
582
|
+
var initCommand = buildCommand3({
|
|
583
|
+
parameters: {
|
|
584
|
+
flags: {},
|
|
585
|
+
positional: {
|
|
586
|
+
kind: "tuple",
|
|
587
|
+
parameters: [
|
|
588
|
+
{
|
|
589
|
+
brief: "AI provider(s): claude-code, cursor, codex, opencode, or comma-separated",
|
|
590
|
+
parse: String,
|
|
591
|
+
optional: true
|
|
592
|
+
}
|
|
593
|
+
]
|
|
594
|
+
}
|
|
595
|
+
},
|
|
596
|
+
docs: {
|
|
597
|
+
brief: "Initialize OmniDev in the current project"
|
|
598
|
+
},
|
|
599
|
+
func: runInit
|
|
375
600
|
});
|
|
376
601
|
function parseProviderArg(arg) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
602
|
+
const allAdapters = getAllAdapters();
|
|
603
|
+
const validIds = new Set(allAdapters.map((a) => a.id));
|
|
604
|
+
if (arg.toLowerCase() === "both") {
|
|
605
|
+
return ["claude-code", "cursor"];
|
|
606
|
+
}
|
|
607
|
+
const parts = arg.split(",").map((p) => p.trim().toLowerCase());
|
|
608
|
+
const result = [];
|
|
609
|
+
for (const part of parts) {
|
|
610
|
+
let id = part;
|
|
611
|
+
if (id === "claude") {
|
|
612
|
+
id = "claude-code";
|
|
613
|
+
}
|
|
614
|
+
if (!validIds.has(id)) {
|
|
615
|
+
throw new Error(`Invalid provider: ${part}. Valid providers: ${[...validIds].join(", ")}`);
|
|
616
|
+
}
|
|
617
|
+
result.push(id);
|
|
618
|
+
}
|
|
619
|
+
return result;
|
|
389
620
|
}
|
|
390
621
|
async function updateRootGitignore() {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
622
|
+
const gitignorePath = ".gitignore";
|
|
623
|
+
const entriesToAdd = [".omni/", "omni.local.toml"];
|
|
624
|
+
let content = "";
|
|
625
|
+
if (existsSync5(gitignorePath)) {
|
|
626
|
+
content = await Bun.file(gitignorePath).text();
|
|
627
|
+
}
|
|
628
|
+
const lines = content.split(`
|
|
629
|
+
`);
|
|
630
|
+
const missingEntries = entriesToAdd.filter((entry) => !lines.some((line) => line.trim() === entry));
|
|
631
|
+
if (missingEntries.length === 0) {
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
const needsNewline = content.length > 0 && !content.endsWith(`
|
|
635
|
+
`);
|
|
636
|
+
const section = `${needsNewline ? `
|
|
637
|
+
` : ""}# OmniDev
|
|
638
|
+
${missingEntries.join(`
|
|
639
|
+
`)}
|
|
640
|
+
`;
|
|
641
|
+
await Bun.write(gitignorePath, content + section);
|
|
401
642
|
}
|
|
402
643
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
644
|
+
// src/commands/profile.ts
|
|
645
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
646
|
+
import { buildCommand as buildCommand4, buildRouteMap as buildRouteMap2 } from "@stricli/core";
|
|
647
|
+
var listCommand2 = buildCommand4({
|
|
648
|
+
docs: {
|
|
649
|
+
brief: "List available profiles"
|
|
650
|
+
},
|
|
651
|
+
parameters: {},
|
|
652
|
+
async func() {
|
|
653
|
+
await runProfileList();
|
|
654
|
+
}
|
|
411
655
|
});
|
|
412
656
|
async function runSetCommand(_flags, profileName) {
|
|
413
|
-
|
|
657
|
+
await runProfileSet(profileName);
|
|
414
658
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
659
|
+
var setCommand = buildCommand4({
|
|
660
|
+
docs: {
|
|
661
|
+
brief: "Set the active profile"
|
|
662
|
+
},
|
|
663
|
+
parameters: {
|
|
664
|
+
flags: {},
|
|
665
|
+
positional: {
|
|
666
|
+
kind: "tuple",
|
|
667
|
+
parameters: [
|
|
668
|
+
{
|
|
669
|
+
brief: "Profile name",
|
|
670
|
+
parse: String
|
|
671
|
+
}
|
|
672
|
+
]
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
func: runSetCommand
|
|
428
676
|
});
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
677
|
+
var profileRoutes = buildRouteMap2({
|
|
678
|
+
routes: {
|
|
679
|
+
list: listCommand2,
|
|
680
|
+
set: setCommand
|
|
681
|
+
},
|
|
682
|
+
docs: {
|
|
683
|
+
brief: "Manage capability profiles"
|
|
684
|
+
}
|
|
435
685
|
});
|
|
436
686
|
async function runProfileList() {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
687
|
+
try {
|
|
688
|
+
if (!existsSync6("omni.toml")) {
|
|
689
|
+
console.log("✗ No config file found");
|
|
690
|
+
console.log(" Run: omnidev init");
|
|
691
|
+
process.exit(1);
|
|
692
|
+
}
|
|
693
|
+
const config = await loadConfig();
|
|
694
|
+
const activeProfile = await getActiveProfile() ?? config.active_profile ?? "default";
|
|
695
|
+
const profiles = config.profiles ?? {};
|
|
696
|
+
const profileNames = Object.keys(profiles);
|
|
697
|
+
if (profileNames.length === 0) {
|
|
698
|
+
console.log("No profiles defined in omni.toml");
|
|
699
|
+
console.log("");
|
|
700
|
+
console.log("Using default capabilities from omni.toml");
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
703
|
+
console.log("Available Profiles:");
|
|
704
|
+
console.log("");
|
|
705
|
+
for (const name of profileNames) {
|
|
706
|
+
const isActive = name === activeProfile;
|
|
707
|
+
const icon = isActive ? "●" : "○";
|
|
708
|
+
const profile = profiles[name];
|
|
709
|
+
if (profile === undefined) {
|
|
710
|
+
continue;
|
|
711
|
+
}
|
|
712
|
+
console.log(`${icon} ${name}${isActive ? " (active)" : ""}`);
|
|
713
|
+
const capabilities = resolveEnabledCapabilities(config, name);
|
|
714
|
+
if (capabilities.length > 0) {
|
|
715
|
+
console.log(` Capabilities: ${capabilities.join(", ")}`);
|
|
716
|
+
} else {
|
|
717
|
+
console.log(" Capabilities: none");
|
|
718
|
+
}
|
|
719
|
+
console.log("");
|
|
720
|
+
}
|
|
721
|
+
} catch (error) {
|
|
722
|
+
console.error("✗ Error loading profiles:", error);
|
|
723
|
+
process.exit(1);
|
|
724
|
+
}
|
|
470
725
|
}
|
|
471
726
|
async function runProfileSet(profileName) {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
727
|
+
try {
|
|
728
|
+
if (!existsSync6("omni.toml")) {
|
|
729
|
+
console.log("✗ No config file found");
|
|
730
|
+
console.log(" Run: omnidev init");
|
|
731
|
+
process.exit(1);
|
|
732
|
+
}
|
|
733
|
+
const config = await loadConfig();
|
|
734
|
+
const profiles = config.profiles ?? {};
|
|
735
|
+
if (!(profileName in profiles)) {
|
|
736
|
+
console.log(`✗ Profile "${profileName}" not found in omni.toml`);
|
|
737
|
+
console.log("");
|
|
738
|
+
console.log("Available profiles:");
|
|
739
|
+
const profileNames = Object.keys(profiles);
|
|
740
|
+
if (profileNames.length === 0) {
|
|
741
|
+
console.log(" (none defined)");
|
|
742
|
+
} else {
|
|
743
|
+
for (const name of profileNames) {
|
|
744
|
+
console.log(` - ${name}`);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
process.exit(1);
|
|
748
|
+
}
|
|
749
|
+
await setActiveProfile(profileName);
|
|
750
|
+
console.log(`✓ Active profile set to: ${profileName}`);
|
|
751
|
+
console.log("");
|
|
752
|
+
const adapters = await getEnabledAdapters();
|
|
753
|
+
await syncAgentConfiguration({ adapters });
|
|
754
|
+
} catch (error) {
|
|
755
|
+
console.error("✗ Error setting profile:", error);
|
|
756
|
+
process.exit(1);
|
|
757
|
+
}
|
|
498
758
|
}
|
|
499
759
|
|
|
500
|
-
|
|
501
|
-
|
|
760
|
+
// src/commands/provider.ts
|
|
761
|
+
import { buildCommand as buildCommand5, buildRouteMap as buildRouteMap3 } from "@stricli/core";
|
|
502
762
|
async function runProviderList() {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
763
|
+
const enabled = await readEnabledProviders();
|
|
764
|
+
const allAdapters = getAllAdapters();
|
|
765
|
+
console.log("Available providers:");
|
|
766
|
+
console.log("");
|
|
767
|
+
for (const adapter of allAdapters) {
|
|
768
|
+
const isEnabled = enabled.includes(adapter.id);
|
|
769
|
+
const marker = isEnabled ? "●" : "○";
|
|
770
|
+
console.log(` ${marker} ${adapter.displayName} (${adapter.id})`);
|
|
771
|
+
}
|
|
772
|
+
console.log("");
|
|
773
|
+
console.log("Legend: ● enabled, ○ disabled");
|
|
514
774
|
}
|
|
515
775
|
async function runProviderEnable(_flags, providerId) {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
});
|
|
776
|
+
if (!providerId) {
|
|
777
|
+
console.error("Error: Provider ID is required");
|
|
778
|
+
console.error("Usage: omnidev provider enable <provider-id>");
|
|
779
|
+
process.exit(1);
|
|
780
|
+
}
|
|
781
|
+
const allAdapters = getAllAdapters();
|
|
782
|
+
const adapter = allAdapters.find((a) => a.id === providerId);
|
|
783
|
+
if (!adapter) {
|
|
784
|
+
console.error(`Error: Unknown provider "${providerId}"`);
|
|
785
|
+
console.error("Available providers:");
|
|
786
|
+
for (const a of allAdapters) {
|
|
787
|
+
console.error(` - ${a.id}`);
|
|
788
|
+
}
|
|
789
|
+
process.exit(1);
|
|
790
|
+
}
|
|
791
|
+
await enableProvider(providerId);
|
|
792
|
+
console.log(`✓ Enabled provider: ${adapter.displayName}`);
|
|
793
|
+
const enabledAdapters = await getEnabledAdapters();
|
|
794
|
+
await syncAgentConfiguration({ silent: false, adapters: enabledAdapters });
|
|
536
795
|
}
|
|
537
796
|
async function runProviderDisable(_flags, providerId) {
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
797
|
+
if (!providerId) {
|
|
798
|
+
console.error("Error: Provider ID is required");
|
|
799
|
+
console.error("Usage: omnidev provider disable <provider-id>");
|
|
800
|
+
process.exit(1);
|
|
801
|
+
}
|
|
802
|
+
const allAdapters = getAllAdapters();
|
|
803
|
+
const adapter = allAdapters.find((a) => a.id === providerId);
|
|
804
|
+
if (!adapter) {
|
|
805
|
+
console.error(`Error: Unknown provider "${providerId}"`);
|
|
806
|
+
console.error("Available providers:");
|
|
807
|
+
for (const a of allAdapters) {
|
|
808
|
+
console.error(` - ${a.id}`);
|
|
809
|
+
}
|
|
810
|
+
process.exit(1);
|
|
811
|
+
}
|
|
812
|
+
await disableProvider(providerId);
|
|
813
|
+
console.log(`✓ Disabled provider: ${adapter.displayName}`);
|
|
553
814
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
func: runProviderList
|
|
815
|
+
var listCommand3 = buildCommand5({
|
|
816
|
+
parameters: {
|
|
817
|
+
flags: {},
|
|
818
|
+
positional: { kind: "tuple", parameters: [] }
|
|
819
|
+
},
|
|
820
|
+
docs: {
|
|
821
|
+
brief: "List all providers and their status"
|
|
822
|
+
},
|
|
823
|
+
func: runProviderList
|
|
564
824
|
});
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
825
|
+
var enableCommand2 = buildCommand5({
|
|
826
|
+
parameters: {
|
|
827
|
+
flags: {},
|
|
828
|
+
positional: {
|
|
829
|
+
kind: "tuple",
|
|
830
|
+
parameters: [
|
|
831
|
+
{
|
|
832
|
+
brief: "Provider ID to enable",
|
|
833
|
+
parse: String,
|
|
834
|
+
optional: true
|
|
835
|
+
}
|
|
836
|
+
]
|
|
837
|
+
}
|
|
838
|
+
},
|
|
839
|
+
docs: {
|
|
840
|
+
brief: "Enable a provider"
|
|
841
|
+
},
|
|
842
|
+
func: runProviderEnable
|
|
579
843
|
});
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
844
|
+
var disableCommand2 = buildCommand5({
|
|
845
|
+
parameters: {
|
|
846
|
+
flags: {},
|
|
847
|
+
positional: {
|
|
848
|
+
kind: "tuple",
|
|
849
|
+
parameters: [
|
|
850
|
+
{
|
|
851
|
+
brief: "Provider ID to disable",
|
|
852
|
+
parse: String,
|
|
853
|
+
optional: true
|
|
854
|
+
}
|
|
855
|
+
]
|
|
856
|
+
}
|
|
857
|
+
},
|
|
858
|
+
docs: {
|
|
859
|
+
brief: "Disable a provider"
|
|
860
|
+
},
|
|
861
|
+
func: runProviderDisable
|
|
594
862
|
});
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
863
|
+
var providerRoutes = buildRouteMap3({
|
|
864
|
+
routes: {
|
|
865
|
+
list: listCommand3,
|
|
866
|
+
enable: enableCommand2,
|
|
867
|
+
disable: disableCommand2
|
|
868
|
+
},
|
|
869
|
+
docs: {
|
|
870
|
+
brief: "Manage AI provider adapters"
|
|
871
|
+
}
|
|
602
872
|
});
|
|
603
873
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
874
|
+
// src/commands/sync.ts
|
|
875
|
+
import { buildCommand as buildCommand6 } from "@stricli/core";
|
|
876
|
+
var syncCommand = buildCommand6({
|
|
877
|
+
docs: {
|
|
878
|
+
brief: "Manually sync all capabilities, roles, and instructions"
|
|
879
|
+
},
|
|
880
|
+
parameters: {},
|
|
881
|
+
async func() {
|
|
882
|
+
return await runSync();
|
|
883
|
+
}
|
|
612
884
|
});
|
|
613
885
|
async function runSync() {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
}
|
|
886
|
+
console.log("Syncing OmniDev configuration...");
|
|
887
|
+
console.log("");
|
|
888
|
+
try {
|
|
889
|
+
const config = await loadConfig();
|
|
890
|
+
const activeProfile = await getActiveProfile() ?? config.active_profile ?? "default";
|
|
891
|
+
const adapters = await getEnabledAdapters();
|
|
892
|
+
const result = await syncAgentConfiguration({ silent: false, adapters });
|
|
893
|
+
console.log("");
|
|
894
|
+
console.log("✓ Sync completed successfully!");
|
|
895
|
+
console.log("");
|
|
896
|
+
console.log(`Profile: ${activeProfile}`);
|
|
897
|
+
console.log(`Capabilities: ${result.capabilities.join(", ") || "none"}`);
|
|
898
|
+
console.log(`Providers: ${adapters.map((a) => a.displayName).join(", ") || "none"}`);
|
|
899
|
+
console.log("");
|
|
900
|
+
console.log("Synced components:");
|
|
901
|
+
console.log(" • Capability registry");
|
|
902
|
+
console.log(" • Capability sync hooks");
|
|
903
|
+
console.log(" • .omni/.gitignore");
|
|
904
|
+
console.log(" • .omni/instructions.md");
|
|
905
|
+
if (adapters.length > 0) {
|
|
906
|
+
console.log(" • Provider-specific files");
|
|
907
|
+
}
|
|
908
|
+
} catch (error) {
|
|
909
|
+
console.error("");
|
|
910
|
+
console.error("✗ Sync failed:");
|
|
911
|
+
console.error(` ${error instanceof Error ? error.message : String(error)}`);
|
|
912
|
+
process.exit(1);
|
|
913
|
+
}
|
|
643
914
|
}
|
|
644
|
-
|
|
645
|
-
//#endregion
|
|
646
|
-
//#region src/lib/dynamic-app.ts
|
|
647
|
-
/**
|
|
648
|
-
* Build CLI app with dynamically loaded capability commands
|
|
649
|
-
*/
|
|
915
|
+
// src/lib/dynamic-app.ts
|
|
650
916
|
async function buildDynamicApp() {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
917
|
+
const routes = {
|
|
918
|
+
init: initCommand,
|
|
919
|
+
doctor: doctorCommand,
|
|
920
|
+
sync: syncCommand,
|
|
921
|
+
capability: capabilityRoutes,
|
|
922
|
+
profile: profileRoutes,
|
|
923
|
+
provider: providerRoutes
|
|
924
|
+
};
|
|
925
|
+
debug("Core routes registered", Object.keys(routes));
|
|
926
|
+
if (existsSync7(".omni/config.toml")) {
|
|
927
|
+
try {
|
|
928
|
+
const capabilityCommands = await loadCapabilityCommands();
|
|
929
|
+
debug("Capability commands loaded", {
|
|
930
|
+
commands: Object.keys(capabilityCommands),
|
|
931
|
+
details: Object.entries(capabilityCommands).map(([name, cmd]) => ({
|
|
932
|
+
name,
|
|
933
|
+
type: typeof cmd,
|
|
934
|
+
constructor: cmd?.constructor?.name,
|
|
935
|
+
keys: Object.keys(cmd),
|
|
936
|
+
hasGetRoutingTargetForInput: typeof cmd?.getRoutingTargetForInput
|
|
937
|
+
}))
|
|
938
|
+
});
|
|
939
|
+
Object.assign(routes, capabilityCommands);
|
|
940
|
+
} catch (error) {
|
|
941
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
942
|
+
console.warn(`Warning: Failed to load capability commands: ${errorMessage}`);
|
|
943
|
+
debug("Full error loading capabilities", error);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
debug("Final routes", Object.keys(routes));
|
|
947
|
+
const app = buildApplication(buildRouteMap4({
|
|
948
|
+
routes,
|
|
949
|
+
docs: {
|
|
950
|
+
brief: "OmniDev commands"
|
|
951
|
+
}
|
|
952
|
+
}), {
|
|
953
|
+
name: "omnidev",
|
|
954
|
+
versionInfo: {
|
|
955
|
+
currentVersion: "0.1.0"
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
debug("App built successfully");
|
|
959
|
+
return app;
|
|
688
960
|
}
|
|
689
|
-
/**
|
|
690
|
-
* Load CLI commands from enabled capabilities
|
|
691
|
-
*/
|
|
692
961
|
async function loadCapabilityCommands() {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
962
|
+
const { buildCapabilityRegistry, installCapabilityDependencies } = await import("./shared/chunk-7txw9v1e.js");
|
|
963
|
+
await installCapabilityDependencies(true);
|
|
964
|
+
const registry = await buildCapabilityRegistry();
|
|
965
|
+
const capabilities = registry.getAllCapabilities();
|
|
966
|
+
const commands = {};
|
|
967
|
+
for (const capability of capabilities) {
|
|
968
|
+
try {
|
|
969
|
+
debug(`Loading capability '${capability.id}'`, { path: capability.path });
|
|
970
|
+
const capabilityExport = await loadCapabilityExport(capability);
|
|
971
|
+
debug(`Capability '${capability.id}' export`, {
|
|
972
|
+
found: !!capabilityExport,
|
|
973
|
+
hasCLICommands: !!capabilityExport?.cliCommands,
|
|
974
|
+
cliCommands: capabilityExport?.cliCommands ? Object.keys(capabilityExport.cliCommands) : []
|
|
975
|
+
});
|
|
976
|
+
if (capabilityExport?.cliCommands) {
|
|
977
|
+
for (const [commandName, command] of Object.entries(capabilityExport.cliCommands)) {
|
|
978
|
+
if (commands[commandName]) {
|
|
979
|
+
console.warn(`Command '${commandName}' from capability '${capability.id}' conflicts with existing command. Using '${capability.id}' version.`);
|
|
980
|
+
}
|
|
981
|
+
commands[commandName] = command;
|
|
982
|
+
debug(`Registered command '${commandName}' from '${capability.id}'`, {
|
|
983
|
+
type: typeof command,
|
|
984
|
+
constructor: command?.constructor?.name
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
} catch (error) {
|
|
989
|
+
console.error(`Failed to load capability '${capability.id}':`, error);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
return commands;
|
|
718
993
|
}
|
|
719
|
-
/**
|
|
720
|
-
* Load the default export from a capability
|
|
721
|
-
*/
|
|
722
994
|
async function loadCapabilityExport(capability) {
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
995
|
+
const capabilityPath = join5(process.cwd(), capability.path);
|
|
996
|
+
const indexPath = join5(capabilityPath, "index.ts");
|
|
997
|
+
if (!existsSync7(indexPath)) {
|
|
998
|
+
const jsIndexPath = join5(capabilityPath, "index.js");
|
|
999
|
+
if (!existsSync7(jsIndexPath)) {
|
|
1000
|
+
return null;
|
|
1001
|
+
}
|
|
1002
|
+
const module2 = await import(jsIndexPath);
|
|
1003
|
+
if (!module2.default) {
|
|
1004
|
+
return null;
|
|
1005
|
+
}
|
|
1006
|
+
return module2.default;
|
|
1007
|
+
}
|
|
1008
|
+
const module = await import(indexPath);
|
|
1009
|
+
if (!module.default) {
|
|
1010
|
+
return null;
|
|
1011
|
+
}
|
|
1012
|
+
const capExport = module.default;
|
|
1013
|
+
if (capExport.cliCommands) {
|
|
1014
|
+
for (const [name, cmd] of Object.entries(capExport.cliCommands)) {
|
|
1015
|
+
debug(`CLI command '${name}' structure`, {
|
|
1016
|
+
type: typeof cmd,
|
|
1017
|
+
constructor: cmd?.constructor?.name,
|
|
1018
|
+
keys: Object.keys(cmd),
|
|
1019
|
+
hasGetRoutingTargetForInput: typeof cmd?.getRoutingTargetForInput,
|
|
1020
|
+
routesKeys: cmd.routes ? Object.keys(cmd.routes) : undefined
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
return capExport;
|
|
743
1025
|
}
|
|
744
1026
|
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
const app = await buildDynamicApp();
|
|
1027
|
+
// src/index.ts
|
|
1028
|
+
var app = await buildDynamicApp();
|
|
748
1029
|
debug("CLI startup", {
|
|
749
|
-
|
|
750
|
-
|
|
1030
|
+
arguments: process.argv.slice(2),
|
|
1031
|
+
cwd: process.cwd()
|
|
751
1032
|
});
|
|
752
1033
|
try {
|
|
753
|
-
|
|
1034
|
+
run(app, process.argv.slice(2), {
|
|
1035
|
+
process
|
|
1036
|
+
});
|
|
754
1037
|
} catch (error) {
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
1038
|
+
if (error instanceof Error) {
|
|
1039
|
+
if (error.message.includes("getRoutingTargetForInput") || error.stack?.includes("@stricli/core")) {
|
|
1040
|
+
const args = process.argv.slice(2);
|
|
1041
|
+
console.error(`
|
|
1042
|
+
Error: Command not found or invalid usage.`);
|
|
1043
|
+
if (args.length > 0) {
|
|
1044
|
+
console.error(`
|
|
1045
|
+
You tried to run: omnidev ${args.join(" ")}`);
|
|
1046
|
+
console.error(`
|
|
1047
|
+
This could mean:`);
|
|
1048
|
+
console.error(" 1. The command doesn't exist");
|
|
1049
|
+
console.error(" 2. A required capability is not enabled");
|
|
1050
|
+
console.error(` 3. Invalid command syntax
|
|
1051
|
+
`);
|
|
1052
|
+
}
|
|
1053
|
+
console.error("Run 'omnidev --help' to see available commands");
|
|
1054
|
+
console.error(`
|
|
1055
|
+
To enable capabilities, run: omnidev capability enable <name>`);
|
|
1056
|
+
console.error("To see enabled capabilities: omnidev capability list");
|
|
1057
|
+
process.exit(1);
|
|
1058
|
+
} else {
|
|
1059
|
+
throw error;
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
770
1062
|
}
|
|
771
|
-
|
|
772
|
-
//#endregion
|