@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 +35 -93
- package/dist/configuration.d.mts +2 -2
- package/dist/configuration.d.ts +2 -2
- package/dist/configuration.js +2633 -13
- package/dist/configuration.mjs +2633 -3
- package/dist/{context-DOUnUNNN.d.ts → context-BbEmsEct.d.ts} +2 -0
- package/dist/{context-3Ck9sBZI.d.mts → context-sqbr2o6i.d.mts} +2 -0
- package/dist/index.d.mts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +2242 -94
- package/dist/index.mjs +2237 -90
- package/dist/llm.d.mts +23 -0
- package/dist/llm.d.ts +23 -0
- package/dist/llm.js +109 -0
- package/dist/llm.mjs +84 -0
- 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 -0
- package/dist/signature.d.ts +1 -0
- package/dist/signature.js +1 -0
- package/dist/signature.mjs +1 -0
- package/package.json +51 -40
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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.
|
package/dist/configuration.d.mts
CHANGED
|
@@ -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-
|
|
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/
|
|
14
|
+
import '@octokit/request-error';
|
|
15
15
|
import '@octokit/core';
|
|
16
16
|
|
|
17
17
|
type GithubPlugin = {
|
package/dist/configuration.d.ts
CHANGED
|
@@ -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-
|
|
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/
|
|
14
|
+
import '@octokit/request-error';
|
|
15
15
|
import '@octokit/core';
|
|
16
16
|
|
|
17
17
|
type GithubPlugin = {
|