@far-world-labs/verblets 0.1.4 → 0.1.7

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.
@@ -72,50 +72,11 @@ jobs:
72
72
  echo "✅ ESLint checks completed"
73
73
  echo "✅ Library is ready for deployment"
74
74
 
75
- # Version bump for PRs - creates commit in PR branch
76
- version-bump:
77
- name: 📦 Version Bump
78
- runs-on: ubuntu-latest
79
- needs: build
80
- if: github.event_name == 'pull_request'
81
- permissions:
82
- contents: write
83
- pull-requests: write
84
- steps:
85
- - uses: actions/checkout@v4
86
- with:
87
- fetch-depth: 0
88
- token: ${{ secrets.GITHUB_TOKEN }}
89
- ref: ${{ github.head_ref }}
90
- - uses: actions/setup-node@v4
91
- with:
92
- node-version: 20.x
93
- cache: 'npm'
94
- - run: npm ci
95
-
96
- - name: Configure Git
97
- run: |
98
- git config --global user.name "github-actions[bot]"
99
- git config --global user.email "github-actions[bot]@users.noreply.github.com"
100
-
101
- - name: Version Bump (No Publish)
102
- env:
103
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104
- run: |
105
- # Ensure we're on the correct branch
106
- git checkout ${{ github.head_ref }}
107
-
108
- # Use release-it to bump version and create tag, but skip npm publish
109
- npx release-it --ci --no-npm.publish --no-github.release
110
-
111
- # Push the version bump back to the PR branch
112
- git push origin ${{ github.head_ref }}
113
-
114
75
  # Required status check that gates merge operations
115
76
  pr-ready-to-merge:
116
77
  name: ✅ PR Ready to Merge
117
78
  runs-on: ubuntu-latest
118
- needs: [lint, test, build, version-bump]
79
+ needs: [lint, test, build]
119
80
  if: github.event_name == 'pull_request'
120
81
  steps:
121
82
  - name: All checks passed
@@ -124,11 +85,11 @@ jobs:
124
85
  echo "✅ Linting: Passed"
125
86
  echo "✅ Tests: Passed on all LTS Node versions"
126
87
  echo "✅ Build: Successful"
127
- echo " Version: Bumped and ready"
88
+ echo "ℹ️ Version: Will be checked on merge (publish only if bumped)"
128
89
  echo ""
129
90
  echo "This PR is now ready for squash and merge."
130
91
 
131
- # Publish the already-bumped version on merge to main
92
+ # Publish to NPM and create git tag - only if version was bumped
132
93
  release:
133
94
  name: 🚀 Publish to NPM
134
95
  runs-on: ubuntu-latest
@@ -149,14 +110,42 @@ jobs:
149
110
  cache: 'npm'
150
111
  - run: npm ci
151
112
 
113
+ - name: Check if version was bumped
114
+ id: version-check
115
+ run: |
116
+ CURRENT_VERSION=$(node -p "require('./package.json').version")
117
+ PUBLISHED_VERSION=$(npm view @far-world-labs/verblets version 2>/dev/null || echo "0.0.0")
118
+
119
+ echo "📦 Current version in package.json: $CURRENT_VERSION"
120
+ echo "📦 Published version on npm: $PUBLISHED_VERSION"
121
+
122
+ if [ "$CURRENT_VERSION" = "$PUBLISHED_VERSION" ]; then
123
+ echo "should-publish=false" >> $GITHUB_OUTPUT
124
+ echo "ℹ️ No version bump detected - skipping publish"
125
+ else
126
+ echo "should-publish=true" >> $GITHUB_OUTPUT
127
+ echo "✅ Version bump detected: $PUBLISHED_VERSION → $CURRENT_VERSION - will publish"
128
+ fi
129
+
130
+ - name: Create Git Tag
131
+ if: steps.version-check.outputs.should-publish == 'true'
132
+ run: |
133
+ VERSION=$(node -p "require('./package.json').version")
134
+ git config --global user.name "github-actions[bot]"
135
+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
136
+ git tag -a "v$VERSION" -m "Release v$VERSION"
137
+ git push origin "v$VERSION"
138
+
152
139
  - name: Publish to NPM
