@codemieai/code 0.0.40 → 0.0.42

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 (211) hide show
  1. package/README.md +5 -6
  2. package/bin/codemie-opencode.js +8 -1
  3. package/dist/agents/codemie-code/agent.d.ts.map +1 -1
  4. package/dist/agents/codemie-code/agent.js +5 -0
  5. package/dist/agents/codemie-code/agent.js.map +1 -1
  6. package/dist/agents/codemie-code/skills/index.d.ts +4 -0
  7. package/dist/agents/codemie-code/skills/index.d.ts.map +1 -1
  8. package/dist/agents/codemie-code/skills/index.js +4 -0
  9. package/dist/agents/codemie-code/skills/index.js.map +1 -1
  10. package/dist/agents/codemie-code/skills/sync/SkillSync.d.ts +52 -0
  11. package/dist/agents/codemie-code/skills/sync/SkillSync.d.ts.map +1 -0
  12. package/dist/agents/codemie-code/skills/sync/SkillSync.js +165 -0
  13. package/dist/agents/codemie-code/skills/sync/SkillSync.js.map +1 -0
  14. package/dist/agents/core/AgentCLI.d.ts.map +1 -1
  15. package/dist/agents/core/AgentCLI.js +38 -8
  16. package/dist/agents/core/AgentCLI.js.map +1 -1
  17. package/dist/agents/core/BaseAgentAdapter.d.ts +11 -1
  18. package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
  19. package/dist/agents/core/BaseAgentAdapter.js +175 -18
  20. package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
  21. package/dist/agents/core/types.d.ts +18 -0
  22. package/dist/agents/core/types.d.ts.map +1 -1
  23. package/dist/agents/plugins/claude/claude-acp.plugin.d.ts +7 -0
  24. package/dist/agents/plugins/claude/claude-acp.plugin.d.ts.map +1 -1
  25. package/dist/agents/plugins/claude/claude-acp.plugin.js +10 -0
  26. package/dist/agents/plugins/claude/claude-acp.plugin.js.map +1 -1
  27. package/dist/agents/plugins/claude/claude.plugin-installer.d.ts +11 -0
  28. package/dist/agents/plugins/claude/claude.plugin-installer.d.ts.map +1 -1
  29. package/dist/agents/plugins/claude/claude.plugin-installer.js +32 -0
  30. package/dist/agents/plugins/claude/claude.plugin-installer.js.map +1 -1
  31. package/dist/agents/plugins/claude/claude.plugin.d.ts +1 -8
  32. package/dist/agents/plugins/claude/claude.plugin.d.ts.map +1 -1
  33. package/dist/agents/plugins/claude/claude.plugin.js +96 -101
  34. package/dist/agents/plugins/claude/claude.plugin.js.map +1 -1
  35. package/dist/agents/plugins/claude/plugin/.claude-plugin/plugin.json +1 -1
  36. package/dist/agents/plugins/claude/plugin/codemie-statusline.mjs +42 -0
  37. package/dist/agents/plugins/claude/plugin/hooks/hooks.json +10 -0
  38. package/dist/agents/plugins/claude/plugin/hooks/hooks.windows.json +98 -0
  39. package/dist/agents/plugins/claude/plugin/scripts/bash/rtk-auto-wrapper.sh +81 -0
  40. package/dist/agents/plugins/claude/plugin/scripts/bash/rtk-baseline.sh +39 -0
  41. package/dist/agents/plugins/claude/sounds-installer.d.ts.map +1 -1
  42. package/dist/agents/plugins/claude/sounds-installer.js +0 -4
  43. package/dist/agents/plugins/claude/sounds-installer.js.map +1 -1
  44. package/dist/agents/plugins/codemie-code-binary.d.ts +17 -0
  45. package/dist/agents/plugins/codemie-code-binary.d.ts.map +1 -0
  46. package/dist/agents/plugins/codemie-code-binary.js +94 -0
  47. package/dist/agents/plugins/codemie-code-binary.js.map +1 -0
  48. package/dist/agents/plugins/codemie-code-hooks/index.d.ts +3 -0
  49. package/dist/agents/plugins/codemie-code-hooks/index.d.ts.map +1 -0
  50. package/dist/agents/plugins/codemie-code-hooks/index.js +3 -0
  51. package/dist/agents/plugins/codemie-code-hooks/index.js.map +1 -0
  52. package/dist/agents/plugins/codemie-code-hooks/inject-hooks.d.ts +22 -0
  53. package/dist/agents/plugins/codemie-code-hooks/inject-hooks.d.ts.map +1 -0
  54. package/dist/agents/plugins/codemie-code-hooks/inject-hooks.js +64 -0
  55. package/dist/agents/plugins/codemie-code-hooks/inject-hooks.js.map +1 -0
  56. package/dist/agents/plugins/codemie-code-hooks/shell-hooks-source.d.ts +15 -0
  57. package/dist/agents/plugins/codemie-code-hooks/shell-hooks-source.d.ts.map +1 -0
  58. package/dist/agents/plugins/codemie-code-hooks/shell-hooks-source.js +522 -0
  59. package/dist/agents/plugins/codemie-code-hooks/shell-hooks-source.js.map +1 -0
  60. package/dist/agents/plugins/codemie-code.plugin.d.ts +56 -12
  61. package/dist/agents/plugins/codemie-code.plugin.d.ts.map +1 -1
  62. package/dist/agents/plugins/codemie-code.plugin.js +502 -125
  63. package/dist/agents/plugins/codemie-code.plugin.js.map +1 -1
  64. package/dist/agents/plugins/gemini/gemini.plugin.d.ts +8 -0
  65. package/dist/agents/plugins/gemini/gemini.plugin.d.ts.map +1 -1
  66. package/dist/agents/plugins/gemini/gemini.plugin.js +45 -1
  67. package/dist/agents/plugins/gemini/gemini.plugin.js.map +1 -1
  68. package/dist/agents/plugins/opencode/opencode-message-types.d.ts +2 -0
  69. package/dist/agents/plugins/opencode/opencode-message-types.d.ts.map +1 -1
  70. package/dist/agents/plugins/opencode/opencode-message-types.js.map +1 -1
  71. package/dist/agents/plugins/opencode/opencode-model-configs.d.ts +12 -2
  72. package/dist/agents/plugins/opencode/opencode-model-configs.d.ts.map +1 -1
  73. package/dist/agents/plugins/opencode/opencode-model-configs.js +329 -24
  74. package/dist/agents/plugins/opencode/opencode-model-configs.js.map +1 -1
  75. package/dist/agents/plugins/opencode/opencode.paths.d.ts +16 -1
  76. package/dist/agents/plugins/opencode/opencode.paths.d.ts.map +1 -1
  77. package/dist/agents/plugins/opencode/opencode.paths.js +43 -5
  78. package/dist/agents/plugins/opencode/opencode.paths.js.map +1 -1
  79. package/dist/agents/plugins/opencode/opencode.plugin.d.ts.map +1 -1
  80. package/dist/agents/plugins/opencode/opencode.plugin.js +91 -25
  81. package/dist/agents/plugins/opencode/opencode.plugin.js.map +1 -1
  82. package/dist/agents/plugins/opencode/opencode.session.d.ts +5 -0
  83. package/dist/agents/plugins/opencode/opencode.session.d.ts.map +1 -1
  84. package/dist/agents/plugins/opencode/opencode.session.js +99 -2
  85. package/dist/agents/plugins/opencode/opencode.session.js.map +1 -1
  86. package/dist/agents/plugins/opencode/opencode.sqlite-reader.d.ts +59 -0
  87. package/dist/agents/plugins/opencode/opencode.sqlite-reader.d.ts.map +1 -0
  88. package/dist/agents/plugins/opencode/opencode.sqlite-reader.js +200 -0
  89. package/dist/agents/plugins/opencode/opencode.sqlite-reader.js.map +1 -0
  90. package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.d.ts +3 -0
  91. package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.d.ts.map +1 -1
  92. package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.js +35 -13
  93. package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.js.map +1 -1
  94. package/dist/agents/registry.d.ts.map +1 -1
  95. package/dist/agents/registry.js +8 -7
  96. package/dist/agents/registry.js.map +1 -1
  97. package/dist/cli/commands/analytics/data-loader.js +1 -1
  98. package/dist/cli/commands/analytics/data-loader.js.map +1 -1
  99. package/dist/cli/commands/doctor/checks/AgentsCheck.d.ts.map +1 -1
  100. package/dist/cli/commands/doctor/checks/AgentsCheck.js +5 -2
  101. package/dist/cli/commands/doctor/checks/AgentsCheck.js.map +1 -1
  102. package/dist/cli/commands/doctor/checks/FrameworksCheck.d.ts.map +1 -1
  103. package/dist/cli/commands/doctor/checks/FrameworksCheck.js +5 -2
  104. package/dist/cli/commands/doctor/checks/FrameworksCheck.js.map +1 -1
  105. package/dist/cli/commands/doctor/checks/JWTAuthCheck.d.ts +9 -0
  106. package/dist/cli/commands/doctor/checks/JWTAuthCheck.d.ts.map +1 -0
  107. package/dist/cli/commands/doctor/checks/JWTAuthCheck.js +113 -0
  108. package/dist/cli/commands/doctor/checks/JWTAuthCheck.js.map +1 -0
  109. package/dist/cli/commands/doctor/checks/index.d.ts +1 -0
  110. package/dist/cli/commands/doctor/checks/index.d.ts.map +1 -1
  111. package/dist/cli/commands/doctor/checks/index.js +1 -0
  112. package/dist/cli/commands/doctor/checks/index.js.map +1 -1
  113. package/dist/cli/commands/doctor/index.d.ts.map +1 -1
  114. package/dist/cli/commands/doctor/index.js +2 -1
  115. package/dist/cli/commands/doctor/index.js.map +1 -1
  116. package/dist/cli/commands/hook.d.ts.map +1 -1
  117. package/dist/cli/commands/hook.js +28 -5
  118. package/dist/cli/commands/hook.js.map +1 -1
  119. package/dist/cli/commands/skill.d.ts.map +1 -1
  120. package/dist/cli/commands/skill.js +80 -1
  121. package/dist/cli/commands/skill.js.map +1 -1
  122. package/dist/cli/commands/test-metrics.d.ts +17 -0
  123. package/dist/cli/commands/test-metrics.d.ts.map +1 -0
  124. package/dist/cli/commands/test-metrics.js +198 -0
  125. package/dist/cli/commands/test-metrics.js.map +1 -0
  126. package/dist/cli/index.js +9 -13
  127. package/dist/cli/index.js.map +1 -1
  128. package/dist/env/types.d.ts +12 -2
  129. package/dist/env/types.d.ts.map +1 -1
  130. package/dist/env/types.js.map +1 -1
  131. package/dist/providers/core/types.d.ts +22 -1
  132. package/dist/providers/core/types.d.ts.map +1 -1
  133. package/dist/providers/core/types.js +12 -1
  134. package/dist/providers/core/types.js.map +1 -1
  135. package/dist/providers/index.d.ts +2 -0
  136. package/dist/providers/index.d.ts.map +1 -1
  137. package/dist/providers/index.js +2 -0
  138. package/dist/providers/index.js.map +1 -1
  139. package/dist/providers/integration/setup-ui.d.ts.map +1 -1
  140. package/dist/providers/integration/setup-ui.js +3 -1
  141. package/dist/providers/integration/setup-ui.js.map +1 -1
  142. package/dist/providers/plugins/jwt/index.d.ts +9 -0
  143. package/dist/providers/plugins/jwt/index.d.ts.map +1 -0
  144. package/dist/providers/plugins/jwt/index.js +13 -0
  145. package/dist/providers/plugins/jwt/index.js.map +1 -0
  146. package/dist/providers/plugins/jwt/jwt.setup-steps.d.ts +9 -0
  147. package/dist/providers/plugins/jwt/jwt.setup-steps.d.ts.map +1 -0
  148. package/dist/providers/plugins/jwt/jwt.setup-steps.js +153 -0
  149. package/dist/providers/plugins/jwt/jwt.setup-steps.js.map +1 -0
  150. package/dist/providers/plugins/jwt/jwt.template.d.ts +12 -0
  151. package/dist/providers/plugins/jwt/jwt.template.d.ts.map +1 -0
  152. package/dist/providers/plugins/jwt/jwt.template.js +55 -0
  153. package/dist/providers/plugins/jwt/jwt.template.js.map +1 -0
  154. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts +3 -1
  155. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts.map +1 -1
  156. package/dist/providers/plugins/sso/proxy/plugins/index.js +5 -1
  157. package/dist/providers/plugins/sso/proxy/plugins/index.js.map +1 -1
  158. package/dist/providers/plugins/sso/proxy/plugins/jwt-auth.plugin.d.ts +16 -0
  159. package/dist/providers/plugins/sso/proxy/plugins/jwt-auth.plugin.d.ts.map +1 -0
  160. package/dist/providers/plugins/sso/proxy/plugins/jwt-auth.plugin.js +53 -0
  161. package/dist/providers/plugins/sso/proxy/plugins/jwt-auth.plugin.js.map +1 -0
  162. package/dist/providers/plugins/sso/proxy/plugins/request-sanitizer.plugin.d.ts +25 -0
  163. package/dist/providers/plugins/sso/proxy/plugins/request-sanitizer.plugin.d.ts.map +1 -0
  164. package/dist/providers/plugins/sso/proxy/plugins/request-sanitizer.plugin.js +74 -0
  165. package/dist/providers/plugins/sso/proxy/plugins/request-sanitizer.plugin.js.map +1 -0
  166. package/dist/providers/plugins/sso/proxy/plugins/sso-auth.plugin.d.ts.map +1 -1
  167. package/dist/providers/plugins/sso/proxy/plugins/sso-auth.plugin.js +13 -2
  168. package/dist/providers/plugins/sso/proxy/plugins/sso-auth.plugin.js.map +1 -1
  169. package/dist/providers/plugins/sso/proxy/plugins/sso.session-sync.plugin.d.ts.map +1 -1
  170. package/dist/providers/plugins/sso/proxy/plugins/sso.session-sync.plugin.js +6 -3
  171. package/dist/providers/plugins/sso/proxy/plugins/sso.session-sync.plugin.js.map +1 -1
  172. package/dist/providers/plugins/sso/proxy/plugins/types.d.ts +2 -2
  173. package/dist/providers/plugins/sso/proxy/plugins/types.d.ts.map +1 -1
  174. package/dist/providers/plugins/sso/proxy/proxy-types.d.ts +2 -0
  175. package/dist/providers/plugins/sso/proxy/proxy-types.d.ts.map +1 -1
  176. package/dist/providers/plugins/sso/proxy/sso.proxy.d.ts +4 -0
  177. package/dist/providers/plugins/sso/proxy/sso.proxy.d.ts.map +1 -1
  178. package/dist/providers/plugins/sso/proxy/sso.proxy.js +39 -10
  179. package/dist/providers/plugins/sso/proxy/sso.proxy.js.map +1 -1
  180. package/dist/providers/plugins/sso/sso.auth.d.ts +3 -1
  181. package/dist/providers/plugins/sso/sso.auth.d.ts.map +1 -1
  182. package/dist/providers/plugins/sso/sso.auth.js +70 -12
  183. package/dist/providers/plugins/sso/sso.auth.js.map +1 -1
  184. package/dist/providers/plugins/sso/sso.http-client.d.ts +38 -8
  185. package/dist/providers/plugins/sso/sso.http-client.d.ts.map +1 -1
  186. package/dist/providers/plugins/sso/sso.http-client.js +83 -85
  187. package/dist/providers/plugins/sso/sso.http-client.js.map +1 -1
  188. package/dist/providers/plugins/sso/sso.models.d.ts.map +1 -1
  189. package/dist/providers/plugins/sso/sso.models.js +3 -3
  190. package/dist/providers/plugins/sso/sso.models.js.map +1 -1
  191. package/dist/providers/plugins/sso/sso.setup-steps.d.ts.map +1 -1
  192. package/dist/providers/plugins/sso/sso.setup-steps.js +4 -1
  193. package/dist/providers/plugins/sso/sso.setup-steps.js.map +1 -1
  194. package/dist/providers/plugins/sso/sso.template.d.ts.map +1 -1
  195. package/dist/providers/plugins/sso/sso.template.js +7 -0
  196. package/dist/providers/plugins/sso/sso.template.js.map +1 -1
  197. package/dist/utils/logger.d.ts +1 -0
  198. package/dist/utils/logger.d.ts.map +1 -1
  199. package/dist/utils/logger.js +16 -1
  200. package/dist/utils/logger.js.map +1 -1
  201. package/dist/utils/native-installer.d.ts.map +1 -1
  202. package/dist/utils/native-installer.js +35 -0
  203. package/dist/utils/native-installer.js.map +1 -1
  204. package/dist/utils/paths.d.ts +1 -1
  205. package/dist/utils/paths.js +1 -1
  206. package/dist/utils/security.d.ts +18 -1
  207. package/dist/utils/security.d.ts.map +1 -1
  208. package/dist/utils/security.js +102 -0
  209. package/dist/utils/security.js.map +1 -1
  210. package/package.json +2 -1
  211. package/scripts/copy-mr-skill-to-global.ts +0 -252
