@link-assistant/hive-mind 0.39.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 (63) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/LICENSE +24 -0
  3. package/README.md +769 -0
  4. package/package.json +58 -0
  5. package/src/agent.lib.mjs +705 -0
  6. package/src/agent.prompts.lib.mjs +196 -0
  7. package/src/buildUserMention.lib.mjs +71 -0
  8. package/src/claude-limits.lib.mjs +389 -0
  9. package/src/claude.lib.mjs +1445 -0
  10. package/src/claude.prompts.lib.mjs +203 -0
  11. package/src/codex.lib.mjs +552 -0
  12. package/src/codex.prompts.lib.mjs +194 -0
  13. package/src/config.lib.mjs +207 -0
  14. package/src/contributing-guidelines.lib.mjs +268 -0
  15. package/src/exit-handler.lib.mjs +205 -0
  16. package/src/git.lib.mjs +145 -0
  17. package/src/github-issue-creator.lib.mjs +246 -0
  18. package/src/github-linking.lib.mjs +152 -0
  19. package/src/github.batch.lib.mjs +272 -0
  20. package/src/github.graphql.lib.mjs +258 -0
  21. package/src/github.lib.mjs +1479 -0
  22. package/src/hive.config.lib.mjs +254 -0
  23. package/src/hive.mjs +1500 -0
  24. package/src/instrument.mjs +191 -0
  25. package/src/interactive-mode.lib.mjs +1000 -0
  26. package/src/lenv-reader.lib.mjs +206 -0
  27. package/src/lib.mjs +490 -0
  28. package/src/lino.lib.mjs +176 -0
  29. package/src/local-ci-checks.lib.mjs +324 -0
  30. package/src/memory-check.mjs +419 -0
  31. package/src/model-mapping.lib.mjs +145 -0
  32. package/src/model-validation.lib.mjs +278 -0
  33. package/src/opencode.lib.mjs +479 -0
  34. package/src/opencode.prompts.lib.mjs +194 -0
  35. package/src/protect-branch.mjs +159 -0
  36. package/src/review.mjs +433 -0
  37. package/src/reviewers-hive.mjs +643 -0
  38. package/src/sentry.lib.mjs +284 -0
  39. package/src/solve.auto-continue.lib.mjs +568 -0
  40. package/src/solve.auto-pr.lib.mjs +1374 -0
  41. package/src/solve.branch-errors.lib.mjs +341 -0
  42. package/src/solve.branch.lib.mjs +230 -0
  43. package/src/solve.config.lib.mjs +342 -0
  44. package/src/solve.error-handlers.lib.mjs +256 -0
  45. package/src/solve.execution.lib.mjs +291 -0
  46. package/src/solve.feedback.lib.mjs +436 -0
  47. package/src/solve.mjs +1128 -0
  48. package/src/solve.preparation.lib.mjs +210 -0
  49. package/src/solve.repo-setup.lib.mjs +114 -0
  50. package/src/solve.repository.lib.mjs +961 -0
  51. package/src/solve.results.lib.mjs +558 -0
  52. package/src/solve.session.lib.mjs +135 -0
  53. package/src/solve.validation.lib.mjs +325 -0
  54. package/src/solve.watch.lib.mjs +572 -0
  55. package/src/start-screen.mjs +324 -0
  56. package/src/task.mjs +308 -0
  57. package/src/telegram-bot.mjs +1481 -0
  58. package/src/telegram-markdown.lib.mjs +64 -0
  59. package/src/usage-limit.lib.mjs +218 -0
  60. package/src/version.lib.mjs +41 -0
  61. package/src/youtrack/solve.youtrack.lib.mjs +116 -0
  62. package/src/youtrack/youtrack-sync.mjs +219 -0
  63. package/src/youtrack/youtrack.lib.mjs +425 -0
@@ -0,0 +1,191 @@
1
+ // Lazy-load config only when needed to avoid loading use-m at module initialization
2
+ // This prevents network fetches that can hang during --help or --version
3
+
4
+ // Check if Sentry should be disabled
5
+ const shouldDisableSentry = () => {
6
+ // Check for --no-sentry flag
7
+ if (process.argv.includes('--no-sentry')) {
8
+ return true;
9
+ }
10
+
11
+ // Check for environment variable
12
+ if (process.env.HIVE_MIND_NO_SENTRY === 'true' || process.env.DISABLE_SENTRY === 'true') {
13
+ return true;
14
+ }
15
+
16
+ // Check for CI environment (disable in CI by default)
17
+ if (process.env.CI === 'true') {
18
+ return true;
19
+ }
20
+
21
+ // Disable Sentry for quick commands that don't need error tracking
22
+ // This prevents Sentry's profiling integration from blocking process exit
23
+ if (process.argv.includes('--help') || process.argv.includes('-h') || process.argv.includes('--version')) {
24
+ return true;
25
+ }
26
+
27
+ // Disable Sentry for dry-run mode to avoid unnecessary network calls that might fail
28
+ // This prevents config.lib.mjs from loading use-m from CDN in testing scenarios
29
+ if (process.argv.includes('--dry-run')) {
30
+ return true;
31
+ }
32
+
33
+ return false;
34
+ };
35
+
36
+ // Lazily import Sentry only if needed
37
+ // This prevents the Sentry packages from keeping the event loop alive when not needed
38
+ let Sentry = null;
39
+ let nodeProfilingIntegration = null;
40
+
41
+ // Initialize Sentry if not disabled
42
+ if (!shouldDisableSentry()) {
43
+ try {
44
+ // Dynamically import config only when Sentry is actually being initialized
45
+ // This avoids loading use-m before command-line arguments are processed
46
+ const { sentry, version } = await import('./config.lib.mjs');
47
+
48
+ // Dynamically import Sentry packages only when needed
49
+ // eslint-disable-next-line quotes
50
+ const sentryModule = await import("@sentry/node");
51
+ Sentry = sentryModule;
52
+ // eslint-disable-next-line quotes
53
+ const profilingModule = await import("@sentry/profiling-node");
54
+ nodeProfilingIntegration = profilingModule.nodeProfilingIntegration;
55
+
56
+ // Initialize Sentry with configuration
57
+ Sentry.init({
58
+ dsn: sentry.dsn,
59
+ integrations: [
60
+ nodeProfilingIntegration(),
61
+ ],
62
+
63
+ // Application name
64
+ environment: process.env.NODE_ENV || 'production',
65
+ release: `hive-mind@${process.env.npm_package_version || version.default}`,
66
+
67
+ // Send structured logs to Sentry
68
+ enableLogs: true,
69
+
70
+ // Tracing
71
+ tracesSampleRate: process.env.NODE_ENV === 'development' ? sentry.tracesSampleRateDev : sentry.tracesSampleRateProd,
72
+
73
+ // Set sampling rate for profiling
74
+ profileSessionSampleRate: process.env.NODE_ENV === 'development' ? sentry.profileSessionSampleRateDev : sentry.profileSessionSampleRateProd,
75
+
76
+ // Trace lifecycle automatically enables profiling during active traces
77
+ profileLifecycle: 'trace',
78
+
79
+ // Setting this option to true will send default PII data to Sentry
80
+ sendDefaultPii: false, // Disabled for privacy
81
+
82
+ // Set debug mode based on environment
83
+ debug: process.env.DEBUG === 'true' || process.env.NODE_ENV === 'development',
84
+
85
+ // Before send hook to filter out sensitive data
86
+ beforeSend(event) {
87
+ // Filter out sensitive environment variables
88
+ if (event.contexts && event.contexts.runtime && event.contexts.runtime.env) {
89
+ const sensitiveKeys = ['API_KEY', 'TOKEN', 'SECRET', 'PASSWORD', 'ANTHROPIC'];
90
+ Object.keys(event.contexts.runtime.env).forEach(key => {
91
+ if (sensitiveKeys.some(sensitive => key.includes(sensitive))) {
92
+ delete event.contexts.runtime.env[key];
93
+ }
94
+ });
95
+ }
96
+
97
+ // Filter out sensitive data from extra context
98
+ if (event.extra) {
99
+ const sensitiveKeys = ['api_key', 'token', 'secret', 'password'];
100
+ Object.keys(event.extra).forEach(key => {
101
+ if (sensitiveKeys.some(sensitive => key.toLowerCase().includes(sensitive))) {
102
+ delete event.extra[key];
103
+ }
104
+ });
105
+ }
106
+
107
+ return event;
108
+ },
109
+
110
+ // Integration specific options
111
+ ignoreErrors: [
112
+ // Ignore specific errors that are expected or not relevant
113
+ 'ECONNRESET',
114
+ 'ETIMEDOUT',
115
+ 'ENOTFOUND',
116
+ /^NetworkError/,
117
+ /^TimeoutError/,
118
+ ],
119
+
120
+ // Transaction name
121
+ beforeTransaction(context) {
122
+ // Customize transaction names to be more meaningful
123
+ if (context.name && context.name.startsWith('hive-mind')) {
124
+ return context;
125
+ }
126
+ context.name = `hive-mind.${context.name || 'unknown'}`;
127
+ return context;
128
+ }
129
+ });
130
+
131
+ // Log that Sentry has been initialized
132
+ if (process.env.DEBUG === 'true' || process.env.NODE_ENV === 'development') {
133
+ console.log('✅ Sentry initialized successfully');
134
+ }
135
+ } catch (error) {
136
+ // Sentry packages not installed or initialization failed - silently continue without Sentry
137
+ // This is expected in some environments (e.g., CI, development without npm install)
138
+ if (process.env.DEBUG === 'true') {
139
+ console.warn('Warning: Sentry initialization failed:', error.message);
140
+ }
141
+ Sentry = null;
142
+ }
143
+ } else {
144
+ // Log that Sentry is disabled
145
+ if (process.env.DEBUG === 'true' || process.env.NODE_ENV === 'development') {
146
+ console.log('ℹ️ Sentry is disabled (--no-sentry flag or environment variable detected)');
147
+ }
148
+ }
149
+
150
+ // Export Sentry for use in other modules (may be null if disabled)
151
+ export default Sentry;
152
+
153
+ // Export utility function to check if Sentry is enabled
154
+ export const isSentryEnabled = () => Sentry !== null && Sentry.getClient() !== undefined;
155
+
156
+ // Export function to safely capture exceptions
157
+ export const captureException = (error, context = {}) => {
158
+ if (isSentryEnabled()) {
159
+ Sentry.captureException(error, {
160
+ extra: context
161
+ });
162
+ }
163
+ };
164
+
165
+ // Export function to safely capture messages
166
+ export const captureMessage = (message, level = 'info', context = {}) => {
167
+ if (isSentryEnabled()) {
168
+ Sentry.captureMessage(message, level, {
169
+ extra: context
170
+ });
171
+ }
172
+ };
173
+
174
+ // Export function to create a transaction
175
+ // Note: In Sentry v10, startTransaction is deprecated in favor of startSpan
176
+ export const startTransaction = (name, op = 'task') => {
177
+ if (isSentryEnabled()) {
178
+ // Use startInactiveSpan for manual transaction control (similar to old startTransaction)
179
+ return Sentry.startInactiveSpan({
180
+ op,
181
+ name,
182
+ });
183
+ }
184
+ // Return a dummy transaction object if Sentry is disabled
185
+ return {
186
+ finish: () => {},
187
+ end: () => {},
188
+ setStatus: () => {},
189
+ setData: () => {},
190
+ };
191
+ };