@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 +34 -109
- package/dist/configuration.d.mts +1 -1
- package/dist/configuration.d.ts +1 -1
- package/dist/configuration.js +2633 -13
- package/dist/configuration.mjs +2633 -3
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2187 -137
- package/dist/index.mjs +2178 -128
- package/dist/llm.d.mts +6 -43
- package/dist/llm.d.ts +6 -43
- package/dist/llm.js +12 -20
- package/dist/llm.mjs +12 -20
- package/dist/octokit.d.mts +2 -2
- package/dist/octokit.d.ts +2 -2
- package/dist/octokit.js +164 -2
- package/dist/octokit.mjs +163 -1
- package/dist/signature.d.mts +1 -3
- package/dist/signature.d.ts +1 -3
- package/dist/signature.js +1 -4
- package/dist/signature.mjs +1 -4
- package/package.json +43 -41
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
|
-
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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.
|
package/dist/configuration.d.mts
CHANGED
|
@@ -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/
|
|
14
|
+
import '@octokit/request-error';
|
|
15
15
|
import '@octokit/core';
|
|
16
16
|
|
|
17
17
|
type GithubPlugin = {
|
package/dist/configuration.d.ts
CHANGED
|
@@ -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/
|
|
14
|
+
import '@octokit/request-error';
|
|
15
15
|
import '@octokit/core';
|
|
16
16
|
|
|
17
17
|
type GithubPlugin = {
|