@@ -0,0 +1,98 @@
1
+ {
2
+ "description": "CodeMie session tracking hooks - unified command handler",
3
+ "hooks": {
4
+ "SessionStart": [
5
+ {
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "codemie hook",
10
+ "timeout": 5
11
+ },
12
+ {
13
+ "type": "command",
14
+ "command": "powershell -ExecutionPolicy Bypass -NonInteractive -File \"%USERPROFILE%\\.codemie\\claude-plugin\\sounds\\play-random-sound.ps1\" \"%USERPROFILE%\\.codemie\\sounds\\SessionStart\""
15
+ }
16
+ ]
17
+ }
18
+ ],
19
+ "SessionEnd": [
20
+ {
21
+ "hooks": [
22
+ {
23
+ "type": "command",
24
+ "command": "codemie hook",
25
+ "timeout": 10
26
+ }
27
+ ]
28
+ }
29
+ ],
30
+ "PermissionRequest": [
31
+ {
32
+ "hooks": [
33
+ {
34
+ "type": "command",
35
+ "command": "codemie hook",
36
+ "timeout": 2
37
+ },
38
+ {
39
+ "type": "command",
40
+ "command": "powershell -ExecutionPolicy Bypass -NonInteractive -File \"%USERPROFILE%\\.codemie\\claude-plugin\\sounds\\play-random-sound.ps1\" \"%USERPROFILE%\\.codemie\\sounds\\PermissionRequest\""
41
+ }
42
+ ]
43
+ }
44
+ ],
45
+ "SubagentStop": [
46
+ {
47
+ "hooks": [
48
+ {
49
+ "type": "command",
50
+ "command": "codemie hook",
51
+ "timeout": 3
52
+ }
53
+ ]
54
+ }
55
+ ],
56
+ "Stop": [
57
+ {
58
+ "hooks": [
59
+ {
60
+ "type": "command",
61
+ "command": "codemie hook",
62
+ "timeout": 2
63
+ },
64
+ {
65
+ "type": "command",
66
+ "command": "powershell -ExecutionPolicy Bypass -NonInteractive -File \"%USERPROFILE%\\.codemie\\claude-plugin\\sounds\\play-random-sound.ps1\" \"%USERPROFILE%\\.codemie\\sounds\\Stop\""
67
+ }
68
+ ]
69
+ }
70
+ ],
71
+ "UserPromptSubmit": [
72
+ {
73
+ "hooks": [
74
+ {
75
+ "type": "command",
76
+ "command": "codemie hook",
77
+ "timeout": 2
78
+ },
79
+ {
80
+ "type": "command",
81
+ "command": "powershell -ExecutionPolicy Bypass -NonInteractive -File \"%USERPROFILE%\\.codemie\\claude-plugin\\sounds\\play-random-sound.ps1\" \"%USERPROFILE%\\.codemie\\sounds\\UserPromptSubmit\""
82
+ }
83
+ ]
84
+ }
85
+ ],
86
+ "PreCompact": [
87
+ {
88
+ "hooks": [
89
+ {
90
+ "type": "command",
91
+ "command": "codemie hook",
92
+ "timeout": 2
93
+ }
94
+ ]
95
+ }
96
+ ]
97
+ }
98
+ }
@@ -0,0 +1,81 @@
1
+ #!/bin/bash
2
+ # RTK Auto-Wrapper Hook
3
+ # Automatically wraps high-verbosity commands with RTK for token optimization
4
+ #
5
+ # Hook: PreToolUse
6
+ # Matcher: Bash
7
+ # Purpose: Intercept bash commands and suggest RTK wrapper if applicable
8
+ #
9
+ # Installation:
10
+ # 1. Copy to .claude/hooks/bash/rtk-auto-wrapper.sh
11
+ # 2. Make executable: chmod +x .claude/hooks/bash/rtk-auto-wrapper.sh
12
+ # 3. Add to settings.json:
13
+ # {
14
+ # "hooks": {
15
+ # "PreToolUse": [{
16
+ # "matcher": "Bash",
17
+ # "hooks": [".claude/hooks/bash/rtk-auto-wrapper.sh"]
18
+ # }]
19
+ # }
20
+ # }
21
+ #
22
+ # Or use `rtk init` for automatic hook setup.
23
+
24
+ # Check if RTK is installed
25
+ if ! command -v rtk &> /dev/null; then
26
+ # RTK not installed, skip silently
27
+ exit 0
28
+ fi
29
+
30
+ # Parse tool input to get the bash command
31
+ COMMAND=$(echo "$TOOL_INPUT" | jq -r '.command // empty' 2>/dev/null)
32
+
33
+ if [ -z "$COMMAND" ]; then
34
+ # No command found, continue
35
+ exit 0
36
+ fi
37
+
38
+ # Define RTK-optimizable commands with their savings
39
+ declare -A RTK_COMMANDS=(
40
+ ["git log"]="92.3"
41
+ ["git status"]="76.0"
42
+ ["git diff"]="55.9"
43
+ ["find"]="76.3"
44
+ ["cargo test"]="90.0"
45
+ ["cargo build"]="80.0"
46
+ ["cargo clippy"]="80.0"
47
+ ["pnpm list"]="82.0"
48
+ ["pnpm outdated"]="90.0"
49
+ ["pnpm test"]="90.0"
50
+ ["python pytest"]="90.0"
51
+ ["python -m pytest"]="90.0"
52
+ ["go test"]="90.0"
53
+ )
54
+
55
+ # Check if command matches RTK-optimizable pattern
56
+ for cmd in "${!RTK_COMMANDS[@]}"; do
57
+ if [[ "$COMMAND" == "$cmd"* ]] && [[ "$COMMAND" != "rtk "* ]]; then
58
+ savings="${RTK_COMMANDS[$cmd]}"
59
+
60
+ # Suggest RTK wrapper
61
+ cat << EOF
62
+ RTK Optimization Available
63
+
64
+ Command: $COMMAND
65
+ Suggested: rtk $COMMAND
66
+ Token Savings: ~${savings}%
67
+
68
+ Using RTK wrapper automatically.
69
+ EOF
70
+
71
+ # Modify command to use RTK
72
+ # Note: This is informational only - actual command modification
73
+ # requires additionalContext return (Claude Code v2.1.9+)
74
+
75
+ # For now, just inform user
76
+ exit 0
77
+ fi
78
+ done
79
+
80
+ # Continue with original command
81
+ exit 0
@@ -0,0 +1,39 @@
1
+ #!/bin/bash
2
+ # .claude/hooks/rtk-baseline.sh
3
+ # Event: SessionStart
4
+ # Save RTK gain baseline for session-summary.sh delta tracking
5
+ #
6
+ # This hook captures RTK's cumulative stats at session start.
7
+ # At session end, session-summary.sh reads this baseline, captures current stats,
8
+ # and computes the delta to show per-session RTK savings.
9
+ #
10
+ # Configuration:
11
+ # SESSION_SUMMARY_RTK=0 - Force disable (skip baseline capture)
12
+ # SESSION_SUMMARY_RTK=1 - Force enable
13
+ # (default: auto-detect if rtk is in PATH)
14
+ #
15
+ # Place in: ~/.claude/hooks/rtk-baseline.sh
16
+ # Register in: ~/.claude/settings.json under SessionStart event
17
+
18
+ set -euo pipefail
19
+
20
+ RTK_ENABLED="${SESSION_SUMMARY_RTK:-auto}"
21
+
22
+ # Auto-detect RTK availability
23
+ if [[ "$RTK_ENABLED" == "auto" ]]; then
24
+ command -v rtk &>/dev/null && RTK_ENABLED=1 || RTK_ENABLED=0
25
+ fi
26
+
27
+ # Skip if disabled or RTK not available
28
+ if [[ "$RTK_ENABLED" != "1" ]]; then
29
+ exit 0
30
+ fi
31
+
32
+ # Build baseline file path (must match session-summary.sh)
33
+ baseline_key=$(echo "${CLAUDE_PROJECT_DIR:-$(pwd)}" | tr '/' '-')
34
+ baseline_file="/tmp/rtk-baseline${baseline_key}.txt"
35
+
36
+ # Capture current RTK cumulative stats
37
+ rtk gain > "$baseline_file" 2>/dev/null || true
38
+
39
+ exit 0
@@ -1 +1 @@
1
- {"version":3,"file":"sounds-installer.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/claude/sounds-installer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA2GH;;;;;GAKG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAqD5D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAI3C"}
1
+ {"version":3,"file":"sounds-installer.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/claude/sounds-installer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuGH;;;;;GAKG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAqD5D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAI3C"}
@@ -95,10 +95,6 @@ function displayPostInstallInstructions() {
95
95
  console.log(chalk.dim(' Script would appear after codemie-claude first run'));
96
96
  console.log(chalk.white('💡 If script did not appear, remove ~/.codemie/claude-plugin directory and restart codemie-claude'));
97
97
  console.log();
98
- console.log(chalk.bold.yellow('⚠️ WINDOWS USERS:'));
99
- console.log(chalk.yellow(' After codemie-claude first run, edit ~/.codemie/claude-plugin/hooks/hooks.json'));
100
- console.log(chalk.yellow(' Change all instances of "play-random-sound.sh" to "play-random-sound.ps1"'));
101
- console.log();
102
98
  }
