@getcoherent/cli 0.1.0 → 0.2.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.
@@ -7,12 +7,10 @@ var OpenAIClient = class _OpenAIClient {
7
7
  defaultModel;
8
8
  constructor(apiKey, model, OpenAIModule) {
9
9
  if (!OpenAIModule) {
10
- throw new Error(
11
- "OpenAI package not installed. Install it with:\n npm install openai"
12
- );
10
+ throw new Error("OpenAI package not installed. Install it with:\n npm install openai");
13
11
  }
14
- this.client = new OpenAIModule({ apiKey });
15
- this.defaultModel = model || "gpt-4-turbo-preview";
12
+ this.client = new OpenAIModule({ apiKey, maxRetries: 1 });
13
+ this.defaultModel = model || process.env.OPENAI_MODEL || "gpt-4o";
16
14
  }
17
15
  /**
18
16
  * Factory method for creating OpenAIClient
@@ -20,9 +18,7 @@ var OpenAIClient = class _OpenAIClient {
20
18
  static async create(apiKey, model) {
21
19
  const OpenAI = await import("openai").catch(() => null);
22
20
  if (!OpenAI) {
23
- throw new Error(
24
- "OpenAI package not installed. Install it with:\n npm install openai"
25
- );
21
+ throw new Error("OpenAI package not installed. Install it with:\n npm install openai");
26
22
  }
27
23
  return new _OpenAIClient(apiKey, model, OpenAI.default || OpenAI);
28
24
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.0",
6
+ "version": "0.2.0",
7
7
  "description": "CLI interface for Coherent Design Method",
8
8
  "type": "module",
9
9
  "main": "./dist/index.js",
@@ -33,27 +33,28 @@
33
33
  ],
34
34
  "author": "Coherent Design Method",
35
35
  "license": "MIT",
36
- "scripts": {
37
- "dev": "tsup --watch",
38
- "build": "tsup",
39
- "typecheck": "tsc --noEmit",
40
- "test": "vitest"
41
- },
42
36
  "dependencies": {
43
- "@getcoherent/core": "0.1.0",
44
37
  "@anthropic-ai/sdk": "^0.32.0",
45
38
  "chalk": "^5.3.0",
39
+ "chokidar": "^4.0.1",
46
40
  "commander": "^11.1.0",
47
41
  "dotenv": "^16.4.5",
48
42
  "open": "^10.1.0",
49
43
  "ora": "^7.0.1",
50
44
  "prompts": "^2.4.2",
51
45
  "zod": "^3.22.4",
52
- "chokidar": "^4.0.1"
46
+ "@getcoherent/core": "0.2.0"
53
47
  },
54
48
  "devDependencies": {
55
49
  "@types/node": "^20.11.0",
50
+ "@types/prompts": "^2.4.9",
56
51
  "tsup": "^8.0.1",
57
52
  "typescript": "^5.3.3"
53
+ },
54
+ "scripts": {
55
+ "dev": "tsup --watch",
56
+ "build": "tsup",
57
+ "typecheck": "tsc --noEmit",
58
+ "test": "vitest"
58
59
  }
59
60
  }
@@ -1,11 +0,0 @@
1
- import {
2
- createBackup,
3
- listBackups,
4
- restoreBackup
5
- } from "./chunk-N2S7FM57.js";
6
- import "./chunk-3RG5ZIWI.js";
7
- export {
8
- createBackup,
9
- listBackups,
10
- restoreBackup
11
- };
@@ -1,101 +0,0 @@
1
- // src/utils/backup.ts
2
- import { existsSync, mkdirSync, readFileSync, writeFileSync, readdirSync, rmSync, copyFileSync } from "fs";
3
- import { join, dirname } from "path";
4
- var BACKUP_DIR = ".coherent/backups";
5
- function findFiles(dir, suffix) {
6
- if (!existsSync(dir)) return [];
7
- const results = [];
8
- for (const entry of readdirSync(dir, { withFileTypes: true })) {
9
- const full = join(dir, entry.name);
10
- if (entry.isDirectory()) {
11
- results.push(...findFiles(full, suffix));
12
- } else if (entry.name.endsWith(suffix)) {
13
- results.push(full);
14
- }
15
- }
16
- return results;
17
- }
18
- var MAX_BACKUPS = 10;
19
- function getBackupRoot(projectRoot) {
20
- return join(projectRoot, BACKUP_DIR);
21
- }
22
- function createBackup(projectRoot, message) {
23
- const backupRoot = getBackupRoot(projectRoot);
24
- const id = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
25
- const backupDir = join(backupRoot, id);
26
- mkdirSync(backupDir, { recursive: true });
27
- const filesToBackup = [
28
- "design-system.config.ts",
29
- "app/layout.tsx",
30
- ...findFiles(join(projectRoot, "app"), "page.tsx").map((f) => f.slice(projectRoot.length + 1)),
31
- ...findFiles(join(projectRoot, "components", "shared"), ".tsx").map((f) => f.slice(projectRoot.length + 1))
32
- ];
33
- const backedUp = [];
34
- for (const relPath of filesToBackup) {
35
- const src = join(projectRoot, relPath);
36
- if (!existsSync(src)) continue;
37
- const dest = join(backupDir, relPath);
38
- mkdirSync(dirname(dest), { recursive: true });
39
- copyFileSync(src, dest);
40
- backedUp.push(relPath);
41
- }
42
- const manifest = {
43
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
44
- message,
45
- files: backedUp
46
- };
47
- writeFileSync(join(backupDir, "manifest.json"), JSON.stringify(manifest, null, 2));
48
- pruneOldBackups(backupRoot);
49
- return id;
50
- }
51
- function restoreBackup(projectRoot, backupId) {
52
- const backupRoot = getBackupRoot(projectRoot);
53
- if (!existsSync(backupRoot)) return null;
54
- const id = backupId || getLatestBackupId(backupRoot);
55
- if (!id) return null;
56
- const backupDir = join(backupRoot, id);
57
- const manifestPath = join(backupDir, "manifest.json");
58
- if (!existsSync(manifestPath)) return null;
59
- const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
60
- for (const relPath of manifest.files) {
61
- const src = join(backupDir, relPath);
62
- const dest = join(projectRoot, relPath);
63
- if (!existsSync(src)) continue;
64
- mkdirSync(dirname(dest), { recursive: true });
65
- copyFileSync(src, dest);
66
- }
67
- return manifest;
68
- }
69
- function listBackups(projectRoot) {
70
- const backupRoot = getBackupRoot(projectRoot);
71
- if (!existsSync(backupRoot)) return [];
72
- const dirs = readdirSync(backupRoot, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort().reverse();
73
- const results = [];
74
- for (const id of dirs) {
75
- const manifestPath = join(backupRoot, id, "manifest.json");
76
- if (!existsSync(manifestPath)) continue;
77
- try {
78
- const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
79
- results.push({ id, manifest });
80
- } catch {
81
- }
82
- }
83
- return results;
84
- }
85
- function getLatestBackupId(backupRoot) {
86
- const dirs = readdirSync(backupRoot, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort();
87
- return dirs[dirs.length - 1];
88
- }
89
- function pruneOldBackups(backupRoot) {
90
- const dirs = readdirSync(backupRoot, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort();
91
- while (dirs.length > MAX_BACKUPS) {
92
- const oldest = dirs.shift();
93
- rmSync(join(backupRoot, oldest), { recursive: true, force: true });
94
- }
95
- }
96
-
97
- export {
98
- createBackup,
99
- restoreBackup,
100
- listBackups
101
- };
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }