skills-layer 0.1.6 → 0.1.8

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.
@@ -1,7 +1,7 @@
1
1
  import { execFile } from "node:child_process";
2
2
  import test from "node:test";
3
3
  import assert from "node:assert/strict";
4
- import { mkdtemp, readFile } from "node:fs/promises";
4
+ import { mkdtemp, readFile, writeFile } from "node:fs/promises";
5
5
  import { tmpdir } from "node:os";
6
6
  import { join } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
@@ -72,6 +72,13 @@ function parseJsonError(result) {
72
72
  return JSON.parse(result.stderr);
73
73
  }
74
74
 
75
+ function jsonResponse(body, status = 200) {
76
+ return new Response(JSON.stringify(body), {
77
+ status,
78
+ headers: { "content-type": "application/json" }
79
+ });
80
+ }
81
+
75
82
  test("public package metadata keeps the npm tree narrow and non-lifecycle", async () => {
76
83
  const packageJson = JSON.parse(await readFile(packageUrl, "utf8"));
77
84
  assert.equal(packageJson.name, "skills-layer");
@@ -87,6 +94,11 @@ test("public package metadata keeps the npm tree narrow and non-lifecycle", asyn
87
94
  });
88
95
  assert.deepEqual(packageJson.bugs, { url: "https://github.com/ankurdhoom/skills-layer/issues" });
89
96
  assert.deepEqual(packageJson.files, [
97
+ "CODE_OF_CONDUCT.md",
98
+ "CONTRIBUTING.md",
99
+ "SECURITY.md",
100
+ ".github/dependabot.yml",
101
+ ".github/workflows/*.yml",
90
102
  "bin/skills-layer.js",
91
103
  "public/skills-layer-public.mjs",
92
104
  "scripts/skills-layer.mjs",
@@ -198,6 +210,89 @@ test("public runtime persists backend preference without network access", async
198
210
  assert.equal(statusPayload.data.loggedIn, false);
199
211
  });
200
212
 
213
+ test("public runtime posts buyer eval summary envelopes with reviews", async () => {
214
+ const home = await makeHome();
215
+ const cwd = await mkdtemp(join(tmpdir(), "skills-layer-cli-package-work-"));
216
+ const summaryPath = join(cwd, "buyer-eval-summary.json");
217
+ const artifactDigest = `sha256:${"a".repeat(64)}`;
218
+ await writeFile(summaryPath, JSON.stringify({
219
+ schemaVersion: "skills-layer.eval.summary.v1",
220
+ status: "passed",
221
+ skillSlug: "project-planner",
222
+ version: "1.0.0",
223
+ artifactDigest,
224
+ evalPackDigest: `sha256:${"b".repeat(64)}`,
225
+ generatedAt: "2026-07-03T00:00:00.000Z",
226
+ counts: {
227
+ cases: 1,
228
+ assertions: 2,
229
+ passed: 2,
230
+ failed: 0,
231
+ skipped: 0
232
+ },
233
+ redaction: {
234
+ mode: "content_free",
235
+ rawContentIncluded: false
236
+ }
237
+ }), "utf8");
238
+
239
+ const fetch = async (input, init = {}) => {
240
+ const url = String(input);
241
+ if (url === "https://api.skills-layer.local/api/v1/me") {
242
+ assert.equal(init.headers.authorization, "Bearer package-test-key");
243
+ return jsonResponse({
244
+ userId: "user_package",
245
+ email: "package@example.com",
246
+ role: "buyer",
247
+ roles: ["buyer"]
248
+ });
249
+ }
250
+ if (url === "https://api.skills-layer.local/api/v1/capabilities") {
251
+ assert.equal(init.headers.authorization, "Bearer package-test-key");
252
+ return jsonResponse({ edition: "saas", capabilities: ["marketplace"] });
253
+ }
254
+ if (url === "https://api.skills-layer.local/api/v1/me/library/project-planner/review") {
255
+ assert.equal(init.method, "POST");
256
+ assert.equal(init.headers.authorization, "Bearer package-test-key");
257
+ const body = JSON.parse(String(init.body));
258
+ assert.deepEqual(body, {
259
+ rating: 5,
260
+ feedback: "Useful",
261
+ evalSummary: {
262
+ schemaVersion: "skills-layer.eval.summary.v1",
263
+ status: "passed",
264
+ skillSlug: "project-planner",
265
+ version: "1.0.0",
266
+ artifactDigest,
267
+ evalPackDigest: `sha256:${"b".repeat(64)}`,
268
+ generatedAt: "2026-07-03T00:00:00.000Z",
269
+ counts: {
270
+ cases: 1,
271
+ assertions: 2,
272
+ passed: 2,
273
+ failed: 0,
274
+ skipped: 0
275
+ },
276
+ redaction: {
277
+ mode: "content_free",
278
+ rawContentIncluded: false
279
+ }
280
+ }
281
+ });
282
+ return jsonResponse({ status: "reviewed", reviewId: "review_package", buyerEval: { status: "recorded" } });
283
+ }
284
+ throw new Error(`Unexpected package contract request: ${url}`);
285
+ };
286
+
287
+ const login = await runPublic(["login", "--api-key", "package-test-key", "--base-url", "https://api.skills-layer.local", "--no-mcp", "--json"], { home, cwd, fetch });
288
+ assert.equal(login.exitCode, 0);
289
+ assert.equal(parseJsonOutput(login).data.email, "package@example.com");
290
+
291
+ const review = await runPublic(["add-review", "project-planner", "--rating", "5", "--feedback", "Useful", "--eval-summary", summaryPath, "--json"], { home, cwd, fetch });
292
+ assert.equal(review.exitCode, 0);
293
+ assert.equal(parseJsonOutput(review).data.buyerEval.status, "recorded");
294
+ });
295
+
201
296
  test("public runtime fails closed for internal and login-required commands", async () => {
202
297
  const admin = await runPublic(["admin", "status", "--json"]);
203
298
  assert.equal(admin.exitCode, 1);