cloving 0.1.7 → 0.1.9

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.
@@ -35,29 +35,24 @@ const extractJsonMetadata = (response) => {
35
35
  exports.extractJsonMetadata = extractJsonMetadata;
36
36
  // Function to extract markdown from the AI response
37
37
  const extractMarkdown = (response) => {
38
- let markdownString;
39
- // Extract the ```markdown block from the response
40
- const markdownBlockStart = response.indexOf('```markdown');
41
- const markdownBlockEnd = response.indexOf('```', markdownBlockStart + 11);
42
- if (markdownBlockStart !== -1 && markdownBlockEnd !== -1) {
43
- markdownString = response.substring(markdownBlockStart + 11, markdownBlockEnd).trim();
44
- }
45
- else {
46
- markdownString = response;
47
- }
48
- const plaintextBlockStart = response.indexOf('```plaintext');
49
- const plaintextBlockEnd = response.indexOf('```', plaintextBlockStart + 12);
50
- if (plaintextBlockStart !== -1 && plaintextBlockEnd !== -1) {
51
- markdownString = response.substring(plaintextBlockStart + 12, plaintextBlockEnd).trim();
52
- }
53
- else {
54
- markdownString = response;
38
+ let markdownString = response;
39
+ // Regular expression to match any ```<word> block
40
+ const codeBlockRegex = /```(\w+)\s*([\s\S]*?)\s*```/g;
41
+ let match;
42
+ while ((match = codeBlockRegex.exec(response)) !== null) {
43
+ // Extract the content inside the code block
44
+ const [, , content] = match;
45
+ markdownString = content.trim();
55
46
  }
56
47
  // Remove any data before the first '#'
57
48
  const jsonStartIndex = markdownString.indexOf('#');
58
49
  if (jsonStartIndex !== -1) {
59
50
  markdownString = markdownString.substring(jsonStartIndex);
60
51
  }
52
+ // Remove the last ``` if it exists
53
+ if (markdownString.endsWith('```')) {
54
+ markdownString = markdownString.substring(0, markdownString.length - 3);
55
+ }
61
56
  return markdownString;
62
57
  };
63
58
  exports.extractMarkdown = extractMarkdown;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "cloving",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
7
- "build": "tsc",
7
+ "build": "tsc && cp package.json dist/package.json",
8
8
  "start": "node dist/index.js",
9
9
  "watch": "tsc -w",
10
10
  "check": "bash -c 'npx tsc --noEmit --skipLibCheck'",
@@ -40,6 +40,7 @@
40
40
  "axios": "^1.7.2",
41
41
  "cli-highlight": "^2.1.11",
42
42
  "commander": "^12.1.0",
43
+ "copy-paste": "^1.5.3",
43
44
  "eslint": "^9.6.0",
44
45
  "eslint-config-prettier": "^9.1.0",
45
46
  "eslint-config-raine": "^0.5.0",
@@ -56,7 +57,9 @@
56
57
  "vite-node": "^2.0.1"
57
58
  },
58
59
  "devDependencies": {
60
+ "@types/copy-paste": "^1.1.33",
59
61
  "@types/ini": "^4.1.1",
62
+ "@types/inquirer": "^9.0.7",
60
63
  "@types/jest": "^29.5.12",
61
64
  "@types/node": "^20.14.10",
62
65
  "husky": "^9.0.11",