dsh-gh-pages-artifacts 0.1.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.
- package/LICENSE +21 -0
- package/README.md +227 -0
- package/assets/artifact-pages/SKILL.md +84 -0
- package/bin/setup.mjs +270 -0
- package/client/client.js +564 -0
- package/cordis.patch.yml +15 -0
- package/icon.svg +6 -0
- package/lib/approval.d.ts +26 -0
- package/lib/approval.js +59 -0
- package/lib/config.d.ts +204 -0
- package/lib/config.js +241 -0
- package/lib/content.d.ts +43 -0
- package/lib/content.js +142 -0
- package/lib/github.d.ts +78 -0
- package/lib/github.js +190 -0
- package/lib/index.d.ts +22 -0
- package/lib/index.js +48 -0
- package/lib/manifest.d.ts +88 -0
- package/lib/manifest.js +172 -0
- package/lib/names.d.ts +17 -0
- package/lib/names.js +17 -0
- package/lib/prompt.d.ts +15 -0
- package/lib/prompt.js +33 -0
- package/lib/registry.d.ts +70 -0
- package/lib/registry.js +151 -0
- package/lib/render.d.ts +43 -0
- package/lib/render.js +128 -0
- package/lib/service.d.ts +292 -0
- package/lib/service.js +1216 -0
- package/lib/skill.d.ts +16 -0
- package/lib/skill.js +59 -0
- package/lib/store.d.ts +167 -0
- package/lib/store.js +379 -0
- package/lib/tools.d.ts +10 -0
- package/lib/tools.js +320 -0
- package/lib/visibility.d.ts +34 -0
- package/lib/visibility.js +81 -0
- package/lib/web-routes.d.ts +29 -0
- package/lib/web-routes.js +84 -0
- package/locale/en.json +6 -0
- package/package.json +130 -0
package/lib/service.d.ts
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { ToolRunContext } from '@deepseek-ai/dsh-tools';
|
|
3
|
+
import { type RepoStrategy, type Settings } from './config.js';
|
|
4
|
+
import { type ArtifactKind } from './manifest.js';
|
|
5
|
+
import { Registry } from './registry.js';
|
|
6
|
+
/** Package version, sent in the User-Agent. */
|
|
7
|
+
export declare const VERSION: string;
|
|
8
|
+
/** Arguments of `artifact_publish`. */
|
|
9
|
+
export interface PublishArgs {
|
|
10
|
+
readonly description: string;
|
|
11
|
+
readonly title?: string | undefined;
|
|
12
|
+
readonly id?: string | undefined;
|
|
13
|
+
readonly path?: string | undefined;
|
|
14
|
+
readonly kind?: ArtifactKind | undefined;
|
|
15
|
+
readonly slug?: string | undefined;
|
|
16
|
+
readonly assets?: ReadonlyArray<{
|
|
17
|
+
readonly path: string;
|
|
18
|
+
readonly name?: string | undefined;
|
|
19
|
+
}> | undefined;
|
|
20
|
+
readonly removeAssets?: readonly string[] | undefined;
|
|
21
|
+
readonly baseRev?: number | undefined;
|
|
22
|
+
readonly content?: string | undefined;
|
|
23
|
+
}
|
|
24
|
+
/** Result of `artifact_publish`. */
|
|
25
|
+
export interface PublishResult {
|
|
26
|
+
id: string;
|
|
27
|
+
title: string;
|
|
28
|
+
kind: ArtifactKind;
|
|
29
|
+
url: string;
|
|
30
|
+
repository: string;
|
|
31
|
+
newRepository: boolean;
|
|
32
|
+
rev: number;
|
|
33
|
+
created: boolean;
|
|
34
|
+
commit: string;
|
|
35
|
+
files: string[];
|
|
36
|
+
warnings: string[];
|
|
37
|
+
}
|
|
38
|
+
/** One row of `artifact_list`. */
|
|
39
|
+
export interface ListedArtifact {
|
|
40
|
+
id: string;
|
|
41
|
+
title: string;
|
|
42
|
+
kind: ArtifactKind;
|
|
43
|
+
url: string;
|
|
44
|
+
repository: string;
|
|
45
|
+
rev: number;
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
status: 'published' | 'deleted';
|
|
48
|
+
description?: string;
|
|
49
|
+
}
|
|
50
|
+
/** Result of `artifact_list`. */
|
|
51
|
+
export interface ListResult {
|
|
52
|
+
total: number;
|
|
53
|
+
artifacts: ListedArtifact[];
|
|
54
|
+
indexFile: string;
|
|
55
|
+
notes: string[];
|
|
56
|
+
nextOffset?: number;
|
|
57
|
+
}
|
|
58
|
+
/** Result of `artifact_read`. */
|
|
59
|
+
export interface ReadResult {
|
|
60
|
+
id: string;
|
|
61
|
+
title: string;
|
|
62
|
+
kind: ArtifactKind;
|
|
63
|
+
url: string;
|
|
64
|
+
repository: string;
|
|
65
|
+
rev: number;
|
|
66
|
+
file: string;
|
|
67
|
+
files: string[];
|
|
68
|
+
totalChars: number;
|
|
69
|
+
offset: number;
|
|
70
|
+
content: string;
|
|
71
|
+
nextOffset?: number;
|
|
72
|
+
}
|
|
73
|
+
/** Result of `artifact_delete`. */
|
|
74
|
+
export interface DeleteResult {
|
|
75
|
+
id: string;
|
|
76
|
+
url: string;
|
|
77
|
+
repository: string;
|
|
78
|
+
deleted: boolean;
|
|
79
|
+
commit: string;
|
|
80
|
+
notes: string[];
|
|
81
|
+
}
|
|
82
|
+
/** Result of `artifact_status`. */
|
|
83
|
+
export interface StatusResult {
|
|
84
|
+
ready: boolean;
|
|
85
|
+
strategy: RepoStrategy;
|
|
86
|
+
repository: string;
|
|
87
|
+
branch: string;
|
|
88
|
+
siteUrl?: string;
|
|
89
|
+
token: {
|
|
90
|
+
configured: boolean;
|
|
91
|
+
source?: string;
|
|
92
|
+
};
|
|
93
|
+
pages: string;
|
|
94
|
+
/** Head commit of the Pages branch. */
|
|
95
|
+
headCommit?: string;
|
|
96
|
+
latestBuild?: {
|
|
97
|
+
status: string;
|
|
98
|
+
commit?: string;
|
|
99
|
+
error?: string;
|
|
100
|
+
};
|
|
101
|
+
/** Whether the head commit has been built and deployed; absent when builds are not visible to the token. */
|
|
102
|
+
deployed?: boolean;
|
|
103
|
+
artifact?: {
|
|
104
|
+
id: string;
|
|
105
|
+
url: string;
|
|
106
|
+
live: boolean;
|
|
107
|
+
httpStatus?: number;
|
|
108
|
+
};
|
|
109
|
+
registryFile: string;
|
|
110
|
+
problems: string[];
|
|
111
|
+
}
|
|
112
|
+
/** Arguments of `artifact_repository`. */
|
|
113
|
+
export interface RepositoryArgs {
|
|
114
|
+
readonly action: 'show' | 'link' | 'unlink' | 'set_strategy';
|
|
115
|
+
readonly repository?: string | undefined;
|
|
116
|
+
readonly strategy?: RepoStrategy | undefined;
|
|
117
|
+
}
|
|
118
|
+
/** Result of `artifact_repository`. */
|
|
119
|
+
export interface RepositoryResult {
|
|
120
|
+
strategy: RepoStrategy;
|
|
121
|
+
strategySource: 'config' | 'user';
|
|
122
|
+
repository: string;
|
|
123
|
+
repositorySource: 'linked' | 'config' | 'token user';
|
|
124
|
+
branch: string;
|
|
125
|
+
newRepositories: string;
|
|
126
|
+
siteUrl?: string;
|
|
127
|
+
pages?: string;
|
|
128
|
+
registryFile: string;
|
|
129
|
+
indexFile: string;
|
|
130
|
+
warnings: string[];
|
|
131
|
+
}
|
|
132
|
+
/** Hooks replaceable in tests. */
|
|
133
|
+
export interface RuntimeHooks {
|
|
134
|
+
readonly fetch?: typeof fetch;
|
|
135
|
+
readonly now?: () => Date;
|
|
136
|
+
readonly randomSuffix?: () => string;
|
|
137
|
+
readonly sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
138
|
+
}
|
|
139
|
+
/** Topic set on repositories created per artifact, so they are easy to find on GitHub. */
|
|
140
|
+
export declare const ARTIFACT_TOPIC = "dsh-artifact";
|
|
141
|
+
/** Owns configuration-derived state shared by the tools. */
|
|
142
|
+
export declare class ArtifactsRuntime {
|
|
143
|
+
private readonly ctx;
|
|
144
|
+
private readonly hooks;
|
|
145
|
+
/** Local record of everything published, and the user's runtime choices. */
|
|
146
|
+
readonly registry: Registry;
|
|
147
|
+
private writeQueue;
|
|
148
|
+
private readonly logins;
|
|
149
|
+
private readonly sites;
|
|
150
|
+
private readonly readSettings;
|
|
151
|
+
/** Loader entry id of this plugin row, which names its settings namespace. */
|
|
152
|
+
private readonly namespace;
|
|
153
|
+
/**
|
|
154
|
+
* @param ctx - plugin context.
|
|
155
|
+
* @param settings - settings, or a reader that returns the current ones; options edited on the
|
|
156
|
+
* plugin's settings page change while the plugin runs, so they are read per operation.
|
|
157
|
+
* @param hooks - test hooks.
|
|
158
|
+
*/
|
|
159
|
+
constructor(ctx: Context, settings: Settings | (() => Settings), hooks?: RuntimeHooks, namespace?: string);
|
|
160
|
+
/** The current settings. */
|
|
161
|
+
get settings(): Settings;
|
|
162
|
+
private now;
|
|
163
|
+
private randomSuffix;
|
|
164
|
+
/**
|
|
165
|
+
* Resolve the GitHub token for one operation; never cached.
|
|
166
|
+
* @returns the token value, or undefined when not configured.
|
|
167
|
+
*/
|
|
168
|
+
resolveToken(): Promise<{
|
|
169
|
+
value: string;
|
|
170
|
+
source: string;
|
|
171
|
+
} | undefined>;
|
|
172
|
+
private missingTokenError;
|
|
173
|
+
private api;
|
|
174
|
+
private login;
|
|
175
|
+
/** The token's own account, refused when the token could come from an untrusted project .env. */
|
|
176
|
+
private tokenOwner;
|
|
177
|
+
/** @returns the effective strategy and whether the user changed it at runtime. */
|
|
178
|
+
private strategyOf;
|
|
179
|
+
/** The shared repository: a linked one, then the configured one, then `repo` under the token's user. */
|
|
180
|
+
private sharedRepository;
|
|
181
|
+
private sharedLocation;
|
|
182
|
+
private ownLocation;
|
|
183
|
+
private store;
|
|
184
|
+
/**
|
|
185
|
+
* Find where an existing artifact lives: the registry first, then the shared repository's
|
|
186
|
+
* manifest (for artifacts published from another machine).
|
|
187
|
+
*/
|
|
188
|
+
private locate;
|
|
189
|
+
/**
|
|
190
|
+
* Discover the public site URL and Pages state of one repository, cached for a few minutes.
|
|
191
|
+
*/
|
|
192
|
+
private siteInfo;
|
|
193
|
+
private artifactUrl;
|
|
194
|
+
/**
|
|
195
|
+
* Turn GitHub Pages on for a repository when it is off. Pushing a gh-pages branch usually does
|
|
196
|
+
* this by itself, so a brand-new repository first gets a few seconds to catch up; otherwise the
|
|
197
|
+
* token needs Pages and Administration write. Never throws: the page is already committed, so a
|
|
198
|
+
* problem here only becomes a warning for the user.
|
|
199
|
+
* @returns warnings for the user when Pages could not be enabled.
|
|
200
|
+
*/
|
|
201
|
+
private ensurePages;
|
|
202
|
+
/** Create the repository of a new per-artifact location. */
|
|
203
|
+
private createRepository;
|
|
204
|
+
/**
|
|
205
|
+
* Enforce the visibility policy at execution time too, so a missed or failed per-Agent
|
|
206
|
+
* restriction can never open a mutating tool to a subagent or a hidden preset.
|
|
207
|
+
*/
|
|
208
|
+
private assertVisible;
|
|
209
|
+
private serialized;
|
|
210
|
+
/** Record a published or updated artifact in the registry. */
|
|
211
|
+
private track;
|
|
212
|
+
/**
|
|
213
|
+
* Create a new artifact or update one in place.
|
|
214
|
+
* @param args - tool arguments.
|
|
215
|
+
* @param exec - tool execution.
|
|
216
|
+
*/
|
|
217
|
+
publish(args: PublishArgs, exec: ToolRunContext): Promise<PublishResult>;
|
|
218
|
+
private readSources;
|
|
219
|
+
/**
|
|
220
|
+
* List tracked artifacts, newest first. Artifacts found in the shared repository but missing
|
|
221
|
+
* from the local registry (published from another machine) are added to it.
|
|
222
|
+
* @param args - filter and paging.
|
|
223
|
+
* @param signal - cancellation.
|
|
224
|
+
*/
|
|
225
|
+
list(args: {
|
|
226
|
+
query?: string | undefined;
|
|
227
|
+
offset?: number | undefined;
|
|
228
|
+
limit?: number | undefined;
|
|
229
|
+
includeDeleted?: boolean | undefined;
|
|
230
|
+
}, signal: AbortSignal): Promise<ListResult>;
|
|
231
|
+
/**
|
|
232
|
+
* Find repositories created per artifact (tagged with the artifact topic) that the registry does
|
|
233
|
+
* not know yet, for example ones published from another machine, and track their artifacts.
|
|
234
|
+
*/
|
|
235
|
+
private discoverOwnRepositories;
|
|
236
|
+
/**
|
|
237
|
+
* Read an artifact's source or one of its text files.
|
|
238
|
+
* @param args - id, file, window.
|
|
239
|
+
* @param signal - cancellation.
|
|
240
|
+
*/
|
|
241
|
+
read(args: {
|
|
242
|
+
id: string;
|
|
243
|
+
file?: string | undefined;
|
|
244
|
+
offset?: number | undefined;
|
|
245
|
+
limit?: number | undefined;
|
|
246
|
+
}, signal: AbortSignal): Promise<ReadResult>;
|
|
247
|
+
/**
|
|
248
|
+
* Delete an artifact for the agent; its id is never reused. Asks for approval per configuration.
|
|
249
|
+
* @param args - id.
|
|
250
|
+
* @param exec - tool execution.
|
|
251
|
+
*/
|
|
252
|
+
remove(args: {
|
|
253
|
+
id: string;
|
|
254
|
+
}, exec: ToolRunContext): Promise<DeleteResult>;
|
|
255
|
+
/**
|
|
256
|
+
* Delete an artifact the user chose in the Artifacts panel. The click (after the panel's own
|
|
257
|
+
* confirmation) is the user's decision, so the agent approval prompt does not apply.
|
|
258
|
+
* @param id - artifact id.
|
|
259
|
+
* @param signal - cancellation.
|
|
260
|
+
*/
|
|
261
|
+
removeByUser(id: string, signal: AbortSignal): Promise<DeleteResult>;
|
|
262
|
+
private deleteArtifact;
|
|
263
|
+
/**
|
|
264
|
+
* Show or change where new artifacts go.
|
|
265
|
+
* @param args - action and its inputs.
|
|
266
|
+
* @param exec - tool execution.
|
|
267
|
+
*/
|
|
268
|
+
repository(args: RepositoryArgs, exec: ToolRunContext): Promise<RepositoryResult>;
|
|
269
|
+
/**
|
|
270
|
+
* Persist a choice made in chat. With the dsh settings service the plugin's own configuration is
|
|
271
|
+
* updated, so the Plugins page and the profile file show it; without it (or when a higher layer
|
|
272
|
+
* fixes the value) the choice is kept in the registry, which then overrides the configuration.
|
|
273
|
+
*/
|
|
274
|
+
private saveChoice;
|
|
275
|
+
private describeRepository;
|
|
276
|
+
/**
|
|
277
|
+
* Diagnose the setup and the deployment of the latest change.
|
|
278
|
+
* @param args - optional artifact id and whether to wait for deployment.
|
|
279
|
+
* @param signal - cancellation.
|
|
280
|
+
*/
|
|
281
|
+
status(args: {
|
|
282
|
+
id?: string | undefined;
|
|
283
|
+
wait?: boolean | undefined;
|
|
284
|
+
}, signal: AbortSignal): Promise<StatusResult>;
|
|
285
|
+
private probe;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* The default public URL of a project site, or of a user/organization site repository.
|
|
289
|
+
* @param owner - repository owner.
|
|
290
|
+
* @param repo - repository name.
|
|
291
|
+
*/
|
|
292
|
+
export declare function defaultSiteUrl(owner: string, repo: string): string;
|