@ubiquity-os/plugin-sdk 3.5.5 → 3.6.2

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
@@ -19,98 +19,40 @@ The `createPlugin` function enables users to create a plugin that will run on Cl
19
19
 
20
20
  ### `postComment`
21
21
 
22
- The `postComment` function enables users to easily post a comment to an issue, a pull-request, or a pull request review thread.
23
-
24
- ## Getting Started
25
-
26
- To set up the project locally, `bun` is the preferred package manager.
27
-
28
- 1. Install the dependencies:
29
-
30
- ```sh
31
- bun install
32
- ```
33
-
34
- 2. Build the SDK
35
- ```
36
- bun sdk:build
37
- ```
38
- 3. Link it locally to another plugin
39
- ```
40
- bun link
41
- ```
42
-
43
- ## Scripts
44
-
45
- The project provides several npm scripts for various tasks:
46
-
47
- - `bun run sdk:build`: Compiles the TypeScript code.
48
- - `bun run test`: Runs the tests.
49
- - `bun run lint`: Runs the linter.
50
- - `bun run format`: Formats the code using Prettier.
51
-
52
- ## Testing
53
-
54
- ### Jest
55
-
56
- To start Jest tests, run:
57
-
58
- ```sh
59
- bun run test
60
- ```
61
-
62
- ## Markdown Cleaning Utility
63
-
64
- `cleanMarkdown` removes top-level HTML comments and configured HTML tags while preserving content inside fenced/indented code blocks, inline code spans, and blockquotes.
65
-
66
- ### Import
67
-
68
- ```ts
69
- import { cleanMarkdown, type CleanMarkdownOptions } from "@ubiquity-os/plugin-sdk/markdown";
70
- ```
71
-
72
- ### Options (`CleanMarkdownOptions`)
73
-
74
- | Option | Type | Default | Description |
75
- | -------------------- | --------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
76
- | `tags` | `(keyof HTMLElementTagNameMap)[]` | `[]` | List of HTML tag names to strip. Whole block tokens that are a single matching root element are removed entirely. Inline self-closing/void-like occurrences (e.g. `<br>`) are also removed. |
77
- | `collapseEmptyLines` | `boolean` | `false` | Collapses runs of 3+ blank lines down to exactly 2. |
78
-
79
- ### Behavior Summary
80
-
81
- - Strips HTML comments (`<!-- ... -->`) outside protected contexts:
82
- - Not inside fenced/indented code blocks
83
- - Not inside inline code spans
84
- - Not inside blockquotes (blockquote content is left untouched)
85
- - Removes entire HTML block tokens consisting of a single root element whose tag is in `tags`.
86
- - Removes inline occurrences of any tag in `tags` (void/self-closing style).
87
- - Leaves everything else unchanged to minimize diff noise.
88
- - Final output is trimmed (no trailing blank lines).
89
-
90
- ### Example
91
-
92
- ```ts
93
- const input = `
94
- <!-- build badge -->
95
- <details>
96
- <summary>Info</summary>
97
- Content inside details
98
- </details>
99
-
100
- Paragraph with <br> line break and \`<br>\` in code.
101
-
102
- \`\`\`ts
103
- // Code block with <!-- comment --> and <br>
104
- const x = 1;
105
- \`\`\`
106
-
107
- > Blockquote with <!-- preserved comment --> and <br>.
108
- `;
109
-
110
- const cleaned = cleanMarkdown(input, {
111
- tags: ["details", "br"],
112
- collapseEmptyLines: true,
22
+ ### `callLlm`
23
+
24
+ The `callLlm` function allows plugins to securely call the ai.ubq.fi LLM endpoint using inherited GitHub authentication.
25
+
26
+ #### Usage
27
+
28
+ ```typescript
29
+ import { PluginInput, createPlugin, callLlm } from '@ubiquity-os/plugin-sdk';
30
+
31
+ export default createPlugin({
32
+ async onCommand(input: PluginInput) {
33
+ // Non-streaming: resolves to ChatCompletion.
34
+ const result = await callLlm(
35
+ {
36
+ messages: [{ role: 'user', content: 'Hello, world!' }]
37
+ },
38
+ input
39
+ );
40
+
41
+ // Streaming: returns AsyncIterable<ChatCompletionChunk>.
42
+ const stream = await callLlm(
43
+ {
44
+ messages: [{ role: 'user', content: 'Hello, world!' }],
45
+ stream: true
46
+ },
47
+ input
48
+ );
49
+ for await (const chunk of stream) {
50
+ const delta = chunk.choices?.[0]?.delta?.content ?? '';
51
+ // handle delta
52
+ }
53
+ return { success: true };
54
+ }
113
55
  });
114
-
115
- console.log(cleaned);
116
56
  ```
57
+
58
+ Automatically extracts `authToken`, `owner`, `repo` from input and passes to ai.ubq.fi with proper headers for secure, repo-scoped access.
@@ -2,7 +2,7 @@ import { Value } from '@sinclair/typebox/value';
2
2
  import YAML from 'js-yaml';
3
3
  import * as _sinclair_typebox from '@sinclair/typebox';
4
4
  import { StaticDecode, TLiteral } from '@sinclair/typebox';
5
- import { C as Context } from './context-3Ck9sBZI.mjs';
5
+ import { C as Context } from './context-sqbr2o6i.mjs';
6
6
  import { Manifest } from './manifest.mjs';
7
7
  import '@octokit/webhooks';
8
8
  import '@ubiquity-os/ubiquity-os-logger';
@@ -11,7 +11,7 @@ import './octokit.mjs';
11
11
  import '@octokit/core/types';
12
12
  import '@octokit/plugin-paginate-graphql';
13
13
  import '@octokit/plugin-paginate-rest';
14
- import '@octokit/webhooks/node_modules/@octokit/request-error';
14
+ import '@octokit/request-error';
15
15
  import '@octokit/core';
16
16
 
17
17
  type GithubPlugin = {
@@ -2,7 +2,7 @@ import { Value } from '@sinclair/typebox/value';
2
2
  import YAML from 'js-yaml';
3
3
  import * as _sinclair_typebox from '@sinclair/typebox';
4
4
  import { StaticDecode, TLiteral } from '@sinclair/typebox';
5
- import { C as Context } from './context-DOUnUNNN.js';
5
+ import { C as Context } from './context-BbEmsEct.js';
6
6
  import { Manifest } from './manifest.js';
7
7
  import '@octokit/webhooks';
8
8
  import '@ubiquity-os/ubiquity-os-logger';
@@ -11,7 +11,7 @@ import './octokit.js';
11
11
  import '@octokit/core/types';
12
12
  import '@octokit/plugin-paginate-graphql';
13
13
  import '@octokit/plugin-paginate-rest';
14
- import '@octokit/webhooks/node_modules/@octokit/request-error';
14
+ import '@octokit/request-error';
15
15
  import '@octokit/core';
16
16
 
17
17
  type GithubPlugin = {