@serviceme/devtools-core 2.0.0 → 2.0.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/dist/auth-Bzss8zOv.mjs +995 -0
- package/dist/auth-Bzss8zOv.mjs.map +1 -0
- package/dist/auth-DXam3c4S.js +1078 -0
- package/dist/auth-DXam3c4S.js.map +1 -0
- package/dist/auth.d.mts +2 -2
- package/dist/auth.d.ts +2 -2
- package/dist/auth.js +14 -1029
- package/dist/auth.mjs +2 -991
- package/dist/device-CDDcwDY6.mjs +758 -0
- package/dist/device-CDDcwDY6.mjs.map +1 -0
- package/dist/device-DuAYH8bk.js +839 -0
- package/dist/device-DuAYH8bk.js.map +1 -0
- package/dist/device.d.mts +2 -455
- package/dist/device.d.ts +2 -455
- package/dist/device.js +15 -728
- package/dist/device.mjs +2 -679
- package/dist/index-2rX86yMq.d.mts +331 -0
- package/dist/index-BI11AfMH.d.mts +377 -0
- package/dist/index-BI11AfMH.d.ts +377 -0
- package/dist/index-CoA6y0MP.d.mts +498 -0
- package/dist/index-CoA6y0MP.d.ts +498 -0
- package/dist/index-DaW7IYA-.d.mts +185 -0
- package/dist/index-DaW7IYA-.d.ts +185 -0
- package/dist/index-Dp6FwWKh.d.ts +331 -0
- package/dist/index.d.mts +2340 -2101
- package/dist/index.d.ts +2340 -2101
- package/dist/index.js +8117 -10538
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7895 -10318
- package/dist/index.mjs.map +1 -1
- package/dist/rolldown-runtime-VH7oDXx4.js +28 -0
- package/dist/skill-linker.d.mts +82 -81
- package/dist/skill-linker.d.ts +82 -81
- package/dist/skill-linker.js +359 -402
- package/dist/skill-linker.js.map +1 -1
- package/dist/skill-linker.mjs +345 -357
- package/dist/skill-linker.mjs.map +1 -1
- package/dist/skill-store-Bym2yinU.mjs +388 -0
- package/dist/skill-store-Bym2yinU.mjs.map +1 -0
- package/dist/skill-store-CJdYyyxu.js +408 -0
- package/dist/skill-store-CJdYyyxu.js.map +1 -0
- package/dist/skill-store.d.mts +41 -42
- package/dist/skill-store.d.ts +41 -42
- package/dist/skill-store.js +5 -338
- package/dist/skill-store.mjs +2 -301
- package/dist/submit-Cg7wSa3x.mjs +84 -0
- package/dist/submit-Cg7wSa3x.mjs.map +1 -0
- package/dist/submit-CltE6YOZ.js +98 -0
- package/dist/submit-CltE6YOZ.js.map +1 -0
- package/dist/submit.d.mts +2 -3
- package/dist/submit.d.ts +2 -3
- package/dist/submit.js +4 -166
- package/dist/submit.mjs +2 -130
- package/dist/toolbox-CbfxpNg-.mjs +540 -0
- package/dist/toolbox-CbfxpNg-.mjs.map +1 -0
- package/dist/toolbox-CxnOr-FY.js +614 -0
- package/dist/toolbox-CxnOr-FY.js.map +1 -0
- package/dist/toolbox.d.mts +2 -244
- package/dist/toolbox.d.ts +2 -244
- package/dist/toolbox.js +14 -584
- package/dist/toolbox.mjs +2 -536
- package/dist/{types-B9gk3dXH.d.ts → types-BCV3IedE.d.mts} +25 -23
- package/dist/{types-B9gk3dXH.d.mts → types-BCV3IedE.d.ts} +25 -23
- package/dist/userHome-BquDeFVE.js +526 -0
- package/dist/userHome-BquDeFVE.js.map +1 -0
- package/dist/userHome-CcnAQPG1.mjs +212 -0
- package/dist/userHome-CcnAQPG1.mjs.map +1 -0
- package/package.json +10 -10
- package/dist/auth.js.map +0 -1
- package/dist/auth.mjs.map +0 -1
- package/dist/device.js.map +0 -1
- package/dist/device.mjs.map +0 -1
- package/dist/index-BMk4tqIT.d.mts +0 -328
- package/dist/index-CymN0x9Z.d.ts +0 -328
- package/dist/index-PD135hlB.d.mts +0 -626
- package/dist/index-PD135hlB.d.ts +0 -626
- package/dist/skill-store.js.map +0 -1
- package/dist/skill-store.mjs.map +0 -1
- package/dist/submit.js.map +0 -1
- package/dist/submit.mjs.map +0 -1
- package/dist/toolbox.js.map +0 -1
- package/dist/toolbox.mjs.map +0 -1
package/dist/submit.js
CHANGED
|
@@ -1,166 +1,4 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/submit/index.ts
|
|
31
|
-
var submit_exports = {};
|
|
32
|
-
__export(submit_exports, {
|
|
33
|
-
SubmitClient: () => SubmitClient,
|
|
34
|
-
SubmitError: () => SubmitError
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(submit_exports);
|
|
37
|
-
var fs = __toESM(require("fs/promises"));
|
|
38
|
-
var path2 = __toESM(require("path"));
|
|
39
|
-
|
|
40
|
-
// src/paths/userHome.ts
|
|
41
|
-
var os = __toESM(require("os"));
|
|
42
|
-
var path = __toESM(require("path"));
|
|
43
|
-
var SERVICEME_DIR_NAME = ".serviceme";
|
|
44
|
-
var REPOS_SUBDIR = "repos";
|
|
45
|
-
var SAFE_REPO_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/;
|
|
46
|
-
var SERVICEME_HOME_ENV = "SERVICEME_HOME";
|
|
47
|
-
var activeOverrides = {};
|
|
48
|
-
function resolveHomeDir() {
|
|
49
|
-
const injected = activeOverrides.homeDir;
|
|
50
|
-
if (injected !== void 0) {
|
|
51
|
-
return injected;
|
|
52
|
-
}
|
|
53
|
-
return os.homedir();
|
|
54
|
-
}
|
|
55
|
-
function resolveServicemeHomeEnv() {
|
|
56
|
-
const injected = activeOverrides.servicemeHomeEnv;
|
|
57
|
-
if (injected !== void 0) {
|
|
58
|
-
return injected.length > 0 ? injected : void 0;
|
|
59
|
-
}
|
|
60
|
-
const envValue = process.env[SERVICEME_HOME_ENV];
|
|
61
|
-
return envValue && envValue.length > 0 ? envValue : void 0;
|
|
62
|
-
}
|
|
63
|
-
function assertSafeRepoId(repoId) {
|
|
64
|
-
if (typeof repoId !== "string" || repoId.length === 0 || !SAFE_REPO_ID_PATTERN.test(repoId)) {
|
|
65
|
-
throw new Error(
|
|
66
|
-
`Invalid repo id: ${JSON.stringify(repoId)}. Must match ${SAFE_REPO_ID_PATTERN} (alphanumeric start, then alphanumerics / underscores / hyphens, \u2264 64 chars).`
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
return repoId;
|
|
70
|
-
}
|
|
71
|
-
function getServicemeHome() {
|
|
72
|
-
const override = resolveServicemeHomeEnv();
|
|
73
|
-
if (override !== void 0) {
|
|
74
|
-
return path.resolve(override);
|
|
75
|
-
}
|
|
76
|
-
return path.join(resolveHomeDir(), SERVICEME_DIR_NAME);
|
|
77
|
-
}
|
|
78
|
-
function getReposDir() {
|
|
79
|
-
return path.join(getServicemeHome(), REPOS_SUBDIR);
|
|
80
|
-
}
|
|
81
|
-
function getRepoDir(repoId) {
|
|
82
|
-
return path.join(getReposDir(), assertSafeRepoId(repoId));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// src/submit/types.ts
|
|
86
|
-
var SubmitError = class extends Error {
|
|
87
|
-
constructor(reason, detail, options) {
|
|
88
|
-
super(`submit failed (${reason}): ${detail}`);
|
|
89
|
-
this.name = "SubmitError";
|
|
90
|
-
this.reason = reason;
|
|
91
|
-
this.detail = detail;
|
|
92
|
-
this.status = options?.status;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
// src/submit/index.ts
|
|
97
|
-
var SubmitClient = class {
|
|
98
|
-
constructor(opts) {
|
|
99
|
-
this.git = opts.gitClient;
|
|
100
|
-
this.getRepoBranch = opts.getRepoBranch ?? (() => void 0);
|
|
101
|
-
this.fetcher = opts.fetcher ?? globalThis.fetch;
|
|
102
|
-
this.defaultServerBaseUrl = opts.defaultServerBaseUrl ?? "http://localhost:3000";
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Validate-only path. Useful for the UI's "Save Draft" flow which
|
|
106
|
-
* wants to surface validation errors without committing or pushing.
|
|
107
|
-
*/
|
|
108
|
-
async validate(req) {
|
|
109
|
-
const url = `${this.defaultServerBaseUrl}/api/v1/skills/validate`;
|
|
110
|
-
const res = await this.fetcher(url, {
|
|
111
|
-
method: "POST",
|
|
112
|
-
headers: { "content-type": "application/json" },
|
|
113
|
-
body: JSON.stringify(req)
|
|
114
|
-
});
|
|
115
|
-
if (!res.ok) {
|
|
116
|
-
throw new SubmitError("network_error", `validate request failed: HTTP ${res.status}`);
|
|
117
|
-
}
|
|
118
|
-
return await res.json();
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Full submit pipeline. Throws `SubmitError` on:
|
|
122
|
-
* - validate deny (reason echoed)
|
|
123
|
-
* - network failure (network_error)
|
|
124
|
-
* - local write failure
|
|
125
|
-
* - commit/push failure
|
|
126
|
-
*/
|
|
127
|
-
async submit(repoId, skillName, files, opts = {}) {
|
|
128
|
-
const v = await this.validate({ repoId, skillName, files });
|
|
129
|
-
if (!v.allow) {
|
|
130
|
-
throw new SubmitError(v.reason ?? "unknown", v.detail ?? "validation denied");
|
|
131
|
-
}
|
|
132
|
-
const localRepoPath = getRepoDir(repoId);
|
|
133
|
-
const targetDir = path2.join(localRepoPath, "skills", skillName);
|
|
134
|
-
await fs.mkdir(targetDir, { recursive: true });
|
|
135
|
-
for (const f of files) {
|
|
136
|
-
const full = path2.join(targetDir, f.path);
|
|
137
|
-
await fs.mkdir(path2.dirname(full), { recursive: true });
|
|
138
|
-
const tmp = `${full}.${process.pid}.${Date.now()}.tmp`;
|
|
139
|
-
await fs.writeFile(tmp, f.content, "utf8");
|
|
140
|
-
await fs.rename(tmp, full);
|
|
141
|
-
}
|
|
142
|
-
const commitMessage = `feat(skills): add ${skillName}`;
|
|
143
|
-
const { commitSha } = await this.git.commit(localRepoPath, commitMessage);
|
|
144
|
-
let pushedRef;
|
|
145
|
-
let pushedSha;
|
|
146
|
-
if (!opts.skipPush) {
|
|
147
|
-
const branch = opts.branch ?? this.getRepoBranch(repoId) ?? "main";
|
|
148
|
-
const pushResult = await this.git.push(repoId, localRepoPath, branch);
|
|
149
|
-
pushedRef = pushResult.ref;
|
|
150
|
-
pushedSha = pushResult.commitSha;
|
|
151
|
-
}
|
|
152
|
-
return {
|
|
153
|
-
repoId,
|
|
154
|
-
skillName,
|
|
155
|
-
commitSha,
|
|
156
|
-
pushedRef,
|
|
157
|
-
pushedSha
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
162
|
-
0 && (module.exports = {
|
|
163
|
-
SubmitClient,
|
|
164
|
-
SubmitError
|
|
165
|
-
});
|
|
166
|
-
//# sourceMappingURL=submit.js.map
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_submit = require("./submit-CltE6YOZ.js");
|
|
3
|
+
exports.SubmitClient = require_submit.SubmitClient;
|
|
4
|
+
exports.SubmitError = require_submit.SubmitError;
|
package/dist/submit.mjs
CHANGED
|
@@ -1,130 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import * as path2 from "path";
|
|
4
|
-
|
|
5
|
-
// src/paths/userHome.ts
|
|
6
|
-
import * as os from "os";
|
|
7
|
-
import * as path from "path";
|
|
8
|
-
var SERVICEME_DIR_NAME = ".serviceme";
|
|
9
|
-
var REPOS_SUBDIR = "repos";
|
|
10
|
-
var SAFE_REPO_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/;
|
|
11
|
-
var SERVICEME_HOME_ENV = "SERVICEME_HOME";
|
|
12
|
-
var activeOverrides = {};
|
|
13
|
-
function resolveHomeDir() {
|
|
14
|
-
const injected = activeOverrides.homeDir;
|
|
15
|
-
if (injected !== void 0) {
|
|
16
|
-
return injected;
|
|
17
|
-
}
|
|
18
|
-
return os.homedir();
|
|
19
|
-
}
|
|
20
|
-
function resolveServicemeHomeEnv() {
|
|
21
|
-
const injected = activeOverrides.servicemeHomeEnv;
|
|
22
|
-
if (injected !== void 0) {
|
|
23
|
-
return injected.length > 0 ? injected : void 0;
|
|
24
|
-
}
|
|
25
|
-
const envValue = process.env[SERVICEME_HOME_ENV];
|
|
26
|
-
return envValue && envValue.length > 0 ? envValue : void 0;
|
|
27
|
-
}
|
|
28
|
-
function assertSafeRepoId(repoId) {
|
|
29
|
-
if (typeof repoId !== "string" || repoId.length === 0 || !SAFE_REPO_ID_PATTERN.test(repoId)) {
|
|
30
|
-
throw new Error(
|
|
31
|
-
`Invalid repo id: ${JSON.stringify(repoId)}. Must match ${SAFE_REPO_ID_PATTERN} (alphanumeric start, then alphanumerics / underscores / hyphens, \u2264 64 chars).`
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
return repoId;
|
|
35
|
-
}
|
|
36
|
-
function getServicemeHome() {
|
|
37
|
-
const override = resolveServicemeHomeEnv();
|
|
38
|
-
if (override !== void 0) {
|
|
39
|
-
return path.resolve(override);
|
|
40
|
-
}
|
|
41
|
-
return path.join(resolveHomeDir(), SERVICEME_DIR_NAME);
|
|
42
|
-
}
|
|
43
|
-
function getReposDir() {
|
|
44
|
-
return path.join(getServicemeHome(), REPOS_SUBDIR);
|
|
45
|
-
}
|
|
46
|
-
function getRepoDir(repoId) {
|
|
47
|
-
return path.join(getReposDir(), assertSafeRepoId(repoId));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// src/submit/types.ts
|
|
51
|
-
var SubmitError = class extends Error {
|
|
52
|
-
constructor(reason, detail, options) {
|
|
53
|
-
super(`submit failed (${reason}): ${detail}`);
|
|
54
|
-
this.name = "SubmitError";
|
|
55
|
-
this.reason = reason;
|
|
56
|
-
this.detail = detail;
|
|
57
|
-
this.status = options?.status;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// src/submit/index.ts
|
|
62
|
-
var SubmitClient = class {
|
|
63
|
-
constructor(opts) {
|
|
64
|
-
this.git = opts.gitClient;
|
|
65
|
-
this.getRepoBranch = opts.getRepoBranch ?? (() => void 0);
|
|
66
|
-
this.fetcher = opts.fetcher ?? globalThis.fetch;
|
|
67
|
-
this.defaultServerBaseUrl = opts.defaultServerBaseUrl ?? "http://localhost:3000";
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Validate-only path. Useful for the UI's "Save Draft" flow which
|
|
71
|
-
* wants to surface validation errors without committing or pushing.
|
|
72
|
-
*/
|
|
73
|
-
async validate(req) {
|
|
74
|
-
const url = `${this.defaultServerBaseUrl}/api/v1/skills/validate`;
|
|
75
|
-
const res = await this.fetcher(url, {
|
|
76
|
-
method: "POST",
|
|
77
|
-
headers: { "content-type": "application/json" },
|
|
78
|
-
body: JSON.stringify(req)
|
|
79
|
-
});
|
|
80
|
-
if (!res.ok) {
|
|
81
|
-
throw new SubmitError("network_error", `validate request failed: HTTP ${res.status}`);
|
|
82
|
-
}
|
|
83
|
-
return await res.json();
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Full submit pipeline. Throws `SubmitError` on:
|
|
87
|
-
* - validate deny (reason echoed)
|
|
88
|
-
* - network failure (network_error)
|
|
89
|
-
* - local write failure
|
|
90
|
-
* - commit/push failure
|
|
91
|
-
*/
|
|
92
|
-
async submit(repoId, skillName, files, opts = {}) {
|
|
93
|
-
const v = await this.validate({ repoId, skillName, files });
|
|
94
|
-
if (!v.allow) {
|
|
95
|
-
throw new SubmitError(v.reason ?? "unknown", v.detail ?? "validation denied");
|
|
96
|
-
}
|
|
97
|
-
const localRepoPath = getRepoDir(repoId);
|
|
98
|
-
const targetDir = path2.join(localRepoPath, "skills", skillName);
|
|
99
|
-
await fs.mkdir(targetDir, { recursive: true });
|
|
100
|
-
for (const f of files) {
|
|
101
|
-
const full = path2.join(targetDir, f.path);
|
|
102
|
-
await fs.mkdir(path2.dirname(full), { recursive: true });
|
|
103
|
-
const tmp = `${full}.${process.pid}.${Date.now()}.tmp`;
|
|
104
|
-
await fs.writeFile(tmp, f.content, "utf8");
|
|
105
|
-
await fs.rename(tmp, full);
|
|
106
|
-
}
|
|
107
|
-
const commitMessage = `feat(skills): add ${skillName}`;
|
|
108
|
-
const { commitSha } = await this.git.commit(localRepoPath, commitMessage);
|
|
109
|
-
let pushedRef;
|
|
110
|
-
let pushedSha;
|
|
111
|
-
if (!opts.skipPush) {
|
|
112
|
-
const branch = opts.branch ?? this.getRepoBranch(repoId) ?? "main";
|
|
113
|
-
const pushResult = await this.git.push(repoId, localRepoPath, branch);
|
|
114
|
-
pushedRef = pushResult.ref;
|
|
115
|
-
pushedSha = pushResult.commitSha;
|
|
116
|
-
}
|
|
117
|
-
return {
|
|
118
|
-
repoId,
|
|
119
|
-
skillName,
|
|
120
|
-
commitSha,
|
|
121
|
-
pushedRef,
|
|
122
|
-
pushedSha
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
export {
|
|
127
|
-
SubmitClient,
|
|
128
|
-
SubmitError
|
|
129
|
-
};
|
|
130
|
-
//# sourceMappingURL=submit.mjs.map
|
|
1
|
+
import { n as SubmitError, t as SubmitClient } from "./submit-Cg7wSa3x.mjs";
|
|
2
|
+
export { SubmitClient, SubmitError };
|