@skillsmith/mcp-server 0.1.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.
Files changed (306) hide show
  1. package/dist/.tsbuildinfo +1 -0
  2. package/dist/src/__tests__/get-skill.test.d.ts +6 -0
  3. package/dist/src/__tests__/get-skill.test.d.ts.map +1 -0
  4. package/dist/src/__tests__/get-skill.test.js +88 -0
  5. package/dist/src/__tests__/get-skill.test.js.map +1 -0
  6. package/dist/src/__tests__/middleware/errorFormatter.test.d.ts +7 -0
  7. package/dist/src/__tests__/middleware/errorFormatter.test.d.ts.map +1 -0
  8. package/dist/src/__tests__/middleware/errorFormatter.test.js +304 -0
  9. package/dist/src/__tests__/middleware/errorFormatter.test.js.map +1 -0
  10. package/dist/src/__tests__/middleware/license.test.d.ts +7 -0
  11. package/dist/src/__tests__/middleware/license.test.d.ts.map +1 -0
  12. package/dist/src/__tests__/middleware/license.test.js +500 -0
  13. package/dist/src/__tests__/middleware/license.test.js.map +1 -0
  14. package/dist/src/__tests__/search.test.d.ts +6 -0
  15. package/dist/src/__tests__/search.test.d.ts.map +1 -0
  16. package/dist/src/__tests__/search.test.js +86 -0
  17. package/dist/src/__tests__/search.test.js.map +1 -0
  18. package/dist/src/__tests__/test-utils.d.ts +19 -0
  19. package/dist/src/__tests__/test-utils.d.ts.map +1 -0
  20. package/dist/src/__tests__/test-utils.js +87 -0
  21. package/dist/src/__tests__/test-utils.js.map +1 -0
  22. package/dist/src/context/index.d.ts +19 -0
  23. package/dist/src/context/index.d.ts.map +1 -0
  24. package/dist/src/context/index.js +25 -0
  25. package/dist/src/context/index.js.map +1 -0
  26. package/dist/src/context/project-detector.d.ts +145 -0
  27. package/dist/src/context/project-detector.d.ts.map +1 -0
  28. package/dist/src/context/project-detector.js +321 -0
  29. package/dist/src/context/project-detector.js.map +1 -0
  30. package/dist/src/context.d.ts +100 -0
  31. package/dist/src/context.d.ts.map +1 -0
  32. package/dist/src/context.js +157 -0
  33. package/dist/src/context.js.map +1 -0
  34. package/dist/src/core-shim.d.ts +7 -0
  35. package/dist/src/core-shim.d.ts.map +1 -0
  36. package/dist/src/core-shim.js +9 -0
  37. package/dist/src/core-shim.js.map +1 -0
  38. package/dist/src/health/healthCheck.d.ts +88 -0
  39. package/dist/src/health/healthCheck.d.ts.map +1 -0
  40. package/dist/src/health/healthCheck.js +117 -0
  41. package/dist/src/health/healthCheck.js.map +1 -0
  42. package/dist/src/health/index.d.ts +21 -0
  43. package/dist/src/health/index.d.ts.map +1 -0
  44. package/dist/src/health/index.js +21 -0
  45. package/dist/src/health/index.js.map +1 -0
  46. package/dist/src/health/readinessCheck.d.ts +139 -0
  47. package/dist/src/health/readinessCheck.d.ts.map +1 -0
  48. package/dist/src/health/readinessCheck.js +266 -0
  49. package/dist/src/health/readinessCheck.js.map +1 -0
  50. package/dist/src/index.d.ts +8 -0
  51. package/dist/src/index.d.ts.map +1 -0
  52. package/dist/src/index.js +178 -0
  53. package/dist/src/index.js.map +1 -0
  54. package/dist/src/index.test.d.ts +2 -0
  55. package/dist/src/index.test.d.ts.map +1 -0
  56. package/dist/src/index.test.js +43 -0
  57. package/dist/src/index.test.js.map +1 -0
  58. package/dist/src/logger.d.ts +26 -0
  59. package/dist/src/logger.d.ts.map +1 -0
  60. package/dist/src/logger.js +179 -0
  61. package/dist/src/logger.js.map +1 -0
  62. package/dist/src/middleware/__tests__/csp.test.d.ts +2 -0
  63. package/dist/src/middleware/__tests__/csp.test.d.ts.map +1 -0
  64. package/dist/src/middleware/__tests__/csp.test.js +389 -0
  65. package/dist/src/middleware/__tests__/csp.test.js.map +1 -0
  66. package/dist/src/middleware/csp.d.ts +87 -0
  67. package/dist/src/middleware/csp.d.ts.map +1 -0
  68. package/dist/src/middleware/csp.js +273 -0
  69. package/dist/src/middleware/csp.js.map +1 -0
  70. package/dist/src/middleware/degradation.d.ts +99 -0
  71. package/dist/src/middleware/degradation.d.ts.map +1 -0
  72. package/dist/src/middleware/degradation.js +315 -0
  73. package/dist/src/middleware/degradation.js.map +1 -0
  74. package/dist/src/middleware/errorFormatter.d.ts +119 -0
  75. package/dist/src/middleware/errorFormatter.d.ts.map +1 -0
  76. package/dist/src/middleware/errorFormatter.js +294 -0
  77. package/dist/src/middleware/errorFormatter.js.map +1 -0
  78. package/dist/src/middleware/index.d.ts +10 -0
  79. package/dist/src/middleware/index.d.ts.map +1 -0
  80. package/dist/src/middleware/index.js +14 -0
  81. package/dist/src/middleware/index.js.map +1 -0
  82. package/dist/src/middleware/license.d.ts +161 -0
  83. package/dist/src/middleware/license.d.ts.map +1 -0
  84. package/dist/src/middleware/license.js +281 -0
  85. package/dist/src/middleware/license.js.map +1 -0
  86. package/dist/src/middleware/toolFeatureMapping.d.ts +36 -0
  87. package/dist/src/middleware/toolFeatureMapping.d.ts.map +1 -0
  88. package/dist/src/middleware/toolFeatureMapping.js +90 -0
  89. package/dist/src/middleware/toolFeatureMapping.js.map +1 -0
  90. package/dist/src/onboarding/first-run.d.ts +64 -0
  91. package/dist/src/onboarding/first-run.d.ts.map +1 -0
  92. package/dist/src/onboarding/first-run.js +77 -0
  93. package/dist/src/onboarding/first-run.js.map +1 -0
  94. package/dist/src/onboarding/index.d.ts +7 -0
  95. package/dist/src/onboarding/index.d.ts.map +1 -0
  96. package/dist/src/onboarding/index.js +7 -0
  97. package/dist/src/onboarding/index.js.map +1 -0
  98. package/dist/src/suggestions/index.d.ts +21 -0
  99. package/dist/src/suggestions/index.d.ts.map +1 -0
  100. package/dist/src/suggestions/index.js +20 -0
  101. package/dist/src/suggestions/index.js.map +1 -0
  102. package/dist/src/suggestions/suggestion-engine.d.ts +185 -0
  103. package/dist/src/suggestions/suggestion-engine.d.ts.map +1 -0
  104. package/dist/src/suggestions/suggestion-engine.js +352 -0
  105. package/dist/src/suggestions/suggestion-engine.js.map +1 -0
  106. package/dist/src/suggestions/types.d.ts +88 -0
  107. package/dist/src/suggestions/types.d.ts.map +1 -0
  108. package/dist/src/suggestions/types.js +21 -0
  109. package/dist/src/suggestions/types.js.map +1 -0
  110. package/dist/src/tools/analyze.d.ts +151 -0
  111. package/dist/src/tools/analyze.d.ts.map +1 -0
  112. package/dist/src/tools/analyze.js +205 -0
  113. package/dist/src/tools/analyze.js.map +1 -0
  114. package/dist/src/tools/compare.d.ts +149 -0
  115. package/dist/src/tools/compare.d.ts.map +1 -0
  116. package/dist/src/tools/compare.js +464 -0
  117. package/dist/src/tools/compare.js.map +1 -0
  118. package/dist/src/tools/get-skill.d.ts +116 -0
  119. package/dist/src/tools/get-skill.d.ts.map +1 -0
  120. package/dist/src/tools/get-skill.js +224 -0
  121. package/dist/src/tools/get-skill.js.map +1 -0
  122. package/dist/src/tools/index.d.ts +20 -0
  123. package/dist/src/tools/index.d.ts.map +1 -0
  124. package/dist/src/tools/index.js +20 -0
  125. package/dist/src/tools/index.js.map +1 -0
  126. package/dist/src/tools/install.d.ts +122 -0
  127. package/dist/src/tools/install.d.ts.map +1 -0
  128. package/dist/src/tools/install.js +314 -0
  129. package/dist/src/tools/install.js.map +1 -0
  130. package/dist/src/tools/recommend.d.ts +171 -0
  131. package/dist/src/tools/recommend.d.ts.map +1 -0
  132. package/dist/src/tools/recommend.js +325 -0
  133. package/dist/src/tools/recommend.js.map +1 -0
  134. package/dist/src/tools/search.d.ts +121 -0
  135. package/dist/src/tools/search.d.ts.map +1 -0
  136. package/dist/src/tools/search.js +249 -0
  137. package/dist/src/tools/search.js.map +1 -0
  138. package/dist/src/tools/suggest.d.ts +181 -0
  139. package/dist/src/tools/suggest.d.ts.map +1 -0
  140. package/dist/src/tools/suggest.js +342 -0
  141. package/dist/src/tools/suggest.js.map +1 -0
  142. package/dist/src/tools/uninstall.d.ts +123 -0
  143. package/dist/src/tools/uninstall.d.ts.map +1 -0
  144. package/dist/src/tools/uninstall.js +250 -0
  145. package/dist/src/tools/uninstall.js.map +1 -0
  146. package/dist/src/tools/validate.d.ts +122 -0
  147. package/dist/src/tools/validate.d.ts.map +1 -0
  148. package/dist/src/tools/validate.js +497 -0
  149. package/dist/src/tools/validate.js.map +1 -0
  150. package/dist/src/utils/installed-skills.d.ts +101 -0
  151. package/dist/src/utils/installed-skills.d.ts.map +1 -0
  152. package/dist/src/utils/installed-skills.js +220 -0
  153. package/dist/src/utils/installed-skills.js.map +1 -0
  154. package/dist/src/utils/validation.d.ts +76 -0
  155. package/dist/src/utils/validation.d.ts.map +1 -0
  156. package/dist/src/utils/validation.js +153 -0
  157. package/dist/src/utils/validation.js.map +1 -0
  158. package/dist/src/webhooks/index.d.ts +8 -0
  159. package/dist/src/webhooks/index.d.ts.map +1 -0
  160. package/dist/src/webhooks/index.js +9 -0
  161. package/dist/src/webhooks/index.js.map +1 -0
  162. package/dist/src/webhooks/webhook-endpoint.d.ts +149 -0
  163. package/dist/src/webhooks/webhook-endpoint.d.ts.map +1 -0
  164. package/dist/src/webhooks/webhook-endpoint.js +339 -0
  165. package/dist/src/webhooks/webhook-endpoint.js.map +1 -0
  166. package/dist/tests/compare.test.d.ts +6 -0
  167. package/dist/tests/compare.test.d.ts.map +1 -0
  168. package/dist/tests/compare.test.js +225 -0
  169. package/dist/tests/compare.test.js.map +1 -0
  170. package/dist/tests/context/project-detector.test.d.ts +6 -0
  171. package/dist/tests/context/project-detector.test.d.ts.map +1 -0
  172. package/dist/tests/context/project-detector.test.js +719 -0
  173. package/dist/tests/context/project-detector.test.js.map +1 -0
  174. package/dist/tests/e2e/compare.e2e.test.d.ts +10 -0
  175. package/dist/tests/e2e/compare.e2e.test.d.ts.map +1 -0
  176. package/dist/tests/e2e/compare.e2e.test.js +286 -0
  177. package/dist/tests/e2e/compare.e2e.test.js.map +1 -0
  178. package/dist/tests/e2e/install-flow.e2e.test.d.ts +10 -0
  179. package/dist/tests/e2e/install-flow.e2e.test.d.ts.map +1 -0
  180. package/dist/tests/e2e/install-flow.e2e.test.js +209 -0
  181. package/dist/tests/e2e/install-flow.e2e.test.js.map +1 -0
  182. package/dist/tests/e2e/recommend.e2e.test.d.ts +12 -0
  183. package/dist/tests/e2e/recommend.e2e.test.d.ts.map +1 -0
  184. package/dist/tests/e2e/recommend.e2e.test.js +347 -0
  185. package/dist/tests/e2e/recommend.e2e.test.js.map +1 -0
  186. package/dist/tests/e2e/skill-flow.e2e.test.d.ts +10 -0
  187. package/dist/tests/e2e/skill-flow.e2e.test.d.ts.map +1 -0
  188. package/dist/tests/e2e/skill-flow.e2e.test.js +280 -0
  189. package/dist/tests/e2e/skill-flow.e2e.test.js.map +1 -0
  190. package/dist/tests/e2e/suggest.e2e.test.d.ts +13 -0
  191. package/dist/tests/e2e/suggest.e2e.test.d.ts.map +1 -0
  192. package/dist/tests/e2e/suggest.e2e.test.js +347 -0
  193. package/dist/tests/e2e/suggest.e2e.test.js.map +1 -0
  194. package/dist/tests/e2e/utils/baseline-collector.d.ts +107 -0
  195. package/dist/tests/e2e/utils/baseline-collector.d.ts.map +1 -0
  196. package/dist/tests/e2e/utils/baseline-collector.js +211 -0
  197. package/dist/tests/e2e/utils/baseline-collector.js.map +1 -0
  198. package/dist/tests/e2e/utils/hardcoded-detector.d.ts +46 -0
  199. package/dist/tests/e2e/utils/hardcoded-detector.d.ts.map +1 -0
  200. package/dist/tests/e2e/utils/hardcoded-detector.js +255 -0
  201. package/dist/tests/e2e/utils/hardcoded-detector.js.map +1 -0
  202. package/dist/tests/e2e/utils/index.d.ts +7 -0
  203. package/dist/tests/e2e/utils/index.d.ts.map +1 -0
  204. package/dist/tests/e2e/utils/index.js +7 -0
  205. package/dist/tests/e2e/utils/index.js.map +1 -0
  206. package/dist/tests/e2e/utils/linear-reporter.d.ts +60 -0
  207. package/dist/tests/e2e/utils/linear-reporter.d.ts.map +1 -0
  208. package/dist/tests/e2e/utils/linear-reporter.js +232 -0
  209. package/dist/tests/e2e/utils/linear-reporter.js.map +1 -0
  210. package/dist/tests/health.test.d.ts +9 -0
  211. package/dist/tests/health.test.d.ts.map +1 -0
  212. package/dist/tests/health.test.js +308 -0
  213. package/dist/tests/health.test.js.map +1 -0
  214. package/dist/tests/integration/analyze.integration.test.d.ts +2 -0
  215. package/dist/tests/integration/analyze.integration.test.d.ts.map +1 -0
  216. package/dist/tests/integration/analyze.integration.test.js +244 -0
  217. package/dist/tests/integration/analyze.integration.test.js.map +1 -0
  218. package/dist/tests/integration/compare.integration.test.d.ts +2 -0
  219. package/dist/tests/integration/compare.integration.test.d.ts.map +1 -0
  220. package/dist/tests/integration/compare.integration.test.js +120 -0
  221. package/dist/tests/integration/compare.integration.test.js.map +1 -0
  222. package/dist/tests/integration/fixtures/test-skills.d.ts +62 -0
  223. package/dist/tests/integration/fixtures/test-skills.d.ts.map +1 -0
  224. package/dist/tests/integration/fixtures/test-skills.js +644 -0
  225. package/dist/tests/integration/fixtures/test-skills.js.map +1 -0
  226. package/dist/tests/integration/get-skill.integration.test.d.ts +6 -0
  227. package/dist/tests/integration/get-skill.integration.test.d.ts.map +1 -0
  228. package/dist/tests/integration/get-skill.integration.test.js +203 -0
  229. package/dist/tests/integration/get-skill.integration.test.js.map +1 -0
  230. package/dist/tests/integration/github-api.integration.test.d.ts +14 -0
  231. package/dist/tests/integration/github-api.integration.test.d.ts.map +1 -0
  232. package/dist/tests/integration/github-api.integration.test.js +190 -0
  233. package/dist/tests/integration/github-api.integration.test.js.map +1 -0
  234. package/dist/tests/integration/install.integration.test.d.ts +6 -0
  235. package/dist/tests/integration/install.integration.test.d.ts.map +1 -0
  236. package/dist/tests/integration/install.integration.test.js +282 -0
  237. package/dist/tests/integration/install.integration.test.js.map +1 -0
  238. package/dist/tests/integration/recommend.integration.test.d.ts +2 -0
  239. package/dist/tests/integration/recommend.integration.test.d.ts.map +1 -0
  240. package/dist/tests/integration/recommend.integration.test.js +215 -0
  241. package/dist/tests/integration/recommend.integration.test.js.map +1 -0
  242. package/dist/tests/integration/search.integration.test.d.ts +6 -0
  243. package/dist/tests/integration/search.integration.test.d.ts.map +1 -0
  244. package/dist/tests/integration/search.integration.test.js +229 -0
  245. package/dist/tests/integration/search.integration.test.js.map +1 -0
  246. package/dist/tests/integration/setup.d.ts +71 -0
  247. package/dist/tests/integration/setup.d.ts.map +1 -0
  248. package/dist/tests/integration/setup.js +124 -0
  249. package/dist/tests/integration/setup.js.map +1 -0
  250. package/dist/tests/integration/uninstall.integration.test.d.ts +6 -0
  251. package/dist/tests/integration/uninstall.integration.test.d.ts.map +1 -0
  252. package/dist/tests/integration/uninstall.integration.test.js +296 -0
  253. package/dist/tests/integration/uninstall.integration.test.js.map +1 -0
  254. package/dist/tests/integration/validate.integration.test.d.ts +2 -0
  255. package/dist/tests/integration/validate.integration.test.d.ts.map +1 -0
  256. package/dist/tests/integration/validate.integration.test.js +181 -0
  257. package/dist/tests/integration/validate.integration.test.js.map +1 -0
  258. package/dist/tests/onboarding/first-run.test.d.ts +7 -0
  259. package/dist/tests/onboarding/first-run.test.d.ts.map +1 -0
  260. package/dist/tests/onboarding/first-run.test.js +258 -0
  261. package/dist/tests/onboarding/first-run.test.js.map +1 -0
  262. package/dist/tests/performance/search-performance.test.d.ts +10 -0
  263. package/dist/tests/performance/search-performance.test.d.ts.map +1 -0
  264. package/dist/tests/performance/search-performance.test.js +218 -0
  265. package/dist/tests/performance/search-performance.test.js.map +1 -0
  266. package/dist/tests/recommend.test.d.ts +6 -0
  267. package/dist/tests/recommend.test.d.ts.map +1 -0
  268. package/dist/tests/recommend.test.js +208 -0
  269. package/dist/tests/recommend.test.js.map +1 -0
  270. package/dist/tests/suggestions/suggestion-engine.test.d.ts +6 -0
  271. package/dist/tests/suggestions/suggestion-engine.test.d.ts.map +1 -0
  272. package/dist/tests/suggestions/suggestion-engine.test.js +448 -0
  273. package/dist/tests/suggestions/suggestion-engine.test.js.map +1 -0
  274. package/dist/tests/test-utils.d.ts +74 -0
  275. package/dist/tests/test-utils.d.ts.map +1 -0
  276. package/dist/tests/test-utils.js +98 -0
  277. package/dist/tests/test-utils.js.map +1 -0
  278. package/dist/tests/tools.test.d.ts +5 -0
  279. package/dist/tests/tools.test.d.ts.map +1 -0
  280. package/dist/tests/tools.test.js +138 -0
  281. package/dist/tests/tools.test.js.map +1 -0
  282. package/dist/tests/unit/installed-skills.test.d.ts +6 -0
  283. package/dist/tests/unit/installed-skills.test.d.ts.map +1 -0
  284. package/dist/tests/unit/installed-skills.test.js +285 -0
  285. package/dist/tests/unit/installed-skills.test.js.map +1 -0
  286. package/dist/tests/unit/logger.test.d.ts +6 -0
  287. package/dist/tests/unit/logger.test.d.ts.map +1 -0
  288. package/dist/tests/unit/logger.test.js +281 -0
  289. package/dist/tests/unit/logger.test.js.map +1 -0
  290. package/dist/tests/validate.test.d.ts +5 -0
  291. package/dist/tests/validate.test.d.ts.map +1 -0
  292. package/dist/tests/validate.test.js +303 -0
  293. package/dist/tests/validate.test.js.map +1 -0
  294. package/dist/tests/webhooks/proxy-trust.security.test.d.ts +8 -0
  295. package/dist/tests/webhooks/proxy-trust.security.test.d.ts.map +1 -0
  296. package/dist/tests/webhooks/proxy-trust.security.test.js +145 -0
  297. package/dist/tests/webhooks/proxy-trust.security.test.js.map +1 -0
  298. package/dist/tests/webhooks/rate-limiter.security.test.d.ts +8 -0
  299. package/dist/tests/webhooks/rate-limiter.security.test.d.ts.map +1 -0
  300. package/dist/tests/webhooks/rate-limiter.security.test.js +122 -0
  301. package/dist/tests/webhooks/rate-limiter.security.test.js.map +1 -0
  302. package/dist/vitest.config.d.ts +6 -0
  303. package/dist/vitest.config.d.ts.map +1 -0
  304. package/dist/vitest.config.js +13 -0
  305. package/dist/vitest.config.js.map +1 -0
  306. package/package.json +63 -0
