@flowfuse/nr-assistant 0.1.0 → 0.1.1-8f87835-202407031618.0

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.
@@ -0,0 +1,51 @@
1
+ name: Build and push packages
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - main
8
+ pull_request:
9
+ branches:
10
+ - main
11
+
12
+ jobs:
13
+ build:
14
+ uses: 'flowfuse/github-actions-workflows/.github/workflows/build_node_package.yml@v0.19.0'
15
+ with:
16
+ node: '[
17
+ {"version": "16", "tests": true, "lint": false},
18
+ {"version": "18", "tests": true, "lint": true},
19
+ {"version": "20", "tests": true, "lint": true},
20
+ ]'
21
+
22
+ publish:
23
+ needs: build
24
+ # if: |
25
+ # ( github.event_name == 'push' && github.ref == 'refs/heads/main' ) ||
26
+ # ( github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' )
27
+ uses: 'flowfuse/github-actions-workflows/.github/workflows/publish_node_package.yml@v0.19.0'
28
+ with:
29
+ package_name: nr-assistant
30
+ publish_package: true
31
+ secrets:
32
+ npm_registry_token: ${{ secrets.NPM_PUBLISH_TOKEN }}
33
+
34
+ dispatch_nr_launcher:
35
+ name: Dispatch nr-launcher package build
36
+ needs: publish
37
+ runs-on: ubuntu-latest
38
+ steps:
39
+ - name: Generate a token
40
+ id: generate_token
41
+ uses: tibdex/github-app-token@v1
42
+ with:
43
+ app_id: ${{ secrets.GH_BOT_APP_ID }}
44
+ private_key: ${{ secrets.GH_BOT_APP_KEY }}
45
+ - name: Trigger nr-launcher package build
46
+ uses: benc-uk/workflow-dispatch@v1
47
+ with:
48
+ workflow: publish.yml
49
+ repo: flowfuse/nr-launcher
50
+ ref: main
51
+ token: ${{ steps.generate_token.outputs.token }}
@@ -13,7 +13,7 @@ jobs:
13
13
  with:
14
14
  node-version: 16
15
15
  - run: npm ci --omit=dev
16
- - uses: JS-DevTools/npm-publish@v3
16
+ - uses: JS-DevTools/npm-publish@v2
17
17
  with:
18
18
  token: ${{ secrets.NPM_PUBLISH_TOKEN }}
19
19
  access: public
package/index.html CHANGED
@@ -90,7 +90,7 @@
90
90
  codeLens.command = {
91
91
  id: codeLens.id,
92
92
  title: 'Ask the FlowFuse Assistant 🪄',
93
- tooltip: 'Click to ask FlowFuse Assistant for help writing code',
93
+ tooltip: 'Click to ask FlowFuse Assistant for help writing JavaScript',
94
94
  arguments: [model, codeLens, token]
95
95
  }
96
96
  return codeLens
@@ -134,9 +134,8 @@
134
134
 
