@serviceme/devtools-core 0.1.8 → 0.2.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/dist/auth.d.mts +590 -0
- package/dist/auth.d.ts +590 -0
- package/dist/auth.js +842 -0
- package/dist/auth.js.map +1 -0
- package/dist/auth.mjs +804 -0
- package/dist/auth.mjs.map +1 -0
- package/dist/device.d.mts +456 -0
- package/dist/device.d.ts +456 -0
- package/dist/device.js +696 -0
- package/dist/device.js.map +1 -0
- package/dist/device.mjs +647 -0
- package/dist/device.mjs.map +1 -0
- package/dist/index-CrNC-aao.d.ts +277 -0
- package/dist/index-Dmyy4urr.d.mts +277 -0
- package/dist/index.d.mts +1372 -27
- package/dist/index.d.ts +1372 -27
- package/dist/index.js +5125 -888
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5022 -906
- package/dist/index.mjs.map +1 -0
- package/dist/skill-linker.d.mts +188 -0
- package/dist/skill-linker.d.ts +188 -0
- package/dist/skill-linker.js +374 -0
- package/dist/skill-linker.js.map +1 -0
- package/dist/skill-linker.mjs +330 -0
- package/dist/skill-linker.mjs.map +1 -0
- package/dist/skill-store.d.mts +35 -0
- package/dist/skill-store.d.ts +35 -0
- package/dist/skill-store.js +291 -0
- package/dist/skill-store.js.map +1 -0
- package/dist/skill-store.mjs +254 -0
- package/dist/skill-store.mjs.map +1 -0
- package/dist/submit.d.mts +3 -0
- package/dist/submit.d.ts +3 -0
- package/dist/submit.js +166 -0
- package/dist/submit.js.map +1 -0
- package/dist/submit.mjs +130 -0
- package/dist/submit.mjs.map +1 -0
- package/dist/toolbox.d.mts +240 -0
- package/dist/toolbox.d.ts +240 -0
- package/dist/toolbox.js +530 -0
- package/dist/toolbox.js.map +1 -0
- package/dist/toolbox.mjs +482 -0
- package/dist/toolbox.mjs.map +1 -0
- package/dist/types-B9gk3dXH.d.mts +62 -0
- package/dist/types-B9gk3dXH.d.ts +62 -0
- package/package.json +50 -5
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { SpawnOptions } from 'node:child_process';
|
|
2
|
+
import { b as SkillFile } from './types-B9gk3dXH.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Skill & Agent v2 — Client GitClient Types (M3)
|
|
6
|
+
*
|
|
7
|
+
* GitClient wraps the local `git` CLI so all commands the SERVICEME
|
|
8
|
+
* pipeline issues (clone, fetch, push, ls-remote) flow through the
|
|
9
|
+
* server's git smart-HTTP proxy instead of talking directly to GitHub.
|
|
10
|
+
*
|
|
11
|
+
* The single trick: `git` only cares about the URL we hand it as a
|
|
12
|
+
* remote. We rewrite `https://github.com/owner/repo.git` to
|
|
13
|
+
* `http://server:port/git-proxy/<id>` and `git` does the rest — the
|
|
14
|
+
* server transparently forwards + injects PATs as needed.
|
|
15
|
+
*
|
|
16
|
+
* @see docs/architecture/skill-agent-v2-repo.md §5.4 GitClient
|
|
17
|
+
*/
|
|
18
|
+
/** Result of a `git fetch` (called via the proxy's git-upload-pack). */
|
|
19
|
+
interface PullResult {
|
|
20
|
+
/** Whether new commits were fetched (false = already up-to-date). */
|
|
21
|
+
updated: boolean;
|
|
22
|
+
/** Commit SHA at FETCH_HEAD after the pull. */
|
|
23
|
+
commitSha: string;
|
|
24
|
+
/** Branch name that was pulled (e.g. "v2"). */
|
|
25
|
+
branch: string;
|
|
26
|
+
}
|
|
27
|
+
/** Result of a `git push` (called via the proxy's git-receive-pack). */
|
|
28
|
+
interface PushResult {
|
|
29
|
+
/** Remote ref updated (e.g. "refs/heads/v2"). */
|
|
30
|
+
ref: string;
|
|
31
|
+
/** New commit SHA on the remote. */
|
|
32
|
+
commitSha: string;
|
|
33
|
+
}
|
|
34
|
+
/** A branch as advertised by `git ls-remote`. */
|
|
35
|
+
interface RemoteBranch {
|
|
36
|
+
/** Full ref name, e.g. `refs/heads/main`. */
|
|
37
|
+
ref: string;
|
|
38
|
+
/** Commit SHA the ref points at. */
|
|
39
|
+
sha: string;
|
|
40
|
+
}
|
|
41
|
+
/** Outcome of any spawned `git` process. */
|
|
42
|
+
interface GitSpawnResult {
|
|
43
|
+
stdout: string;
|
|
44
|
+
stderr: string;
|
|
45
|
+
code: number;
|
|
46
|
+
}
|
|
47
|
+
/** Strategy for executing git commands. Tests inject a stub. */
|
|
48
|
+
interface GitSpawner {
|
|
49
|
+
spawn(args: string[], opts: SpawnOptions): Promise<GitSpawnResult>;
|
|
50
|
+
}
|
|
51
|
+
/** Options for instantiating GitClient. */
|
|
52
|
+
interface GitClientOptions {
|
|
53
|
+
/** Base URL of the server git proxy. e.g. `http://localhost:3000/git-proxy`. */
|
|
54
|
+
serverProxyBase: string;
|
|
55
|
+
/** Inject a custom spawner (default: spawn real `git` CLI). */
|
|
56
|
+
spawner?: GitSpawner;
|
|
57
|
+
/** Inject an env override for spawned git (default: process.env minus proxy secrets). */
|
|
58
|
+
env?: NodeJS.ProcessEnv;
|
|
59
|
+
}
|
|
60
|
+
/** Sentinel error when git exits non-zero. */
|
|
61
|
+
declare class GitError extends Error {
|
|
62
|
+
readonly args: string[];
|
|
63
|
+
readonly code: number;
|
|
64
|
+
readonly stderr: string;
|
|
65
|
+
readonly stdout: string;
|
|
66
|
+
constructor(args: string[], result: GitSpawnResult);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Skill & Agent v2 — Client GitClient (M3)
|
|
71
|
+
*
|
|
72
|
+
* Wraps `git` so all upstream traffic flows through the server's git
|
|
73
|
+
* proxy at `serverProxyBase`. See docs/architecture/skill-agent-v2-repo.md
|
|
74
|
+
* §5.4.
|
|
75
|
+
*
|
|
76
|
+
* Why a wrapper instead of using libgit2 directly:
|
|
77
|
+
* 1. `git` is already installed everywhere we run (extension host,
|
|
78
|
+
* CLI). No native deps.
|
|
79
|
+
* 2. Users can debug their skill repos with plain `git` commands when
|
|
80
|
+
* SERVICEME is misbehaving — the wrappers keep a familiar CLI.
|
|
81
|
+
* 3. libgit2's packfile negotiation has subtle correctness gaps that
|
|
82
|
+
* we don't want to debug server-side.
|
|
83
|
+
*
|
|
84
|
+
* URL rewrite:
|
|
85
|
+
* `https://github.com/owner/repo.git` → `<proxyBase>/<id>`
|
|
86
|
+
*
|
|
87
|
+
* When git hits `<proxyBase>/<id>` it discovers the proxy's
|
|
88
|
+
* `/info/refs?service=git-upload-pack` endpoint via the smart-HTTP
|
|
89
|
+
* protocol. From there the server takes over.
|
|
90
|
+
*/
|
|
91
|
+
declare class GitClient {
|
|
92
|
+
private readonly serverProxyBase;
|
|
93
|
+
private readonly spawner;
|
|
94
|
+
constructor(opts: GitClientOptions);
|
|
95
|
+
/**
|
|
96
|
+
* Rewrite an upstream URL to its proxy form.
|
|
97
|
+
*
|
|
98
|
+
* Examples:
|
|
99
|
+
* rewriteRemoteUrl("medalsoftchina-ms-skills",
|
|
100
|
+
* "https://github.com/medalsoftchina/ms-skills.git")
|
|
101
|
+
* → "http://localhost:3000/git-proxy/medalsoftchina-ms-skills"
|
|
102
|
+
*
|
|
103
|
+
* rewriteRemoteUrl("my-team-internal",
|
|
104
|
+
* "git@github.com:medalsoftchina/ms-skills.git")
|
|
105
|
+
* → "http://localhost:3000/git-proxy/my-team-internal"
|
|
106
|
+
*
|
|
107
|
+
* The original URL's host/owner is intentionally DROPPED — the proxy
|
|
108
|
+
* knows the upstream from the per-repo config, not from the URL. This
|
|
109
|
+
* means callers can't accidentally route a user-repo URL through the
|
|
110
|
+
* default-repo proxy slot.
|
|
111
|
+
*/
|
|
112
|
+
rewriteRemoteUrl(_repoId: string, _originalUrl: string): string;
|
|
113
|
+
/**
|
|
114
|
+
* `git clone <proxyUrl> <localPath>` — initialize a new local repo
|
|
115
|
+
* from the proxy. Returns when the clone succeeds; throws on failure.
|
|
116
|
+
*/
|
|
117
|
+
clone(repoId: string, originalUrl: string, localPath: string): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* `git fetch <remote> <branch>` + return the resulting commit SHA.
|
|
120
|
+
* Operates on an already-cloned repo at `localPath`.
|
|
121
|
+
*/
|
|
122
|
+
pull(repoId: string, localPath: string): Promise<PullResult>;
|
|
123
|
+
/**
|
|
124
|
+
* `git push origin <branch>` via the proxy. Caller is responsible
|
|
125
|
+
* for committing locally first. The server's GitProxy injects the
|
|
126
|
+
* PAT on the way upstream.
|
|
127
|
+
*/
|
|
128
|
+
push(repoId: string, localPath: string, branch: string): Promise<PushResult>;
|
|
129
|
+
/**
|
|
130
|
+
* `git ls-remote <proxyUrl>` — list advertised branches without
|
|
131
|
+
* cloning. Used by addUserRepo to detect the default branch.
|
|
132
|
+
*/
|
|
133
|
+
lsRemote(repoId: string, originalUrl: string): Promise<RemoteBranch[]>;
|
|
134
|
+
/**
|
|
135
|
+
* `git add <pathspec…>` followed by `git commit -m <message>`. The
|
|
136
|
+
* commit message convention follows the spec: `feat(skills): add
|
|
137
|
+
* <name>` / `feat(agents): add <name>`.
|
|
138
|
+
*/
|
|
139
|
+
commit(localPath: string, message: string, addPath?: string): Promise<{
|
|
140
|
+
commitSha: string;
|
|
141
|
+
}>;
|
|
142
|
+
private runOrThrow;
|
|
143
|
+
private getRemoteUrl;
|
|
144
|
+
private safeRevParse;
|
|
145
|
+
private currentBranch;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
declare class NodeGitSpawner implements GitSpawner {
|
|
149
|
+
spawn(args: string[], opts: {
|
|
150
|
+
cwd?: string;
|
|
151
|
+
}): Promise<GitSpawnResult>;
|
|
152
|
+
}
|
|
153
|
+
/** Convenience: a record-based stub spawner for tests. */
|
|
154
|
+
declare class StubGitSpawner implements GitSpawner {
|
|
155
|
+
/** queue of canned responses, consumed FIFO per spawn() call. */
|
|
156
|
+
readonly script: GitSpawnResult[];
|
|
157
|
+
/** All spawn() invocations, in order, for assertions. */
|
|
158
|
+
readonly calls: Array<{
|
|
159
|
+
args: string[];
|
|
160
|
+
cwd: string | undefined;
|
|
161
|
+
}>;
|
|
162
|
+
constructor(script: GitSpawnResult[]);
|
|
163
|
+
spawn(args: string[], opts: {
|
|
164
|
+
cwd?: string;
|
|
165
|
+
}): Promise<GitSpawnResult>;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Helper: encode a bare absolute file URL (`file:///...`) for local
|
|
169
|
+
* git clone tests. Not used by GitClient directly — exposed for
|
|
170
|
+
* RepoManager's `localSeed` use case.
|
|
171
|
+
*/
|
|
172
|
+
declare function toFileUrl(absolutePath: string): string;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Skill & Agent v2 — SubmitClient Types (M4)
|
|
176
|
+
*
|
|
177
|
+
* Mirrors the server's POST /api/v1/skills/validate contract (M2
|
|
178
|
+
* SubmitApi). Defined here as a separate types file so the test
|
|
179
|
+
* fixtures + the client can both import without circular deps.
|
|
180
|
+
*/
|
|
181
|
+
/** Reasons the server may deny a submission. */
|
|
182
|
+
type DenyReason = "repo_not_writable" | "file_too_large" | "path_traversal" | "invalid_frontmatter" | "name_conflict"
|
|
183
|
+
/** Local-client-side errors that don't come from the server. */
|
|
184
|
+
| "network_error" | "write_error" | "commit_error" | "push_error" | "unknown";
|
|
185
|
+
/** Request payload. Identical to the server's SubmitValidationRequest. */
|
|
186
|
+
interface SubmitValidationRequest {
|
|
187
|
+
repoId: string;
|
|
188
|
+
skillName: string;
|
|
189
|
+
files: Array<{
|
|
190
|
+
path: string;
|
|
191
|
+
content: string;
|
|
192
|
+
}>;
|
|
193
|
+
}
|
|
194
|
+
/** Response payload. Identical to the server's SubmitValidationResponse. */
|
|
195
|
+
interface SubmitValidationResponse {
|
|
196
|
+
allow: boolean;
|
|
197
|
+
reason?: DenyReason;
|
|
198
|
+
detail?: string;
|
|
199
|
+
}
|
|
200
|
+
/** Sentinel error thrown by SubmitClient.submit() / validate(). */
|
|
201
|
+
declare class SubmitError extends Error {
|
|
202
|
+
readonly reason: DenyReason;
|
|
203
|
+
readonly detail: string;
|
|
204
|
+
readonly status?: number;
|
|
205
|
+
constructor(reason: DenyReason, detail: string, options?: {
|
|
206
|
+
status?: number;
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Skill & Agent v2 — SubmitClient (M4)
|
|
212
|
+
*
|
|
213
|
+
* SubmitClient orchestrates the "validate then push" flow described
|
|
214
|
+
* in docs/architecture/skill-agent-v2-repo.md §5.7:
|
|
215
|
+
*
|
|
216
|
+
* 1. **validate** — POST the candidate files to the server's
|
|
217
|
+
* `/api/v1/skills/validate` endpoint (5 deny reasons: repo_not_
|
|
218
|
+
* writable, file_too_large, path_traversal, invalid_frontmatter,
|
|
219
|
+
* name_conflict).
|
|
220
|
+
* 2. **write** — materialize the files into the local repo clone at
|
|
221
|
+
* `~/.serviceme/repos/<repoId>/skills/<name>/` (or `agents/`).
|
|
222
|
+
* 3. **commit** — `git add . && git commit -m "feat(skills): add <name>"`.
|
|
223
|
+
* 4. **push** — `git push origin <branch>` via the server proxy.
|
|
224
|
+
*
|
|
225
|
+
* The client is intentionally thin: it does NOT do its own validation
|
|
226
|
+
* (the server is the gate), and it does NOT cache anything across
|
|
227
|
+
* calls. The single source of truth for "is this submission allowed?"
|
|
228
|
+
* is the server's validate endpoint.
|
|
229
|
+
*
|
|
230
|
+
* @see docs/architecture/skill-agent-v2-repo.md §5.7 SubmitClient
|
|
231
|
+
*/
|
|
232
|
+
interface SubmitOptions {
|
|
233
|
+
/** Override the server's validate URL. Defaults to `http://localhost:3000/api/v1`. */
|
|
234
|
+
serverBaseUrl?: string;
|
|
235
|
+
/** Override the branch to push. Defaults to the repo's `branch` field. */
|
|
236
|
+
branch?: string;
|
|
237
|
+
/** Skip the actual push (for tests + dry-runs). When true, step 4 returns a synthetic PushResult. */
|
|
238
|
+
skipPush?: boolean;
|
|
239
|
+
}
|
|
240
|
+
interface SubmitResult {
|
|
241
|
+
repoId: string;
|
|
242
|
+
skillName: string;
|
|
243
|
+
commitSha: string;
|
|
244
|
+
pushedRef?: string;
|
|
245
|
+
pushedSha?: string;
|
|
246
|
+
}
|
|
247
|
+
interface SubmitClientOptions {
|
|
248
|
+
gitClient: GitClient;
|
|
249
|
+
/** Lookup the default branch for a repo (config-driven). */
|
|
250
|
+
getRepoBranch?: (repoId: string) => string | undefined;
|
|
251
|
+
/** HTTP fetch impl (defaults to the global `fetch`). */
|
|
252
|
+
fetcher?: typeof fetch;
|
|
253
|
+
/** Default server base URL when no override is supplied. */
|
|
254
|
+
defaultServerBaseUrl?: string;
|
|
255
|
+
}
|
|
256
|
+
declare class SubmitClient {
|
|
257
|
+
private readonly git;
|
|
258
|
+
private readonly getRepoBranch;
|
|
259
|
+
private readonly fetcher;
|
|
260
|
+
private readonly defaultServerBaseUrl;
|
|
261
|
+
constructor(opts: SubmitClientOptions);
|
|
262
|
+
/**
|
|
263
|
+
* Validate-only path. Useful for the UI's "Save Draft" flow which
|
|
264
|
+
* wants to surface validation errors without committing or pushing.
|
|
265
|
+
*/
|
|
266
|
+
validate(req: SubmitValidationRequest): Promise<SubmitValidationResponse>;
|
|
267
|
+
/**
|
|
268
|
+
* Full submit pipeline. Throws `SubmitError` on:
|
|
269
|
+
* - validate deny (reason echoed)
|
|
270
|
+
* - network failure (network_error)
|
|
271
|
+
* - local write failure
|
|
272
|
+
* - commit/push failure
|
|
273
|
+
*/
|
|
274
|
+
submit(repoId: string, skillName: string, files: SkillFile[], opts?: SubmitOptions): Promise<SubmitResult>;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export { GitClient as G, NodeGitSpawner as N, type PullResult as P, StubGitSpawner as S, GitError as a, SubmitClient as b, type SubmitClientOptions as c, SubmitError as d, type SubmitOptions as e, type SubmitResult as f, toFileUrl as t };
|