@enactprotocol/shared 2.2.4 → 2.3.4

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.
Files changed (111) hide show
  1. package/README.md +1 -18
  2. package/dist/config.d.ts +12 -0
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/config.js +32 -6
  5. package/dist/config.js.map +1 -1
  6. package/dist/execution/action-command.d.ts +131 -0
  7. package/dist/execution/action-command.d.ts.map +1 -0
  8. package/dist/execution/action-command.js +300 -0
  9. package/dist/execution/action-command.js.map +1 -0
  10. package/dist/execution/command.d.ts +8 -8
  11. package/dist/execution/command.js +6 -6
  12. package/dist/execution/index.d.ts +1 -0
  13. package/dist/execution/index.d.ts.map +1 -1
  14. package/dist/execution/index.js +2 -0
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/execution/types.d.ts +5 -2
  17. package/dist/execution/types.d.ts.map +1 -1
  18. package/dist/execution/types.js.map +1 -1
  19. package/dist/index.d.ts +8 -6
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +11 -4
  22. package/dist/index.js.map +1 -1
  23. package/dist/manifest/actions-loader.d.ts +29 -0
  24. package/dist/manifest/actions-loader.d.ts.map +1 -0
  25. package/dist/manifest/actions-loader.js +34 -0
  26. package/dist/manifest/actions-loader.js.map +1 -0
  27. package/dist/manifest/actions-parser.d.ts +69 -0
  28. package/dist/manifest/actions-parser.d.ts.map +1 -0
  29. package/dist/manifest/actions-parser.js +265 -0
  30. package/dist/manifest/actions-parser.js.map +1 -0
  31. package/dist/manifest/index.d.ts +2 -0
  32. package/dist/manifest/index.d.ts.map +1 -1
  33. package/dist/manifest/index.js +4 -0
  34. package/dist/manifest/index.js.map +1 -1
  35. package/dist/manifest/loader.d.ts +7 -2
  36. package/dist/manifest/loader.d.ts.map +1 -1
  37. package/dist/manifest/loader.js +71 -4
  38. package/dist/manifest/loader.js.map +1 -1
  39. package/dist/manifest/parser.d.ts +1 -0
  40. package/dist/manifest/parser.d.ts.map +1 -1
  41. package/dist/manifest/parser.js +1 -0
  42. package/dist/manifest/parser.js.map +1 -1
  43. package/dist/manifest/scripts.d.ts +19 -0
  44. package/dist/manifest/scripts.d.ts.map +1 -0
  45. package/dist/manifest/scripts.js +102 -0
  46. package/dist/manifest/scripts.js.map +1 -0
  47. package/dist/manifest/validator.d.ts +1 -8
  48. package/dist/manifest/validator.d.ts.map +1 -1
  49. package/dist/manifest/validator.js +14 -13
  50. package/dist/manifest/validator.js.map +1 -1
  51. package/dist/mcp-registry.js +5 -5
  52. package/dist/mcp-registry.js.map +1 -1
  53. package/dist/paths.d.ts +9 -2
  54. package/dist/paths.d.ts.map +1 -1
  55. package/dist/paths.js +12 -3
  56. package/dist/paths.js.map +1 -1
  57. package/dist/registry.d.ts +3 -2
  58. package/dist/registry.d.ts.map +1 -1
  59. package/dist/registry.js +5 -5
  60. package/dist/registry.js.map +1 -1
  61. package/dist/resolver.d.ts +55 -4
  62. package/dist/resolver.d.ts.map +1 -1
  63. package/dist/resolver.js +133 -75
  64. package/dist/resolver.js.map +1 -1
  65. package/dist/types/actions.d.ts +194 -0
  66. package/dist/types/actions.d.ts.map +1 -0
  67. package/dist/types/actions.js +32 -0
  68. package/dist/types/actions.js.map +1 -0
  69. package/dist/types/index.d.ts +3 -1
  70. package/dist/types/index.d.ts.map +1 -1
  71. package/dist/types/index.js +1 -0
  72. package/dist/types/index.js.map +1 -1
  73. package/dist/types/manifest.d.ts +50 -5
  74. package/dist/types/manifest.d.ts.map +1 -1
  75. package/dist/types/manifest.js +10 -2
  76. package/dist/types/manifest.js.map +1 -1
  77. package/package.json +2 -2
  78. package/src/config.ts +48 -6
  79. package/src/execution/action-command.ts +417 -0
  80. package/src/execution/command.ts +8 -8
  81. package/src/execution/index.ts +17 -0
  82. package/src/execution/types.ts +13 -2
  83. package/src/index.ts +37 -0
  84. package/src/manifest/actions-loader.ts +49 -0
  85. package/src/manifest/index.ts +12 -0
  86. package/src/manifest/loader.ts +77 -4
  87. package/src/manifest/parser.ts +1 -0
  88. package/src/manifest/scripts.ts +116 -0
  89. package/src/manifest/validator.ts +15 -14
  90. package/src/mcp-registry.ts +5 -5
  91. package/src/paths.ts +13 -3
  92. package/src/registry.ts +5 -5
  93. package/src/resolver.ts +172 -77
  94. package/src/types/actions.ts +223 -0
  95. package/src/types/index.ts +11 -0
  96. package/src/types/manifest.ts +67 -6
  97. package/tests/action-command.test.ts +249 -0
  98. package/tests/config-normalization.test.ts +279 -0
  99. package/tests/config.test.ts +4 -1
  100. package/tests/effective-input-schema.test.ts +86 -0
  101. package/tests/fixtures/valid-tool.md +5 -12
  102. package/tests/fixtures/valid-tool.yaml +3 -10
  103. package/tests/hooks.test.ts +177 -0
  104. package/tests/manifest/loader.test.ts +34 -20
  105. package/tests/manifest/parser.test.ts +11 -15
  106. package/tests/manifest/validator.test.ts +7 -17
  107. package/tests/manifest-types.test.ts +9 -11
  108. package/tests/paths.test.ts +11 -4
  109. package/tests/registry.test.ts +12 -11
  110. package/tests/resolver.test.ts +11 -7
  111. package/tsconfig.tsbuildinfo +1 -1
@@ -9,6 +9,7 @@ import {
9
9
  getGlobalEnvPath,
10
10
  getProjectEnactDir,
11
11
  getProjectEnvPath,
12
+ getSkillsDir,
12
13
  getToolsDir,
13
14
  } from "../src/paths";
14
15
 
@@ -106,14 +107,20 @@ describe("path utilities", () => {
106
107
  });
107
108
  });
108
109
 
109
- describe("getCacheDir", () => {
110
- test("returns ~/.enact/cache/ path", () => {
111
- const result = getCacheDir();
112
- const expected = join(homedir(), ".enact", "cache");
110
+ describe("getSkillsDir", () => {
111
+ test("returns ~/.agent/skills/ path", () => {
112
+ const result = getSkillsDir();
113
+ const expected = join(homedir(), ".agent", "skills");
113
114
  expect(result).toBe(expected);
114
115
  });
115
116
  });
116
117
 
118
+ describe("getCacheDir (deprecated)", () => {
119
+ test("returns same path as getSkillsDir", () => {
120
+ expect(getCacheDir()).toBe(getSkillsDir());
121
+ });
122
+ });
123
+
117
124
  describe("getConfigPath", () => {
118
125
  test("returns ~/.enact/config.yaml path", () => {
119
126
  const result = getConfigPath();
@@ -199,18 +199,19 @@ describe("registry", () => {
199
199
  });
200
200
 
201
201
  describe("getToolCachePath", () => {
202
- test("returns cache path with version", () => {
202
+ test("returns skill path under ~/.agent/skills/", () => {
203
203
  const path = getToolCachePath("org/tool", "1.0.0");
204
- expect(path).toContain(".enact");
205
- expect(path).toContain("cache");
204
+ expect(path).toContain(".agent");
205
+ expect(path).toContain("skills");
206
206
  expect(path).toContain("org/tool");
207
- expect(path).toContain("v1.0.0");
207
+ // No version subdirectory in new layout
208
+ expect(path).not.toContain("v1.0.0");
208
209
  });
209
210
 
210
- test("normalizes version prefix", () => {
211
- const pathWithV = getToolCachePath("org/tool", "v1.0.0");
212
- const pathWithoutV = getToolCachePath("org/tool", "1.0.0");
213
- expect(pathWithV).toBe(pathWithoutV);
211
+ test("returns same path regardless of version", () => {
212
+ const path1 = getToolCachePath("org/tool", "1.0.0");
213
+ const path2 = getToolCachePath("org/tool", "2.0.0");
214
+ expect(path1).toBe(path2);
214
215
  });
215
216
  });
216
217
 
@@ -296,11 +297,11 @@ describe("registry", () => {
296
297
 
297
298
  describe("resolveAlias", () => {
298
299
  test("resolves existing alias to tool name", () => {
299
- addToolToRegistry("org/category/full-name", "1.0.0", "project", PROJECT_DIR);
300
- addAlias("short", "org/category/full-name", "project", PROJECT_DIR);
300
+ addToolToRegistry("org/full-name", "1.0.0", "project", PROJECT_DIR);
301
+ addAlias("short", "org/full-name", "project", PROJECT_DIR);
301
302
 
302
303
  const resolved = resolveAlias("short", "project", PROJECT_DIR);
303
- expect(resolved).toBe("org/category/full-name");
304
+ expect(resolved).toBe("org/full-name");
304
305
 
305
306
  // Clean up
306
307
  rmSync(join(PROJECT_ENACT_DIR, "tools.json"));
@@ -25,7 +25,7 @@ describe("tool resolver", () => {
25
25
 
26
26
  // Create a project-level tool
27
27
  writeFileSync(
28
- join(PROJECT_ENACT_DIR, "tools", "test", "project-tool", "enact.yaml"),
28
+ join(PROJECT_ENACT_DIR, "tools", "test", "project-tool", "skill.yaml"),
29
29
  `
30
30
  name: test/project-tool
31
31
  description: A project-level test tool
@@ -37,7 +37,7 @@ version: "1.0.0"
37
37
  // Create a direct tool directory for path-based resolution
38
38
  mkdirSync(join(TEST_DIR, "direct-tool"), { recursive: true });
39
39
  writeFileSync(
40
- join(TEST_DIR, "direct-tool", "enact.yaml"),
40
+ join(TEST_DIR, "direct-tool", "skill.yaml"),
41
41
  `
42
42
  name: test/direct-tool
43
43
  description: A directly referenced tool
@@ -74,11 +74,11 @@ Documentation here.
74
74
  describe("utility functions", () => {
75
75
  describe("normalizeToolName", () => {
76
76
  test("lowercases name", () => {
77
- expect(normalizeToolName("Acme/Utils/Greeter")).toBe("acme/utils/greeter");
77
+ expect(normalizeToolName("Acme/Greeter")).toBe("acme/greeter");
78
78
  });
79
79
 
80
80
  test("converts backslashes to forward slashes", () => {
81
- expect(normalizeToolName("acme\\utils\\greeter")).toBe("acme/utils/greeter");
81
+ expect(normalizeToolName("acme\\greeter")).toBe("acme/greeter");
82
82
  });
83
83
 
84
84
  test("trims whitespace", () => {
@@ -88,7 +88,11 @@ Documentation here.
88
88
 
89
89
  describe("toolNameToPath", () => {
90
90
  test("returns path-like string", () => {
91
- expect(toolNameToPath("acme/utils/greeter")).toBe("acme/utils/greeter");
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");
92
96
  });
93
97
 
94
98
  test("normalizes backslashes", () => {
@@ -142,7 +146,7 @@ Documentation here.
142
146
  });
143
147
 
144
148
  test("resolves tool from manifest file directly", () => {
145
- const manifestPath = join(TEST_DIR, "direct-tool", "enact.yaml");
149
+ const manifestPath = join(TEST_DIR, "direct-tool", "skill.yaml");
146
150
  const result = resolveToolFromPath(manifestPath);
147
151
 
148
152
  expect(result.manifest.name).toBe("test/direct-tool");
@@ -314,7 +318,7 @@ Documentation here.
314
318
  test("full tool names bypass alias resolution", () => {
315
319
  addToolToRegistry("test/project-tool", "1.0.0", "project", PROJECT_DIR);
316
320
  // Create an alias that would conflict if checked
317
- addAlias("test/project-tool", "some/other/tool", "project", PROJECT_DIR);
321
+ addAlias("test/project-tool", "some/other-tool", "project", PROJECT_DIR);
318
322
 
319
323
  try {
320
324
  // Full name with slashes should resolve directly, not via alias