@far-world-labs/verblets 0.1.1

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 (167) hide show
  1. package/.eslintrc.json +42 -0
  2. package/.husky/pre-commit +4 -0
  3. package/.release-it.json +9 -0
  4. package/.vite.config.examples.js +8 -0
  5. package/.vite.config.js +8 -0
  6. package/docker-compose.yml +7 -0
  7. package/docs/README.md +41 -0
  8. package/docs/babel.config.js +3 -0
  9. package/docs/blog/2019-05-28-first-blog-post.md +12 -0
  10. package/docs/blog/2019-05-29-long-blog-post.md +44 -0
  11. package/docs/blog/2021-08-01-mdx-blog-post.mdx +20 -0
  12. package/docs/blog/2021-08-26-welcome/docusaurus-plushie-banner.jpeg +0 -0
  13. package/docs/blog/2021-08-26-welcome/index.md +25 -0
  14. package/docs/blog/authors.yml +17 -0
  15. package/docs/docs/api/bool.md +74 -0
  16. package/docs/docs/api/search.md +51 -0
  17. package/docs/docs/intro.md +47 -0
  18. package/docs/docs/tutorial-basics/_category_.json +8 -0
  19. package/docs/docs/tutorial-basics/congratulations.md +23 -0
  20. package/docs/docs/tutorial-basics/create-a-blog-post.md +34 -0
  21. package/docs/docs/tutorial-basics/create-a-document.md +57 -0
  22. package/docs/docs/tutorial-basics/create-a-page.md +43 -0
  23. package/docs/docs/tutorial-basics/deploy-your-site.md +31 -0
  24. package/docs/docs/tutorial-basics/markdown-features.mdx +152 -0
  25. package/docs/docs/tutorial-extras/_category_.json +7 -0
  26. package/docs/docs/tutorial-extras/img/docsVersionDropdown.png +0 -0
  27. package/docs/docs/tutorial-extras/img/localeDropdown.png +0 -0
  28. package/docs/docs/tutorial-extras/manage-docs-versions.md +55 -0
  29. package/docs/docs/tutorial-extras/translate-your-site.md +88 -0
  30. package/docs/docusaurus.config.js +120 -0
  31. package/docs/package.json +44 -0
  32. package/docs/sidebars.js +31 -0
  33. package/docs/src/components/HomepageFeatures/index.js +61 -0
  34. package/docs/src/components/HomepageFeatures/styles.module.css +11 -0
  35. package/docs/src/css/custom.css +30 -0
  36. package/docs/src/pages/index.js +43 -0
  37. package/docs/src/pages/index.module.css +23 -0
  38. package/docs/src/pages/markdown-page.md +7 -0
  39. package/docs/static/.nojekyll +0 -0
  40. package/docs/static/img/docusaurus-social-card.jpg +0 -0
  41. package/docs/static/img/docusaurus.png +0 -0
  42. package/docs/static/img/favicon.ico +0 -0
  43. package/docs/static/img/logo.svg +1 -0
  44. package/docs/static/img/undraw_docusaurus_mountain.svg +171 -0
  45. package/docs/static/img/undraw_docusaurus_react.svg +170 -0
  46. package/docs/static/img/undraw_docusaurus_tree.svg +40 -0
  47. package/package.json +75 -0
  48. package/scripts/generate-chain/index.js +111 -0
  49. package/scripts/generate-lib/index.js +68 -0
  50. package/scripts/generate-test/index.js +111 -0
  51. package/scripts/generate-verblet/README.md +17 -0
  52. package/scripts/generate-verblet/index.js +110 -0
  53. package/scripts/run.sh +15 -0
  54. package/scripts/runner/index.js +30 -0
  55. package/scripts/simple-editor/README.md +34 -0
  56. package/scripts/simple-editor/index.js +68 -0
  57. package/scripts/summarize-files/index.js +46 -0
  58. package/src/chains/dismantle/dismantle.examples.js +0 -0
  59. package/src/chains/dismantle/index.examples.js +30 -0
  60. package/src/chains/dismantle/index.js +314 -0
  61. package/src/chains/dismantle/index.spec.js +33 -0
  62. package/src/chains/list/index.examples.js +72 -0
  63. package/src/chains/list/index.js +161 -0
  64. package/src/chains/list/index.spec.js +68 -0
  65. package/src/chains/list/schema.json +24 -0
  66. package/src/chains/questions/index.examples.js +68 -0
  67. package/src/chains/questions/index.js +136 -0
  68. package/src/chains/questions/index.spec.js +29 -0
  69. package/src/chains/scan-js/index.js +119 -0
  70. package/src/chains/sort/index.examples.js +40 -0
  71. package/src/chains/sort/index.js +113 -0
  72. package/src/chains/sort/index.spec.js +115 -0
  73. package/src/chains/summary-map/README.md +33 -0
  74. package/src/chains/summary-map/index.examples.js +57 -0
  75. package/src/chains/summary-map/index.js +208 -0
  76. package/src/chains/summary-map/index.spec.js +78 -0
  77. package/src/chains/test/index.js +118 -0
  78. package/src/chains/test-advice/index.js +36 -0
  79. package/src/constants/common.js +9 -0
  80. package/src/constants/messages.js +3 -0
  81. package/src/constants/openai.js +65 -0
  82. package/src/index.js +33 -0
  83. package/src/json-schemas/cars-test.json +11 -0
  84. package/src/json-schemas/index.js +18 -0
  85. package/src/json-schemas/intent.json +38 -0
  86. package/src/json-schemas/schema-dot-org-photograph.json +127 -0
  87. package/src/json-schemas/schema-dot-org-place.json +56 -0
  88. package/src/lib/any-signal/index.js +28 -0
  89. package/src/lib/chatgpt/index.js +143 -0
  90. package/src/lib/editor/index.js +31 -0
  91. package/src/lib/parse-js-parts/index.js +333 -0
  92. package/src/lib/parse-js-parts/index.spec.js +156 -0
  93. package/src/lib/path-aliases/index.js +39 -0
  94. package/src/lib/path-aliases/index.spec.js +70 -0
  95. package/src/lib/pave/index.js +34 -0
  96. package/src/lib/pave/index.spec.js +73 -0
  97. package/src/lib/prompt-cache/index.js +46 -0
  98. package/src/lib/retry/index.js +63 -0
  99. package/src/lib/retry/index.spec.js +86 -0
  100. package/src/lib/search-best-first/index.js +66 -0
  101. package/src/lib/search-js-files/code-features-property-definitions.json +123 -0
  102. package/src/lib/search-js-files/index.examples.js +22 -0
  103. package/src/lib/search-js-files/index.js +158 -0
  104. package/src/lib/search-js-files/index.spec.js +34 -0
  105. package/src/lib/search-js-files/scan-file.js +253 -0
  106. package/src/lib/shorten-text/index.js +30 -0
  107. package/src/lib/shorten-text/index.spec.js +68 -0
  108. package/src/lib/strip-numeric/index.js +5 -0
  109. package/src/lib/strip-response/index.js +35 -0
  110. package/src/lib/timed-abort-controller/index.js +41 -0
  111. package/src/lib/to-bool/index.js +8 -0
  112. package/src/lib/to-enum/index.js +14 -0
  113. package/src/lib/to-number/index.js +12 -0
  114. package/src/lib/to-number-with-units/index.js +51 -0
  115. package/src/lib/transcribe/index.js +61 -0
  116. package/src/prompts/README.md +15 -0
  117. package/src/prompts/as-enum.js +5 -0
  118. package/src/prompts/as-json-schema.js +9 -0
  119. package/src/prompts/as-object-with-schema.js +31 -0
  120. package/src/prompts/as-schema-org-text.js +17 -0
  121. package/src/prompts/as-schema-org-type.js +1 -0
  122. package/src/prompts/blog-post.js +7 -0
  123. package/src/prompts/code-features.js +28 -0
  124. package/src/prompts/constants.js +101 -0
  125. package/src/prompts/features-json-schema.js +27 -0
  126. package/src/prompts/generate-collection.js +26 -0
  127. package/src/prompts/generate-list.js +48 -0
  128. package/src/prompts/generate-questions.js +19 -0
  129. package/src/prompts/index.js +20 -0
  130. package/src/prompts/intent.js +66 -0
  131. package/src/prompts/output-succinct-names.js +3 -0
  132. package/src/prompts/select-from-threshold.js +18 -0
  133. package/src/prompts/sort.js +35 -0
  134. package/src/prompts/style.js +41 -0
  135. package/src/prompts/summarize.js +13 -0
  136. package/src/prompts/token-budget.js +3 -0
  137. package/src/prompts/wrap-list.js +14 -0
  138. package/src/prompts/wrap-variable.js +36 -0
  139. package/src/services/llm-model/index.js +114 -0
  140. package/src/services/llm-model/model.js +21 -0
  141. package/src/services/redis/index.js +84 -0
  142. package/src/verblets/auto/index.examples.js +28 -0
  143. package/src/verblets/auto/index.js +28 -0
  144. package/src/verblets/auto/index.spec.js +34 -0
  145. package/src/verblets/bool/index.examples.js +28 -0
  146. package/src/verblets/bool/index.js +28 -0
  147. package/src/verblets/bool/index.schema.json +14 -0
  148. package/src/verblets/bool/index.spec.js +35 -0
  149. package/src/verblets/enum/index.examples.js +33 -0
  150. package/src/verblets/enum/index.js +15 -0
  151. package/src/verblets/enum/index.spec.js +35 -0
  152. package/src/verblets/intent/index.examples.js +51 -0
  153. package/src/verblets/intent/index.js +72 -0
  154. package/src/verblets/intent/index.spec.js +31 -0
  155. package/src/verblets/number/index.examples.js +33 -0
  156. package/src/verblets/number/index.js +22 -0
  157. package/src/verblets/number/index.spec.js +35 -0
  158. package/src/verblets/number-with-units/index.examples.js +34 -0
  159. package/src/verblets/number-with-units/index.js +19 -0
  160. package/src/verblets/number-with-units/index.spec.js +46 -0
  161. package/src/verblets/schema-org/index.examples.js +56 -0
  162. package/src/verblets/schema-org/index.js +8 -0
  163. package/src/verblets/schema-org/index.spec.js +39 -0
  164. package/src/verblets/to-object/README.md +38 -0
  165. package/src/verblets/to-object/index.examples.js +29 -0
  166. package/src/verblets/to-object/index.js +136 -0
  167. package/src/verblets/to-object/index.spec.js +74 -0
