@codemieai/code 0.0.58 → 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 (261) hide show
  1. package/README.md +56 -15
  2. package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
  3. package/dist/agents/core/BaseAgentAdapter.js +3 -0
  4. package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
  5. package/dist/agents/plugins/claude/claude.plugin.d.ts.map +1 -1
  6. package/dist/agents/plugins/claude/claude.plugin.js +18 -0
  7. package/dist/agents/plugins/claude/claude.plugin.js.map +1 -1
  8. package/dist/agents/plugins/claude/plugin/.claude-plugin/plugin.json +1 -1
  9. package/dist/agents/plugins/claude/plugin/commands/README.md +2 -31
  10. package/dist/agents/plugins/claude/plugin/commands/codemie-catchup.md +5 -0
  11. package/dist/agents/plugins/claude/plugin/commands/codemie-init.md +42 -43
  12. package/dist/agents/plugins/claude/plugin/commands/codemie-subagents.md +5 -0
  13. package/dist/agents/plugins/claude/plugin/commands/handoff.md +56 -0
  14. package/dist/agents/plugins/claude/plugin/commands/memory-refresh.md +5 -0
  15. package/dist/agents/plugins/claude/plugin/hooks/hooks.json +1 -1
  16. package/dist/agents/plugins/claude/plugin/scripts/bash/rtk-rewrite.sh +101 -0
  17. package/dist/agents/plugins/claude/plugin/skills/msgraph/README.md +4 -1
  18. package/dist/agents/plugins/claude/plugin/skills/msgraph/SKILL.md +27 -8
  19. package/dist/agents/plugins/claude/plugin/skills/msgraph/scripts/msgraph.js +63 -3
  20. package/dist/agents/plugins/claude/plugin/skills/report-issue/SKILL.md +1 -0
  21. package/dist/assets/demo.gif +0 -0
  22. package/dist/assets/skills-sh-egress-guard.cjs +166 -0
  23. package/dist/cli/commands/assistants/setup/constants.d.ts +1 -25
  24. package/dist/cli/commands/assistants/setup/constants.d.ts.map +1 -1
  25. package/dist/cli/commands/assistants/setup/constants.js +1 -20
  26. package/dist/cli/commands/assistants/setup/constants.js.map +1 -1
  27. package/dist/cli/commands/assistants/setup/generators/claude-agent-generator.d.ts +4 -4
  28. package/dist/cli/commands/assistants/setup/generators/claude-agent-generator.d.ts.map +1 -1
  29. package/dist/cli/commands/assistants/setup/generators/claude-agent-generator.js +11 -10
  30. package/dist/cli/commands/assistants/setup/generators/claude-agent-generator.js.map +1 -1
  31. package/dist/cli/commands/assistants/setup/generators/claude-skill-generator.d.ts +4 -4
  32. package/dist/cli/commands/assistants/setup/generators/claude-skill-generator.d.ts.map +1 -1
  33. package/dist/cli/commands/assistants/setup/generators/claude-skill-generator.js +11 -9
  34. package/dist/cli/commands/assistants/setup/generators/claude-skill-generator.js.map +1 -1
  35. package/dist/cli/commands/assistants/setup/helpers.d.ts +4 -18
  36. package/dist/cli/commands/assistants/setup/helpers.d.ts.map +1 -1
  37. package/dist/cli/commands/assistants/setup/helpers.js +10 -60
  38. package/dist/cli/commands/assistants/setup/helpers.js.map +1 -1
  39. package/dist/cli/commands/assistants/setup/index.d.ts +0 -8
  40. package/dist/cli/commands/assistants/setup/index.d.ts.map +1 -1
  41. package/dist/cli/commands/assistants/setup/index.js +20 -164
  42. package/dist/cli/commands/assistants/setup/index.js.map +1 -1
  43. package/dist/cli/commands/assistants/setup/selection/actions.d.ts +1 -30
  44. package/dist/cli/commands/assistants/setup/selection/actions.d.ts.map +1 -1
  45. package/dist/cli/commands/assistants/setup/selection/actions.js +1 -320
  46. package/dist/cli/commands/assistants/setup/selection/actions.js.map +1 -1
  47. package/dist/cli/commands/assistants/setup/selection/constants.d.ts +3 -65
  48. package/dist/cli/commands/assistants/setup/selection/constants.d.ts.map +1 -1
  49. package/dist/cli/commands/assistants/setup/selection/constants.js +4 -81
  50. package/dist/cli/commands/assistants/setup/selection/constants.js.map +1 -1
  51. package/dist/cli/commands/assistants/setup/selection/index.d.ts +1 -9
  52. package/dist/cli/commands/assistants/setup/selection/index.d.ts.map +1 -1
  53. package/dist/cli/commands/assistants/setup/selection/index.js +14 -34
  54. package/dist/cli/commands/assistants/setup/selection/index.js.map +1 -1
  55. package/dist/cli/commands/assistants/setup/selection/interactive-prompt.d.ts +1 -19
  56. package/dist/cli/commands/assistants/setup/selection/interactive-prompt.d.ts.map +1 -1
  57. package/dist/cli/commands/assistants/setup/selection/interactive-prompt.js +1 -338
  58. package/dist/cli/commands/assistants/setup/selection/interactive-prompt.js.map +1 -1
  59. package/dist/cli/commands/assistants/setup/selection/types.d.ts +7 -23
  60. package/dist/cli/commands/assistants/setup/selection/types.d.ts.map +1 -1
  61. package/dist/cli/commands/assistants/setup/selection/ui.d.ts +0 -8
  62. package/dist/cli/commands/assistants/setup/selection/ui.d.ts.map +1 -1
  63. package/dist/cli/commands/assistants/setup/selection/ui.js +7 -123
  64. package/dist/cli/commands/assistants/setup/selection/ui.js.map +1 -1
  65. package/dist/cli/commands/doctor/index.d.ts.map +1 -1
  66. package/dist/cli/commands/doctor/index.js +10 -1
  67. package/dist/cli/commands/doctor/index.js.map +1 -1
  68. package/dist/cli/commands/proxy/connectors/desktop-managed-mcp-servers.json +50 -0
  69. package/dist/cli/commands/proxy/connectors/desktop.d.ts +13 -3
  70. package/dist/cli/commands/proxy/connectors/desktop.d.ts.map +1 -1
  71. package/dist/cli/commands/proxy/connectors/desktop.js +47 -4
  72. package/dist/cli/commands/proxy/connectors/desktop.js.map +1 -1
  73. package/dist/cli/commands/proxy/index.d.ts.map +1 -1
  74. package/dist/cli/commands/proxy/index.js +89 -52
  75. package/dist/cli/commands/proxy/index.js.map +1 -1
  76. package/dist/cli/commands/setup.d.ts.map +1 -1
  77. package/dist/cli/commands/setup.js +2 -0
  78. package/dist/cli/commands/setup.js.map +1 -1
  79. package/dist/cli/commands/shared/constants.d.ts +15 -0
  80. package/dist/cli/commands/shared/constants.d.ts.map +1 -0
  81. package/dist/cli/commands/shared/constants.js +10 -0
  82. package/dist/cli/commands/shared/constants.js.map +1 -0
  83. package/dist/cli/commands/shared/helpers.d.ts +12 -0
  84. package/dist/cli/commands/shared/helpers.d.ts.map +1 -0
  85. package/dist/cli/commands/shared/helpers.js +54 -0
  86. package/dist/cli/commands/shared/helpers.js.map +1 -0
  87. package/dist/cli/commands/shared/prompts/storage-scope.d.ts +6 -0
  88. package/dist/cli/commands/shared/prompts/storage-scope.d.ts.map +1 -0
  89. package/dist/cli/commands/shared/prompts/storage-scope.js +84 -0
  90. package/dist/cli/commands/shared/prompts/storage-scope.js.map +1 -0
  91. package/dist/cli/commands/shared/selection/actions.d.ts +40 -0
  92. package/dist/cli/commands/shared/selection/actions.d.ts.map +1 -0
  93. package/dist/cli/commands/shared/selection/actions.js +264 -0
  94. package/dist/cli/commands/shared/selection/actions.js.map +1 -0
  95. package/dist/cli/commands/shared/selection/constants.d.ts +68 -0
  96. package/dist/cli/commands/shared/selection/constants.d.ts.map +1 -0
  97. package/dist/cli/commands/shared/selection/constants.js +70 -0
  98. package/dist/cli/commands/shared/selection/constants.js.map +1 -0
  99. package/dist/cli/commands/shared/selection/interactive-prompt.d.ts +16 -0
  100. package/dist/cli/commands/shared/selection/interactive-prompt.d.ts.map +1 -0
  101. package/dist/cli/commands/shared/selection/interactive-prompt.js +276 -0
  102. package/dist/cli/commands/shared/selection/interactive-prompt.js.map +1 -0
  103. package/dist/cli/commands/shared/selection/types.d.ts +31 -0
  104. package/dist/cli/commands/shared/selection/types.d.ts.map +1 -0
  105. package/dist/cli/commands/shared/selection/types.js +2 -0
  106. package/dist/cli/commands/shared/selection/types.js.map +1 -0
  107. package/dist/cli/commands/shared/selection/ui.d.ts +9 -0
  108. package/dist/cli/commands/shared/selection/ui.d.ts.map +1 -0
  109. package/dist/cli/commands/shared/selection/ui.js +92 -0
  110. package/dist/cli/commands/shared/selection/ui.js.map +1 -0
  111. package/dist/cli/commands/skills/add.d.ts +9 -0
  112. package/dist/cli/commands/skills/add.d.ts.map +1 -0
  113. package/dist/cli/commands/skills/add.js +187 -0
  114. package/dist/cli/commands/skills/add.js.map +1 -0
  115. package/dist/cli/commands/skills/find.d.ts +17 -0
  116. package/dist/cli/commands/skills/find.d.ts.map +1 -0
  117. package/dist/cli/commands/skills/find.js +94 -0
  118. package/dist/cli/commands/skills/find.js.map +1 -0
  119. package/dist/cli/commands/skills/index.d.ts +10 -0
  120. package/dist/cli/commands/skills/index.d.ts.map +1 -0
  121. package/dist/cli/commands/skills/index.js +23 -0
  122. package/dist/cli/commands/skills/index.js.map +1 -0
  123. package/dist/cli/commands/skills/lib/agent-detection.d.ts +27 -0
  124. package/dist/cli/commands/skills/lib/agent-detection.d.ts.map +1 -0
  125. package/dist/cli/commands/skills/lib/agent-detection.js +50 -0
  126. package/dist/cli/commands/skills/lib/agent-detection.js.map +1 -0
  127. package/dist/cli/commands/skills/lib/error-classify.d.ts +14 -0
  128. package/dist/cli/commands/skills/lib/error-classify.d.ts.map +1 -0
  129. package/dist/cli/commands/skills/lib/error-classify.js +64 -0
  130. package/dist/cli/commands/skills/lib/error-classify.js.map +1 -0
  131. package/dist/cli/commands/skills/lib/require-auth.d.ts +17 -0
  132. package/dist/cli/commands/skills/lib/require-auth.d.ts.map +1 -0
  133. package/dist/cli/commands/skills/lib/require-auth.js +44 -0
  134. package/dist/cli/commands/skills/lib/require-auth.js.map +1 -0
  135. package/dist/cli/commands/skills/lib/result-render.d.ts +26 -0
  136. package/dist/cli/commands/skills/lib/result-render.d.ts.map +1 -0
  137. package/dist/cli/commands/skills/lib/result-render.js +77 -0
  138. package/dist/cli/commands/skills/lib/result-render.js.map +1 -0
  139. package/dist/cli/commands/skills/lib/run-skills-cli.d.ts +46 -0
  140. package/dist/cli/commands/skills/lib/run-skills-cli.d.ts.map +1 -0
  141. package/dist/cli/commands/skills/lib/run-skills-cli.js +217 -0
  142. package/dist/cli/commands/skills/lib/run-skills-cli.js.map +1 -0
  143. package/dist/cli/commands/skills/lib/sanitize.d.ts +17 -0
  144. package/dist/cli/commands/skills/lib/sanitize.d.ts.map +1 -0
  145. package/dist/cli/commands/skills/lib/sanitize.js +73 -0
  146. package/dist/cli/commands/skills/lib/sanitize.js.map +1 -0
  147. package/dist/cli/commands/skills/lib/skills-metrics.d.ts +74 -0
  148. package/dist/cli/commands/skills/lib/skills-metrics.d.ts.map +1 -0
  149. package/dist/cli/commands/skills/lib/skills-metrics.js +268 -0
  150. package/dist/cli/commands/skills/lib/skills-metrics.js.map +1 -0
  151. package/dist/cli/commands/skills/lib/skills-search-client.d.ts +36 -0
  152. package/dist/cli/commands/skills/lib/skills-search-client.d.ts.map +1 -0
  153. package/dist/cli/commands/skills/lib/skills-search-client.js +147 -0
  154. package/dist/cli/commands/skills/lib/skills-search-client.js.map +1 -0
  155. package/dist/cli/commands/skills/lib/skills-sh-telemetry.d.ts +10 -0
  156. package/dist/cli/commands/skills/lib/skills-sh-telemetry.d.ts.map +1 -0
  157. package/dist/cli/commands/skills/lib/skills-sh-telemetry.js +33 -0
  158. package/dist/cli/commands/skills/lib/skills-sh-telemetry.js.map +1 -0
  159. package/dist/cli/commands/skills/list.d.ts +13 -0
  160. package/dist/cli/commands/skills/list.d.ts.map +1 -0
  161. package/dist/cli/commands/skills/list.js +55 -0
  162. package/dist/cli/commands/skills/list.js.map +1 -0
  163. package/dist/cli/commands/skills/remove.d.ts +11 -0
  164. package/dist/cli/commands/skills/remove.d.ts.map +1 -0
  165. package/dist/cli/commands/skills/remove.js +93 -0
  166. package/dist/cli/commands/skills/remove.js.map +1 -0
  167. package/dist/cli/commands/skills/setup/constants.d.ts +2 -0
  168. package/dist/cli/commands/skills/setup/constants.d.ts.map +1 -0
  169. package/dist/cli/commands/skills/setup/constants.js +2 -0
  170. package/dist/cli/commands/skills/setup/constants.js.map +1 -0
  171. package/dist/cli/commands/skills/setup/data.d.ts +28 -0
  172. package/dist/cli/commands/skills/setup/data.d.ts.map +1 -0
  173. package/dist/cli/commands/skills/setup/data.js +79 -0
  174. package/dist/cli/commands/skills/setup/data.js.map +1 -0
  175. package/dist/cli/commands/skills/setup/generators/claude-skill-generator.d.ts +12 -0
  176. package/dist/cli/commands/skills/setup/generators/claude-skill-generator.d.ts.map +1 -0
  177. package/dist/cli/commands/skills/setup/generators/claude-skill-generator.js +94 -0
  178. package/dist/cli/commands/skills/setup/generators/claude-skill-generator.js.map +1 -0
  179. package/dist/cli/commands/skills/setup/helpers.d.ts +12 -0
  180. package/dist/cli/commands/skills/setup/helpers.d.ts.map +1 -0
  181. package/dist/cli/commands/skills/setup/helpers.js +31 -0
  182. package/dist/cli/commands/skills/setup/helpers.js.map +1 -0
  183. package/dist/cli/commands/skills/setup/index.d.ts +5 -0
  184. package/dist/cli/commands/skills/setup/index.d.ts.map +1 -0
  185. package/dist/cli/commands/skills/setup/index.js +137 -0
  186. package/dist/cli/commands/skills/setup/index.js.map +1 -0
  187. package/dist/cli/commands/skills/setup/selection/actions.d.ts +2 -0
  188. package/dist/cli/commands/skills/setup/selection/actions.d.ts.map +1 -0
  189. package/dist/cli/commands/skills/setup/selection/actions.js +2 -0
  190. package/dist/cli/commands/skills/setup/selection/actions.js.map +1 -0
  191. package/dist/cli/commands/skills/setup/selection/constants.d.ts +11 -0
  192. package/dist/cli/commands/skills/setup/selection/constants.d.ts.map +1 -0
  193. package/dist/cli/commands/skills/setup/selection/constants.js +11 -0
  194. package/dist/cli/commands/skills/setup/selection/constants.js.map +1 -0
  195. package/dist/cli/commands/skills/setup/selection/index.d.ts +13 -0
  196. package/dist/cli/commands/skills/setup/selection/index.d.ts.map +1 -0
  197. package/dist/cli/commands/skills/setup/selection/index.js +113 -0
  198. package/dist/cli/commands/skills/setup/selection/index.js.map +1 -0
  199. package/dist/cli/commands/skills/setup/selection/interactive-prompt.d.ts +2 -0
  200. package/dist/cli/commands/skills/setup/selection/interactive-prompt.d.ts.map +1 -0
  201. package/dist/cli/commands/skills/setup/selection/interactive-prompt.js +2 -0
  202. package/dist/cli/commands/skills/setup/selection/interactive-prompt.js.map +1 -0
  203. package/dist/cli/commands/skills/setup/selection/types.d.ts +13 -0
  204. package/dist/cli/commands/skills/setup/selection/types.d.ts.map +1 -0
  205. package/dist/cli/commands/skills/setup/selection/types.js +2 -0
  206. package/dist/cli/commands/skills/setup/selection/types.js.map +1 -0
  207. package/dist/cli/commands/skills/setup/selection/ui.d.ts +3 -0
  208. package/dist/cli/commands/skills/setup/selection/ui.d.ts.map +1 -0
  209. package/dist/cli/commands/skills/setup/selection/ui.js +68 -0
  210. package/dist/cli/commands/skills/setup/selection/ui.js.map +1 -0
  211. package/dist/cli/commands/skills/setup/sync.d.ts +13 -0
  212. package/dist/cli/commands/skills/setup/sync.d.ts.map +1 -0
  213. package/dist/cli/commands/skills/setup/sync.js +46 -0
  214. package/dist/cli/commands/skills/setup/sync.js.map +1 -0
  215. package/dist/cli/commands/skills/update.d.ts +7 -0
  216. package/dist/cli/commands/skills/update.d.ts.map +1 -0
  217. package/dist/cli/commands/skills/update.js +71 -0
  218. package/dist/cli/commands/skills/update.js.map +1 -0
  219. package/dist/cli/first-time.d.ts.map +1 -1
  220. package/dist/cli/first-time.js +4 -0
  221. package/dist/cli/first-time.js.map +1 -1
  222. package/dist/cli/index.js +2 -0
  223. package/dist/cli/index.js.map +1 -1
  224. package/dist/env/types.d.ts +14 -0
  225. package/dist/env/types.d.ts.map +1 -1
  226. package/dist/env/types.js.map +1 -1
  227. package/dist/providers/core/types.d.ts +1 -1
  228. package/dist/providers/core/types.d.ts.map +1 -1
  229. package/dist/providers/plugins/anthropic-subscription/anthropic-subscription.template.d.ts.map +1 -1
  230. package/dist/providers/plugins/anthropic-subscription/anthropic-subscription.template.js +26 -2
  231. package/dist/providers/plugins/anthropic-subscription/anthropic-subscription.template.js.map +1 -1
  232. package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.d.ts +31 -0
  233. package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.d.ts.map +1 -0
  234. package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.js +148 -0
  235. package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.js.map +1 -0
  236. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts +12 -13
  237. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts.map +1 -1
  238. package/dist/providers/plugins/sso/proxy/plugins/index.js +15 -17
  239. package/dist/providers/plugins/sso/proxy/plugins/index.js.map +1 -1
  240. package/dist/providers/plugins/sso/sso.http-client.d.ts +1 -1
  241. package/dist/providers/plugins/sso/sso.http-client.js +3 -3
  242. package/dist/providers/plugins/sso/sso.http-client.js.map +1 -1
  243. package/dist/providers/plugins/sso/sso.models.js +2 -2
  244. package/dist/providers/plugins/sso/sso.models.js.map +1 -1
  245. package/dist/providers/plugins/sso/sso.setup-steps.d.ts.map +1 -1
  246. package/dist/providers/plugins/sso/sso.setup-steps.js +6 -10
  247. package/dist/providers/plugins/sso/sso.setup-steps.js.map +1 -1
  248. package/dist/utils/config.d.ts +14 -3
  249. package/dist/utils/config.d.ts.map +1 -1
  250. package/dist/utils/config.js +95 -5
  251. package/dist/utils/config.js.map +1 -1
  252. package/package.json +22 -10
  253. package/scripts/copy-plugins.js +5 -0
  254. package/scripts/sonar/package.json +3 -0
  255. package/scripts/sonar/run-local-sonar.js +405 -0
  256. package/dist/agents/plugins/claude/plugin/commands/codemie-commit.md +0 -31
  257. package/dist/agents/plugins/claude/plugin/scripts/bash/rtk-auto-wrapper.sh +0 -81
  258. package/dist/providers/plugins/sso/proxy/plugins/claude-thinking-transformer.plugin.d.ts +0 -30
  259. package/dist/providers/plugins/sso/proxy/plugins/claude-thinking-transformer.plugin.d.ts.map +0 -1
  260. package/dist/providers/plugins/sso/proxy/plugins/claude-thinking-transformer.plugin.js +0 -111
  261. package/dist/providers/plugins/sso/proxy/plugins/claude-thinking-transformer.plugin.js.map +0 -1