135
135
  getUserInput({
136
136
  defaultInput: previousPrompt,
137
- title: 'FlowFuse Assistant : Function Code',
138
- explanation: 'The FlowFuse Assistant can help you write code.',
139
- description: 'Enter a short description of what you want the function to do.'
137
+ title: 'FlowFuse JavaScript Assistant',
138
+ description: 'Enter a short prompt explaining what you want the function to do.'
140
139
  }).then((prompt) => {
141
140
  if (prompt) {
142
141
  previousPrompt = prompt
@@ -248,43 +247,37 @@
248
247
  // const flowBuilderTitle = 'FlowFuse Flow Assistant'
249
248
  // RED.actions.add('ff:nr-assistant-flow-builder', showFlowBuilderPrompt, { label: flowBuilderTitle })
250
249
 
251
- // Add toolbar button
250
+ // Add toolbar button with menu items
252
251
  const toolbarMenuButton = $('<li><a id="red-ui-header-button-ff-ai" class="button fa fa-magic" href="#"></a></li>')
253
252
  toolbarMenuButton.prependTo('.red-ui-header-toolbar')
254
- toolbarMenuButton.on('click', function (e) {
255
- RED.actions.invoke('ff:nr-assistant-function-builder')
253
+ RED.menu.init({
254
+ id: 'red-ui-header-button-ff-ai',
255
+ options: [
256
+ { id: 'menu-item-ff-ai-new-func', label: funcBuilderTitle, disabled: !assistantOptions.enabled, onselect: 'ff:nr-assistant-function-builder' }
257
+ // { id: "menu-item-ff-ai-new-flow", label: flowBuilderTitle, disabled: !assistantOptions.enabled, onselect: "ff:nr-assistant-flow-builder" } // FUTURE: enable this when the flow builder is ready
258
+ ]
256
259
  })
257
- RED.popover.tooltip(toolbarMenuButton, 'FlowFuse Assistant')
258
260
  assistantInitialised = true
259
261
  }
260
262
 
261
- function getUserInput ({ title, explanation, description, placeholder, defaultInput } = {
263
+ function getUserInput ({ title, description, placeholder, defaultInput } = {
262
264
  title: 'FlowFuse Assistant',
263
- explanation: 'The FlowFuse Assistant can help you create things.',
264
- description: 'Enter a short description explaining what you want it to do.',
265
- placeholder: '',
265
+ description: 'Enter a short prompt explaining what you want the function node to do.',
266
+ placeholder: 'Example: convert the payload to uppercase',
266
267
  defaultInput: ''
267
268
  }) {
268
- const bodyText = []
269
- if (explanation) {
270
- bodyText.push(`<p style="">${explanation}</p>`)
271
- }
272
- if (description) {
273
- bodyText.push(`<p>${description}</p>`)
274
- }
275
- const body = bodyText.join('')
276
269
  return new Promise((resolve, reject) => {
277
270
  const dialog = $('<div id="ff-nr-ai-dialog-input" class="hide red-ui-editor"></div>')
278
271
  const containerDiv = $('<div style="height: 100%;display: flex;flex-direction: column; height: calc(100% - 12px);">')
279
- if (body) {
280
- containerDiv.append('<div style="margin-bottom: 8px; margin-top: -10px">' + body + '</div>')
272
+ if (description) {
273
+ containerDiv.append('<div style="margin-bottom: 12px; margin-top: -8px">' + description + '</div>')
281
274
  }
282
275
  const form = $('<form id="ff-nr-ai-dialog-input-fields" style="flex-grow: 1; margin-bottom: 6px;"></form>')
283
276
  const input = $('<textarea id="ff-nr-ai-dialog-input-editor" style="height:100%;width:100%; position:relative; resize: none;" maxlength="400" placeholder="' + (placeholder || '') + '">' + (defaultInput || '') + '</textarea>')
284
277
  form.append(input)
285
278
  containerDiv.append(form)
286
279
  dialog.append(containerDiv)
287
- const minHeight = 260 + (description ? 32 : 0) + (explanation ? 32 : 0)
280
+ const minHeight = 200 + (description ? 32 : 0)
288
281
  const minWidth = 480
289
282
  dialog.dialog({
290
283
  autoOpen: true,
@@ -292,7 +285,7 @@
292
285
  modal: true,
293
286
  closeOnEscape: true,
294
287
  height: minHeight,
295
- width: minWidth,
288
+ width: 580,
296
289
  minHeight,
297
290
  minWidth,
298
291
  resizable: true,
@@ -325,16 +318,15 @@
325
318
  }
326
319
 
327
320
  let previousFunctionBuilderPrompt
328
- function showFunctionBuilderPrompt (title) {
321
+ function showFunctionBuilderPrompt (title, description) {
329
322
  if (!assistantOptions.enabled) {
330
323
  RED.notify('The FlowFuse Assistant is not enabled', 'warning')
331
324
  return
332
325
  }
333
326
  getUserInput({
334
327
  defaultInput: previousFunctionBuilderPrompt,
335
- title: title || 'FlowFuse Assistant : Create A Function Node',
336
- explanation: 'The FlowFuse Assistant can help you create a Function Node.',
337
- description: 'Enter a short description of what you want it to do.'
328
+ title: title || 'FlowFuse Function Node Assistant',
329
+ description: description || 'Enter a short prompt explaining what you want the function node to do.'
338
330
  }).then((prompt) => {
339
331
  /** @type {JQueryXHR} */
340
332
  let xhr = null
@@ -391,16 +383,15 @@
391
383
 
392
384
  let previousFlowBuilderPrompt
393
385
  // eslint-disable-next-line no-unused-vars
394
- function showFlowBuilderPrompt (title) {
386
+ function showFlowBuilderPrompt (title, description) {
395
387
  if (!assistantOptions.enabled) {
396
388
  RED.notify('The FlowFuse Assistant is not enabled', 'warning')
397
389
  return
398
390
  }
399
391
  getUserInput({
400
392
  defaultInput: previousFlowBuilderPrompt,
401
- title: title || 'FlowFuse Assistant : Flow Builder',
402
- explanation: 'The FlowFuse Assistant can help you create a new flow.',
403
- description: 'Enter a short description of what you want the flow to do.'
393
+ title: title || 'FlowFuse Flow Builder',
394
+ description: description || 'Enter a short prompt explaining what you want the flow to do.'
404
395
  }).then((prompt) => {
405
396
  /** @type {JQueryXHR} */
406
397
  let xhr = null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowfuse/nr-assistant",
3
- "version": "0.1.0",
3
+ "version": "0.1.1-8f87835-202407031618.0",
4
4
  "description": "FlowFuse Node-RED assistant plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -44,4 +44,4 @@
44
44
  "eslint-plugin-html": "7.1.0",
45
45
  "eslint-plugin-no-only-tests": "^3.1.0"
46
46
  }
47
- }
47
+ }