@ubiquity-os/plugin-sdk 3.6.0 → 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
@@ -17,117 +17,42 @@ The `createActionsPlugin` function allows users to create plugins that will be a
17
17
 
18
18
  The `createPlugin` function enables users to create a plugin that will run on Cloudflare Workers environment.
19
19
 
20
- ### `callLlm`
21
-
22
- The `callLlm` function sends chat completion requests to `ai.ubq.fi` using the auth token and repository context supplied by the kernel.
23
-
24
20
  ### `postComment`
25
21
 
26
- The `postComment` function enables users to easily post a comment to an issue, a pull-request, or a pull request review thread.
27
-
28
- ## Getting Started
29
-
30
- To set up the project locally, `bun` is the preferred package manager.
31
-
32
- 1. Install the dependencies:
33
-
34
- ```sh
35
- bun install
36
- ```
37
-
38
- 2. Build the SDK
39
- ```
40
- bun sdk:build
41
- ```
42
- 3. Link it locally to another plugin
43
- ```
44
- bun link
45
- ```
46
-
47
- ## Scripts
48
-
49
- The project provides several npm scripts for various tasks:
50
-
51
- - `bun run sdk:build`: Compiles the TypeScript code.
52
- - `bun run test`: Runs the tests.
53
- - `bun run lint`: Runs the linter.
54
- - `bun run format`: Formats the code using Prettier.
55
-
56
- ## Testing
57
-
58
- ### Jest
59
-
60
- To start Jest tests, run:
61
-
62
- ```sh
63
- bun run test
64
- ```
65
-
66
- ## LLM Utility
67
-
68
- ```ts
69
- import { callLlm } from "@ubiquity-os/plugin-sdk";
70
-
71
- const result = await callLlm(
72
- {
73
- messages: [{ role: "user", content: "Summarize this issue." }],
74
- },
75
- context
76
- );
77
- ```
78
-
79
- ## Markdown Cleaning Utility
80
-
81
- `cleanMarkdown` removes top-level HTML comments and configured HTML tags while preserving content inside fenced/indented code blocks, inline code spans, and blockquotes.
82
-
83
- ### Import
84
-
85
- ```ts
86
- import { cleanMarkdown, type CleanMarkdownOptions } from "@ubiquity-os/plugin-sdk/markdown";
87
- ```
88
-
89
- ### Options (`CleanMarkdownOptions`)
90
-
91
- | Option | Type | Default | Description |
92
- | -------------------- | --------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
93
- | `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. |
94
- | `collapseEmptyLines` | `boolean` | `false` | Collapses runs of 3+ blank lines down to exactly 2. |
95
-
96
- ### Behavior Summary
97
-
98
- - Strips HTML comments (`<!-- ... -->`) outside protected contexts:
99
- - Not inside fenced/indented code blocks
100
- - Not inside inline code spans
101
- - Not inside blockquotes (blockquote content is left untouched)
102
- - Removes entire HTML block tokens consisting of a single root element whose tag is in `tags`.
103
- - Removes inline occurrences of any tag in `tags` (void/self-closing style).
104
- - Leaves everything else unchanged to minimize diff noise.
105
- - Final output is trimmed (no trailing blank lines).
106
-
107
- ### Example
108
-
109
- ```ts
110
- const input = `
111
- <!-- build badge -->
112
- <details>
113
- <summary>Info</summary>
114
- Content inside details
115
- </details>
116
-
117
- Paragraph with <br> line break and \`<br>\` in code.
118
-
119
- \`\`\`ts
120
- // Code block with <!-- comment --> and <br>
121
- const x = 1;
122
- \`\`\`
123
-
124
- > Blockquote with <!-- preserved comment --> and <br>.
125
- `;
22
+ ### `callLlm`
126
23
 
127
- const cleaned = cleanMarkdown(input, {
128
- tags: ["details", "br"],
129
- collapseEmptyLines: true,
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
+ }
130
55
  });
131
-
132
- console.log(cleaned);
133
56
  ```
57
+
58
+ Automatically extracts `authToken`, `owner`, `repo` from input and passes to ai.ubq.fi with proper headers for secure, repo-scoped access.
@@ -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 = {
@@ -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 = {