@far-world-labs/verblets 0.1.1 → 0.1.3
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.
- package/.cursor/launch.json +30 -0
- package/.cursor/settings.json +20 -0
- package/.github/workflows/branch-protection.yml +22 -0
- package/.github/workflows/ci.yml +120 -0
- package/.prettierrc +6 -0
- package/.release-it.json +4 -1
- package/.vscode/launch.json +31 -0
- package/AGENTS.md +220 -0
- package/DEVELOPING.md +105 -0
- package/README.md +254 -0
- package/eslint.config.js +80 -0
- package/package.json +29 -17
- package/scripts/generate-test/index.js +29 -3
- package/scripts/runner/index.js +26 -0
- package/scripts/simple-editor/index.js +29 -18
- package/scripts/summarize-files/index.js +28 -4
- package/src/chains/README.md +30 -0
- package/src/chains/anonymize/README.md +21 -0
- package/src/chains/anonymize/index.examples.js +75 -0
- package/src/chains/anonymize/index.js +121 -0
- package/src/chains/anonymize/index.spec.js +78 -0
- package/src/chains/bulk-central-tendency/index.examples.js +138 -0
- package/src/chains/bulk-central-tendency/index.js +91 -0
- package/src/chains/bulk-filter/README.md +21 -0
- package/src/chains/bulk-filter/index.examples.js +22 -0
- package/src/chains/bulk-filter/index.js +58 -0
- package/src/chains/bulk-filter/index.spec.js +38 -0
- package/src/chains/bulk-find/README.md +16 -0
- package/src/chains/bulk-find/index.examples.js +20 -0
- package/src/chains/bulk-find/index.js +30 -0
- package/src/chains/bulk-find/index.spec.js +26 -0
- package/src/chains/bulk-group/README.md +23 -0
- package/src/chains/bulk-group/index.examples.js +18 -0
- package/src/chains/bulk-group/index.js +34 -0
- package/src/chains/bulk-group/index.spec.js +41 -0
- package/src/chains/bulk-map/README.md +43 -0
- package/src/chains/bulk-map/index.examples.js +17 -0
- package/src/chains/bulk-map/index.js +86 -0
- package/src/chains/bulk-map/index.spec.js +44 -0
- package/src/chains/bulk-reduce/README.md +12 -0
- package/src/chains/bulk-reduce/index.examples.js +15 -0
- package/src/chains/bulk-reduce/index.js +13 -0
- package/src/chains/bulk-reduce/index.spec.js +25 -0
- package/src/chains/bulk-score/README.md +16 -0
- package/src/chains/bulk-score/bulk-score-result.json +18 -0
- package/src/chains/bulk-score/index.examples.js +22 -0
- package/src/chains/bulk-score/index.js +133 -0
- package/src/chains/bulk-score/index.spec.js +30 -0
- package/src/chains/category-samples/README.md +61 -0
- package/src/chains/category-samples/index.examples.js +103 -0
- package/src/chains/category-samples/index.js +134 -0
- package/src/chains/collect-terms/README.md +12 -0
- package/src/chains/collect-terms/index.examples.js +16 -0
- package/src/chains/collect-terms/index.js +44 -0
- package/src/chains/collect-terms/index.spec.js +25 -0
- package/src/chains/date/README.md +12 -0
- package/src/chains/date/index.examples.js +47 -0
- package/src/chains/date/index.js +74 -0
- package/src/chains/date/index.spec.js +62 -0
- package/src/chains/disambiguate/README.md +22 -0
- package/src/chains/disambiguate/disambiguate-meanings-result.json +16 -0
- package/src/chains/disambiguate/index.examples.js +18 -0
- package/src/chains/disambiguate/index.js +92 -0
- package/src/chains/disambiguate/index.spec.js +25 -0
- package/src/chains/dismantle/README.md +67 -0
- package/src/chains/dismantle/dismantle.examples.js +27 -0
- package/src/chains/dismantle/index.js +6 -17
- package/src/chains/dismantle/index.spec.js +1 -2
- package/src/chains/expect/README.md +171 -0
- package/src/chains/expect/index.examples.js +146 -0
- package/src/chains/expect/index.js +173 -0
- package/src/chains/expect/index.spec.js +324 -0
- package/src/chains/filter-ambiguous/README.md +11 -0
- package/src/chains/filter-ambiguous/index.examples.js +20 -0
- package/src/chains/filter-ambiguous/index.js +49 -0
- package/src/chains/filter-ambiguous/index.spec.js +31 -0
- package/src/chains/glossary/README.md +19 -0
- package/src/chains/glossary/index.examples.js +386 -0
- package/src/chains/glossary/index.js +75 -0
- package/src/chains/glossary/index.spec.js +19 -0
- package/src/chains/intersections/README.md +152 -0
- package/src/chains/intersections/index.examples.js +279 -0
- package/src/chains/intersections/index.js +366 -0
- package/src/chains/intersections/intersection-result.json +38 -0
- package/src/chains/list/index.examples.js +12 -16
- package/src/chains/list/index.js +106 -53
- package/src/chains/list/index.spec.js +8 -9
- package/src/chains/list/list-result.json +16 -0
- package/src/chains/llm-logger/README.md +208 -0
- package/src/chains/llm-logger/index.js +205 -0
- package/src/chains/llm-logger/index.spec.js +330 -0
- package/src/chains/questions/index.examples.js +2 -1
- package/src/chains/questions/index.js +14 -15
- package/src/chains/scan-js/index.js +6 -9
- package/src/chains/set-interval/README.md +81 -0
- package/src/chains/set-interval/index.examples.js +36 -0
- package/src/chains/set-interval/index.js +131 -0
- package/src/chains/set-interval/index.spec.js +70 -0
- package/src/chains/socratic/README.md +17 -0
- package/src/chains/socratic/index.js +64 -0
- package/src/chains/socratic/index.spec.js +24 -0
- package/src/chains/sort/index.examples.js +3 -7
- package/src/chains/sort/index.js +65 -15
- package/src/chains/sort/index.spec.js +5 -8
- package/src/chains/sort/sort-result.json +16 -0
- package/src/chains/summary-map/README.md +9 -1
- package/src/chains/summary-map/index.examples.js +9 -2
- package/src/chains/summary-map/index.js +43 -25
- package/src/chains/summary-map/index.spec.js +78 -3
- package/src/chains/test/index.js +9 -13
- package/src/chains/test-advice/index.js +4 -5
- package/src/chains/themes/README.md +20 -0
- package/src/chains/themes/index.examples.js +17 -0
- package/src/chains/themes/index.js +28 -0
- package/src/chains/themes/index.spec.js +19 -0
- package/src/chains/veiled-variants/index.examples.js +18 -0
- package/src/chains/veiled-variants/index.js +107 -0
- package/src/chains/veiled-variants/index.spec.js +40 -0
- package/src/constants/common.js +0 -2
- package/src/constants/models.js +172 -0
- package/src/index.js +178 -18
- package/src/json-schemas/README.md +13 -0
- package/src/json-schemas/index.js +8 -14
- package/src/json-schemas/schema-dot-org-photograph.json +11 -5
- package/src/json-schemas/schema-dot-org-place.json +78 -5
- package/src/lib/README.md +26 -0
- package/src/lib/bulk-filter/README.md +22 -0
- package/src/lib/bulk-filter/index.examples.js +27 -0
- package/src/lib/bulk-filter/index.js +63 -0
- package/src/lib/bulk-filter/index.spec.js +38 -0
- package/src/lib/bulk-find/README.md +18 -0
- package/src/lib/bulk-find/index.examples.js +19 -0
- package/src/lib/bulk-find/index.js +30 -0
- package/src/lib/bulk-find/index.spec.js +41 -0
- package/src/lib/chatgpt/index.js +63 -43
- package/src/lib/combinations/index.js +30 -0
- package/src/lib/combinations/index.spec.js +23 -0
- package/src/lib/functional/index.js +28 -0
- package/src/lib/logger-service/index.js +32 -0
- package/src/lib/parse-js-parts/index.js +9 -21
- package/src/lib/parse-llm-list/README.md +39 -0
- package/src/lib/parse-llm-list/index.js +54 -0
- package/src/lib/parse-llm-list/index.spec.js +59 -0
- package/src/lib/path-aliases/index.js +1 -3
- package/src/lib/path-aliases/index.spec.js +2 -8
- package/src/lib/pave/index.js +4 -4
- package/src/lib/pave/index.spec.js +6 -3
- package/src/lib/prompt-cache/index.js +14 -10
- package/src/lib/retry/index.js +11 -8
- package/src/lib/ring-buffer/README.md +460 -0
- package/src/lib/ring-buffer/index.js +1074 -0
- package/src/lib/search-best-first/city-walk.spec.js +37 -0
- package/src/lib/search-best-first/index.js +42 -11
- package/src/lib/search-best-first/index.spec.js +35 -0
- package/src/lib/search-js-files/index.js +44 -47
- package/src/lib/search-js-files/scan-file.js +10 -21
- package/src/lib/shorten-text/index.js +2 -7
- package/src/lib/shorten-text/index.spec.js +3 -3
- package/src/lib/strip-response/index.js +2 -7
- package/src/lib/template-replace/index.js +23 -0
- package/src/lib/template-replace/index.spec.js +60 -0
- package/src/lib/to-date/index.js +11 -0
- package/src/lib/to-number/index.js +1 -1
- package/src/lib/transcribe/index.js +26 -9
- package/src/prompts/README.md +3 -1
- package/src/prompts/as-object-with-schema.js +3 -8
- package/src/prompts/as-schema-org-text.js +10 -2
- package/src/prompts/code-features.js +1 -5
- package/src/prompts/constants.js +27 -27
- package/src/prompts/generate-collection.js +1 -1
- package/src/prompts/intent.js +16 -22
- package/src/prompts/select-from-threshold.js +1 -2
- package/src/prompts/sort.js +4 -8
- package/src/prompts/style.js +4 -7
- package/src/prompts/wrap-list.js +1 -4
- package/src/services/llm-model/global-overrides.spec.js +432 -0
- package/src/services/llm-model/index.js +234 -40
- package/src/services/llm-model/model.js +2 -2
- package/src/services/llm-model/negotiate.spec.js +447 -0
- package/src/services/redis/index.js +70 -7
- package/src/test/setup.js +20 -0
- package/src/verblets/README.md +26 -0
- package/src/verblets/auto/index.examples.js +12 -9
- package/src/verblets/auto/index.js +10 -10
- package/src/verblets/auto/index.spec.js +4 -6
- package/src/verblets/bool/README.md +36 -0
- package/src/verblets/bool/index.examples.js +53 -1
- package/src/verblets/bool/index.js +6 -9
- package/src/verblets/bool/index.spec.js +1 -3
- package/src/verblets/central-tendency/README.md +166 -0
- package/src/verblets/central-tendency/central-tendency-result.json +24 -0
- package/src/verblets/central-tendency/index.examples.js +196 -0
- package/src/verblets/central-tendency/index.js +171 -0
- package/src/verblets/central-tendency/index.spec.js +148 -0
- package/src/verblets/enum/index.examples.js +1 -4
- package/src/verblets/enum/index.js +7 -4
- package/src/verblets/expect/README.md +64 -0
- package/src/verblets/expect/index.examples.js +109 -0
- package/src/verblets/expect/index.js +75 -0
- package/src/verblets/expect/index.spec.js +127 -0
- package/src/verblets/intent/index.examples.js +95 -7
- package/src/verblets/intent/index.js +56 -68
- package/src/verblets/intersection/README.md +16 -0
- package/src/verblets/intersection/index.examples.js +89 -0
- package/src/verblets/intersection/index.js +84 -0
- package/src/verblets/intersection/index.spec.js +60 -0
- package/src/verblets/intersection/intersection-result.json +16 -0
- package/src/verblets/list-expand/README.md +10 -0
- package/src/verblets/list-expand/index.examples.js +14 -0
- package/src/verblets/list-expand/index.js +104 -0
- package/src/verblets/list-expand/index.spec.js +18 -0
- package/src/verblets/list-expand/list-expand-result.json +16 -0
- package/src/verblets/list-filter/README.md +22 -0
- package/src/verblets/list-filter/index.examples.js +26 -0
- package/src/verblets/list-filter/index.js +18 -0
- package/src/verblets/list-filter/index.spec.js +19 -0
- package/src/verblets/list-find/README.md +11 -0
- package/src/verblets/list-find/index.examples.js +15 -0
- package/src/verblets/list-find/index.js +17 -0
- package/src/verblets/list-find/index.spec.js +19 -0
- package/src/verblets/list-group/README.md +16 -0
- package/src/verblets/list-group/index.examples.js +16 -0
- package/src/verblets/list-group/index.js +112 -0
- package/src/verblets/list-group/index.spec.js +35 -0
- package/src/verblets/list-group/list-group-result.json +16 -0
- package/src/verblets/list-map/README.md +11 -0
- package/src/verblets/list-map/index.examples.js +15 -0
- package/src/verblets/list-map/index.js +26 -0
- package/src/verblets/list-map/index.spec.js +17 -0
- package/src/verblets/list-reduce/README.md +10 -0
- package/src/verblets/list-reduce/index.examples.js +14 -0
- package/src/verblets/list-reduce/index.js +21 -0
- package/src/verblets/list-reduce/index.spec.js +27 -0
- package/src/verblets/list-reduce/index.spec.jsx +27 -0
- package/src/verblets/name/README.md +15 -0
- package/src/verblets/name/index.examples.js +28 -0
- package/src/verblets/name/index.js +19 -0
- package/src/verblets/name/index.spec.js +33 -0
- package/src/verblets/name-similar-to/README.md +26 -0
- package/src/verblets/name-similar-to/index.examples.js +18 -0
- package/src/verblets/name-similar-to/index.js +20 -0
- package/src/verblets/name-similar-to/index.spec.js +13 -0
- package/src/verblets/number/index.examples.js +173 -7
- package/src/verblets/number/index.js +5 -2
- package/src/verblets/number/index.spec.js +1 -3
- package/src/verblets/number-with-units/index.examples.js +5 -1
- package/src/verblets/number-with-units/index.js +74 -9
- package/src/verblets/number-with-units/number-with-units-result.json +23 -0
- package/src/verblets/schema-org/index.examples.js +2 -7
- package/src/verblets/schema-org/index.js +32 -3
- package/src/verblets/sentiment/README.md +10 -0
- package/src/verblets/sentiment/index.examples.js +20 -0
- package/src/verblets/sentiment/index.js +9 -0
- package/src/verblets/sentiment/index.spec.js +20 -0
- package/src/verblets/to-object/index.js +10 -15
- package/src/verblets/to-object/index.spec.js +1 -4
- package/.eslintrc.json +0 -42
- package/docs/README.md +0 -41
- package/docs/babel.config.js +0 -3
- package/docs/blog/2019-05-28-first-blog-post.md +0 -12
- package/docs/blog/2019-05-29-long-blog-post.md +0 -44
- package/docs/blog/2021-08-01-mdx-blog-post.mdx +0 -20
- package/docs/blog/2021-08-26-welcome/docusaurus-plushie-banner.jpeg +0 -0
- package/docs/blog/2021-08-26-welcome/index.md +0 -25
- package/docs/blog/authors.yml +0 -17
- package/docs/docs/api/bool.md +0 -74
- package/docs/docs/api/search.md +0 -51
- package/docs/docs/intro.md +0 -47
- package/docs/docs/tutorial-basics/_category_.json +0 -8
- package/docs/docs/tutorial-basics/congratulations.md +0 -23
- package/docs/docs/tutorial-basics/create-a-blog-post.md +0 -34
- package/docs/docs/tutorial-basics/create-a-document.md +0 -57
- package/docs/docs/tutorial-basics/create-a-page.md +0 -43
- package/docs/docs/tutorial-basics/deploy-your-site.md +0 -31
- package/docs/docs/tutorial-basics/markdown-features.mdx +0 -152
- package/docs/docs/tutorial-extras/_category_.json +0 -7
- package/docs/docs/tutorial-extras/img/docsVersionDropdown.png +0 -0
- package/docs/docs/tutorial-extras/img/localeDropdown.png +0 -0
- package/docs/docs/tutorial-extras/manage-docs-versions.md +0 -55
- package/docs/docs/tutorial-extras/translate-your-site.md +0 -88
- package/docs/docusaurus.config.js +0 -120
- package/docs/package.json +0 -44
- package/docs/sidebars.js +0 -31
- package/docs/src/components/HomepageFeatures/index.js +0 -61
- package/docs/src/components/HomepageFeatures/styles.module.css +0 -11
- package/docs/src/css/custom.css +0 -30
- package/docs/src/pages/index.js +0 -43
- package/docs/src/pages/index.module.css +0 -23
- package/docs/src/pages/markdown-page.md +0 -7
- package/docs/static/.nojekyll +0 -0
- package/docs/static/img/docusaurus-social-card.jpg +0 -0
- package/docs/static/img/docusaurus.png +0 -0
- package/docs/static/img/favicon.ico +0 -0
- package/docs/static/img/logo.svg +0 -1
- package/docs/static/img/undraw_docusaurus_mountain.svg +0 -171
- package/docs/static/img/undraw_docusaurus_react.svg +0 -170
- package/docs/static/img/undraw_docusaurus_tree.svg +0 -40
- package/src/constants/openai.js +0 -65
- /package/{.vite.config.examples.js → .vitest.config.examples.js} +0 -0
- /package/{.vite.config.js → .vitest.config.js} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"type": "node",
|
|
6
|
+
"request": "launch",
|
|
7
|
+
"name": "Run Regular Tests",
|
|
8
|
+
"autoAttachChildProcesses": true,
|
|
9
|
+
"skipFiles": ["<node_internals>/**"],
|
|
10
|
+
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
|
|
11
|
+
"args": ["run", "--config", ".vitest.config.js"],
|
|
12
|
+
"smartStep": true,
|
|
13
|
+
"console": "integratedTerminal"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"type": "node",
|
|
17
|
+
"request": "launch",
|
|
18
|
+
"name": "Run Example Tests",
|
|
19
|
+
"autoAttachChildProcesses": true,
|
|
20
|
+
"skipFiles": ["<node_internals>/**"],
|
|
21
|
+
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
|
|
22
|
+
"args": ["run", "--config", ".vitest.config.examples.js"],
|
|
23
|
+
"env": {
|
|
24
|
+
"EXAMPLES": "true"
|
|
25
|
+
},
|
|
26
|
+
"smartStep": true,
|
|
27
|
+
"console": "integratedTerminal"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"vitest.enable": true,
|
|
3
|
+
"vitest.configPath": ".vitest.config.examples.js",
|
|
4
|
+
"vitest.env": {
|
|
5
|
+
"EXAMPLES": "true"
|
|
6
|
+
},
|
|
7
|
+
"testExplorer": {
|
|
8
|
+
"showOnRun": true,
|
|
9
|
+
"showOutputOnFailure": true,
|
|
10
|
+
"configPath": ".vitest.config.examples.js"
|
|
11
|
+
},
|
|
12
|
+
"vitest.testExplorer": {
|
|
13
|
+
"showOutputOnFailure": true,
|
|
14
|
+
"showOutputOnRun": true,
|
|
15
|
+
"configPath": ".vitest.config.examples.js"
|
|
16
|
+
},
|
|
17
|
+
"vitest.testFiles": ["**/*.examples.js"],
|
|
18
|
+
"vitest.include": ["src/**/*.examples.js"],
|
|
19
|
+
"vitest.commandLine": "vitest --config .vitest.config.examples.js"
|
|
20
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: Branch Protection
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
types: [opened, synchronize, reopened]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
# Simple gate that waits for essential checks
|
|
9
|
+
merge-gate:
|
|
10
|
+
name: 🚪 Merge Gate
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
if: github.event_name == 'pull_request'
|
|
13
|
+
steps:
|
|
14
|
+
- name: Wait for essential checks
|
|
15
|
+
run: |
|
|
16
|
+
echo "This job serves as a merge gate."
|
|
17
|
+
echo "Configure branch protection rules in GitHub to require:"
|
|
18
|
+
echo "- 🔍 Lint Code"
|
|
19
|
+
echo "- At least one 🧪 Test on Node job"
|
|
20
|
+
echo "- This 🚪 Merge Gate job"
|
|
21
|
+
echo ""
|
|
22
|
+
echo "✅ Merge gate check passed"
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
name: CI/CD Pipeline
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- main
|
|
10
|
+
|
|
11
|
+
env:
|
|
12
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
get-lts-versions:
|
|
16
|
+
name: 🧱 Get LTS Node Versions
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
outputs:
|
|
19
|
+
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
|
20
|
+
steps:
|
|
21
|
+
- name: Fetch Node LTS versions
|
|
22
|
+
id: set-matrix
|
|
23
|
+
run: |
|
|
24
|
+
LTS_VERSIONS=$(curl -s https://raw.githubusercontent.com/nodejs/Release/main/schedule.json | \
|
|
25
|
+
jq -cr 'to_entries | map(select(.value.lts != false and .value.end > (now | strftime("%Y-%m-%d")))) | map(.key)')
|
|
26
|
+
echo "matrix={\"node-version\": $LTS_VERSIONS}" >> $GITHUB_OUTPUT
|
|
27
|
+
|
|
28
|
+
lint:
|
|
29
|
+
name: 🔍 Lint Code
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- uses: actions/setup-node@v4
|
|
34
|
+
with:
|
|
35
|
+
node-version: 20.x
|
|
36
|
+
cache: 'npm'
|
|
37
|
+
cache-dependency-path: '**/package-lock.json'
|
|
38
|
+
- run: npm ci
|
|
39
|
+
- name: Run ESLint
|
|
40
|
+
run: npm run lint
|
|
41
|
+
|
|
42
|
+
test:
|
|
43
|
+
name: 🧪 Test on Node ${{ matrix.node-version }}
|
|
44
|
+
needs: get-lts-versions
|
|
45
|
+
runs-on: ubuntu-latest
|
|
46
|
+
strategy:
|
|
47
|
+
matrix: ${{ fromJson(needs.get-lts-versions.outputs.matrix) }}
|
|
48
|
+
steps:
|
|
49
|
+
- uses: actions/checkout@v4
|
|
50
|
+
- uses: actions/setup-node@v4
|
|
51
|
+
with:
|
|
52
|
+
node-version: ${{ matrix.node-version }}
|
|
53
|
+
cache: 'npm'
|
|
54
|
+
cache-dependency-path: '**/package-lock.json'
|
|
55
|
+
- name: Cache npm global
|
|
56
|
+
uses: actions/cache@v4
|
|
57
|
+
with:
|
|
58
|
+
path: ~/.npm
|
|
59
|
+
key: npm-global-${{ runner.os }}-${{ matrix.node-version }}
|
|
60
|
+
- run: npm ci
|
|
61
|
+
- name: Run tests
|
|
62
|
+
run: npm test -- --run
|
|
63
|
+
|
|
64
|
+
build:
|
|
65
|
+
name: 🛠️ Build
|
|
66
|
+
runs-on: ubuntu-latest
|
|
67
|
+
needs: [lint, test]
|
|
68
|
+
steps:
|
|
69
|
+
- name: Build complete
|
|
70
|
+
run: |
|
|
71
|
+
echo "✅ All tests passed across Node.js LTS versions"
|
|
72
|
+
echo "✅ ESLint checks completed"
|
|
73
|
+
echo "✅ Library is ready for deployment"
|
|
74
|
+
|
|
75
|
+
# Required status check that gates merge operations
|
|
76
|
+
pr-ready-to-merge:
|
|
77
|
+
name: ✅ PR Ready to Merge
|
|
78
|
+
runs-on: ubuntu-latest
|
|
79
|
+
needs: [lint, test, build]
|
|
80
|
+
if: github.event_name == 'pull_request'
|
|
81
|
+
steps:
|
|
82
|
+
- name: All checks passed
|
|
83
|
+
run: |
|
|
84
|
+
echo "🎉 All required checks have passed!"
|
|
85
|
+
echo "✅ Linting: Passed"
|
|
86
|
+
echo "✅ Tests: Passed on all LTS Node versions"
|
|
87
|
+
echo "✅ Build: Successful"
|
|
88
|
+
echo ""
|
|
89
|
+
echo "This PR is now ready for squash and merge."
|
|
90
|
+
|
|
91
|
+
release:
|
|
92
|
+
name: 🚀 Release
|
|
93
|
+
runs-on: ubuntu-latest
|
|
94
|
+
needs: build
|
|
95
|
+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
96
|
+
permissions:
|
|
97
|
+
contents: write
|
|
98
|
+
pull-requests: write
|
|
99
|
+
steps:
|
|
100
|
+
- uses: actions/checkout@v4
|
|
101
|
+
with:
|
|
102
|
+
fetch-depth: 0
|
|
103
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
104
|
+
- uses: actions/setup-node@v4
|
|
105
|
+
with:
|
|
106
|
+
node-version: 20.x
|
|
107
|
+
registry-url: 'https://registry.npmjs.org'
|
|
108
|
+
cache: 'npm'
|
|
109
|
+
- run: npm ci
|
|
110
|
+
|
|
111
|
+
- name: Configure Git
|
|
112
|
+
run: |
|
|
113
|
+
git config --global user.name "github-actions[bot]"
|
|
114
|
+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
115
|
+
|
|
116
|
+
- name: Release
|
|
117
|
+
env:
|
|
118
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
119
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
120
|
+
run: npx release-it --ci
|
package/.prettierrc
ADDED
package/.release-it.json
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
|
|
5
|
+
{
|
|
6
|
+
"type": "node",
|
|
7
|
+
"request": "launch",
|
|
8
|
+
"name": "Run Regular Tests",
|
|
9
|
+
"autoAttachChildProcesses": true,
|
|
10
|
+
"skipFiles": ["<node_internals>/**"],
|
|
11
|
+
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
|
|
12
|
+
"args": ["run"],
|
|
13
|
+
"smartStep": true,
|
|
14
|
+
"console": "integratedTerminal"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"type": "node",
|
|
18
|
+
"request": "launch",
|
|
19
|
+
"name": "Run Example Tests",
|
|
20
|
+
"autoAttachChildProcesses": true,
|
|
21
|
+
"skipFiles": ["<node_internals>/**"],
|
|
22
|
+
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
|
|
23
|
+
"args": ["run", "--config", ".vitest.config.examples.js"],
|
|
24
|
+
"env": {
|
|
25
|
+
"EXAMPLES": "true"
|
|
26
|
+
},
|
|
27
|
+
"smartStep": true,
|
|
28
|
+
"console": "integratedTerminal"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Agents Guide
|
|
2
|
+
|
|
3
|
+
This document explains the internal architecture and development practices for the verblets project. It's intended for AI agents and developers working on the codebase.
|
|
4
|
+
|
|
5
|
+
## Architecture Overview
|
|
6
|
+
|
|
7
|
+
The verblets project has two main types of components:
|
|
8
|
+
|
|
9
|
+
### **Chains** (`src/chains/`)
|
|
10
|
+
LLM orchestrations that combine multiple verblets, other chains, and library utilities to perform complex workflows. Chains handle multi-step reasoning, batch processing, and sophisticated AI operations.
|
|
11
|
+
|
|
12
|
+
**Examples:**
|
|
13
|
+
- `anonymize` - Multi-step process to identify and replace sensitive information
|
|
14
|
+
- `socratic` - Iterative questioning dialogue using multiple LLM calls
|
|
15
|
+
- `bulk-map` - Parallel processing of large datasets with retry logic
|
|
16
|
+
- `summary-map` - Self-resizing hash table with AI-powered summarization
|
|
17
|
+
|
|
18
|
+
**Characteristics:**
|
|
19
|
+
- Use multiple LLM calls or orchestrate other modules
|
|
20
|
+
- Handle complex workflows and state management
|
|
21
|
+
- Often include retry logic and error handling
|
|
22
|
+
- May process data in chunks or batches
|
|
23
|
+
|
|
24
|
+
### **Verblets** (`src/verblets/`)
|
|
25
|
+
Single LLM calls with carefully crafted prompts and prompt-supporting functions. Each verblet performs one specific AI task with high reliability and constrained outputs.
|
|
26
|
+
|
|
27
|
+
**Examples:**
|
|
28
|
+
- `bool` - Extract true/false decisions from natural language
|
|
29
|
+
- `enum` - Map text to predefined options with high accuracy
|
|
30
|
+
- `intent` - Parse user intent and extract structured parameters
|
|
31
|
+
- `to-object` - Convert descriptions to structured JSON objects
|
|
32
|
+
|
|
33
|
+
**Characteristics:**
|
|
34
|
+
- Single LLM call per operation
|
|
35
|
+
- Substantial, optimized prompts with prompt variables
|
|
36
|
+
- Constrained outputs to prevent hallucination
|
|
37
|
+
- High reliability for specific tasks
|
|
38
|
+
|
|
39
|
+
### **Library Utilities** (`src/lib/`)
|
|
40
|
+
Supporting utilities that don't use LLMs directly. These provide infrastructure, data processing, and reusable functions that support both chains and verblets.
|
|
41
|
+
|
|
42
|
+
**Examples:**
|
|
43
|
+
- `chatgpt` - OpenAI API wrapper with error handling
|
|
44
|
+
- `prompt-cache` - Caching layer for LLM responses
|
|
45
|
+
- `retry` - Robust retry logic for async operations
|
|
46
|
+
- `parse-js-parts` - JavaScript AST parsing utilities
|
|
47
|
+
- `parse-llm-list` - Parse JSON arrays or CSV from LLM responses with filtering
|
|
48
|
+
|
|
49
|
+
**Characteristics:**
|
|
50
|
+
- No direct LLM usage
|
|
51
|
+
- Pure functions or utility classes
|
|
52
|
+
- Infrastructure and data processing
|
|
53
|
+
- Reusable across verblets and chains
|
|
54
|
+
|
|
55
|
+
## Module Structure
|
|
56
|
+
|
|
57
|
+
Every module (chain, verblet, or lib utility) follows a consistent structure:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
module-name/
|
|
61
|
+
├── index.js # Main implementation
|
|
62
|
+
├── index.spec.js # Deterministic tests with mocks
|
|
63
|
+
├── index.examples.js # Non-deterministic tests with real LLM calls
|
|
64
|
+
└── README.md # Documentation with compelling examples and docs for the JS API
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Required Files
|
|
68
|
+
|
|
69
|
+
#### `index.js`
|
|
70
|
+
The main implementation. Should export a default function or class.
|
|
71
|
+
|
|
72
|
+
#### `index.spec.js`
|
|
73
|
+
Deterministic tests using table-driven examples. These tests:
|
|
74
|
+
- Mock LLM interfaces (chatGPT, etc.)
|
|
75
|
+
- Use predictable inputs and expected outputs
|
|
76
|
+
- Run quickly and reliably in CI/CD
|
|
77
|
+
- Follow the `examples` array pattern
|
|
78
|
+
|
|
79
|
+
**Example:** See [`src/verblets/bool/index.spec.js`](src/verblets/bool/index.spec.js) for the table-driven testing pattern.
|
|
80
|
+
|
|
81
|
+
#### `index.examples.js`
|
|
82
|
+
Non-deterministic tests using real LLM calls. These tests:
|
|
83
|
+
- Use actual API calls (require API keys)
|
|
84
|
+
- Verify behavior with LLM assertion chains
|
|
85
|
+
- Use the `expect` chain or verblet for intelligent assertions
|
|
86
|
+
- Include `longTestTimeout` for API call delays
|
|
87
|
+
|
|
88
|
+
**Example:** See [`src/verblets/bool/index.examples.js`](src/verblets/bool/index.examples.js) for LLM assertion usage.
|
|
89
|
+
|
|
90
|
+
#### `README.md`
|
|
91
|
+
Documentation with at least one compelling example that demonstrates how LLM programming changes what's possible. Should show real-world value and be accessible to developers.
|
|
92
|
+
|
|
93
|
+
**Example:** See [`src/chains/socratic/README.md`](src/chains/socratic/README.md) for compelling documentation.
|
|
94
|
+
|
|
95
|
+
## Testing Strategy
|
|
96
|
+
|
|
97
|
+
### Two-Tier Testing Approach
|
|
98
|
+
|
|
99
|
+
1. **Spec Tests** (`*.spec.js`)
|
|
100
|
+
- Fast, deterministic, mocked
|
|
101
|
+
- Table-driven with `examples` arrays
|
|
102
|
+
- Run with `npm run test`
|
|
103
|
+
- Essential for CI/CD and development
|
|
104
|
+
|
|
105
|
+
2. **Example Tests** (`*.examples.js`)
|
|
106
|
+
- Slow, non-deterministic, real LLM calls
|
|
107
|
+
- LLM assertions using `expect` chain or verblet
|
|
108
|
+
- Run with `npm run examples` (requires API keys--not possible as an agent)
|
|
109
|
+
- Validate real-world behavior
|
|
110
|
+
|
|
111
|
+
### Testing Patterns
|
|
112
|
+
|
|
113
|
+
#### Table-Driven Examples
|
|
114
|
+
All tests use a consistent `examples` array structure. See [`src/verblets/enum/index.spec.js`](src/verblets/enum/index.spec.js) for the standard pattern.
|
|
115
|
+
|
|
116
|
+
#### LLM Assertion Chains
|
|
117
|
+
For example tests, use the `expect` chain or verblet for assertions that blind assertions cannot handle:
|
|
118
|
+
|
|
119
|
+
**Chain Usage:** See [`src/chains/expect/index.examples.js`](src/chains/expect/index.examples.js) for enhanced LLM assertions.
|
|
120
|
+
|
|
121
|
+
**Verblet Usage:** See [`src/verblets/expect/index.examples.js`](src/verblets/expect/index.examples.js) for simple LLM assertions.
|
|
122
|
+
|
|
123
|
+
**Real-World Usage:** See [`src/chains/intersections/index.examples.js`](src/chains/intersections/index.examples.js) for LLM assertions in practice.
|
|
124
|
+
|
|
125
|
+
**Key Benefits of LLM Assertions:**
|
|
126
|
+
- Verify semantic meaning, not just structure
|
|
127
|
+
- Check content quality and appropriateness
|
|
128
|
+
- Validate business logic and context understanding
|
|
129
|
+
- Handle cases where traditional assertions are insufficient
|
|
130
|
+
|
|
131
|
+
## Development Commands
|
|
132
|
+
|
|
133
|
+
### Core Commands
|
|
134
|
+
- `npm run test` - Run deterministic spec tests
|
|
135
|
+
- `npm run lint` - Check code style
|
|
136
|
+
- `npm run lint:fix` - Auto-fix linting issues
|
|
137
|
+
|
|
138
|
+
### Example Commands (Require API Keys)
|
|
139
|
+
- `npm run examples` - Run non-deterministic example tests
|
|
140
|
+
- `npm run examples:warn` - Run examples with warning-level LLM expectations
|
|
141
|
+
|
|
142
|
+
**Note for Agents:** The `npm run examples` command won't work for AI agents since it requires API keys that agents don't have access to.
|
|
143
|
+
|
|
144
|
+
## Export Strategy
|
|
145
|
+
|
|
146
|
+
### Internal Organization
|
|
147
|
+
Internally, we maintain clear distinctions between chains, verblets, and lib utilities for architectural clarity and development organization.
|
|
148
|
+
|
|
149
|
+
### Public API
|
|
150
|
+
In the top-level README and `src/index.js`, we export everything as "verblets" to provide a unified, simple API for users. See [`src/index.js`](src/index.js) for the export structure.
|
|
151
|
+
|
|
152
|
+
This approach:
|
|
153
|
+
- Simplifies the user experience
|
|
154
|
+
- Maintains internal architectural clarity
|
|
155
|
+
- Allows for easy refactoring and organization
|
|
156
|
+
- Provides a consistent mental model for users
|
|
157
|
+
|
|
158
|
+
## Documentation Standards
|
|
159
|
+
|
|
160
|
+
### README Requirements
|
|
161
|
+
Every module README must include:
|
|
162
|
+
|
|
163
|
+
1. **Clear description** of what the module does
|
|
164
|
+
2. **At least one compelling example** showing real-world value
|
|
165
|
+
3. **Demonstration of LLM capabilities** that would be difficult/impossible with traditional programming
|
|
166
|
+
4. **Accessible code examples** that developers can immediately understand and use
|
|
167
|
+
|
|
168
|
+
### Example Quality
|
|
169
|
+
Examples should demonstrate transformative capabilities. See [`src/verblets/bool/README.md`](src/verblets/bool/README.md) and [`src/verblets/enum/README.md`](src/verblets/enum/README.md) for examples that show LLM understanding of context and nuance.
|
|
170
|
+
|
|
171
|
+
### Linking Strategy
|
|
172
|
+
- Most modules should be linked from the top-level README
|
|
173
|
+
- Organize by functional categories (primitives, lists, content, etc.)
|
|
174
|
+
- Prioritize modules that best demonstrate LLM capabilities
|
|
175
|
+
- Include brief descriptions that highlight unique value
|
|
176
|
+
|
|
177
|
+
## Development Environment
|
|
178
|
+
|
|
179
|
+
### .cursor Directory
|
|
180
|
+
The `.cursor` directory contains IDE-specific configuration and rules for the Cursor editor. This should include:
|
|
181
|
+
- Code style preferences
|
|
182
|
+
- AI assistant behavior guidelines
|
|
183
|
+
- Project-specific linting rules
|
|
184
|
+
- Development workflow configurations
|
|
185
|
+
|
|
186
|
+
**Note:** The `.cursor` directory should have comprehensive rules to guide development practices, though these may not be fully implemented yet.
|
|
187
|
+
|
|
188
|
+
## Best Practices
|
|
189
|
+
|
|
190
|
+
### For Chains
|
|
191
|
+
- Use clear step-by-step orchestration
|
|
192
|
+
- Include robust error handling and retry logic
|
|
193
|
+
- Document the workflow in comments
|
|
194
|
+
- Consider chunking for large datasets
|
|
195
|
+
- Provide progress feedback for long operations
|
|
196
|
+
|
|
197
|
+
### For Verblets
|
|
198
|
+
- Craft prompts carefully for reliability
|
|
199
|
+
- Constrain outputs to prevent hallucination
|
|
200
|
+
- Use JSON schemas for structured outputs
|
|
201
|
+
- Test edge cases thoroughly
|
|
202
|
+
- Optimize for single-call efficiency
|
|
203
|
+
|
|
204
|
+
### For Library Utilities
|
|
205
|
+
- Keep functions pure when possible
|
|
206
|
+
- Provide comprehensive error handling
|
|
207
|
+
- Include detailed JSDoc comments
|
|
208
|
+
- Design for reusability across modules
|
|
209
|
+
- Follow standard JavaScript patterns
|
|
210
|
+
|
|
211
|
+
### Testing Guidelines
|
|
212
|
+
- Write spec tests first (TDD approach)
|
|
213
|
+
- Mock all external dependencies in spec tests
|
|
214
|
+
- Use realistic but simple examples
|
|
215
|
+
- Make example tests robust with LLM assertions
|
|
216
|
+
- Include edge cases and error conditions
|
|
217
|
+
- Test both success and failure paths
|
|
218
|
+
- Use LLM assertions for content that traditional assertions cannot verify
|
|
219
|
+
|
|
220
|
+
This architecture enables building sophisticated AI-powered applications while maintaining code quality, testability, and developer experience.
|
package/DEVELOPING.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Developing Verblets
|
|
2
|
+
|
|
3
|
+
This document explains the development workflow and testing strategy for the Verblets library.
|
|
4
|
+
|
|
5
|
+
## Testing Strategy
|
|
6
|
+
|
|
7
|
+
The Verblets library uses a dual testing approach with two types of test files:
|
|
8
|
+
|
|
9
|
+
### 1. Spec Files (`*.spec.js`)
|
|
10
|
+
- **Purpose**: Deterministic unit tests with mocked LLM responses
|
|
11
|
+
- **Reliability**: Should always pass consistently
|
|
12
|
+
- **LLM Usage**: Uses mocked responses, no actual API calls
|
|
13
|
+
- **Caching**: Uses in-memory `NullRedisClient` or local mocking (no Redis required)
|
|
14
|
+
- **Speed**: Fast execution
|
|
15
|
+
- **Use Case**: CI/CD, development validation, regression testing
|
|
16
|
+
|
|
17
|
+
### 2. Example Files (`*.examples.js`)
|
|
18
|
+
- **Purpose**: Non-deterministic integration tests with real LLM calls
|
|
19
|
+
- **Reliability**: May fail due to LLM response variability
|
|
20
|
+
- **LLM Usage**: Makes actual API calls to language models
|
|
21
|
+
- **Caching**: Uses Redis for response caching (when available)
|
|
22
|
+
- **Speed**: Slower due to network calls (mitigated by caching)
|
|
23
|
+
- **Use Case**: Manual testing, demonstrating real-world usage, validating LLM integration
|
|
24
|
+
|
|
25
|
+
## Environment Configuration
|
|
26
|
+
|
|
27
|
+
### Spec Tests
|
|
28
|
+
```bash
|
|
29
|
+
npm test # Runs spec tests with mocked responses
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Example Tests
|
|
33
|
+
```bash
|
|
34
|
+
npm run examples # Runs example tests with real LLM calls
|
|
35
|
+
EXAMPLES=true npm run examples # Automatically set, enables Redis caching
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Caching Control
|
|
39
|
+
```bash
|
|
40
|
+
# Disable caching for all LLM calls (forces fresh API calls)
|
|
41
|
+
DISABLE_CACHE=true npm run examples
|
|
42
|
+
|
|
43
|
+
# Enable caching (default behavior when Redis is available)
|
|
44
|
+
npm run examples
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Caching System
|
|
48
|
+
|
|
49
|
+
### Redis Caching for Examples
|
|
50
|
+
- Example tests use Redis to cache LLM responses based on prompt content
|
|
51
|
+
- Cached responses reduce API costs and improve test speed
|
|
52
|
+
- Falls back to in-memory caching if Redis is unavailable
|
|
53
|
+
|
|
54
|
+
### Cache Behavior
|
|
55
|
+
- **Cache Hit**: Returns cached response instantly
|
|
56
|
+
- **Cache Miss**: Makes LLM API call and caches the response
|
|
57
|
+
- **TTL**: Cached responses expire based on `cacheTTL` configuration
|
|
58
|
+
- **Fallback**: Gracefully handles Redis connection failures
|
|
59
|
+
|
|
60
|
+
## Development Workflow
|
|
61
|
+
|
|
62
|
+
### Adding New Verblets or Chains
|
|
63
|
+
|
|
64
|
+
When creating a new verblet or chain, you should add both types of tests:
|
|
65
|
+
|
|
66
|
+
#### 1. Create Spec File (`index.spec.js`)
|
|
67
|
+
```javascript
|
|
68
|
+
import { describe, expect, it } from 'vitest';
|
|
69
|
+
import myVerblet from './index.js';
|
|
70
|
+
|
|
71
|
+
const examples = [
|
|
72
|
+
{
|
|
73
|
+
inputs: { text: 'test input' },
|
|
74
|
+
want: { result: 'expected output' },
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
describe('My Verblet', () => {
|
|
79
|
+
examples.forEach((example) => {
|
|
80
|
+
it(example.inputs.text, async () => {
|
|
81
|
+
const result = await myVerblet(example.inputs.text);
|
|
82
|
+
expect(result).toStrictEqual(example.want.result);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### 2. Create Example File (`index.examples.js`)
|
|
89
|
+
```javascript
|
|
90
|
+
import { describe, expect, it } from 'vitest';
|
|
91
|
+
import myVerblet from './index.js';
|
|
92
|
+
import { longTestTimeout } from '../../constants/common.js';
|
|
93
|
+
|
|
94
|
+
describe('My Verblet Examples', () => {
|
|
95
|
+
it(
|
|
96
|
+
'processes real input',
|
|
97
|
+
async () => {
|
|
98
|
+
const result = await myVerblet('What is the capital of France?');
|
|
99
|
+
expect(typeof result).toBe('string');
|
|
100
|
+
expect(result.length).toBeGreaterThan(0);
|
|
101
|
+
},
|
|
102
|
+
longTestTimeout
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
```
|