omo-recommend-models 1.0.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.
@@ -0,0 +1,43 @@
1
+ import fs from "node:fs";
2
+ import { execFileSync } from "node:child_process";
3
+
4
+ function backupConfig(configPath, backupPath) {
5
+ if (!fs.existsSync(configPath)) return false;
6
+ fs.copyFileSync(configPath, backupPath);
7
+ return true;
8
+ }
9
+
10
+ function restoreConfig(configPath, backupPath) {
11
+ if (!fs.existsSync(backupPath)) return false;
12
+ fs.copyFileSync(backupPath, configPath);
13
+ return true;
14
+ }
15
+
16
+ function runValidator(validatorPath, stdio = "inherit") {
17
+ execFileSync(process.execPath, [validatorPath, "--fix"], {
18
+ stdio,
19
+ env: { ...process.env, TERM: "dumb" },
20
+ });
21
+ }
22
+
23
+ function writeConfigWithValidation({
24
+ config,
25
+ configPath,
26
+ backupPath,
27
+ validatorPath,
28
+ validateStdio = "inherit",
29
+ }) {
30
+ const backedUp = backupConfig(configPath, backupPath);
31
+ fs.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\n`, "utf-8");
32
+
33
+ try {
34
+ runValidator(validatorPath, validateStdio);
35
+ } catch (err) {
36
+ if (backedUp) restoreConfig(configPath, backupPath);
37
+ throw err;
38
+ }
39
+
40
+ return { backedUp };
41
+ }
42
+
43
+ export { backupConfig, restoreConfig, runValidator, writeConfigWithValidation };
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "omo-recommend-models",
3
+ "version": "1.0.0",
4
+ "description": "Consolidated AI-powered model recommendation CLI for OpenCode OMO agent configurations",
5
+ "type": "module",
6
+ "bin": {
7
+ "omo-recommend-models": "./bin/omo-recommend-models"
8
+ },
9
+ "engines": {
10
+ "node": ">=18.0.0"
11
+ },
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/rajannpatel/omo-recommend-models.git"
16
+ },
17
+ "files": [
18
+ "bin/omo-recommend-models",
19
+ "bin/omo-validate-config",
20
+ "lib"
21
+ ],
22
+ "scripts": {
23
+ "test": "node --test"
24
+ },
25
+ "dependencies": {
26
+ "@clack/prompts": "^0.7.0",
27
+ "mri": "^1.2.0",
28
+ "picocolors": "^1.0.1"
29
+ }
30
+ }