140
+ if: steps.version-check.outputs.should-publish == 'true'
153
141
  env:
154
142
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
155
143
  run: |
156
- # Simple publish - version is already bumped in package.json from PR
144
+ # Version was manually bumped and validated in PR
157
145
  npm publish --access public
158
146
 
159
147
  - name: Create GitHub Release
148
+ if: steps.version-check.outputs.should-publish == 'true'
160
149
  env:
161
150
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
162
151
  run: |
@@ -168,3 +157,9 @@ jobs:
168
157
  --title "Release v$VERSION" \
169
158
  --notes "Automated release of version $VERSION" \
170
159
  --latest
160
+
161
+ - name: Skip publish
162
+ if: steps.version-check.outputs.should-publish == 'false'
163
+ run: |
164
+ echo "ℹ️ No version bump detected - publish skipped"
165
+ echo "This merge completed without triggering a release"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@far-world-labs/verblets",
3
- "version": "0.1.4",
4
- "description": "OpenAI Client",
3
+ "version": "0.1.7",
4
+ "description": "Verblets is a collection of tools for building LLM-powered applications.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
7
7
  "repository": {
@@ -23,12 +23,9 @@
23
23
  "husky:install": "husky install",
24
24
  "husky:uninstall": "husky uninstall",
25
25
  "prepare": "npx husky install",
26
- "version:patch": "node scripts/version-bump.js patch",
27
- "version:minor": "node scripts/version-bump.js minor",
28
- "version:major": "node scripts/version-bump.js major",
29
- "release:patch": "node scripts/version-bump.js patch",
30
- "release:minor": "node scripts/version-bump.js minor",
31
- "release:major": "node scripts/version-bump.js major"
26
+ "version:patch": "npm version patch",
27
+ "version:minor": "npm version minor",
28
+ "version:major": "npm version major"
32
29
  },