@@ -0,0 +1,217 @@
1
+ /**
2
+ * Spawns the upstream `skills` CLI as a child Node process with safe defaults:
3
+ *
4
+ * - Blocks upstream telemetry/audit egress to `add-skill.vercel.sh` via a
5
+ * `NODE_OPTIONS=--require <shim>` injection.
6
+ * - Sets `DO_NOT_TRACK` / `DISABLE_TELEMETRY` / `CI` so the upstream
7
+ * `track()` env gate is closed.
8
+ * - Inherits stdio so interactive prompts from `skills.sh` keep working.
9
+ *
10
+ * Resolution rules:
11
+ *
12
+ * - The skills bin is resolved from the project's `node_modules`
13
+ * (`skills/bin/cli.mjs`).
14
+ * - The egress shim is resolved from this module's own directory; both the
15
+ * source layout (`<repo>/src/cli/commands/skills/lib`) and the dist layout
16
+ * (`<repo>/dist/cli/commands/skills/lib`) are supported by walking up to
17
+ * the package root and checking `dist/assets/...` first, then
18
+ * `assets/...` as a fallback for ts-node / dev runs.
19
+ */
20
+ import { spawn } from 'node:child_process';
21
+ import { createRequire } from 'node:module';
22
+ import { existsSync } from 'node:fs';
23
+ import path from 'node:path';
24
+ import os from 'node:os';
25
+ import { logger } from '../../../../utils/logger.js';
26
+ import { getDirname } from '../../../../utils/paths.js';
27
+ import { SKILLS_SH_TELEMETRY_MARKER } from './skills-sh-telemetry.js';
28
+ const SHIM_FILENAME = 'skills-sh-egress-guard.cjs';
29
+ /**
30
+ * Spawn the upstream `skills` CLI directly (not via the project `exec()` helper)
31
+ * because that helper rejects on non-zero exit when `interactive: true`. We need
32
+ * to surface the real exit code so `classifySkillError()` can map upstream
33
+ * failures to stable `error_code` values; rejection collapses everything to
34
+ * `unknown`.
35
+ *
36
+ * Even in interactive mode, child stderr is captured (in addition to being
37
+ * tee'd to the parent terminal) so that markers like
38
+ * `CODEMIE_SKILL_EGRESS_BLOCKED` remain visible to the classifier.
39
+ */
40
+ export async function runSkillsCli(args, options = {}) {
41
+ const skillsBin = resolveSkillsBin();
42
+ const shimPath = resolveShimPath();
43
+ const interactive = options.interactive !== false;
44
+ const baseEnv = {
45
+ NODE_OPTIONS: buildNodeOptions(shimPath),
46
+ };
47
+ if (args[0] === 'add' || args[0] === 'remove' || args[0] === 'update') {
48
+ // We temporarily reopen upstream's telemetry gate only after resolving
49
+ // NODE_OPTIONS with the CodeMie egress guard shim. The shim captures the
50
+ // selected-skill payload locally and blocks add-skill.vercel.sh, so the
51
+ // request never leaves the machine.
52
+ baseEnv.DO_NOT_TRACK = '';
53
+ baseEnv.DISABLE_TELEMETRY = '';
54
+ baseEnv.CODEMIE_CAPTURE_SKILLS_SH_INSTALL_TELEMETRY = '1';
55
+ if (args[0] === 'update') {
56
+ baseEnv.CODEMIE_CAPTURE_SKILLS_SH_UPDATE_STDOUT = '1';
57
+ }
58
+ }
59
+ else {
60
+ baseEnv.DO_NOT_TRACK = '1';
61
+ baseEnv.DISABLE_TELEMETRY = '1';
62
+ }
63
+ // Force CI=1 only for non-interactive runs to suppress any prompts the
64
+ // upstream might fire. Forcing it on interactive runs interferes with
65
+ // Clack/inquirer prompt + spinner behavior; DO_NOT_TRACK / DISABLE_TELEMETRY
66
+ // already cover the telemetry gate.
67
+ if (!interactive) {
68
+ baseEnv.CI = process.env.CI ?? '1';
69
+ }
70
+ const env = { ...process.env, ...baseEnv, ...options.env };
71
+ const timeoutMs = options.timeoutMs;
72
+ logger.debug('[skills] Spawning skills CLI', {
73
+ bin: skillsBin,
74
+ args,
75
+ interactive,
76
+ shimPath,
77
+ });
78
+ return new Promise((resolve, reject) => {
79
+ // Interactive runs inherit stdout so the child sees a real TTY: Clack's
80
+ // multiselect renderer (used by skills.sh) computes visible rows from
81
+ // process.stdout.rows, which is undefined when stdout is a pipe — turning
82
+ // every prompt into an empty list. stderr stays piped so error markers
83
+ // (e.g. CODEMIE_SKILL_EGRESS_BLOCKED) still reach classifySkillError().
84
+ // Non-interactive callers (e.g. `list --json`) need captured stdout, so
85
+ // both streams pipe in that mode.
86
+ const stdio = interactive
87
+ ? ['inherit', 'inherit', 'pipe']
88
+ : ['inherit', 'pipe', 'pipe'];
89
+ const child = spawn(process.execPath, [skillsBin, ...args], {
90
+ cwd: options.cwd ?? process.cwd(),
91
+ env,
92
+ stdio,
93
+ windowsHide: os.platform() === 'win32',
94
+ });
95
+ let stdout = '';
96
+ let stderr = '';
97
+ let interactiveStderrBuffer = '';
98
+ let timedOut = false;
99
+ let timeout;
100
+ let forceKillTimeout;
101
+ let settled = false;
102
+ const cleanup = () => {
103
+ if (timeout) {
104
+ clearTimeout(timeout);
105
+ timeout = undefined;
106
+ }
107
+ if (forceKillTimeout) {
108
+ clearTimeout(forceKillTimeout);
109
+ forceKillTimeout = undefined;
110
+ }
111
+ };
112
+ const timeoutMessage = () => {
113
+ const seconds = Math.ceil((timeoutMs ?? 0) / 1000);
114
+ return `CODEMIE_SKILLS_TIMEOUT: skills CLI did not finish within ${seconds}s.`;
115
+ };
116
+ // stdout is null when inherited (interactive mode); only fires when piped.
117
+ child.stdout?.on('data', (data) => {
118
+ stdout += data.toString();
119
+ });
120
+ child.stderr?.on('data', (data) => {
121
+ const text = data.toString();
122
+ stderr += text;
123
+ if (interactive) {
124
+ interactiveStderrBuffer += text;
125
+ const lines = interactiveStderrBuffer.split(/\r?\n/);
126
+ interactiveStderrBuffer = lines.pop() ?? '';
127
+ for (const line of lines) {
128
+ if (!line.startsWith(`${SKILLS_SH_TELEMETRY_MARKER} `)) {
129
+ process.stderr.write(`${line}\n`);
130
+ }
131
+ }
132
+ }
133
+ });
134
+ child.on('error', (error) => {
135
+ if (settled) {
136
+ return;
137
+ }
138
+ settled = true;
139
+ cleanup();
140
+ reject(new Error(`Failed to spawn skills CLI: ${error.message}`));
141
+ });
142
+ child.on('close', (code, signal) => {
143
+ if (settled) {
144
+ return;
145
+ }
146
+ settled = true;
147
+ cleanup();
148
+ if (interactive &&
149
+ interactiveStderrBuffer.length > 0 &&
150
+ !interactiveStderrBuffer.startsWith(`${SKILLS_SH_TELEMETRY_MARKER} `)) {
151
+ process.stderr.write(interactiveStderrBuffer);
152
+ }
153
+ resolve({
154
+ code: timedOut ? 124 : code ?? (signal ? 130 : 1),
155
+ stdout: stdout.trim(),
156
+ stderr: stderr.trim(),
157
+ signal,
158
+ });
159
+ });
160
+ if (timeoutMs && timeoutMs > 0) {
161
+ timeout = setTimeout(() => {
162
+ timedOut = true;
163
+ const message = timeoutMessage();
164
+ stderr += stderr.length > 0 ? `\n${message}` : message;
165
+ child.kill('SIGTERM');
166
+ forceKillTimeout = setTimeout(() => {
167
+ if (!settled) {
168
+ child.kill('SIGKILL');
169
+ }
170
+ }, 5000);
171
+ }, timeoutMs);
172
+ }
173
+ });
174
+ }
175
+ function resolveSkillsBin() {
176
+ // Test-only override: e2e tests point this at a stub bin so they exercise
177
+ // the wrapper end-to-end without touching the network. Production code must
178
+ // never set this — it is intentionally undocumented to users.
179
+ const override = process.env.CODEMIE_SKILLS_BIN_OVERRIDE;
180
+ if (override && existsSync(override)) {
181
+ return override;
182
+ }
183
+ const requireFromHere = createRequire(import.meta.url);
184
+ try {
185
+ return requireFromHere.resolve('skills/bin/cli.mjs');
186
+ }
187
+ catch (error) {
188
+ throw new Error(`Failed to resolve "skills" CLI binary. Run "npm install" in the codemie-code package. Underlying error: ${error instanceof Error ? error.message : String(error)}`);
189
+ }
190
+ }
191
+ function resolveShimPath() {
192
+ const here = getDirname(import.meta.url);
193
+ // Walk up from <root>/src/cli/commands/skills/lib (or its dist twin) to <root>.
194
+ // Five "../" hops cover both layouts.
195
+ const projectRoot = path.resolve(here, '..', '..', '..', '..', '..');
196
+ const candidates = [
197
+ path.join(projectRoot, 'dist', 'assets', SHIM_FILENAME),
198
+ path.join(projectRoot, 'assets', SHIM_FILENAME),
199
+ ];
200
+ for (const candidate of candidates) {
201
+ if (existsSync(candidate)) {
202
+ return candidate;
203
+ }
204
+ }
205
+ throw new Error(`Failed to locate skills.sh egress guard shim "${SHIM_FILENAME}". Looked in: ${candidates.join(', ')}`);
206
+ }
207
+ function buildNodeOptions(shimAbsPath) {
208
+ // Forward slashes work on all platforms (Node accepts them on Windows too)
209
+ // and avoid backslash-handling edge cases in NODE_OPTIONS on Windows.
210
+ const normalizedPath = shimAbsPath.replaceAll('\\', '/');
211
+ const ours = `--require "${normalizedPath}"`;
212
+ const inherited = process.env.NODE_OPTIONS;
213
+ // Preserve user-supplied NODE_OPTIONS (e.g., --max-old-space-size) but
214
+ // append our require so the shim runs first in child processes.
215
+ return inherited ? `${inherited} ${ours}` : ours;
216
+ }
217
+ //# sourceMappingURL=run-skills-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-skills-cli.js","sourceRoot":"","sources":["../../../../../src/cli/commands/skills/lib/run-skills-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAEtE,MAAM,aAAa,GAAG,4BAA4B,CAAC;AAgBnD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAc,EACd,UAA+B,EAAE;IAEjC,MAAM,SAAS,GAAG,gBAAgB,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,KAAK,KAAK,CAAC;IAElD,MAAM,OAAO,GAA2B;QACtC,YAAY,EAAE,gBAAgB,CAAC,QAAQ,CAAC;KACzC,CAAC;IACF,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;QACtE,uEAAuE;QACvE,yEAAyE;QACzE,wEAAwE;QACxE,oCAAoC;QACpC,OAAO,CAAC,YAAY,GAAG,EAAE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}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Sanitizers for optional wrapper-known metric values.
3
+ *
4
+ * Strict goals:
5
+ * - strip user:pass credentials from URLs
6
+ * - normalize the user's home directory to `~/...`
7
+ * - strip control characters
8
+ * - cap string length and list size
9
+ *
10
+ * Non-goals:
11
+ * - classifying source as GitHub/GitLab/internal/public
12
+ * - resolving aliases or catalog metadata
13
+ */
14
+ export declare function sanitizeSource(source: string | undefined): string | undefined;
15
+ export declare function capList(values: readonly string[] | undefined, max?: number): string[] | undefined;
16
+ export declare function stripControlChars(value: string): string;
17
+ //# sourceMappingURL=sanitize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/skills/lib/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAgB7E;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,GAAE,MAAuB,GAAG,MAAM,EAAE,GAAG,SAAS,CAejH;AAqBD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Sanitizers for optional wrapper-known metric values.
3
+ *
4
+ * Strict goals:
5
+ * - strip user:pass credentials from URLs
6
+ * - normalize the user's home directory to `~/...`
7
+ * - strip control characters
8
+ * - cap string length and list size
9
+ *
10
+ * Non-goals:
11
+ * - classifying source as GitHub/GitLab/internal/public
12
+ * - resolving aliases or catalog metadata
13
+ */
14
+ import os from 'node:os';
15
+ const MAX_SOURCE_LENGTH = 256;
16
+ const MAX_LIST_ITEMS = 20;
17
+ const MAX_LIST_ITEM_LENGTH = 128;
18
+ // eslint-disable-next-line no-control-regex
19
+ const CONTROL_CHARS = /[\u0000-\u001F\u007F]/g;
20
+ export function sanitizeSource(source) {
21
+ if (!source) {
22
+ return undefined;
23
+ }
24
+ const trimmed = source.trim();
25
+ if (trimmed.length === 0) {
26
+ return undefined;
27
+ }
28
+ let cleaned = stripCredentials(trimmed);
29
+ cleaned = normalizeHome(cleaned);
30
+ cleaned = stripControlChars(cleaned);
31
+ cleaned = capLength(cleaned, MAX_SOURCE_LENGTH);
32
+ return cleaned.length > 0 ? cleaned : undefined;
33
+ }
34
+ export function capList(values, max = MAX_LIST_ITEMS) {
35
+ if (!values || values.length === 0) {
36
+ return undefined;
37
+ }
38
+ const cleaned = values
39
+ .map((value) => stripControlChars(value).trim())
40
+ .filter((value) => value.length > 0)
41
+ .map((value) => capLength(value, MAX_LIST_ITEM_LENGTH));
42
+ if (cleaned.length === 0) {
43
+ return undefined;
44
+ }
45
+ return cleaned.slice(0, max);
46
+ }
47
+ function stripCredentials(value) {
48
+ // Match scheme://user:pass@host or scheme://user@host and remove the user info
49
+ return value.replace(/^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)([^/@\s]+@)/, '$1');
50
+ }
51
+ function normalizeHome(value) {
52
+ const home = os.homedir();
53
+ if (!home) {
54
+ return value;
55
+ }
56
+ if (value === home) {
57
+ return '~';
58
+ }
59
+ if (value.startsWith(`${home}/`) || value.startsWith(`${home}\\`)) {
60
+ return `~${value.slice(home.length)}`;
61
+ }
62
+ return value;
63
+ }
64
+ export function stripControlChars(value) {
65
+ return value.replace(CONTROL_CHARS, '');
66
+ }
67
+ function capLength(value, max) {
68
+ if (value.length <= max) {
69
+ return value;
70
+ }
71
+ return `${value.slice(0, max - 1)}…`;
72
+ }
73
+ //# sourceMappingURL=sanitize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../../../../../src/cli/commands/skills/lib/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,MAAM,iBAAiB,GAAG,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AK,CAAC,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa;IACrC,+EAA+E;IAC/E,OAAO,KAAK,CAAC,OAAO,CAAC,4CAA4C,EAAE,IAAI,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;IAC1B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAO,GAAG,CAAC;IACb,CAAC;IACD,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC;QAClE,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;IACxC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAO,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,SAAS,CAAC,KAAa,EAAE,GAAW;IAC3C,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;AACvC,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Lifecycle event emitter for `codemie skills *` commands.
3
+ *
4
+ * Each event is POSTed to the CodeMie backend at `/v1/skills/events`, where
5
+ * it is persisted in Postgres (authoritative, durable) and mirrored to the
6
+ * legacy Elastic-backed metrics path. Postgres survives Elastic retention,
7
+ * so install-count / popularity queries remain accurate forever.
8
+ *
9
+ * Behaviour:
10
+ * - **Auth-gated (spec §7).** If no SSO credentials are present, the helper
11
+ * becomes a no-op silently — no event is sent.
12
+ * - **Fan-out per skill.** When the wrapper knows which skills the operation
13
+ * targets (explicit `--skill foo bar`), one POST is emitted per skill so
14
+ * the backend stores `(event, skill)` rows and trivial COUNT(*) queries
15
+ * work. For ops without a specific skill (bare `list`, interactive `add`),
16
+ * a single POST is sent with `skill_*` fields null.
17
+ * - **Best-effort.** Any failure to load credentials, resolve the API URL,
18
+ * or POST is logged at debug level and swallowed — telemetry must never
19
+ * block a real user command.
20
+ */
21
+ export type SkillCommand = 'add' | 'update' | 'remove' | 'list' | 'find';
22
+ export type SkillStatus = 'started' | 'completed' | 'failed';
23
+ export type SkillScope = 'global' | 'project' | 'unknown';
24
+ export type AgentSelectionMode = 'explicit' | 'auto_detected' | 'prompted' | 'upstream';
25
+ interface PartialAttributes {
26
+ scope?: SkillScope;
27
+ source?: string;
28
+ skill_names?: string[];
29
+ skill_count?: number;
30
+ target_agents?: string[];
31
+ agent_selection_mode?: AgentSelectionMode;
32
+ error_code?: string;
33
+ /**
34
+ * Forward-compat escape hatch matching the backend `attributes` JSONB
35
+ * field on `SkillEventRequest`. Use this for command-specific telemetry
36
+ * that does not fit the strict top-level schema.
37
+ */
38
+ attributes?: Record<string, unknown>;
39
+ }
40
+ export interface SkillMetricSession {
41
+ command: SkillCommand;
42
+ sessionId: string;
43
+ agentVersion: string;
44
+ workingDirectory: string;
45
+ /**
46
+ * Resolved transport. `null` when no SSO credentials are available — every
47
+ * `emit*` becomes a no-op.
48
+ */
49
+ transport: SkillEventTransport | null;
50
+ }
51
+ interface SkillEventTransport {
52
+ apiUrl: string;
53
+ cookieHeader: string;
54
+ cliVersion: string;
55
+ }
56
+ /**
57
+ * Build a metric session for a single `codemie skills <command>` invocation.
58
+ * Loads SSO credentials best-effort; if anything fails, returns a session
59
+ * whose `transport` is null and the lifecycle helpers become no-ops.
60
+ */
61
+ export declare function startSkillMetric(command: SkillCommand, workingDirectory?: string): Promise<SkillMetricSession>;
62
+ export declare function emitStarted(session: SkillMetricSession, partial: Pick<PartialAttributes, 'scope' | 'source' | 'skill_names' | 'skill_count' | 'target_agents' | 'agent_selection_mode'>): Promise<void>;
63
+ export declare function emitCompleted(session: SkillMetricSession, partial: PartialAttributes): Promise<void>;
64
+ export declare function emitFailed(session: SkillMetricSession, partial: PartialAttributes): Promise<void>;
65
+ /**
66
+ * Mirror of upstream `skills` CLI `toSkillSlug`. Keeping the algorithm
67
+ * byte-for-byte identical means the canonical `<source>/<slug>` we send
68
+ * matches whatever the upstream tooling computes, so cross-system joins
69
+ * (e.g. comparing our install counts to skills.sh download counts) work
70
+ * without a translation layer.
71
+ */
72
+ export declare function toSkillSlug(name: string): string;
73
+ export {};
74
+ //# sourceMappingURL=skills-metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills-metrics.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/skills/lib/skills-metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAgBH,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AACzE,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAC7D,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAC1D,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,eAAe,GAAG,UAAU,GAAG,UAAU,CAAC;AAExF,UAAU,iBAAiB;IACzB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM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