node-red-contrib-vibe-function 0.1.0 → 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.
package/README.md CHANGED
@@ -13,9 +13,7 @@ mkdir -p node-red-contrib-vibe-function
13
13
  cp vibe-function.* node-red-contrib-vibe-function/
14
14
  ln -s ../node-red-contrib-vibe-function node_modules/node-red-contrib-vibe-function
15
15
 
16
- # 设置 API Key(二选一)
17
- export DEEPSEEK_API_KEY=sk-xxxxx # 环境变量
18
- # 或在编辑面板中创建 vibe-function-config 配置节点
16
+ # 在编辑面板中创建 vibe-function-config 配置节点,填入 API Key
19
17
 
20
18
  # 重启 Node-RED
21
19
  node-red
@@ -87,7 +85,7 @@ msg.payload = "YYYY-MM-DD HH:mm:ss" formatted time string
87
85
  | Model | `deepseek-v4-pro[1m]` | 模型名称 |
88
86
  | API Key | *(必填)* | 凭证,加密存储 |
89
87
 
90
- 可创建多个配置节点供不同节点使用。未配置时回退到 `DEEPSEEK_API_KEY` 环境变量。
88
+ 可创建多个配置节点供不同节点使用。API Key 加密存储在 Node-RED 凭证文件中。
91
89
 
92
90
  ## 兼容的 API 提供商
93
91
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-vibe-function",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "AI-powered Node-RED function node — generate, validate, and self-heal code with natural language",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",
27
- "url": "https://github.com/iceshard999/node-red-contrib-vibe-function"
27
+ "url": "git+https://github.com/iceshard999/node-red-contrib-vibe-function.git"
28
28
  },
29
29
  "author": {
30
30
  "name": "Kesong Wan",
@@ -410,3 +410,49 @@
410
410
 
411
411
  </div>
412
412
  </script>
413
+
414
+ <script type="text/html" data-help-name="vibe-function">
415
+ <h3>Vibe Function</h3>
416
+ <p>AI 驱动的 Function 节点。用自然语言描述需求,自动生成、校验、修复 JavaScript 代码。</p>
417
+
418
+ <h4>Tabs</h4>
419
+ <dl class="node-help">
420
+ <dt>Coding</dt><dd>核心面板:选择 API 配置、输入需求描述、一键生成代码。</dd>
421
+ <dt>Schema</dt><dd>定义输入/输出 msg 结构。提供属性下拉快速添加,会传给 LLM 以生成更精准的代码。</dd>
422
+ <dt>Setup</dt><dd>Outputs 数量、Timeout、外部模块导入(如 lodash、moment)。</dd>
423
+ <dt>On Start</dt><dd>初始化代码,节点启动时执行一次。可初始化变量、建立连接,可用 <code>node.send()</code>。</dd>
424
+ <dt>On Message</dt><dd>消息处理函数 (<code>async function</code>)。每次收到 msg 时执行,可用 <code>return msg</code> / <code>node.send(msg)</code> / <code>await</code>。</dd>
425
+ <dt>On Stop</dt><dd>清理代码,节点停止时执行。清理资源、关闭连接。不可使用 <code>node.send()</code>。</dd>
426
+ </dl>
427
+
428
+ <h4>Debug 模式</h4>
429
+ <p>节点上的 🐛/</> 按钮开启 Debug:</p>
430
+ <ul>
431
+ <li>代码异常 → 自动 LLM 修复并重试</li>
432
+ <li>输出校验 → 对照 Output Schema,不符合则自动修复</li>
433
+ <li>修复后代码同步到编辑器(即时生效,无需部署)</li>
434
+ </ul>
435
+
436
+ <h4>沙箱环境</h4>
437
+ <ul>
438
+ <li><code>node.send(msg)</code> / <code>node.done()</code></li>
439
+ <li><code>context</code> / <code>flow</code> / <code>global</code></li>
440
+ <li><code>env.get("VAR")</code></li>
441
+ <li><code>util</code> / <code>Buffer</code> / <code>Date</code></li>
442
+ <li><code>setTimeout</code> / <code>setInterval</code>(自动清理)</li>
443
+ </ul>
444
+
445
+ <h4>API 配置</h4>
446
+ <p>使用 <code>vibe-function-config</code> 配置节点。支持 Anthropic Messages 和 OpenAI Chat Completions 两种格式。</p>
447
+ </script>
448
+
449
+ <script type="text/html" data-help-name="vibe-function-config">
450
+ <h3>Vibe Function API Config</h3>
451
+ <p>Vibe Function 节点的 API 连接配置。</p>
452
+ <dl class="node-help">
453
+ <dt>API 格式</dt><dd>Anthropic Messages 或 OpenAI Chat Completions。</dd>
454
+ <dt>Base URL</dt><dd>API 基础地址,不含路径。</dd>
455
+ <dt>Model</dt><dd>模型名称,如 <code>deepseek-v4-pro[1m]</code>。</dd>
456
+ <dt>API Key</dt><dd>加密存储的 API 凭证。</dd>
457
+ </dl>
458
+ </script>
package/vibe-function.js CHANGED
@@ -9,7 +9,7 @@ module.exports = function(RED) {
9
9
  async function callLLM(configNodeId, promptContent) {
10
10
  let baseUrl = 'https://api.deepseek.com/anthropic';
11
11
  let model = 'deepseek-v4-pro[1m]';
12
- let apiKey = process.env.DEEPSEEK_API_KEY;
12
+ let apiKey;
13
13
  let apiFormat = 'anthropic';
14
14
 
15
15
  if (configNodeId) {
@@ -291,7 +291,7 @@ Reply EXACTLY "YES" if the output matches the schema, or "NO: <reason>" if it do
291
291
 
292
292
  async function autoFixCode(reason, inputMsg) {
293
293
  if (!node.debug) return null;
294
- const canCall = !!(process.env.DEEPSEEK_API_KEY || (node.configRef && RED.nodes.getNode(node.configRef)));
294
+ const canCall = !!(node.configRef && RED.nodes.getNode(node.configRef));
295
295
  if (!canCall) return null;
296
296
  try {
297
297
  const prompt = `你是一个 Node-RED function 节点调试修复器。
@@ -456,9 +456,8 @@ ${node.func}
456
456
  // Debug 启动检查
457
457
  if (node.debug) {
458
458
  const hasConfig = !!(node.configRef && RED.nodes.getNode(node.configRef));
459
- const hasEnvKey = !!process.env.DEEPSEEK_API_KEY;
460
- if (!hasConfig && !hasEnvKey) {
461
- node.warn('[Debug] 未配置 API Key,自动修复不会生效。请在 Coding Tab 中选择 API 配置或设置 DEEPSEEK_API_KEY 环境变量');
459
+ if (!hasConfig) {
460
+ node.warn('[Debug] 未选择 API 配置,自动修复不会生效。请在 Coding Tab 中选择 API 配置');
462
461
  }
463
462
  }
464
463