@omnidev-ai/cli 0.10.0 → 0.11.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.
Files changed (2) hide show
  1. package/dist/index.js +97 -20
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
22
22
  import { run } from "@stricli/core";
23
23
 
24
24
  // src/lib/dynamic-app.ts
25
- import { existsSync as existsSync8 } from "node:fs";
25
+ import { existsSync as existsSync9 } from "node:fs";
26
26
  import { createRequire as createRequire2 } from "node:module";
27
27
  import { join as join9 } from "node:path";
28
28
  import { buildApplication, buildRouteMap as buildRouteMap5 } from "@stricli/core";
@@ -103,12 +103,12 @@ var InstructionsMdWriter = {
103
103
  omniMdContent = await readFile2(omniMdPath, "utf-8");
104
104
  }
105
105
  let content = omniMdContent;
106
- content += `
107
-
108
- ## OmniDev
106
+ if (bundle.instructionsContent) {
107
+ content += `
109
108
 
110
109
  ${bundle.instructionsContent}
111
110
  `;
111
+ }
112
112
  await writeFile3(outputFullPath, content, "utf-8");
113
113
  return {
114
114
  filesWritten: [ctx.outputPath]
@@ -365,7 +365,7 @@ async function runAddCap(flags, name) {
365
365
  console.log(` Inferred capability ID: ${capabilityId}`);
366
366
  }
367
367
  const config = await loadBaseConfig();
368
- const activeProfile = await getActiveProfile() ?? config.active_profile ?? "default";
368
+ const activeProfile = await getActiveProfile() ?? "default";
369
369
  if (config.capabilities?.sources?.[capabilityId]) {
370
370
  console.error(`✗ Capability source "${capabilityId}" already exists`);
371
371
  console.log(" Use a different name or remove the existing source first");
@@ -400,7 +400,7 @@ async function runAddMcp(flags, name) {
400
400
  process.exit(1);
401
401
  }
402
402
  const config = await loadBaseConfig();
403
- const activeProfile = await getActiveProfile() ?? config.active_profile ?? "default";
403
+ const activeProfile = await getActiveProfile() ?? "default";
404
404
  if (config.mcps?.[name]) {
405
405
  console.error(`✗ MCP "${name}" already exists`);
406
406
  console.log(" Use a different name or remove the existing MCP first");
@@ -1205,13 +1205,7 @@ async function runInit(_flags, providerArg) {
1205
1205
  projectRoot: process.cwd(),
1206
1206
  config
1207
1207
  };
1208
- const allAdapters = getAllAdapters();
1209
- const selectedAdapters = allAdapters.filter((a) => providerIds.includes(a.id));
1210
- for (const adapter of selectedAdapters) {
1211
- if (adapter.init) {
1212
- await adapter.init(ctx);
1213
- }
1214
- }
1208
+ const selectedAdapters = await initializeAdaptersForProviders(providerIds, ctx);
1215
1209
  const enabledAdapters = await getEnabledAdapters();
1216
1210
  await syncAgentConfiguration3({ silent: true, adapters: enabledAdapters });
1217
1211
  console.log("");
@@ -1222,6 +1216,16 @@ async function runInit(_flags, providerArg) {
1222
1216
  console.log("");
1223
1217
  console.log("\uD83D\uDCA1 Run 'omnidev capability list' to see available capabilities.");
1224
1218
  }
1219
+ async function initializeAdaptersForProviders(providerIds, ctx) {
1220
+ const allAdapters = getAllAdapters();
1221
+ const selectedAdapters = allAdapters.filter((a) => providerIds.includes(a.id));
1222
+ for (const adapter of selectedAdapters) {
1223
+ if (adapter.init) {
1224
+ await adapter.init(ctx);
1225
+ }
1226
+ }
1227
+ return selectedAdapters;
1228
+ }
1225
1229
  var initCommand = buildCommand4({
1226
1230
  parameters: {
1227
1231
  flags: {},
@@ -1359,7 +1363,7 @@ async function runProfileList() {
1359
1363
  process.exit(1);
1360
1364
  }
1361
1365
  const config = await loadConfig2();
1362
- const activeProfile = await getActiveProfile2() ?? config.active_profile ?? "default";
1366
+ const activeProfile = await getActiveProfile2() ?? "default";
1363
1367
  const profiles = config.profiles ?? {};
1364
1368
  const profileNames = Object.keys(profiles);
1365
1369
  if (profileNames.length === 0) {
@@ -1546,8 +1550,15 @@ var providerRoutes = buildRouteMap4({
1546
1550
  });
1547
1551
 
1548
1552
  // src/commands/sync.ts
1549
- import { getActiveProfile as getActiveProfile3, loadConfig as loadConfig3, syncAgentConfiguration as syncAgentConfiguration6 } from "@omnidev-ai/core";
1553
+ import { existsSync as existsSync8 } from "node:fs";
1554
+ import {
1555
+ getActiveProfile as getActiveProfile3,
1556
+ loadConfig as loadConfig3,
1557
+ syncAgentConfiguration as syncAgentConfiguration6,
1558
+ writeEnabledProviders as writeEnabledProviders2
1559
+ } from "@omnidev-ai/core";
1550
1560
  import { buildCommand as buildCommand7 } from "@stricli/core";
1561
+ var PROVIDERS_STATE_PATH = ".omni/state/providers.json";
1551
1562
  var syncCommand = buildCommand7({
1552
1563
  docs: {
1553
1564
  brief: "Manually sync all capabilities, roles, and instructions"
@@ -1562,8 +1573,19 @@ async function runSync() {
1562
1573
  console.log("");
1563
1574
  try {
1564
1575
  const config = await loadConfig3();
1565
- const activeProfile = await getActiveProfile3() ?? config.active_profile ?? "default";
1566
- const adapters = await getEnabledAdapters();
1576
+ const activeProfile = await getActiveProfile3() ?? "default";
1577
+ let adapters = await getEnabledAdapters();
1578
+ if (!existsSync8(PROVIDERS_STATE_PATH) || adapters.length === 0) {
1579
+ console.log("No providers configured yet. Select your provider(s):");
1580
+ const providerIds = await promptForProviders();
1581
+ await writeEnabledProviders2(providerIds);
1582
+ const ctx = {
1583
+ projectRoot: process.cwd(),
1584
+ config
1585
+ };
1586
+ adapters = await initializeAdaptersForProviders(providerIds, ctx);
1587
+ console.log("");
1588
+ }
1567
1589
  const result = await syncAgentConfiguration6({ silent: false, adapters });
1568
1590
  console.log("");
1569
1591
  console.log("✓ Sync completed successfully!");
@@ -1610,7 +1632,7 @@ async function buildDynamicApp() {
1610
1632
  provider: providerRoutes
1611
1633
  };
1612
1634
  debug("Core routes registered", Object.keys(routes));
1613
- if (existsSync8(".omni/config.toml")) {
1635
+ if (existsSync9(".omni/config.toml")) {
1614
1636
  try {
1615
1637
  const capabilityCommands = await loadCapabilityCommands();
1616
1638
  debug("Capability commands loaded", {
@@ -1681,9 +1703,9 @@ async function loadCapabilityCommands() {
1681
1703
  async function loadCapabilityExport(capability) {
1682
1704
  const capabilityPath = join9(process.cwd(), capability.path);
1683
1705
  const indexPath = join9(capabilityPath, "index.ts");
1684
- if (!existsSync8(indexPath)) {
1706
+ if (!existsSync9(indexPath)) {
1685
1707
  const jsIndexPath = join9(capabilityPath, "index.js");
1686
- if (!existsSync8(jsIndexPath)) {
1708
+ if (!existsSync9(jsIndexPath)) {
1687
1709
  return null;
1688
1710
  }
1689
1711
  const module2 = await import(jsIndexPath);
@@ -1713,15 +1735,70 @@ async function loadCapabilityExport(capability) {
1713
1735
 
1714
1736
  // src/index.ts
1715
1737
  import { debug as debug2 } from "@omnidev-ai/core";
1738
+
1739
+ // src/lib/version-check.ts
1740
+ var NPM_REGISTRY_URL = "https://registry.npmjs.org/@omnidev-ai/cli/latest";
1741
+ var FETCH_TIMEOUT_MS = 3000;
1742
+ async function fetchLatestVersion() {
1743
+ try {
1744
+ const controller = new AbortController;
1745
+ const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
1746
+ const response = await fetch(NPM_REGISTRY_URL, {
1747
+ signal: controller.signal,
1748
+ headers: {
1749
+ Accept: "application/json"
1750
+ }
1751
+ });
1752
+ clearTimeout(timeoutId);
1753
+ if (!response.ok) {
1754
+ return null;
1755
+ }
1756
+ const data = await response.json();
1757
+ return data.version ?? null;
1758
+ } catch {
1759
+ return null;
1760
+ }
1761
+ }
1762
+ function isNewerVersion(currentVersion, latestVersion) {
1763
+ const current = currentVersion.split(".").map(Number);
1764
+ const latest = latestVersion.split(".").map(Number);
1765
+ for (let i = 0;i < Math.max(current.length, latest.length); i++) {
1766
+ const c = current[i] ?? 0;
1767
+ const l = latest[i] ?? 0;
1768
+ if (l > c)
1769
+ return true;
1770
+ if (l < c)
1771
+ return false;
1772
+ }
1773
+ return false;
1774
+ }
1775
+ async function checkForUpdates(currentVersion) {
1776
+ try {
1777
+ const latestVersion = await fetchLatestVersion();
1778
+ if (!latestVersion) {
1779
+ return;
1780
+ }
1781
+ if (isNewerVersion(currentVersion, latestVersion)) {
1782
+ console.log("");
1783
+ console.log(`\x1B[33m⚠️ A new version of OmniDev is available: ${latestVersion} (current: ${currentVersion})\x1B[0m`);
1784
+ console.log(` Run \x1B[36mnpm update -g @omnidev-ai/cli\x1B[0m to update`);
1785
+ console.log("");
1786
+ }
1787
+ } catch {}
1788
+ }
1789
+
1790
+ // src/index.ts
1716
1791
  var app = await buildDynamicApp();
1717
1792
  debug2("CLI startup", {
1718
1793
  arguments: process.argv.slice(2),
1719
1794
  cwd: process.cwd()
1720
1795
  });
1796
+ var versionCheckPromise = checkForUpdates(readCliVersion());
1721
1797
  try {
1722
1798
  run(app, process.argv.slice(2), {
1723
1799
  process
1724
1800
  });
1801
+ await versionCheckPromise;
1725
1802
  } catch (error) {
1726
1803
  if (error instanceof Error) {
1727
1804
  if (error.message.includes("getRoutingTargetForInput") || error.stack?.includes("@stricli/core")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnidev-ai/cli",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@inquirer/prompts": "^8.1.0",
31
- "@omnidev-ai/core": "0.10.0",
31
+ "@omnidev-ai/core": "0.11.0",
32
32
  "@stricli/core": "^1.2.5"
33
33
  },
34
34
  "devDependencies": {