package/.eslintrc.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "extends": [
3
+ "eslint:recommended",
4
+ "airbnb",
5
+ "plugin:prettier/recommended"
6
+ ],
7
+ "plugins": ["jest"],
8
+ "parserOptions": {
9
+ "ecmaVersion": 2022,
10
+ "sourceType": "module"
11
+ },
12
+ "env": {
13
+ "es2022": true,
14
+ "node": true
15
+ },
16
+ "rules": {
17
+ "import/extensions": "off",
18
+ "no-console": "off",
19
+ "no-multi-str": "off",
20
+ "no-restricted-syntax": "warn",
21
+ "no-underscore-dangle": ["warn", { "allow": ["__dirname"] }],
22
+ "no-unused-vars": ["warn", { "argsIgnorePattern": "next" }],
23
+ "object-shorthand": "off",
24
+ "prettier/prettier": ["error", { "singleQuote": true }],
25
+ "quotes": ["error", "single", { "allowTemplateLiterals": true }],
26
+ "no-restricted-syntax": [
27
+ "error",
28
+ {
29
+ "selector": "ForInStatement",
30
+ "message": "for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array."
31
+ },
32
+ {
33
+ "selector": "LabeledStatement",
34
+ "message": "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand."
35
+ },
36
+ {
37
+ "selector": "WithStatement",
38
+ "message": "`with` is disallowed in strict mode because it makes code impossible to predict and optimize."
39
+ }
40
+ ]
41
+ }
42
+ }
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npm run lint
@@ -0,0 +1,9 @@
1
+ {
2
+ "git": {
3
+ "commitMessage": "chore: release v${version}",
4
+ "tagName": "v${version}"
5
+ },
6
+ "npm": {
7
+ "publish": false
8
+ }
9
+ }
@@ -0,0 +1,8 @@
1
+ import { configDefaults, defineConfig } from 'vitest/config'
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ exclude: [...configDefaults.exclude],
6
+ include: ['src/**/*.examples.js']
7
+ },
8
+ });
@@ -0,0 +1,8 @@
1
+ import { configDefaults, defineConfig } from 'vitest/config'
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ exclude: [...configDefaults.exclude],
6
+ include: ['**/*.spec.js']
7
+ },
8
+ });
@@ -0,0 +1,7 @@
1
+ version: '3.8'
2
+
3
+ services:
4
+ redis:
5
+ image: 'redis:latest'
6
+ ports:
7
+ - '6379:6379'
package/docs/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Website
2
+
3
+ This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
4
+
5
+ ### Installation
6
+
7
+ ```
8
+ $ yarn
9
+ ```
10
+
11
+ ### Local Development
12
+
13
+ ```
14
+ $ yarn start
15
+ ```
16
+
17
+ This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
18
+
19
+ ### Build
20
+
21
+ ```
22
+ $ yarn build
23
+ ```
24
+
25
+ This command generates static content into the `build` directory and can be served using any static contents hosting service.
26
+
27
+ ### Deployment
28
+
29
+ Using SSH:
30
+
31
+ ```
32
+ $ USE_SSH=true yarn deploy
33
+ ```
34
+
35
+ Not using SSH:
36
+
37
+ ```
38
+ $ GIT_USER=<Your GitHub username> yarn deploy
39
+ ```
40
+
41
+ If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
3
+ };
@@ -0,0 +1,12 @@
1
+ ---
2
+ slug: first-blog-post
3
+ title: First Blog Post
4
+ authors:
5
+ name: Gao Wei
6
+ title: Docusaurus Core Team
7
+ url: https://github.com/wgao19
8
+ image_url: https://github.com/wgao19.png
9
+ tags: [hola, docusaurus]
10
+ ---
11
+
12
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
@@ -0,0 +1,44 @@
1
+ ---
2
+ slug: long-blog-post
3
+ title: Long Blog Post
4
+ authors: endi
5
+ tags: [hello, docusaurus]
6
+ ---
7
+
8
+ This is the summary of a very long blog post,
9
+
10
+ Use a `<!--` `truncate` `-->` comment to limit blog post size in the list view.
11
+
12
+ <!--truncate-->
13
+
14
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
15
+
16
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
17
+
18
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
19
+
20
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
21
+
22
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
23
+
24
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
25
+
26
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
27
+
28
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
29
+
30
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
31
+
32
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
33
+
34
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
35
+
36
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
37
+
38
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
39
+
40
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
41
+
42
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
43
+
44
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
@@ -0,0 +1,20 @@
1
+ ---
2
+ slug: mdx-blog-post
3
+ title: MDX Blog Post
4
+ authors: [slorber]
5
+ tags: [docusaurus]
6
+ ---
7
+
8
+ Blog posts support [Docusaurus Markdown features](https://docusaurus.io/docs/markdown-features), such as [MDX](https://mdxjs.com/).
9
+
10
+ :::tip
11
+
12
+ Use the power of React to create interactive blog posts.
13
+
14
+ ```js
15
+ <button onClick={() => alert('button clicked!')}>Click me!</button>
16
+ ```
17
+
18
+ <button onClick={() => alert('button clicked!')}>Click me!</button>
19
+
20
+ :::
@@ -0,0 +1,25 @@
1
+ ---
2
+ slug: welcome
3
+ title: Welcome
4
+ authors: [slorber, yangshun]
5
+ tags: [facebook, hello, docusaurus]
6
+ ---
7
+
8
+ [Docusaurus blogging features](https://docusaurus.io/docs/blog) are powered by the [blog plugin](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-blog).
9
+
10
+ Simply add Markdown files (or folders) to the `blog` directory.
11
+
12
+ Regular blog authors can be added to `authors.yml`.
13
+
14
+ The blog post date can be extracted from filenames, such as:
15
+
16
+ - `2019-05-30-welcome.md`
17
+ - `2019-05-30-welcome/index.md`
18
+
19
+ A blog post folder can be convenient to co-locate blog post images:
20
+
21
+ ![Docusaurus Plushie](./docusaurus-plushie-banner.jpeg)
22
+
23
+ The blog supports tags as well!
24
+
25
+ **And if you don't want a blog**: just delete this directory, and use `blog: false` in your Docusaurus config.
@@ -0,0 +1,17 @@
1
+ endi:
2
+ name: Endilie Yacop Sucipto
3
+ title: Maintainer of Docusaurus
4
+ url: https://github.com/endiliey
5
+ image_url: https://github.com/endiliey.png
6
+
7
+ yangshun:
8
+ name: Yangshun Tay
9
+ title: Front End Engineer @ Facebook
10
+ url: https://github.com/yangshun
11
+ image_url: https://github.com/yangshun.png
12
+
13
+ slorber:
14
+ name: Sébastien Lorber
15
+ title: Docusaurus maintainer
16
+ url: https://sebastienlorber.com
17
+ image_url: https://github.com/slorber.png
@@ -0,0 +1,74 @@
1
+ # Bool
2
+
3
+ ## Overview
4
+
5
+ The Bool module is a general-purpose JavaScript utility function to work with LLM responses as a single boolean value. This is useful in applications requiring decision-making logic based on complex LLM inputs, without the overhead of handling extensive data outputs. Applications include feature toggles, validation, and data-driven workflow decisions.
6
+
7
+ ## Usage
8
+
9
+ The primary function `bool(text)` takes a string text as input and returns a boolean value.
10
+
11
+ ```javascript
12
+ import verblets from '@far-world-labs/verblets';
13
+
14
+ const options = {
15
+ node: { filename: './src/index.js' },
16
+ features: 'maintainability', // Specify features to analyze
17
+ };
18
+
19
+ try {
20
+ const result = await verblets.scanJS(options);
21
+ console.log(result);
22
+ } catch (error) {
23
+ console.log(error);
24
+ }
25
+ ```
26
+
27
+ ## Examples
28
+
29
+ ### Evaluating natural language inputs
30
+
31
+ ```javascript
32
+ const feedback = "I love the new update, it's fantastic!";
33
+ const isPositiveFeedback = await bool(`Is the following user feedback positive? "${feedback}"`);
34
+ if (isPositiveFeedback) {
35
+ console.log("Positive feedback received.");
36
+ } else {
37
+ console.log("Negative feedback received.");
38
+ }
39
+ ```
40
+
41
+ ### Content Appropriateness Checker
42
+ ```javascript
43
+ const userContent = "This is some user-generated content...";
44
+ const isAppropriate = await bool(`Is the following content appropriate for all ages? "${userContent}"`);
45
+ if (!isAppropriate) {
46
+ console.log("Content flagged as inappropriate.");
47
+ }
48
+ ```
49
+
50
+ ### Triage Based on Issue Description
51
+ ```javascript
52
+ const bugDescription = "The app crashes when I click the save button.";
53
+ const isCriticalBug = await bool(`Is the following bug critical? "${bugDescription}"`);
54
+ if (isCriticalBug) {
55
+ console.log("Critical bug reported.");
56
+ } else {
57
+ console.log("Bug is not critical.");
58
+ }
59
+ ```
60
+
61
+
62
+ ## API Reference
63
+
64
+ ### `bool(text)`
65
+
66
+ Interprets a given text and returns a boolean value based on the Large Language Model's response.
67
+
68
+ #### Parameters
69
+
70
+ - `text` (String): The text to be evaluated by the Large Language Model.
71
+
72
+ #### Returns
73
+
74
+ - `(Promise<Boolean>)`: A promise that resolves to a boolean value. `true` if the LLM interprets the text affirmatively, and `false` otherwise.
@@ -0,0 +1,51 @@
1
+ # JavaScript Scanner
2
+
3
+ ## Overview
4
+
5
+ This module provides a basic framework for analyzing JavaScript repositories. It scans JavaScript files function-by-function, and evaluates them based on a variety of criteria including maintainability, readability, and performance, as well as user-defined criteria.
6
+
7
+ The algorithm scans a JavaScript codebase to evaluate various code quality metrics. It reads these features from a JSON file, sorts and filters the resulting functions based on given criteria, and then iteratively visits different parts of the codebase. For each visited function, the scanner uses the ChatGPT API to analyze the code based on the predetermined features and criteria. The results are then organized, structured, and output to the console.
8
+
9
+ ## Features
10
+
11
+ - **Best-First Search**: Scans JavaScript repositories using a best-first search strategy.
12
+ - **Function Analysis**: Evaluates functions based on predefined criteria such as single responsibility, clear naming, small size, and more.
13
+ - **Code Feature Extraction**: Utilizes a JSON schema for defining and extracting code features.
14
+ - **Path Aliasing**: Supports path aliasing for better readability of output.
15
+
16
+ ## Usage
17
+
18
+ To use the module, you need to call the main function with the appropriate options. Here's an example of how to use it:
19
+
20
+ ```javascript
21
+ import verblets from '@far-world-labs/verblets';
22
+
23
+ const options = {
24
+ node: { filename: './src/index.js' },
25
+ features: 'maintainability', // Specify features to analyze
26
+ };
27
+
28
+ try {
29
+ const result = await verblets.scanJS(options);
30
+ console.log(result);
31
+ } catch (error) {
32
+ console.log(error);
33
+ }
34
+ ```
35
+
36
+ ## API Reference
37
+
38
+ ### `scanJS(options)`
39
+
40
+ Analyzes a JavaScript repository.
41
+
42
+ #### Parameters
43
+
44
+ - `options` (Object): Configuration options for the analysis.
45
+ - `node` (Object): Specifies the starting point for the analysis.
46
+ - `filename` (String): Path to the JavaScript file to start analysis.
47
+ - `features` (String): Feature criteria for analysis (e.g., 'maintainability').
48
+
49
+ #### Returns
50
+
51
+ - `(Promise<Object>)`: A promise that resolves to an object containing the analysis results.
@@ -0,0 +1,47 @@
1
+ ---
2
+ sidebar_position: 1
3
+ ---
4
+
5
+ # Tutorial Intro
6
+
7
+ Let's discover **Docusaurus in less than 5 minutes**.
8
+
9
+ ## Getting Started
10
+
11
+ Get started by **creating a new site**.
12
+
13
+ Or **try Docusaurus immediately** with **[docusaurus.new](https://docusaurus.new)**.
14
+
15
+ ### What you'll need
16
+
17
+ - [Node.js](https://nodejs.org/en/download/) version 18.0 or above:
18
+ - When installing Node.js, you are recommended to check all checkboxes related to dependencies.
19
+
20
+ ## Generate a new site
21
+
22
+ Generate a new Docusaurus site using the **classic template**.
23
+
24
+ The classic template will automatically be added to your project after you run the command:
25
+
26
+ ```bash
27
+ npm init docusaurus@latest my-website classic
28
+ ```
29
+
30
+ You can type this command into Command Prompt, Powershell, Terminal, or any other integrated terminal of your code editor.
31
+
32
+ The command also installs all necessary dependencies you need to run Docusaurus.
33
+
34
+ ## Start your site
35
+
36
+ Run the development server:
37
+
38
+ ```bash
39
+ cd my-website
40
+ npm run start
41
+ ```
42
+
43
+ The `cd` command changes the directory you're working with. In order to work with your newly created Docusaurus site, you'll need to navigate the terminal there.
44
+
45
+ The `npm run start` command builds your website locally and serves it through a development server, ready for you to view at http://localhost:3000/.
46
+
47
+ Open `docs/intro.md` (this page) and edit some lines: the site **reloads automatically** and displays your changes.
@@ -0,0 +1,8 @@
1
+ {
2
+ "label": "Tutorial - Basics",
3
+ "position": 2,
4
+ "link": {
5
+ "type": "generated-index",
6
+ "description": "5 minutes to learn the most important Docusaurus concepts."
7
+ }
8
+ }
@@ -0,0 +1,23 @@
1
+ ---
2
+ sidebar_position: 6
3
+ ---
4
+
5
+ # Congratulations!
6
+
7
+ You have just learned the **basics of Docusaurus** and made some changes to the **initial template**.
8
+
9
+ Docusaurus has **much more to offer**!
10
+
11
+ Have **5 more minutes**? Take a look at **[versioning](../tutorial-extras/manage-docs-versions.md)** and **[i18n](../tutorial-extras/translate-your-site.md)**.
12
+
13
+ Anything **unclear** or **buggy** in this tutorial? [Please report it!](https://github.com/facebook/docusaurus/discussions/4610)
14
+
15
+ ## What's next?
16
+
17
+ - Read the [official documentation](https://docusaurus.io/)
18
+ - Modify your site configuration with [`docusaurus.config.js`](https://docusaurus.io/docs/api/docusaurus-config)
19
+ - Add navbar and footer items with [`themeConfig`](https://docusaurus.io/docs/api/themes/configuration)
20
+ - Add a custom [Design and Layout](https://docusaurus.io/docs/styling-layout)
21
+ - Add a [search bar](https://docusaurus.io/docs/search)
22
+ - Find inspirations in the [Docusaurus showcase](https://docusaurus.io/showcase)
23
+ - Get involved in the [Docusaurus Community](https://docusaurus.io/community/support)
@@ -0,0 +1,34 @@
1
+ ---
2
+ sidebar_position: 3
3
+ ---
4
+
5
+ # Create a Blog Post
6
+
7
+ Docusaurus creates a **page for each blog post**, but also a **blog index page**, a **tag system**, an **RSS** feed...
8
+
9
+ ## Create your first Post
10
+
11
+ Create a file at `blog/2021-02-28-greetings.md`:
12
+
13
+ ```md title="blog/2021-02-28-greetings.md"
14
+ ---
15
+ slug: greetings
16
+ title: Greetings!
17
+ authors:
18
+ - name: Joel Marcey
19
+ title: Co-creator of Docusaurus 1
20
+ url: https://github.com/JoelMarcey
21
+ image_url: https://github.com/JoelMarcey.png
22
+ - name: Sébastien Lorber
23
+ title: Docusaurus maintainer
24
+ url: https://sebastienlorber.com
25
+ image_url: https://github.com/slorber.png
26
+ tags: [greetings]
27
+ ---
28
+
29
+ Congratulations, you have made your first post!
30
+
31
+ Feel free to play around and edit this post as much you like.
32
+ ```
33
+
34
+ A new blog post is now available at [http://localhost:3000/blog/greetings](http://localhost:3000/blog/greetings).
@@ -0,0 +1,57 @@
1
+ ---
2
+ sidebar_position: 2
3
+ ---
4
+
5
+ # Create a Document
6
+
7
+ Documents are **groups of pages** connected through:
8
+
9
+ - a **sidebar**
10
+ - **previous/next navigation**
11
+ - **versioning**
12
+
13
+ ## Create your first Doc
14
+
15
+ Create a Markdown file at `docs/hello.md`:
16
+
17
+ ```md title="docs/hello.md"
18
+ # Hello
19
+
20
+ This is my **first Docusaurus document**!
21
+ ```
22
+
23
+ A new document is now available at [http://localhost:3000/docs/hello](http://localhost:3000/docs/hello).
24
+
25
+ ## Configure the Sidebar
26
+
27
+ Docusaurus automatically **creates a sidebar** from the `docs` folder.
28
+
29
+ Add metadata to customize the sidebar label and position:
30
+
31
+ ```md title="docs/hello.md" {1-4}
32
+ ---
33
+ sidebar_label: 'Hi!'
34
+ sidebar_position: 3
35
+ ---
36
+
37
+ # Hello
38
+
39
+ This is my **first Docusaurus document**!
40
+ ```
41
+
42
+ It is also possible to create your sidebar explicitly in `sidebars.js`:
43
+
44
+ ```js title="sidebars.js"
45
+ export default {
46
+ tutorialSidebar: [
47
+ 'intro',
48
+ // highlight-next-line
49
+ 'hello',
50
+ {
51
+ type: 'category',
52
+ label: 'Tutorial',
53
+ items: ['tutorial-basics/create-a-document'],
54
+ },
55
+ ],
56
+ };
57
+ ```
@@ -0,0 +1,43 @@
1
+ ---
2
+ sidebar_position: 1
3
+ ---
4
+
5
+ # Create a Page
6
+
7
+ Add **Markdown or React** files to `src/pages` to create a **standalone page**:
8
+
9
+ - `src/pages/index.js` → `localhost:3000/`
10
+ - `src/pages/foo.md` → `localhost:3000/foo`
11
+ - `src/pages/foo/bar.js` → `localhost:3000/foo/bar`
12
+
13
+ ## Create your first React Page
14
+
15
+ Create a file at `src/pages/my-react-page.js`:
16
+
17
+ ```jsx title="src/pages/my-react-page.js"
18
+ import React from 'react';
19
+ import Layout from '@theme/Layout';
20
+
21
+ export default function MyReactPage() {
22
+ return (
23
+ <Layout>
24
+ <h1>My React page</h1>
25
+ <p>This is a React page</p>
26
+ </Layout>
27
+ );
28
+ }
29
+ ```
30
+
31
+ A new page is now available at [http://localhost:3000/my-react-page](http://localhost:3000/my-react-page).
32
+
33
+ ## Create your first Markdown Page
34
+
35
+ Create a file at `src/pages/my-markdown-page.md`:
36
+
37
+ ```mdx title="src/pages/my-markdown-page.md"
38
+ # My Markdown page
39
+
40
+ This is a Markdown page
41
+ ```
42
+
43
+ A new page is now available at [http://localhost:3000/my-markdown-page](http://localhost:3000/my-markdown-page).
@@ -0,0 +1,31 @@
1
+ ---
2
+ sidebar_position: 5
3
+ ---
4
+
5
+ # Deploy your site
6
+
7
+ Docusaurus is a **static-site-generator** (also called **[Jamstack](https://jamstack.org/)**).
8
+
9
+ It builds your site as simple **static HTML, JavaScript and CSS files**.
10
+
11
+ ## Build your site
12
+
13
+ Build your site **for production**:
14
+
15
+ ```bash
16
+ npm run build
17
+ ```
18
+
19
+ The static files are generated in the `build` folder.
20
+
21
+ ## Deploy your site
22
+
23
+ Test your production build locally:
24
+
25
+ ```bash
26
+ npm run serve
27
+ ```
28
+
29
+ The `build` folder is now served at [http://localhost:3000/](http://localhost:3000/).
30
+
31
+ You can now deploy the `build` folder **almost anywhere** easily, **for free** or very small cost (read the **[Deployment Guide](https://docusaurus.io/docs/deployment)**).