@@ -0,0 +1,281 @@
1
+ /**
2
+ * License validation middleware for MCP server
3
+ *
4
+ * Validates that the user has the required license features for enterprise tools.
5
+ * Gracefully degrades if @skillsmith/enterprise is not installed.
6
+ *
7
+ * @see SMI-1055: Add license middleware to MCP server
8
+ */
9
+ import { TOOL_FEATURES, FEATURE_DISPLAY_NAMES, FEATURE_TIERS, } from './toolFeatureMapping.js';
10
+ /**
11
+ * Configuration for the upgrade URL
12
+ */
13
+ const UPGRADE_URL = 'https://skillsmith.io/pricing';
14
+ /**
15
+ * Type guard to validate enterprise module structure
16
+ */
17
+ function isEnterpriseModule(mod) {
18
+ return (typeof mod === 'object' &&
19
+ mod !== null &&
20
+ 'LicenseValidator' in mod &&
21
+ typeof mod['LicenseValidator'] === 'function');
22
+ }
23
+ /**
24
+ * Attempt to load the enterprise license validator
25
+ * Returns null if the package is not installed
26
+ */
27
+ async function tryLoadEnterpriseValidator() {
28
+ try {
29
+ // Dynamic import with variable to prevent TypeScript from resolving at compile time
30
+ // This is an optional peer dependency that may not be installed
31
+ const packageName = '@skillsmith/enterprise';
32
+ const enterprise = await import(/* webpackIgnore: true */ packageName);
33
+ if (isEnterpriseModule(enterprise)) {
34
+ return new enterprise.LicenseValidator();
35
+ }
36
+ return null;
37
+ }
38
+ catch {
39
+ // Enterprise package not installed - this is expected for community users
40
+ return null;
41
+ }
42
+ }
43
+ /**
44
+ * Check if a tool name corresponds to an enterprise feature
45
+ *
46
+ * @param toolName - The name of the MCP tool
47
+ * @returns true if the tool requires an enterprise license
48
+ */
49
+ export function isEnterpriseFeature(toolName) {
50
+ const feature = TOOL_FEATURES[toolName];
51
+ if (feature == null) {
52
+ return false;
53
+ }
54
+ return FEATURE_TIERS[feature] === 'enterprise';
55
+ }
56
+ /**
57
+ * Check if a tool name requires any license (team or enterprise)
58
+ *
59
+ * @param toolName - The name of the MCP tool
60
+ * @returns true if the tool requires any license
61
+ */
62
+ export function requiresLicense(toolName) {
63
+ return TOOL_FEATURES[toolName] !== null && TOOL_FEATURES[toolName] !== undefined;
64
+ }
65
+ /**
66
+ * Get the required feature for a tool
67
+ *
68
+ * @param toolName - The name of the MCP tool
69
+ * @returns The feature flag required, or null if community tool
70
+ */
71
+ export function getRequiredFeature(toolName) {
72
+ return TOOL_FEATURES[toolName] ?? null;
73
+ }
74
+ /**
75
+ * Check if license is expiring soon (within 30 days)
76
+ */
77
+ function getExpirationWarning(expiresAt) {
78
+ if (!expiresAt)
79
+ return undefined;
80
+ const daysUntilExpiry = Math.floor((expiresAt.getTime() - Date.now()) / (1000 * 60 * 60 * 24));
81
+ if (daysUntilExpiry <= 30 && daysUntilExpiry > 0) {
82
+ return `Your license expires in ${daysUntilExpiry} day${daysUntilExpiry === 1 ? '' : 's'}. Please renew to avoid service interruption.`;
83
+ }
84
+ return undefined;
85
+ }
86
+ /**
87
+ * Create a license middleware factory
88
+ *
89
+ * This middleware reads the license key from environment variables and
90
+ * validates tool access based on the license features.
91
+ *
92
+ * @param options - Optional configuration
93
+ * @returns License middleware instance
94
+ */
95
+ export function createLicenseMiddleware(options) {
96
+ const envVar = options?.licenseKeyEnvVar ?? 'SKILLSMITH_LICENSE_KEY';
97
+ const cacheTtl = options?.cacheTtlMs ?? 5 * 60 * 1000; // 5 minutes default
98
+ const context = {
99
+ validator: null,
100
+ licenseKey: process.env[envVar],
101
+ cachedLicense: null,
102
+ cacheExpiry: 0,
103
+ };
104
+ // Initialize validator lazily
105
+ let validatorPromise = null;
106
+ async function getValidator() {
107
+ if (!validatorPromise) {
108
+ validatorPromise = tryLoadEnterpriseValidator();
109
+ }
110
+ if (context.validator === null) {
111
+ context.validator = await validatorPromise;
112
+ }
113
+ return context.validator;
114
+ }
115
+ async function getLicenseInfo() {
116
+ // Check cache first
117
+ if (context.cachedLicense && Date.now() < context.cacheExpiry) {
118
+ return context.cachedLicense;
119
+ }
120
+ // No license key = community user
121
+ if (!context.licenseKey) {
122
+ const communityLicense = {
123
+ valid: true,
124
+ tier: 'community',
125
+ features: [],
126
+ };
127
+ context.cachedLicense = communityLicense;
128
+ context.cacheExpiry = Date.now() + cacheTtl;
129
+ return communityLicense;
130
+ }
131
+ // Try to validate with enterprise package
132
+ const validator = await getValidator();
133
+ if (!validator) {
134
+ // Enterprise package not installed but license key provided
135
+ // Security-conscious decision: Return null to indicate validation failure
136
+ // rather than silently degrading to community tier. This ensures paying
137
+ // customers get feedback that their license couldn't be validated.
138
+ // See SMI-1130 for rationale.
139
+ return null;
140
+ }
141
+ try {
142
+ const result = await validator.validate(context.licenseKey);
143
+ // Check if validation was successful
144
+ if (!result.valid || !result.license) {
145
+ // Invalid license - return null to indicate validation failure
146
+ return null;
147
+ }
148
+ // Convert enterprise License to middleware LicenseInfo
149
+ const license = {
150
+ valid: true,
151
+ tier: result.license.tier,
152
+ features: result.license.features,
153
+ expiresAt: result.license.expiresAt,
154
+ organizationId: result.license.customerId,
155
+ };
156
+ context.cachedLicense = license;
157
+ context.cacheExpiry = Date.now() + cacheTtl;
158
+ return license;
159
+ }
160
+ catch {
161
+ // Validation threw an exception - treat as invalid license
162
+ return null;
163
+ }
164
+ }
165
+ async function checkFeature(feature) {
166
+ const license = await getLicenseInfo();
167
+ // No valid license
168
+ if (!license || !license.valid) {
169
+ const tier = FEATURE_TIERS[feature];
170
+ const displayName = FEATURE_DISPLAY_NAMES[feature];
171
+ return {
172
+ valid: false,
173
+ feature,
174
+ message: `The "${displayName}" feature requires a ${tier} license. Your license could not be validated.`,
175
+ upgradeUrl: `${UPGRADE_URL}?feature=${feature}`,
176
+ };
177
+ }
178
+ // Community tier - no paid features
179
+ if (license.tier === 'community') {
180
+ const tier = FEATURE_TIERS[feature];
181
+ const displayName = FEATURE_DISPLAY_NAMES[feature];
182
+ return {
183
+ valid: false,
184
+ feature,
185
+ message: `The "${displayName}" feature requires a ${tier} license. You are currently on the community tier.`,
186
+ upgradeUrl: `${UPGRADE_URL}?feature=${feature}&current=community`,
187
+ };
188
+ }
189
+ // Team tier - only team features
190
+ if (license.tier === 'team' && FEATURE_TIERS[feature] === 'enterprise') {
191
+ const displayName = FEATURE_DISPLAY_NAMES[feature];
192
+ return {
193
+ valid: false,
194
+ feature,
195
+ message: `The "${displayName}" feature requires an enterprise license. You are currently on the team tier.`,
196
+ upgradeUrl: `${UPGRADE_URL}?feature=${feature}&current=team`,
197
+ };
198
+ }
199
+ // Check if feature is in the license
200
+ if (!license.features.includes(feature)) {
201
+ const displayName = FEATURE_DISPLAY_NAMES[feature];
202
+ const tier = FEATURE_TIERS[feature];
203
+ return {
204
+ valid: false,
205
+ feature,
206
+ message: `The "${displayName}" feature is not included in your license. Please upgrade to access this ${tier} feature.`,
207
+ upgradeUrl: `${UPGRADE_URL}?feature=${feature}&upgrade=true`,
208
+ };
209
+ }
210
+ const warning = getExpirationWarning(license.expiresAt);
211
+ return { valid: true, warning };
212
+ }
213
+ async function checkTool(toolName) {
214
+ const requiredFeature = getRequiredFeature(toolName);
215
+ // Community tool - no license required
216
+ if (requiredFeature === null) {
217
+ return { valid: true };
218
+ }
219
+ return checkFeature(requiredFeature);
220
+ }
221
+ function invalidateCache() {
222
+ context.cachedLicense = null;
223
+ context.cacheExpiry = 0;
224
+ }
225
+ return {
226
+ checkFeature,
227
+ checkTool,
228
+ getLicenseInfo,
229
+ invalidateCache,
230
+ };
231
+ }
232
+ /**
233
+ * Higher-order function to create feature requirement middleware
234
+ *
235
+ * Use this to wrap tool handlers that require specific features.
236
+ *
237
+ * @param feature - The feature flag required
238
+ * @returns Middleware function that checks the feature
239
+ *
240
+ * @example
241
+ * ```typescript
242
+ * const middleware = createLicenseMiddleware();
243
+ * const requireAudit = requireFeature('audit_logging');
244
+ *
245
+ * // In tool handler:
246
+ * const validation = await requireAudit(middleware);
247
+ * if (!validation.valid) {
248
+ * return { error: validation.message, upgradeUrl: validation.upgradeUrl };
249
+ * }
250
+ * ```
251
+ */
252
+ export function requireFeature(feature) {
253
+ return async (middleware) => {
254
+ return middleware.checkFeature(feature);
255
+ };
256
+ }
257
+ /**
258
+ * Create an error response for license validation failures
259
+ *
260
+ * @param result - The license validation result
261
+ * @returns MCP-formatted error response
262
+ */
263
+ export function createLicenseErrorResponse(result) {
264
+ return {
265
+ content: [
266
+ {
267
+ type: 'text',
268
+ text: JSON.stringify({
269
+ error: 'license_required',
270
+ message: result.message,
271
+ feature: result.feature,
272
+ upgradeUrl: result.upgradeUrl,
273
+ }, null, 2),
274
+ },
275
+ ],
276
+ isError: true,
277
+ _meta: result.upgradeUrl ? { upgradeUrl: result.upgradeUrl } : undefined,
278
+ };
279
+ }
280
+ export { TOOL_FEATURES, FEATURE_DISPLAY_NAMES, FEATURE_TIERS } from './toolFeatureMapping.js';
281
+ //# sourceMappingURL=license.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"license.js","sourceRoot":"","sources":["../../../src/middleware/license.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,aAAa,GAEd,MAAM,yBAAyB,CAAA;AAEhC;;GAEG;AACH,MAAM,WAAW,GAAG,+BAA+B,CAAA;AAuDnD;;GAEG;AACH,SAAS,kBAAkB,CACzB,GAAY;IAEZ,OAAO,CACL,OAAO,GAAG,KAAK,QAAQ;QACvB,GAAG,KAAK,IAAI;QACZ,kBAAkB,IAAI,GAAG;QACzB,OAAQ,GAA+B,CAAC,kBAAkB,CAAC,KAAK,UAAU,CAC3E,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,0BAA0B;IACvC,IAAI,CAAC;QACH,oFAAoF;QACpF,gEAAgE;QAChE,MAAM,WAAW,GAAG,wBAAwB,CAAA;QAC5C,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,WAAW,CAAC,CAAA;QACtE,IAAI,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC;YACnC,OAAO,IAAI,UAAU,CAAC,gBAAgB,EAAE,CAAA;QAC1C,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,MAAM,CAAC;QACP,0EAA0E;QAC1E,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;IACvC,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,aA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OAAO,YAAY,CAAC,eAAe,CAAC,CAAA;IACtC,CAAC;IAED,SAAS,eAAe;QACtB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAA;QAC5B,OAAO,CAAC,WAAW,GAAG,CAAC,CAAA;IACzB,CAAC;IAED,OAAO;QACL,YAAY;QACZ,SAAS;QACT,cAAc;QACd,eAAe;KAChB,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAoB;IAEpB,OAAO,KAAK,EAAE,UAA6B,EAAE,EAAE;QAC7C,OAAO,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;IACzC,CAAC,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,MAA+B;IAKxE,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;oBACE,KAAK,EAAE,kBAAkB;oBACzB,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,UAAU,EAAE,MAAM,CAAC,UAAU;iBAC9B,EACD,IAAI,EACJ,CAAC,CACF;aACF;SACF;QACD,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS;KACzE,CAAA;AACH,CAAC;AAID,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Tool-to-Feature mapping for license validation
3
+ *
4
+ * Maps MCP tool names to their required feature flags.
5
+ * null = community feature (no license required)
6
+ * string = feature flag that must be enabled in the license
7
+ *
8
+ * @see SMI-1055: Add license middleware to MCP server
9
+ * @see SMI-1091: Unified tier feature definitions across packages
10
+ */
11
+ /**
12
+ * Feature flags for enterprise licensing
13
+ *
14
+ * This type mirrors the canonical FeatureFlag from @skillsmith/enterprise.
15
+ * We define it locally because @skillsmith/enterprise is an optional peer
16
+ * dependency that may not be installed for community users.
17
+ *
18
+ * @see packages/enterprise/src/license/FeatureFlags.ts for canonical definition
19
+ */
20
+ export type FeatureFlag = 'private_skills' | 'team_workspaces' | 'usage_analytics' | 'priority_support' | 'sso_saml' | 'rbac' | 'audit_logging' | 'siem_export' | 'compliance_reports' | 'private_registry' | 'custom_integrations' | 'advanced_analytics';
21
+ /**
22
+ * Mapping of tool names to their required feature flags
23
+ *
24
+ * null = community tool (no license required)
25
+ * FeatureFlag = requires that feature to be enabled in license
26
+ */
27
+ export declare const TOOL_FEATURES: Record<string, FeatureFlag | null>;
28
+ /**
29
+ * Human-readable names for feature flags
30
+ */
31
+ export declare const FEATURE_DISPLAY_NAMES: Record<FeatureFlag, string>;
32
+ /**
33
+ * Tier information for upgrade messaging
34
+ */
35
+ export declare const FEATURE_TIERS: Record<FeatureFlag, 'team' | 'enterprise'>;
36
+ //# sourceMappingURL=toolFeatureMapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolFeatureMapping.d.ts","sourceRoot":"","sources":["../../../src/middleware/toolFeatureMapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAEnB,gBAAgB,GAChB,iBAAiB,GACjB,iBAAiB,GACjB,kBAAkB,GAElB,UAAU,GACV,MAAM,GACN,eAAe,GACf,aAAa,GACb,oBAAoB,GACpB,kBAAkB,GAElB,qBAAqB,GACrB,oBAAoB,CAAA;AAExB;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAoC5D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAgB7D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,CAgBpE,CAAA"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Tool-to-Feature mapping for license validation
3
+ *
4
+ * Maps MCP tool names to their required feature flags.
5
+ * null = community feature (no license required)
6
+ * string = feature flag that must be enabled in the license
7
+ *
8
+ * @see SMI-1055: Add license middleware to MCP server
9
+ * @see SMI-1091: Unified tier feature definitions across packages
10
+ */
11
+ /**
12
+ * Mapping of tool names to their required feature flags
13
+ *
14
+ * null = community tool (no license required)
15
+ * FeatureFlag = requires that feature to be enabled in license
16
+ */
17
+ export const TOOL_FEATURES = {
18
+ // Core tools - no feature required (null = community)
19
+ search: null,
20
+ get_skill: null,
21
+ install_skill: null,
22
+ uninstall_skill: null,
23
+ skill_recommend: null,
24
+ skill_validate: null,
25
+ skill_compare: null,
26
+ skill_suggest: null,
27
+ // Team tools - require team features
28
+ publish_private: 'private_skills',
29
+ team_workspace: 'team_workspaces',
30
+ share_skill: 'team_workspaces',
31
+ // Enterprise tools - require enterprise features
32
+ configure_sso: 'sso_saml',
33
+ sso_settings: 'sso_saml',
34
+ audit_export: 'audit_logging',
35
+ audit_query: 'audit_logging',
36
+ rbac_manage: 'rbac',
37
+ rbac_assign_role: 'rbac',
38
+ rbac_create_policy: 'rbac',
39
+ siem_export: 'siem_export',
40
+ compliance_report: 'compliance_reports',
41
+ private_registry_publish: 'private_registry',
42
+ private_registry_manage: 'private_registry',
43
+ // Analytics tools
44
+ analytics_dashboard: 'advanced_analytics',
45
+ usage_report: 'advanced_analytics',
46
+ // Integration tools
47
+ webhook_configure: 'custom_integrations',
48
+ api_key_manage: 'custom_integrations',
49
+ };
50
+ /**
51
+ * Human-readable names for feature flags
52
+ */
53
+ export const FEATURE_DISPLAY_NAMES = {
54
+ // Team tier features
55
+ private_skills: 'Private Skills',
56
+ team_workspaces: 'Team Workspaces',
57
+ usage_analytics: 'Usage Analytics',
58
+ priority_support: 'Priority Support',
59
+ // Enterprise tier features
60
+ sso_saml: 'SSO/SAML Integration',
61
+ rbac: 'Role-Based Access Control',
62
+ audit_logging: 'Audit Logging',
63
+ siem_export: 'SIEM Export',
64
+ compliance_reports: 'Compliance Reports',
65
+ private_registry: 'Private Registry',
66
+ // Additional features
67
+ custom_integrations: 'Custom Integrations',
68
+ advanced_analytics: 'Advanced Analytics',
69
+ };
70
+ /**
71
+ * Tier information for upgrade messaging
72
+ */
73
+ export const FEATURE_TIERS = {
74
+ // Team tier features
75
+ private_skills: 'team',
76
+ team_workspaces: 'team',
77
+ usage_analytics: 'team',
78
+ priority_support: 'team',
79
+ // Enterprise tier features
80
+ sso_saml: 'enterprise',
81
+ rbac: 'enterprise',
82
+ audit_logging: 'enterprise',
83
+ siem_export: 'enterprise',
84
+ compliance_reports: 'enterprise',
85
+ private_registry: 'enterprise',
86
+ // Additional features
87
+ custom_integrations: 'enterprise',
88
+ advanced_analytics: 'enterprise',
89
+ };
90
+ //# sourceMappingURL=toolFeatureMapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolFeatureMapping.js","sourceRoot":"","sources":["../../../src/middleware/toolFeatureMapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA4BH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAuC;IAC/D,sDAAsD;IACtD,MAAM,EAAE,IAAI;IACZ,SAAS,EAAE,IAAI;IACf,aAAa,EAAE,IAAI;IACnB,eAAe,EAAE,IAAI;IACrB,eAAe,EAAE,IAAI;IACrB,cAAc,EAAE,IAAI;IACpB,aAAa,EAAE,IAAI;IACnB,aAAa,EAAE,IAAI;IAEnB,qCAAqC;IACrC,eAAe,EAAE,gBAAgB;IACjC,cAAc,EAAE,iBAAiB;IACjC,WAAW,EAAE,iBAAiB;IAE9B,iDAAiD;IACjD,aAAa,EAAE,UAAU;IACzB,YAAY,EAAE,UAAU;IACxB,YAAY,EAAE,eAAe;IAC7B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1
+ /**
2
+ * SMI-911: First Run Detection and Tier 1 Skill Auto-Installation
3
+ *
4
+ * Detects first run of Skillsmith MCP server and provides:
5
+ * - First run detection via marker file
6
+ * - Tier 1 skills list for auto-installation
7
+ * - Welcome message formatting
8
+ *
9
+ * Tier 1 skills (from research doc):
10
+ * - varlock (score: 95) - Security foundation
11
+ * - commit (score: 92) - Git workflow
12
+ * - governance (score: 88) - Code quality
13
+ */
14
+ /**
15
+ * Skillsmith configuration directory
16
+ */
17
+ export declare const SKILLSMITH_DIR: string;
18
+ /**
19
+ * Marker file indicating first run is complete
20
+ */
21
+ export declare const FIRST_RUN_MARKER: string;
22
+ /**
23
+ * Tier 1 skill definition
24
+ */
25
+ export interface Tier1Skill {
26
+ /** Full skill ID (e.g., 'anthropic/varlock') */
27
+ id: string;
28
+ /** Short name for display */
29
+ name: string;
30
+ /** Quality score from research (0-100) */
31
+ score: number;
32
+ }
33
+ /**
34
+ * Tier 1 skills to auto-install on first run
35
+ *
36
+ * These are the highest-value, lowest-friction skills identified
37
+ * in the skill prioritization research.
38
+ */
39
+ export declare const TIER1_SKILLS: readonly Tier1Skill[];
40
+ /**
41
+ * Check if this is the first run of Skillsmith
42
+ *
43
+ * First run is detected by the absence of the marker file
44
+ * at ~/.skillsmith/.first-run-complete
45
+ *
46
+ * @returns true if this is the first run, false otherwise
47
+ */
48
+ export declare function isFirstRun(): boolean;
49
+ /**
50
+ * Mark first run as complete
51
+ *
52
+ * Creates the marker file at ~/.skillsmith/.first-run-complete
53
+ * with the current timestamp. Also ensures the .skillsmith
54
+ * directory exists.
55
+ */
56
+ export declare function markFirstRunComplete(): void;
57
+ /**
58
+ * Generate welcome message after first run setup
59
+ *
60
+ * @param installedSkills - List of skill names that were installed
61
+ * @returns Formatted welcome message
62
+ */
63
+ export declare function getWelcomeMessage(installedSkills: string[]): string;
64
+ //# sourceMappingURL=first-run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"first-run.d.ts","sourceRoot":"","sources":["../../../src/onboarding/first-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH;;GAEG;AACH,eAAO,MAAM,cAAc,QAAiC,CAAA;AAE5D;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAA8C,CAAA;AAE3E;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,gDAAgD;IAChD,EAAE,EAAE,MAAM,CAAA;IACV,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAIpC,CAAA;AAEV;;;;;;;GAOG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAK3C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,eAAe,EAAE,MAAM,EAAE,GAAG,MAAM,CAWnE"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * SMI-911: First Run Detection and Tier 1 Skill Auto-Installation
3
+ *
4
+ * Detects first run of Skillsmith MCP server and provides:
5
+ * - First run detection via marker file
6
+ * - Tier 1 skills list for auto-installation
7
+ * - Welcome message formatting
8
+ *
9
+ * Tier 1 skills (from research doc):
10
+ * - varlock (score: 95) - Security foundation
11
+ * - commit (score: 92) - Git workflow
12
+ * - governance (score: 88) - Code quality
13
+ */
14
+ import { existsSync, mkdirSync, writeFileSync } from 'fs';
15
+ import { join } from 'path';
16
+ import { homedir } from 'os';
17
+ /**
18
+ * Skillsmith configuration directory
19
+ */
20
+ export const SKILLSMITH_DIR = join(homedir(), '.skillsmith');
21
+ /**
22
+ * Marker file indicating first run is complete
23
+ */
24
+ export const FIRST_RUN_MARKER = join(SKILLSMITH_DIR, '.first-run-complete');
25
+ /**
26
+ * Tier 1 skills to auto-install on first run
27
+ *
28
+ * These are the highest-value, lowest-friction skills identified
29
+ * in the skill prioritization research.
30
+ */
31
+ export const TIER1_SKILLS = [
32
+ { id: 'anthropic/varlock', name: 'varlock', score: 95 },
33
+ { id: 'anthropic/commit', name: 'commit', score: 92 },
34
+ { id: 'anthropic/governance', name: 'governance', score: 88 },
35
+ ];
36
+ /**
37
+ * Check if this is the first run of Skillsmith
38
+ *
39
+ * First run is detected by the absence of the marker file
40
+ * at ~/.skillsmith/.first-run-complete
41
+ *
42
+ * @returns true if this is the first run, false otherwise
43
+ */
44
+ export function isFirstRun() {
45
+ return !existsSync(FIRST_RUN_MARKER);
46
+ }
47
+ /**
48
+ * Mark first run as complete
49
+ *
50
+ * Creates the marker file at ~/.skillsmith/.first-run-complete
51
+ * with the current timestamp. Also ensures the .skillsmith
52
+ * directory exists.
53
+ */
54
+ export function markFirstRunComplete() {
55
+ if (!existsSync(SKILLSMITH_DIR)) {
56
+ mkdirSync(SKILLSMITH_DIR, { recursive: true });
57
+ }
58
+ writeFileSync(FIRST_RUN_MARKER, new Date().toISOString());
59
+ }
60
+ /**
61
+ * Generate welcome message after first run setup
62
+ *
63
+ * @param installedSkills - List of skill names that were installed
64
+ * @returns Formatted welcome message
65
+ */
66
+ export function getWelcomeMessage(installedSkills) {
67
+ const skillList = installedSkills.map((s) => ` - ${s}`).join('\n');
68
+ return `
69
+ Welcome to Skillsmith!
70
+
71
+ Essential skills installed:
72
+ ${skillList}
73
+
74
+ Try: "Write a commit message" to see the commit skill in action.
75
+ `.trim();
76
+ }
77
+ //# sourceMappingURL=first-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"first-run.js","sourceRoot":"","sources":["../../../src/onboarding/first-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AAE5B;;GAEG;AACH,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to-installation functionality.
5
+ */
6
+ export { SKILLSMITH_DIR, FIRST_RUN_MARKER, TIER1_SKILLS, isFirstRun, markFirstRunComplete, getWelcomeMessage, type Tier1Skill, } from './first-run.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/onboarding/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,iBAAiB,EACjB,KAAK,UAAU,GAChB,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * SMI-911: Onboarding Module
3
+ *
4
+ * Exports first-run detection and Tier 1 skill auto-installation functionality.
5
+ */
6
+ export { SKILLSMITH_DIR, FIRST_RUN_MARKER, TIER1_SKILLS, isFirstRun, markFirstRunComplete, getWelcomeMessage, } from './first-run.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/onboarding/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,iBAAiB,GAElB,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @fileoverview Suggestion Module Exports
3
+ * @module @skillsmith/mcp-server/suggestions
4
+ * @see SMI-913: Contextual skill suggestions after first success
5
+ *
6
+ * Re-exports all suggestion-related types and the SuggestionEngine class.
7
+ *
8
+ * @example
9
+ * import {
10
+ * SuggestionEngine,
11
+ * type SkillSuggestion,
12
+ * type SuggestionConfig,
13
+ * type SuggestionState,
14
+ * } from './suggestions';
15
+ *
16
+ * const engine = new SuggestionEngine();
17
+ * const suggestions = engine.getSuggestions(context);
18
+ */
19
+ export { SuggestionEngine } from './suggestion-engine.js';
20
+ export type { SkillSuggestion, SuggestionConfig, SuggestionState } from './types.js';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/suggestions/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAEzD,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @fileoverview Suggestion Module Exports
3
+ * @module @skillsmith/mcp-server/suggestions
4
+ * @see SMI-913: Contextual skill suggestions after first success
5
+ *
6
+ * Re-exports all suggestion-related types and the SuggestionEngine class.
7
+ *
8
+ * @example
9
+ * import {
10
+ * SuggestionEngine,
11
+ * type SkillSuggestion,
12
+ * type SuggestionConfig,
13
+ * type SuggestionState,
14
+ * } from './suggestions';
15
+ *
16
+ * const engine = new SuggestionEngine();
17
+ * const suggestions = engine.getSuggestions(context);
18
+ */
19
+ export { SuggestionEngine } from './suggestion-engine.js';
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/suggestions/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA"}