@getcoherent/cli 0.6.45 → 0.6.47

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,98 @@
1
+ import {
2
+ runTscCheck
3
+ } from "./chunk-XPBD3L7V.js";
4
+ import {
5
+ safeWrite
6
+ } from "./chunk-U6M76BKY.js";
7
+ import "./chunk-3RG5ZIWI.js";
8
+
9
+ // src/utils/tsc-ai-fix.ts
10
+ import { readFileSync } from "fs";
11
+ import { resolve } from "path";
12
+ var MAX_AI_FILES = 5;
13
+ async function applyAiFixes(errors, projectRoot, backups, aiProvider) {
14
+ if (!aiProvider?.editPageCode) {
15
+ return { fixed: [], failed: errors };
16
+ }
17
+ const fileErrors = /* @__PURE__ */ new Map();
18
+ for (const err of errors) {
19
+ const list = fileErrors.get(err.file) || [];
20
+ list.push(err);
21
+ fileErrors.set(err.file, list);
22
+ }
23
+ const fixed = [];
24
+ const failed = [];
25
+ let filesProcessed = 0;
26
+ for (const [file, errs] of fileErrors) {
27
+ filesProcessed++;
28
+ if (filesProcessed > MAX_AI_FILES) {
29
+ failed.push(...errs);
30
+ continue;
31
+ }
32
+ const absPath = resolve(projectRoot, file);
33
+ let code;
34
+ try {
35
+ code = readFileSync(absPath, "utf-8");
36
+ } catch {
37
+ failed.push(...errs);
38
+ continue;
39
+ }
40
+ const relatedContext = gatherRelatedContext(errs, projectRoot);
41
+ const errorList = errs.map((e) => `Line ${e.line}: [${e.code}] ${e.message}`).join("\n");
42
+ const instruction = [
43
+ "Fix these TypeScript compilation errors:",
44
+ errorList,
45
+ "",
46
+ relatedContext ? `Reference interfaces (DO NOT modify these):
47
+ ${relatedContext}` : "",
48
+ "",
49
+ "Rules:",
50
+ "- Fix the data/props to match the expected types",
51
+ "- Do NOT change component interfaces or imports from shared components",
52
+ "- Keep all existing functionality intact"
53
+ ].filter(Boolean).join("\n");
54
+ try {
55
+ const fixedCode = await aiProvider.editPageCode(code, instruction, file);
56
+ if (!fixedCode || fixedCode.length < 50) {
57
+ failed.push(...errs);
58
+ continue;
59
+ }
60
+ const { ok } = safeWrite(absPath, fixedCode, projectRoot, backups);
61
+ if (!ok) {
62
+ failed.push(...errs);
63
+ continue;
64
+ }
65
+ const afterErrors = runTscCheck(projectRoot).filter((e) => e.file === file);
66
+ if (afterErrors.length >= errs.length) {
67
+ const original = backups.get(absPath);
68
+ if (original) safeWrite(absPath, original, projectRoot, backups);
69
+ failed.push(...errs);
70
+ } else {
71
+ fixed.push(file);
72
+ if (afterErrors.length > 0) failed.push(...afterErrors);
73
+ }
74
+ } catch {
75
+ failed.push(...errs);
76
+ }
77
+ }
78
+ return { fixed, failed };
79
+ }
80
+ function gatherRelatedContext(errors, projectRoot) {
81
+ const relatedFiles = /* @__PURE__ */ new Set();
82
+ for (const err of errors) {
83
+ for (const f of err.relatedFiles) relatedFiles.add(f);
84
+ }
85
+ const parts = [];
86
+ for (const file of relatedFiles) {
87
+ try {
88
+ const content = readFileSync(resolve(projectRoot, file), "utf-8");
89
+ parts.push(`// --- ${file} ---
90
+ ${content}`);
91
+ } catch {
92
+ }
93
+ }
94
+ return parts.join("\n\n");
95
+ }
96
+ export {
97
+ applyAiFixes
98
+ };
@@ -0,0 +1,16 @@
1
+ import {
2
+ applyDeterministicFixes,
3
+ fixFieldRename,
4
+ fixMissingEventHandler,
5
+ fixUnionType,
6
+ runTscCheck
7
+ } from "./chunk-XPBD3L7V.js";
8
+ import "./chunk-U6M76BKY.js";
9
+ import "./chunk-3RG5ZIWI.js";
10
+ export {
11
+ applyDeterministicFixes,
12
+ fixFieldRename,
13
+ fixMissingEventHandler,
14
+ fixUnionType,
15
+ runTscCheck
16
+ };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.6.45",
6
+ "version": "0.6.47",
7
7
  "description": "CLI interface for Coherent Design Method",
8
8
  "type": "module",
9
9
  "main": "./dist/index.js",
@@ -33,8 +33,15 @@
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
+ },
36
42
  "dependencies": {
37
43
  "@anthropic-ai/sdk": "^0.32.0",
44
+ "@getcoherent/core": "workspace:*",
38
45
  "chalk": "^5.3.0",
39
46
  "chokidar": "^4.0.1",
40
47
  "commander": "^11.1.0",
@@ -42,8 +49,7 @@
42
49
  "open": "^10.1.0",
43
50
  "ora": "^7.0.1",
44
51
  "prompts": "^2.4.2",
45
- "zod": "^3.22.4",
46
- "@getcoherent/core": "0.6.45"
52
+ "zod": "^3.22.4"
47
53
  },
48
54
  "devDependencies": {
49
55
  "@types/node": "^20.11.0",
@@ -52,11 +58,5 @@
52
58
  "react": "^19.2.4",
53
59
  "tsup": "^8.0.1",
54
60
  "typescript": "^5.3.3"
55
- },
56
- "scripts": {
57
- "dev": "tsup --watch",
58
- "build": "tsup",
59
- "typecheck": "tsc --noEmit",
60
- "test": "vitest"
61
61
  }
62
- }
62
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Sergei Kovtun
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.