103
99
  /**
104
100
  * Install fun sounds system
@@ -1 +1 @@
1
- {"version":3,"file":"sounds-installer.js","sourceRoot":"","sources":["../../../../src/agents/plugins/claude/sounds-installer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,UAAU,EAAC,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAC;AAClC,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAC;AAE5D;;;GAGG;AACH,KAAK,UAAU,gBAAgB;IAC3B,MAAM,OAAO,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAExD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC;YACD,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;YACtC,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;YAClE,OAAO,MAAM,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,uCAAuC;YACvC,MAAM,CAAC,KAAK,CAAC,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AC,CAAC;IAE3C,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Platform-specific package name mapping for @codemieai/codemie-opencode.
3
+ * The wrapper package lists these as optionalDependencies; npm only downloads
4
+ * the one matching the current platform.
5
+ */
6
+ export declare function getPlatformPackage(): string | null;
7
+ /**
8
+ * Resolve the bundled @codemieai/codemie-opencode binary from node_modules.
9
+ *
10
+ * Resolution order:
11
+ * 1. CODEMIE_OPENCODE_WL_BIN env var override (escape hatch)
12
+ * 2. Platform-specific binary from node_modules/@codemieai/codemie-opencode-{platform}-{arch}/bin/codemie
13
+ * 3. Wrapper package binary from node_modules/@codemieai/codemie-opencode/bin/codemie
14
+ * 4. Fallback: null (binary not found)
15
+ */
16
+ export declare function resolveCodemieOpenCodeBinary(): string | null;
17
+ //# sourceMappingURL=codemie-code-binary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codemie-code-binary.d.ts","sourceRoot":"","sources":["../../../src/agents/plugins/codemie-code-binary.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,IAAI,CAoBlD;AAuBD;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,IAAI,MAAM,GAAG,IAAI,CAyC5D"}
@@ -0,0 +1,94 @@
1
+ import { existsSync } from 'fs';
2
+ import { join, dirname } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import { logger } from '../../utils/logger.js';
5
+ /**
6
+ * Platform-specific package name mapping for @codemieai/codemie-opencode.
7
+ * The wrapper package lists these as optionalDependencies; npm only downloads
8
+ * the one matching the current platform.
9
+ */
10
+ export function getPlatformPackage() {
11
+ const platform = process.platform;
12
+ const arch = process.arch;
13
+ const platformMap = {
14
+ darwin: {
15
+ x64: '@codemieai/codemie-opencode-darwin-x64',
16
+ arm64: '@codemieai/codemie-opencode-darwin-arm64',
17
+ },
18
+ linux: {
19
+ x64: '@codemieai/codemie-opencode-linux-x64',
20
+ arm64: '@codemieai/codemie-opencode-linux-arm64',
21
+ },
22
+ win32: {
23
+ x64: '@codemieai/codemie-opencode-windows-x64',
24
+ arm64: '@codemieai/codemie-opencode-windows-arm64',
25
+ },
26
+ };
27
+ return platformMap[platform]?.[arch] ?? null;
28
+ }
29
+ /**
30
+ * Walk up from a starting directory looking for a node_modules directory
31
+ * that contains the given package.
32
+ */
33
+ function findPackageInNodeModules(startDir, packageName) {
34
+ let current = startDir;
35
+ while (true) {
36
+ const candidate = join(current, 'node_modules', packageName);
37
+ if (existsSync(candidate)) {
38
+ return candidate;
39
+ }
40
+ const parent = dirname(current);
41
+ if (parent === current)
42
+ break; // reached filesystem root
43
+ current = parent;
44
+ }
45
+ return null;
46
+ }
47
+ /**
48
+ * Resolve the bundled @codemieai/codemie-opencode binary from node_modules.
49
+ *
50
+ * Resolution order:
51
+ * 1. CODEMIE_OPENCODE_WL_BIN env var override (escape hatch)
52
+ * 2. Platform-specific binary from node_modules/@codemieai/codemie-opencode-{platform}-{arch}/bin/codemie
53
+ * 3. Wrapper package binary from node_modules/@codemieai/codemie-opencode/bin/codemie
54
+ * 4. Fallback: null (binary not found)
55
+ */
56
+ export function resolveCodemieOpenCodeBinary() {
57
+ // 1. Environment variable override
58
+ const envBin = process.env.CODEMIE_OPENCODE_WL_BIN;
59
+ if (envBin) {
60
+ if (existsSync(envBin)) {
61
+ logger.debug(`[codemie-code] Using binary from CODEMIE_OPENCODE_WL_BIN: ${envBin}`);
62
+ return envBin;
63
+ }
64
+ logger.warn(`[codemie-code] CODEMIE_OPENCODE_WL_BIN set but binary not found: ${envBin}`);
65
+ }
66
+ // Start searching from this module's directory
67
+ const moduleDir = dirname(fileURLToPath(import.meta.url));
68
+ const binName = process.platform === 'win32' ? 'codemie.exe' : 'codemie';
69
+ // 2. Try platform-specific package first (direct binary, no wrapper)
70
+ const platformPkg = getPlatformPackage();
71
+ if (platformPkg) {
72
+ const platformDir = findPackageInNodeModules(moduleDir, platformPkg);
73
+ if (platformDir) {
74
+ const platformBin = join(platformDir, 'bin', binName);
75
+ if (existsSync(platformBin)) {
76
+ logger.debug(`[codemie-code] Resolved platform binary: ${platformBin}`);
77
+ return platformBin;
78
+ }
79
+ }
80
+ }
81
+ // 3. Fall back to wrapper package binary
82
+ const wrapperDir = findPackageInNodeModules(moduleDir, '@codemieai/codemie-opencode');
83
+ if (wrapperDir) {
84
+ const wrapperBin = join(wrapperDir, 'bin', binName);
85
+ if (existsSync(wrapperBin)) {
86
+ logger.debug(`[codemie-code] Resolved wrapper binary: ${wrapperBin}`);
87
+ return wrapperBin;
88
+ }
89
+ }
90
+ // 4. Not found
91
+ logger.debug('[codemie-code] Binary not found in node_modules');
92
+ return null;
93
+ }
94
+ //# sourceMappingURL=codemie-code-binary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codemie-code-binary.js","sourceRoot":"","sources":["../../../src/agents/plugins/codemie-code-binary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IAChC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAE1B,MAAM,WAAW,GAA2C;QAC1D,MAAM,EAAE;YACN,GAAG,EAAE,wCAAwC;YAC7C,KAAK,EAAE,0CAA0C;SAClD;QACD,KAAK,EAAE;YACL,GAAG,EAAE,uCAAuC;YAC5C,KAAK,EAAE,yCAAyC;SACjD;QACD,KAAK,EAAE;YACL,GAAG,EAAE,yCAAyC;YAC9C,KAAK,EAAE,2CAA2C;SACnD;KACF,CAAC;IAEF,OAAO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EAAE,CAAC;QAChB,MAAM,WAAW,GAAG,wBAAwB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QACrE,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YACtD,IAAI,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC5B,MAAM,CAAC,KAAK,CAAC,4CAA4C,WAAW,EAAE,CAAC,CAAC;gBACxE,OAAO,WAAW,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IAED,yCAAyC;IACzC,MAAM,UAAU,GAAG,wBAAwB,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC;IACtF,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACpD,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3B,MAAM,CAAC,KAAK,CAAC,2CAA2C,UAAU,EAAE,CAAC,CAAC;YACtE,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;IAED,eAAe;IACf,MAAM,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAChE,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { getHooksPluginFileUrl, cleanupHooksPlugin } from './inject-hooks.js';
2
+ export { SHELL_HOOKS_PLUGIN_SOURCE } from './shell-hooks-source.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/codemie-code-hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { getHooksPluginFileUrl, cleanupHooksPlugin } from './inject-hooks.js';
2
+ export { SHELL_HOOKS_PLUGIN_SOURCE } from './shell-hooks-source.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/agents/plugins/codemie-code-hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Hooks Plugin Injection Utility
3
+ *
4
+ * Writes the shell-hooks plugin to a temp file and returns its file:// URL
5
+ * for injection into OpenCode's plugin array via OPENCODE_CONFIG_CONTENT.
6
+ *
7
+ * Lifecycle:
8
+ * 1. beforeRun: getHooksPluginFileUrl() writes plugin to /tmp/codemie-hooks/shell-hooks.ts
9
+ * 2. opencode binary loads plugin from file:// URL
10
+ * 3. process exit: cleanup handler removes temp file (best effort)
11
+ */
12
+ /**
13
+ * Write the shell-hooks plugin to a temp file and return its file:// URL.
14
+ * Idempotent — reuses the same file path if already written.
15
+ */
16
+ export declare function getHooksPluginFileUrl(): string;
17
+ /**
18
+ * Clean up temp plugin files (best effort).
19
+ * Called on process exit and can be called explicitly.
20
+ */
21
+ export declare function cleanupHooksPlugin(): void;
22
+ //# sourceMappingURL=inject-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inject-hooks.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/codemie-code-hooks/inject-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA2BH;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAa9C;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAUzC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Hooks Plugin Injection Utility
3
+ *
4
+ * Writes the shell-hooks plugin to a temp file and returns its file:// URL
5
+ * for injection into OpenCode's plugin array via OPENCODE_CONFIG_CONTENT.
6
+ *
7
+ * Lifecycle:
8
+ * 1. beforeRun: getHooksPluginFileUrl() writes plugin to /tmp/codemie-hooks/shell-hooks.ts
9
+ * 2. opencode binary loads plugin from file:// URL
10
+ * 3. process exit: cleanup handler removes temp file (best effort)
11
+ */
12
+ import { writeFileSync, unlinkSync, mkdirSync } from 'fs';
13
+ import { tmpdir } from 'os';
14
+ import { join } from 'path';
15
+ import { logger } from '../../../utils/logger.js';
16
+ import { SHELL_HOOKS_PLUGIN_SOURCE } from './shell-hooks-source.js';
17
+ const HOOKS_TEMP_DIR = join(tmpdir(), 'codemie-hooks');
18
+ const HOOKS_FILE_NAME = 'shell-hooks.ts';
19
+ let pluginFilePath = null;
20
+ let cleanupRegistered = false;
21
+ /**
22
+ * Register process exit handler for temp file cleanup (best effort).
23
+ * Only registers once.
24
+ */
25
+ function registerCleanupHandler() {
26
+ if (cleanupRegistered)
27
+ return;
28
+ cleanupRegistered = true;
29
+ process.on('exit', () => {
30
+ cleanupHooksPlugin();
31
+ });
32
+ }
33
+ /**
34
+ * Write the shell-hooks plugin to a temp file and return its file:// URL.
35
+ * Idempotent — reuses the same file path if already written.
36
+ */
37
+ export function getHooksPluginFileUrl() {
38
+ if (pluginFilePath) {
39
+ return `file://${pluginFilePath}`;
40
+ }
41
+ mkdirSync(HOOKS_TEMP_DIR, { recursive: true });
42
+ pluginFilePath = join(HOOKS_TEMP_DIR, HOOKS_FILE_NAME);
43
+ writeFileSync(pluginFilePath, SHELL_HOOKS_PLUGIN_SOURCE, 'utf-8');
44
+ registerCleanupHandler();
45
+ logger.debug(`[hooks] Wrote shell-hooks plugin to ${pluginFilePath}`);
46
+ return `file://${pluginFilePath}`;
47
+ }
48
+ /**
49
+ * Clean up temp plugin files (best effort).
50
+ * Called on process exit and can be called explicitly.
51
+ */
52
+ export function cleanupHooksPlugin() {
53
+ if (!pluginFilePath)
54
+ return;
55
+ try {
56
+ unlinkSync(pluginFilePath);
57
+ logger.debug(`[hooks] Cleaned up plugin: ${pluginFilePath}`);
58
+ }
59
+ catch {
60
+ // Ignore — file may already be deleted
61
+ }
62
+ pluginFilePath = null;
63
+ }
64
+ //# sourceMappingURL=inject-hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inject-hooks.js","sourceRoot":"","sources":["../../../../src/agents/plugins/codemie-code-hooks/inject-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEpE,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC;AACvD,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAEzC,IAAI,cAAc,GAAkB,IAAI,CAAC;AACzC,IAAI,iBAAiB,GAAG,KAAK,CAAC;AAE9B;;;GAGG;AACH,SAAS,sBAAsB;IAC7B,IAAI,iBAAiB;QAAE,OAAO;IAC9B,iBAAiB,GAAG,IAAI,CAAC;IAEzB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACtB,kBAAkB,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,UAAU,cAAc,EAAE,CAAC;IACpC,CAAC;IAED,SAAS,CAAC,cAAc,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,cAAc,GAAG,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;IAEvD,aAAa,CAAC,cAAc,EAAE,yBAAyB,EAAE,OAAO,CAAC,CAAC;IAClE,sBAAsB,EAAE,CAAC;IACzB,MAAM,CAAC,KAAK,CAAC,uCAAuC,cAAc,EAAE,CAAC,CAAC;IAEtE,OAAO,UAAU,cAAc,EAAE,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB;IAChC,IAAI,CAAC,cAAc;QAAE,OAAO;IAE5B,IAAI,CAAC;QACH,UAAU,CAAC,cAAc,CAAC,CAAC;QAC3B,MAAM,CAAC,KAAK,CAAC,8BAA8B,cAAc,EAAE,CAAC,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,uCAAuC;IACzC,CAAC;IACD,cAAc,GAAG,IAAI,CAAC;AACxB,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Shell Hooks Plugin Source
3
+ *
4
+ * Contains the OpenCode plugin TypeScript source as a string constant.
5
+ * At runtime this is written to a temp file and loaded by the OpenCode binary.
6
+ *
7
+ * The plugin reads hooks configuration from the OPENCODE_HOOKS environment variable
8
+ * (Anthropic/Claude Code format) and maps them to OpenCode plugin lifecycle hooks.
9
+ *
10
+ * Why a string constant: The plugin uses `import type { Plugin } from "@opencode-ai/plugin"`
11
+ * which doesn't exist in codemie-code's dependencies. Embedding as a string avoids
12
+ * TypeScript compilation issues. Bun strips the type import at runtime.
13
+ */
14
+ export declare const SHELL_HOOKS_PLUGIN_SOURCE = "\nimport type { Plugin } from \"@opencode-ai/plugin\";\nimport { execSync, spawn } from \"child_process\";\nimport { readFileSync, existsSync } from \"fs\";\nimport { join } from \"path\";\n\n// \u2500\u2500\u2500 Types \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\ninterface HookConfig {\n type: \"command\" | \"prompt\" | \"agent\";\n command?: string;\n timeout?: number; // seconds\n async?: boolean;\n}\n\ninterface HookMatcherEntry {\n matcher?: string;\n hooks: HookConfig[];\n}\n\ntype HookEventName =\n | \"PreToolUse\"\n | \"PostToolUse\"\n | \"UserPromptSubmit\"\n | \"PermissionRequest\"\n | \"PreCompact\"\n | \"SessionStart\"\n | \"SessionEnd\"\n | \"Stop\"\n | \"Notification\";\n\ninterface HooksConfig {\n hooks?: Partial<Record<HookEventName, HookMatcherEntry[]>>;\n}\n\ninterface HookStdinPayload {\n hook_event_name: string;\n session_id: string;\n cwd: string;\n permission_mode: string;\n transcript_path: string;\n tool_name?: string;\n tool_input?: Record<string, unknown>;\n tool_output?: string;\n prompt?: string;\n [key: string]: unknown;\n}\n\n// \u2500\u2500\u2500 Matcher (ported from codemie-code src/hooks/matcher.ts) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction matchesPattern(pattern: string, toolName: string): boolean {\n try {\n if (!pattern || pattern === \"*\") return true;\n if (/[|[\\]{}()]/.test(pattern)) {\n try {\n return new RegExp(\"^(\" + pattern + \")$\").test(toolName);\n } catch {\n return pattern === toolName;\n }\n }\n return pattern === toolName;\n } catch {\n return false;\n }\n}\n\n// \u2500\u2500\u2500 Config Loading \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction loadHooksConfig(): HooksConfig {\n // Priority 1: OPENCODE_HOOKS env var (set by codemie-code)\n const envHooks = process.env.OPENCODE_HOOKS;\n if (envHooks) {\n try {\n const parsed = JSON.parse(envHooks);\n if (parsed.hooks && Object.keys(parsed.hooks).length > 0) {\n return parsed as HooksConfig;\n }\n } catch {\n // Fall through to file-based config\n }\n }\n\n // Priority 2: .opencode/hooks.json in project directory\n const projectDir = process.env.OPENCODE_PROJECT_DIR || process.cwd();\n const hooksFile = join(projectDir, \".opencode\", \"hooks.json\");\n if (existsSync(hooksFile)) {\n try {\n const content = readFileSync(hooksFile, \"utf-8\");\n const parsed = JSON.parse(content);\n if (parsed.hooks) return parsed as HooksConfig;\n } catch {\n // Ignore parse errors\n }\n }\n\n return { hooks: {} };\n}\n\n// \u2500\u2500\u2500 Hook Resolution \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction getMatchingCommands(\n config: HooksConfig,\n event: HookEventName,\n toolName?: string,\n): Array<{ command: string; timeout: number; isAsync: boolean }> {\n const matchers = config.hooks?.[event];\n if (!matchers || matchers.length === 0) return [];\n\n const result: Array<{ command: string; timeout: number; isAsync: boolean }> = [];\n\n for (const entry of matchers) {\n const pattern = entry.matcher || \"*\";\n const shouldMatch = !toolName || matchesPattern(pattern, toolName);\n if (!shouldMatch) continue;\n\n for (const hook of entry.hooks) {\n // Only support \"command\" type \u2014 skip \"prompt\" and \"agent\"\n if (hook.type !== \"command\" || !hook.command) continue;\n result.push({\n command: hook.command,\n timeout: (hook.timeout || 60) * 1000, // seconds \u2192 ms\n isAsync: hook.async === true,\n });\n }\n }\n\n return result;\n}\n\n// \u2500\u2500\u2500 Shell Execution \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction buildEnvVars(sessionId: string, event: string): Record<string, string> {\n const projectDir = process.env.OPENCODE_PROJECT_DIR || process.cwd();\n return {\n OPENCODE_PROJECT_DIR: projectDir,\n OPENCODE_SESSION_ID: sessionId,\n OPENCODE_HOOK_EVENT: event,\n CLAUDE_PROJECT_DIR: projectDir, // Anthropic alias\n };\n}\n\ninterface ExecResult {\n stdout: string;\n stderr: string;\n exitCode: number;\n}\n\nfunction execCommand(\n command: string,\n stdin: string,\n env: Record<string, string>,\n timeout: number,\n): ExecResult {\n try {\n const stdout = execSync(command, {\n input: stdin,\n timeout,\n env: { ...process.env, ...env },\n encoding: \"utf-8\",\n maxBuffer: 1024 * 1024,\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n });\n return { stdout: stdout || \"\", stderr: \"\", exitCode: 0 };\n } catch (err: any) {\n return {\n stdout: err.stdout || \"\",\n stderr: err.stderr || \"\",\n exitCode: typeof err.status === \"number\" ? err.status : 1,\n };\n }\n}\n\nfunction execCommandAsync(\n command: string,\n stdin: string,\n env: Record<string, string>,\n): void {\n const child = spawn(\"sh\", [\"-c\", command], {\n env: { ...process.env, ...env },\n stdio: [\"pipe\", \"ignore\", \"ignore\"],\n detached: true,\n });\n if (child.stdin) {\n child.stdin.write(stdin);\n child.stdin.end();\n }\n child.unref();\n}\n\n// \u2500\u2500\u2500 Response Parsing \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\ninterface ParsedResponse {\n blocked: boolean;\n reason?: string;\n updatedInput?: Record<string, unknown>;\n permissionDecision?: \"allow\" | \"deny\" | \"ask\";\n additionalContext?: string;\n}\n\nfunction parseResponse(\n result: ExecResult,\n event: HookEventName,\n): ParsedResponse {\n // Exit code 2 = block\n if (result.exitCode === 2) {\n const reason = [result.stderr, result.stdout.trim()].filter(Boolean).join(\"\\n\");\n return { blocked: true, reason: reason || \"Hook blocked execution (exit code 2)\" };\n }\n\n // Non-zero, non-2 = non-blocking error (allow)\n if (result.exitCode !== 0) {\n return { blocked: false };\n }\n\n // Parse stdout JSON\n const trimmed = result.stdout.trim();\n if (!trimmed) return { blocked: false };\n\n try {\n const json = JSON.parse(trimmed);\n\n // PreToolUse: check for hookSpecificOutput.updatedInput or plain object \u2192 merge into args\n if (event === \"PreToolUse\") {\n const updated = json.hookSpecificOutput?.updatedInput || json.updatedInput;\n if (updated && typeof updated === \"object\") {\n return { blocked: false, updatedInput: updated };\n }\n // If it's a plain object without known keys, treat as updatedInput\n if (typeof json === \"object\" && !json.hookSpecificOutput && !json.decision) {\n return { blocked: false, updatedInput: json };\n }\n }\n\n // PermissionRequest: check for permissionDecision\n if (event === \"PermissionRequest\") {\n const decision =\n json.hookSpecificOutput?.permissionDecision || json.permissionDecision;\n if (decision && [\"allow\", \"deny\", \"ask\"].includes(decision)) {\n return { blocked: false, permissionDecision: decision };\n }\n // Plain string\n if (typeof json === \"string\" && [\"allow\", \"deny\", \"ask\"].includes(json)) {\n return { blocked: false, permissionDecision: json };\n }\n }\n\n // PreCompact: additionalContext\n if (event === \"PreCompact\") {\n const context = json.additionalContext || json.context;\n if (typeof context === \"string\") {\n return { blocked: false, additionalContext: context };\n }\n }\n\n return { blocked: false };\n } catch {\n // Non-JSON output \u2014 treat as informational\n return { blocked: false };\n }\n}\n\n// \u2500\u2500\u2500 Plugin Definition \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst config = loadHooksConfig();\nconst hasHooks = config.hooks && Object.keys(config.hooks).length > 0;\n\nconst plugin: Plugin = {\n name: \"shell-hooks\",\n ...(hasHooks\n ? {\n hooks: {\n // PreToolUse \u2192 tool.execute.before (blocking)\n tool: {\n execute: {\n before: async (input) => {\n const commands = getMatchingCommands(config, \"PreToolUse\", input.tool);\n if (commands.length === 0) return input;\n\n const sessionId = process.env.OPENCODE_SESSION_ID || \"\";\n const env = buildEnvVars(sessionId, \"PreToolUse\");\n const payload: HookStdinPayload = {\n hook_event_name: \"PreToolUse\",\n session_id: sessionId,\n cwd: process.cwd(),\n permission_mode: \"default\",\n transcript_path: \"\",\n tool_name: input.tool,\n tool_input: input.args as Record<string, unknown>,\n };\n const stdin = JSON.stringify(payload);\n\n let mergedInput = { ...input };\n for (const cmd of commands) {\n if (cmd.isAsync) {\n execCommandAsync(cmd.command, stdin, env);\n continue;\n }\n const result = execCommand(cmd.command, stdin, env, cmd.timeout);\n const parsed = parseResponse(result, \"PreToolUse\");\n if (parsed.blocked) {\n throw new Error(parsed.reason || \"Hook blocked tool execution\");\n }\n if (parsed.updatedInput) {\n mergedInput = {\n ...mergedInput,\n args: { ...(mergedInput.args as Record<string, unknown>), ...parsed.updatedInput },\n };\n }\n }\n return mergedInput;\n },\n\n // PostToolUse \u2192 tool.execute.after (fire-and-forget)\n after: async (output) => {\n const commands = getMatchingCommands(config, \"PostToolUse\", output.tool);\n if (commands.length === 0) return output;\n\n const sessionId = process.env.OPENCODE_SESSION_ID || \"\";\n const env = buildEnvVars(sessionId, \"PostToolUse\");\n const payload: HookStdinPayload = {\n hook_event_name: \"PostToolUse\",\n session_id: sessionId,\n cwd: process.cwd(),\n permission_mode: \"default\",\n transcript_path: \"\",\n tool_name: output.tool,\n tool_input: output.args as Record<string, unknown>,\n tool_output: typeof output.result === \"string\" ? output.result : JSON.stringify(output.result),\n };\n const stdin = JSON.stringify(payload);\n\n for (const cmd of commands) {\n if (cmd.isAsync) {\n execCommandAsync(cmd.command, stdin, env);\n continue;\n }\n try {\n execCommand(cmd.command, stdin, env, cmd.timeout);\n } catch {\n // PostToolUse is fire-and-forget\n }\n }\n return output;\n },\n },\n },\n\n // UserPromptSubmit \u2192 chat.message (blocking)\n chat: {\n message: async (input) => {\n const commands = getMatchingCommands(config, \"UserPromptSubmit\");\n if (commands.length === 0) return input;\n\n const sessionId = process.env.OPENCODE_SESSION_ID || \"\";\n const env = buildEnvVars(sessionId, \"UserPromptSubmit\");\n const payload: HookStdinPayload = {\n hook_event_name: \"UserPromptSubmit\",\n session_id: sessionId,\n cwd: process.cwd(),\n permission_mode: \"default\",\n transcript_path: \"\",\n prompt: Array.isArray(input.parts)\n ? input.parts\n .filter((p: any) => p.type === \"text\")\n .map((p: any) => p.text)\n .join(\"\\n\")\n : String(input.parts),\n };\n const stdin = JSON.stringify(payload);\n\n for (const cmd of commands) {\n if (cmd.isAsync) {\n execCommandAsync(cmd.command, stdin, env);\n continue;\n }\n const result = execCommand(cmd.command, stdin, env, cmd.timeout);\n const parsed = parseResponse(result, \"UserPromptSubmit\");\n if (parsed.blocked) {\n // Clear message parts to block submission\n return { ...input, parts: [] };\n }\n }\n return input;\n },\n },\n\n // PermissionRequest \u2192 permission.ask (blocking)\n permission: {\n ask: async (input) => {\n const commands = getMatchingCommands(config, \"PermissionRequest\", input.tool);\n if (commands.length === 0) return input;\n\n const sessionId = process.env.OPENCODE_SESSION_ID || \"\";\n const env = buildEnvVars(sessionId, \"PermissionRequest\");\n const payload: HookStdinPayload = {\n hook_event_name: \"PermissionRequest\",\n session_id: sessionId,\n cwd: process.cwd(),\n permission_mode: \"default\",\n transcript_path: \"\",\n tool_name: input.tool,\n tool_input: input.args as Record<string, unknown>,\n };\n const stdin = JSON.stringify(payload);\n\n for (const cmd of commands) {\n if (cmd.isAsync) {\n execCommandAsync(cmd.command, stdin, env);\n continue;\n }\n const result = execCommand(cmd.command, stdin, env, cmd.timeout);\n const parsed = parseResponse(result, \"PermissionRequest\");\n if (parsed.permissionDecision === \"allow\") {\n return { ...input, allowed: true };\n }\n if (parsed.permissionDecision === \"deny\") {\n return { ...input, allowed: false };\n }\n }\n return input;\n },\n },\n\n // PreCompact \u2192 experimental.session.compacting (non-blocking)\n experimental: {\n session: {\n compacting: async (input) => {\n const commands = getMatchingCommands(config, \"PreCompact\");\n if (commands.length === 0) return input;\n\n const sessionId = process.env.OPENCODE_SESSION_ID || \"\";\n const env = buildEnvVars(sessionId, \"PreCompact\");\n const payload: HookStdinPayload = {\n hook_event_name: \"PreCompact\",\n session_id: sessionId,\n cwd: process.cwd(),\n permission_mode: \"default\",\n transcript_path: \"\",\n };\n const stdin = JSON.stringify(payload);\n\n for (const cmd of commands) {\n if (cmd.isAsync) {\n execCommandAsync(cmd.command, stdin, env);\n continue;\n }\n try {\n const result = execCommand(cmd.command, stdin, env, cmd.timeout);\n const parsed = parseResponse(result, \"PreCompact\");\n if (parsed.additionalContext) {\n return {\n ...input,\n context: ((input as any).context || \"\") + \"\\n\" + parsed.additionalContext,\n };\n }\n } catch {\n // Non-blocking\n }\n }\n return input;\n },\n },\n },\n\n // SessionStart/SessionEnd/Stop/Notification \u2192 event (non-blocking)\n event: async (input) => {\n let hookEvent: HookEventName | undefined;\n const eventType = (input as any).type || (input as any).event;\n if (eventType === \"session.created\") hookEvent = \"SessionStart\";\n else if (eventType === \"session.deleted\") hookEvent = \"SessionEnd\";\n else if (eventType === \"session.idle\") hookEvent = \"Stop\";\n else if (eventType === \"session.error\") hookEvent = \"Notification\";\n\n if (!hookEvent) return;\n\n const commands = getMatchingCommands(config, hookEvent);\n if (commands.length === 0) return;\n\n const sessionId = process.env.OPENCODE_SESSION_ID || \"\";\n const env = buildEnvVars(sessionId, hookEvent);\n const payload: HookStdinPayload = {\n hook_event_name: hookEvent,\n session_id: sessionId,\n cwd: process.cwd(),\n permission_mode: \"default\",\n transcript_path: \"\",\n };\n const stdin = JSON.stringify(payload);\n\n for (const cmd of commands) {\n if (cmd.isAsync) {\n execCommandAsync(cmd.command, stdin, env);\n continue;\n }\n try {\n execCommand(cmd.command, stdin, env, cmd.timeout);\n } catch {\n // Event hooks are non-blocking\n }\n }\n },\n },\n }\n : {}),\n};\n\nexport default plugin;\n";
15
+ //# sourceMappingURL=shell-hooks-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-hooks-source.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/codemie-code-hooks/shell-hooks-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,yBAAyB,stmBA2frC,CAAC"}