@flowfuse/nr-assistant 0.1.1-8f87835-202407031618.0 → 0.1.1-cc561a2-202407081555.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.
@@ -21,9 +21,9 @@ jobs:
21
21
 
22
22
  publish:
23
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' )
24
+ if: |
25
+ ( github.event_name == 'push' && github.ref == 'refs/heads/main' ) ||
26
+ ( github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' )
27
27
  uses: 'flowfuse/github-actions-workflows/.github/workflows/publish_node_package.yml@v0.19.0'
28
28
  with:
29
29
  package_name: nr-assistant
@@ -38,7 +38,7 @@ jobs:
38
38
  steps:
39
39
  - name: Generate a token
40
40
  id: generate_token
41
- uses: tibdex/github-app-token@v1
41
+ uses: tibdex/github-app-token@v2
42
42
  with:
43
43
  app_id: ${{ secrets.GH_BOT_APP_ID }}
44
44
  private_key: ${{ secrets.GH_BOT_APP_KEY }}
@@ -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@v2
16
+ - uses: JS-DevTools/npm-publish@v3
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 JavaScript',
93
+ tooltip: 'Click to ask FlowFuse Assistant for help writing code',
94
94
  arguments: [model, codeLens, token]
95
95
  }
96
96
  return codeLens
@@ -134,8 +134,9 @@
134
134
 
135
135
  getUserInput({
136
136
  defaultInput: previousPrompt,
137
- title: 'FlowFuse JavaScript Assistant',
138
- description: 'Enter a short prompt explaining what you want the function to do.'
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.'
139
140
  }).then((prompt) => {
140
141
  if (prompt) {
141
142
  previousPrompt = prompt
@@ -247,37 +248,43 @@
247
248
  // const flowBuilderTitle = 'FlowFuse Flow Assistant'
248
249
  // RED.actions.add('ff:nr-assistant-flow-builder', showFlowBuilderPrompt, { label: flowBuilderTitle })
249
250
 
250
- // Add toolbar button with menu items
251
+ // Add toolbar button
251
252
  const toolbarMenuButton = $('<li><a id="red-ui-header-button-ff-ai" class="button fa fa-magic" href="#"></a></li>')
252
253
  toolbarMenuButton.prependTo('.red-ui-header-toolbar')
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
- ]
254
+ toolbarMenuButton.on('click', function (e) {
255
+ RED.actions.invoke('ff:nr-assistant-function-builder')
259
256
  })
257
+ RED.popover.tooltip(toolbarMenuButton, 'FlowFuse Assistant')
260
258
  assistantInitialised = true
261
259
  }
262
260
 
263
- function getUserInput ({ title, description, placeholder, defaultInput } = {
261
+ function getUserInput ({ title, explanation, description, placeholder, defaultInput } = {
264
262
  title: 'FlowFuse Assistant',
265
- description: 'Enter a short prompt explaining what you want the function node to do.',
266
- placeholder: 'Example: convert the payload to uppercase',
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: '',
267
266
  defaultInput: ''
268
267
  }) {
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('')
269
276
  return new Promise((resolve, reject) => {
270
277
  const dialog = $('<div id="ff-nr-ai-dialog-input" class="hide red-ui-editor"></div>')
271
278
  const containerDiv = $('<div style="height: 100%;display: flex;flex-direction: column; height: calc(100% - 12px);">')
272
- if (description) {
273
- containerDiv.append('<div style="margin-bottom: 12px; margin-top: -8px">' + description + '</div>')
279
+ if (body) {
280
+ containerDiv.append('<div style="margin-bottom: 8px; margin-top: -10px">' + body + '</div>')
274
281
  }
275
282
  const form = $('<form id="ff-nr-ai-dialog-input-fields" style="flex-grow: 1; margin-bottom: 6px;"></form>')
276
283
  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>')
277
284
  form.append(input)
278
285
  containerDiv.append(form)
279
286
  dialog.append(containerDiv)
280
- const minHeight = 200 + (description ? 32 : 0)
287
+ const minHeight = 260 + (description ? 32 : 0) + (explanation ? 32 : 0)
281
288
  const minWidth = 480
282
289
  dialog.dialog({
283
290
  autoOpen: true,
@@ -285,7 +292,7 @@
285
292
  modal: true,
286
293
  closeOnEscape: true,
287
294
  height: minHeight,
288
- width: 580,
295
+ width: minWidth,
289
296
  minHeight,
290
297
  minWidth,
291
298
  resizable: true,
@@ -318,15 +325,16 @@
318
325
  }
319
326
 
320
327
  let previousFunctionBuilderPrompt
321
- function showFunctionBuilderPrompt (title, description) {
328
+ function showFunctionBuilderPrompt (title) {
322
329
  if (!assistantOptions.enabled) {
323
330
  RED.notify('The FlowFuse Assistant is not enabled', 'warning')
324
331
  return
325
332
  }
326
333
  getUserInput({
327
334
  defaultInput: previousFunctionBuilderPrompt,
328
- title: title || 'FlowFuse Function Node Assistant',
329
- description: description || 'Enter a short prompt explaining what you want the function node to do.'
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.'
330
338
  }).then((prompt) => {
331
339
  /** @type {JQueryXHR} */
332
340
  let xhr = null
@@ -383,15 +391,16 @@
383
391
 
384
392
  let previousFlowBuilderPrompt
385
393
  // eslint-disable-next-line no-unused-vars
386
- function showFlowBuilderPrompt (title, description) {
394
+ function showFlowBuilderPrompt (title) {
387
395
  if (!assistantOptions.enabled) {
388
396
  RED.notify('The FlowFuse Assistant is not enabled', 'warning')
389
397
  return
390
398
  }
391
399
  getUserInput({
392
400
  defaultInput: previousFlowBuilderPrompt,
393
- title: title || 'FlowFuse Flow Builder',
394
- description: description || 'Enter a short prompt explaining what you want the flow to do.'
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.'
395
404
  }).then((prompt) => {
396
405
  /** @type {JQueryXHR} */
397
406
  let xhr = null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowfuse/nr-assistant",
3
- "version": "0.1.1-8f87835-202407031618.0",
3
+ "version": "0.1.1-cc561a2-202407081555.0",
4
4
  "description": "FlowFuse Node-RED assistant plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {