@enactprotocol/shared 2.2.2 → 2.3.1
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 +1 -18
- package/dist/config.d.ts +12 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +32 -6
- package/dist/config.js.map +1 -1
- package/dist/execution/action-command.d.ts +131 -0
- package/dist/execution/action-command.d.ts.map +1 -0
- package/dist/execution/action-command.js +300 -0
- package/dist/execution/action-command.js.map +1 -0
- package/dist/execution/command.d.ts +8 -8
- package/dist/execution/command.js +6 -6
- package/dist/execution/index.d.ts +1 -0
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +2 -0
- package/dist/execution/index.js.map +1 -1
- package/dist/execution/types.d.ts +5 -2
- package/dist/execution/types.d.ts.map +1 -1
- package/dist/execution/types.js.map +1 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/dist/manifest/actions-loader.d.ts +29 -0
- package/dist/manifest/actions-loader.d.ts.map +1 -0
- package/dist/manifest/actions-loader.js +34 -0
- package/dist/manifest/actions-loader.js.map +1 -0
- package/dist/manifest/actions-parser.d.ts +69 -0
- package/dist/manifest/actions-parser.d.ts.map +1 -0
- package/dist/manifest/actions-parser.js +265 -0
- package/dist/manifest/actions-parser.js.map +1 -0
- package/dist/manifest/index.d.ts +2 -0
- package/dist/manifest/index.d.ts.map +1 -1
- package/dist/manifest/index.js +4 -0
- package/dist/manifest/index.js.map +1 -1
- package/dist/manifest/loader.d.ts +7 -2
- package/dist/manifest/loader.d.ts.map +1 -1
- package/dist/manifest/loader.js +71 -4
- package/dist/manifest/loader.js.map +1 -1
- package/dist/manifest/parser.d.ts +1 -0
- package/dist/manifest/parser.d.ts.map +1 -1
- package/dist/manifest/parser.js +1 -0
- package/dist/manifest/parser.js.map +1 -1
- package/dist/manifest/scripts.d.ts +19 -0
- package/dist/manifest/scripts.d.ts.map +1 -0
- package/dist/manifest/scripts.js +102 -0
- package/dist/manifest/scripts.js.map +1 -0
- package/dist/manifest/validator.d.ts +1 -8
- package/dist/manifest/validator.d.ts.map +1 -1
- package/dist/manifest/validator.js +14 -13
- package/dist/manifest/validator.js.map +1 -1
- package/dist/mcp-registry.js +5 -5
- package/dist/mcp-registry.js.map +1 -1
- package/dist/paths.d.ts +9 -2
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +12 -3
- package/dist/paths.js.map +1 -1
- package/dist/registry.d.ts +47 -2
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +100 -7
- package/dist/registry.js.map +1 -1
- package/dist/resolver.d.ts +55 -4
- package/dist/resolver.d.ts.map +1 -1
- package/dist/resolver.js +144 -77
- package/dist/resolver.js.map +1 -1
- package/dist/types/actions.d.ts +194 -0
- package/dist/types/actions.d.ts.map +1 -0
- package/dist/types/actions.js +32 -0
- package/dist/types/actions.js.map +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/manifest.d.ts +50 -5
- package/dist/types/manifest.d.ts.map +1 -1
- package/dist/types/manifest.js +10 -2
- package/dist/types/manifest.js.map +1 -1
- package/package.json +2 -2
- package/src/config.ts +48 -6
- package/src/execution/action-command.ts +417 -0
- package/src/execution/command.ts +8 -8
- package/src/execution/index.ts +17 -0
- package/src/execution/types.ts +13 -2
- package/src/index.ts +43 -0
- package/src/manifest/actions-loader.ts +49 -0
- package/src/manifest/index.ts +12 -0
- package/src/manifest/loader.ts +77 -4
- package/src/manifest/parser.ts +1 -0
- package/src/manifest/scripts.ts +116 -0
- package/src/manifest/validator.ts +15 -14
- package/src/mcp-registry.ts +5 -5
- package/src/paths.ts +13 -3
- package/src/registry.ts +136 -7
- package/src/resolver.ts +185 -79
- package/src/types/actions.ts +223 -0
- package/src/types/index.ts +11 -0
- package/src/types/manifest.ts +67 -6
- package/tests/action-command.test.ts +249 -0
- package/tests/config-normalization.test.ts +279 -0
- package/tests/config.test.ts +4 -1
- package/tests/effective-input-schema.test.ts +86 -0
- package/tests/fixtures/valid-tool.md +5 -12
- package/tests/fixtures/valid-tool.yaml +3 -10
- package/tests/hooks.test.ts +177 -0
- package/tests/manifest/loader.test.ts +34 -20
- package/tests/manifest/parser.test.ts +11 -15
- package/tests/manifest/validator.test.ts +7 -17
- package/tests/manifest-types.test.ts +9 -11
- package/tests/paths.test.ts +11 -4
- package/tests/registry.test.ts +204 -8
- package/tests/resolver.test.ts +90 -6
- package/tsconfig.tsbuildinfo +1 -1
package/tests/resolver.test.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
|
2
2
|
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
+
import { addAlias, addToolToRegistry, removeAlias } from "../src/registry";
|
|
4
5
|
import {
|
|
5
6
|
ToolResolveError,
|
|
6
7
|
getToolPath,
|
|
@@ -24,7 +25,7 @@ describe("tool resolver", () => {
|
|
|
24
25
|
|
|
25
26
|
// Create a project-level tool
|
|
26
27
|
writeFileSync(
|
|
27
|
-
join(PROJECT_ENACT_DIR, "tools", "test", "project-tool", "
|
|
28
|
+
join(PROJECT_ENACT_DIR, "tools", "test", "project-tool", "skill.yaml"),
|
|
28
29
|
`
|
|
29
30
|
name: test/project-tool
|
|
30
31
|
description: A project-level test tool
|
|
@@ -36,7 +37,7 @@ version: "1.0.0"
|
|
|
36
37
|
// Create a direct tool directory for path-based resolution
|
|
37
38
|
mkdirSync(join(TEST_DIR, "direct-tool"), { recursive: true });
|
|
38
39
|
writeFileSync(
|
|
39
|
-
join(TEST_DIR, "direct-tool", "
|
|
40
|
+
join(TEST_DIR, "direct-tool", "skill.yaml"),
|
|
40
41
|
`
|
|
41
42
|
name: test/direct-tool
|
|
42
43
|
description: A directly referenced tool
|
|
@@ -73,11 +74,11 @@ Documentation here.
|
|
|
73
74
|
describe("utility functions", () => {
|
|
74
75
|
describe("normalizeToolName", () => {
|
|
75
76
|
test("lowercases name", () => {
|
|
76
|
-
expect(normalizeToolName("Acme/
|
|
77
|
+
expect(normalizeToolName("Acme/Greeter")).toBe("acme/greeter");
|
|
77
78
|
});
|
|
78
79
|
|
|
79
80
|
test("converts backslashes to forward slashes", () => {
|
|
80
|
-
expect(normalizeToolName("acme\\
|
|
81
|
+
expect(normalizeToolName("acme\\greeter")).toBe("acme/greeter");
|
|
81
82
|
});
|
|
82
83
|
|
|
83
84
|
test("trims whitespace", () => {
|
|
@@ -87,7 +88,11 @@ Documentation here.
|
|
|
87
88
|
|
|
88
89
|
describe("toolNameToPath", () => {
|
|
89
90
|
test("returns path-like string", () => {
|
|
90
|
-
expect(toolNameToPath("acme/
|
|
91
|
+
expect(toolNameToPath("acme/greeter")).toBe("acme/greeter");
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test("strips @ prefix for disk paths", () => {
|
|
95
|
+
expect(toolNameToPath("@acme/greeter")).toBe("acme/greeter");
|
|
91
96
|
});
|
|
92
97
|
|
|
93
98
|
test("normalizes backslashes", () => {
|
|
@@ -141,7 +146,7 @@ Documentation here.
|
|
|
141
146
|
});
|
|
142
147
|
|
|
143
148
|
test("resolves tool from manifest file directly", () => {
|
|
144
|
-
const manifestPath = join(TEST_DIR, "direct-tool", "
|
|
149
|
+
const manifestPath = join(TEST_DIR, "direct-tool", "skill.yaml");
|
|
145
150
|
const result = resolveToolFromPath(manifestPath);
|
|
146
151
|
|
|
147
152
|
expect(result.manifest.name).toBe("test/direct-tool");
|
|
@@ -269,4 +274,83 @@ Documentation here.
|
|
|
269
274
|
expect(error.searchedLocations).toEqual(["/path/1", "/path/2"]);
|
|
270
275
|
});
|
|
271
276
|
});
|
|
277
|
+
|
|
278
|
+
describe("alias resolution", () => {
|
|
279
|
+
test("resolves tool via alias", () => {
|
|
280
|
+
// Set up an alias for the project tool
|
|
281
|
+
addToolToRegistry("test/project-tool", "1.0.0", "project", PROJECT_DIR);
|
|
282
|
+
addAlias("pt", "test/project-tool", "project", PROJECT_DIR);
|
|
283
|
+
|
|
284
|
+
try {
|
|
285
|
+
// Resolve using the alias (no slashes = potential alias)
|
|
286
|
+
const result = resolveTool("pt", { startDir: PROJECT_DIR });
|
|
287
|
+
expect(result.manifest.name).toBe("test/project-tool");
|
|
288
|
+
expect(result.location).toBe("project");
|
|
289
|
+
} finally {
|
|
290
|
+
// Clean up
|
|
291
|
+
removeAlias("pt", "project", PROJECT_DIR);
|
|
292
|
+
rmSync(join(PROJECT_ENACT_DIR, "tools.json"), { force: true });
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
test("alias resolution is case-insensitive (normalized to lowercase)", () => {
|
|
297
|
+
addToolToRegistry("test/project-tool", "1.0.0", "project", PROJECT_DIR);
|
|
298
|
+
addAlias("mytool", "test/project-tool", "project", PROJECT_DIR);
|
|
299
|
+
|
|
300
|
+
try {
|
|
301
|
+
// Lowercase alias should work
|
|
302
|
+
const result = resolveTool("mytool", { startDir: PROJECT_DIR });
|
|
303
|
+
expect(result.manifest.name).toBe("test/project-tool");
|
|
304
|
+
|
|
305
|
+
// Uppercase alias should also work (normalized to lowercase)
|
|
306
|
+
const upperResult = resolveTool("MYTOOL", { startDir: PROJECT_DIR });
|
|
307
|
+
expect(upperResult.manifest.name).toBe("test/project-tool");
|
|
308
|
+
|
|
309
|
+
// Mixed case should also work
|
|
310
|
+
const mixedResult = resolveTool("MyTool", { startDir: PROJECT_DIR });
|
|
311
|
+
expect(mixedResult.manifest.name).toBe("test/project-tool");
|
|
312
|
+
} finally {
|
|
313
|
+
removeAlias("mytool", "project", PROJECT_DIR);
|
|
314
|
+
rmSync(join(PROJECT_ENACT_DIR, "tools.json"), { force: true });
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
test("full tool names bypass alias resolution", () => {
|
|
319
|
+
addToolToRegistry("test/project-tool", "1.0.0", "project", PROJECT_DIR);
|
|
320
|
+
// Create an alias that would conflict if checked
|
|
321
|
+
addAlias("test/project-tool", "some/other-tool", "project", PROJECT_DIR);
|
|
322
|
+
|
|
323
|
+
try {
|
|
324
|
+
// Full name with slashes should resolve directly, not via alias
|
|
325
|
+
const result = resolveTool("test/project-tool", { startDir: PROJECT_DIR });
|
|
326
|
+
expect(result.manifest.name).toBe("test/project-tool");
|
|
327
|
+
} finally {
|
|
328
|
+
removeAlias("test/project-tool", "project", PROJECT_DIR);
|
|
329
|
+
rmSync(join(PROJECT_ENACT_DIR, "tools.json"), { force: true });
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
test("tryResolveTool works with aliases", () => {
|
|
334
|
+
addToolToRegistry("test/project-tool", "1.0.0", "project", PROJECT_DIR);
|
|
335
|
+
addAlias("try-alias", "test/project-tool", "project", PROJECT_DIR);
|
|
336
|
+
|
|
337
|
+
try {
|
|
338
|
+
const result = tryResolveTool("try-alias", { startDir: PROJECT_DIR });
|
|
339
|
+
expect(result).not.toBeNull();
|
|
340
|
+
expect(result?.manifest.name).toBe("test/project-tool");
|
|
341
|
+
} finally {
|
|
342
|
+
removeAlias("try-alias", "project", PROJECT_DIR);
|
|
343
|
+
rmSync(join(PROJECT_ENACT_DIR, "tools.json"), { force: true });
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
test("non-existent alias returns null from tryResolveTool", () => {
|
|
348
|
+
const result = tryResolveTool("nonexistent-alias", {
|
|
349
|
+
startDir: PROJECT_DIR,
|
|
350
|
+
skipUser: true,
|
|
351
|
+
skipCache: true,
|
|
352
|
+
});
|
|
353
|
+
expect(result).toBeNull();
|
|
354
|
+
});
|
|
355
|
+
});
|
|
272
356
|
});
|