33
30
  "config": {
34
31
  "gen-script": "./scripts/run.sh gen-$1"
@@ -11,7 +11,7 @@ export default async function themes(text, config = {}) {
11
11
  const { chunkSize = 5, topN, llm, ...options } = config;
12
12
  const pieces = splitText(text);
13
13
  const reducePrompt =
14
- 'Update the accumulator with short themes from this text. Avoid duplicates. Return a comma-separated list of themes.';
14
+ 'Update the accumulator with short themes from this text. Avoid duplicates. Return ONLY a comma-separated list of themes with no explanation or additional text.';
15
15
  const firstPass = await bulkReduce(shuffle(pieces), reducePrompt, { chunkSize, llm, ...options });
16
16
  const rawThemes = firstPass
17
17
  .split(',')
@@ -19,7 +19,7 @@ export default async function themes(text, config = {}) {
19
19
  .filter(Boolean);
20
20
 
21
21
  const limitText = topN ? `Limit to the top ${topN} themes.` : 'Return all meaningful themes.';
22
- const refinePrompt = `Refine the accumulator by merging similar themes. ${limitText} Return a comma-separated list.`;
22
+ const refinePrompt = `Refine the accumulator by merging similar themes. ${limitText} Return ONLY a comma-separated list with no explanation or additional text.`;
23
23
  const final = await bulkReduce(rawThemes, refinePrompt, { chunkSize, llm, ...options });
24
24
  return final
25
25
  .split(',')
@@ -1,9 +1,10 @@
1
- // Importing dotenv config to load environment variables from .env file
2
- // eslint-disable-next-line no-unused-vars
3
- import dotenv from 'dotenv/config';
1
+ // Environment variables loaded in index.js
4
2
 
5
3
  const _models = {};
6
4
 
5
+ // Function to get API key at runtime
6
+ const getOpenAIKey = () => process.env.OPENAI_API_KEY;
7
+
7
8
  const systemPrompt = `You are a superintelligent processing unit, answering prompts with precise instructions.
8
9
  You are a small but critical component in a complex system, so your role in giving quality outputs to your given inputs and instructions is critical.
9
10
  You must obey those instructions to the letter at all costs--do not deviate or add your own interpretation or flair. Stick to the instructions.
@@ -45,7 +46,9 @@ _models.fastCheapMulti = {
45
46
  maxContextWindow: 128_000,
46
47
  maxOutputTokens: 16_384,
47
48
  requestTimeout: 20_000,
48
- apiKey: process.env.OPENAI_API_KEY ?? 'undefined',
49
+ get apiKey() {
50
+ return getOpenAIKey();
51
+ },
49
52
  apiUrl: 'https://api.openai.com/',
50
53
  systemPrompt,
51
54
  };
@@ -59,7 +62,9 @@ _models.goodMulti = {
59
62
  maxContextWindow: 128_000,
60
63
  maxOutputTokens: 16_384,
61
64
  requestTimeout: 20_000,
62
- apiKey: process.env.OPENAI_API_KEY ?? 'undefined',
65
+ get apiKey() {
66
+ return getOpenAIKey();
67
+ },
63
68
  apiUrl: 'https://api.openai.com/',
64
69
  systemPrompt,
65
70
  };
@@ -73,7 +78,9 @@ _models.fastCheapReasoningMulti = {
73
78
  maxContextWindow: 128_000,
74
79
  maxOutputTokens: 16_384,
75
80
  requestTimeout: 40_000,
76
- apiKey: process.env.OPENAI_API_KEY ?? 'undefined',
81
+ get apiKey() {
82
+ return getOpenAIKey();
83
+ },
77
84
  apiUrl: 'https://api.openai.com/',
78
85
  systemPrompt,
79
86
  };
@@ -87,7 +94,9 @@ _models.reasoningNoImage = {
87
94
  maxContextWindow: 200_000,
88
95
  maxOutputTokens: 100_000,
89
96
  requestTimeout: 120_000,
90
- apiKey: process.env.OPENAI_API_KEY ?? 'undefined',
97
+ get apiKey() {
98
+ return getOpenAIKey();
99
+ },
91
100
  apiUrl: 'https://api.openai.com/',
92
101
  systemPrompt,
93
102
  };
@@ -132,7 +141,9 @@ _models.privacy = {
132
141
  apiUrl: (process.env.OPENWEBUI_API_URL ?? '').endsWith('/')
133
142
  ? process.env.OPENWEBUI_API_URL
134
143
  : `${process.env.OPENWEBUI_API_URL}/`,
135
- apiKey: process.env.OPENWEBUI_API_KEY ?? 'undefined',
144
+ get apiKey() {
145
+ return process.env.OPENWEBUI_API_KEY;
146
+ },
136
147
  systemPrompt,
137
148
  modelOptions: {
138
149
  stop: ['</s>'],
package/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
- // Importing dotenv config to load environment variables from .env file
2
- // eslint-disable-next-line no-unused-vars
3
- import dotenv from 'dotenv/config';
1
+ // Load environment variables from .env file FIRST
2
+ import dotenv from 'dotenv';
3
+ dotenv.config();
4
4
 
5
5
  import chatGPT from './lib/chatgpt/index.js';
6
6
 
@@ -1,33 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { execSync } from 'child_process';
4
- import { readFileSync } from 'fs';
5
-
6
- const args = process.argv.slice(2);
7
- const bumpType = args[0] || 'patch'; // patch, minor, major
8
-
9
- if (!['patch', 'minor', 'major'].includes(bumpType)) {
10
- console.error('Usage: node scripts/version-bump.js [patch|minor|major]');
11
- process.exit(1);
12
- }
13
-
14
- try {
15
- console.log(`🔄 Bumping ${bumpType} version...`);
16
-
17
- // Use release-it to bump version and create tag (no publish, no GitHub release)
18
- execSync(`npx release-it ${bumpType} --ci --no-npm.publish --no-github.release`, {
19
- stdio: 'inherit'
20
- });
21
-
22
- // Get the new version
23
- const pkg = JSON.parse(readFileSync('package.json', 'utf8'));
24
- const newVersion = pkg.version;
25
-
26
- console.log(`✅ Version bumped to ${newVersion}`);
27
- console.log('📝 Commit and push this change in your PR');
28
- console.log('🚀 Publishing will happen automatically when PR is merged');
29
-
30
- } catch (error) {
31
- console.error('❌ Version bump failed:', error.message);
32
- process.exit(1);
33
- }