claude-comms 1.0.0 → 1.0.2

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.
@@ -0,0 +1,397 @@
1
+ /**
2
+ * Constants and default configuration for NPX installer
3
+ * Centralized API endpoints, error codes, and system defaults
4
+ */
5
+
6
+ /**
7
+ * GitHub Repository Configuration
8
+ */
9
+ const REPOSITORY = {
10
+ OWNER: 'alexsavage',
11
+ NAME: 'claude-code-hooks-multi-agent-observability',
12
+ BRANCH: 'main',
13
+ FULL_NAME: 'alexsavage/claude-code-hooks-multi-agent-observability'
14
+ };
15
+
16
+ /**
17
+ * GitHub API Endpoints
18
+ */
19
+ const GITHUB_API = {
20
+ BASE_URL: 'https://api.github.com',
21
+ VERSION: '2022-11-28',
22
+
23
+ // Repository APIs
24
+ REPO: `/repos/${REPOSITORY.FULL_NAME}`,
25
+ CONTENTS: `/repos/${REPOSITORY.FULL_NAME}/contents`,
26
+ TREES: `/repos/${REPOSITORY.FULL_NAME}/git/trees`,
27
+ COMMITS: `/repos/${REPOSITORY.FULL_NAME}/commits`,
28
+ RELEASES: `/repos/${REPOSITORY.FULL_NAME}/releases`,
29
+
30
+ // Archive URLs
31
+ ARCHIVE_TARBALL: `https://github.com/${REPOSITORY.FULL_NAME}/archive/refs/heads/{branch}.tar.gz`,
32
+ ARCHIVE_ZIPBALL: `https://github.com/${REPOSITORY.FULL_NAME}/archive/refs/heads/{branch}.zip`,
33
+
34
+ // Raw content URLs
35
+ RAW_BASE: `https://raw.githubusercontent.com/${REPOSITORY.FULL_NAME}`,
36
+
37
+ // Rate limiting
38
+ RATE_LIMIT: {
39
+ UNAUTHENTICATED: 60, // 60 requests per hour
40
+ AUTHENTICATED: 5000, // 5000 requests per hour
41
+ CORE_RESET_HEADER: 'x-ratelimit-reset',
42
+ REMAINING_HEADER: 'x-ratelimit-remaining',
43
+ LIMIT_HEADER: 'x-ratelimit-limit'
44
+ }
45
+ };
46
+
47
+ /**
48
+ * File paths and patterns
49
+ */
50
+ const FILE_PATHS = {
51
+ // Main installation targets
52
+ CLAUDE_DIR: '.claude',
53
+ CLAUDE_MD: 'CLAUDE.md',
54
+
55
+ // Claude directory structure
56
+ CLAUDE_SUBDIRS: [
57
+ '.claude/agents',
58
+ '.claude/commands',
59
+ '.claude/hooks',
60
+ '.claude/hooks/comms'
61
+ ],
62
+
63
+ // Key files to install
64
+ REQUIRED_FILES: [
65
+ '.claude/settings.json',
66
+ '.claude/hooks/comms/get_unread_messages.py',
67
+ '.claude/hooks/comms/send_message.py',
68
+ 'CLAUDE.md'
69
+ ],
70
+
71
+ // Configuration files
72
+ CONFIG_FILES: [
73
+ '.claude-installer.json',
74
+ '.claude/settings.local.json'
75
+ ],
76
+
77
+ // Exclude patterns
78
+ EXCLUDE_PATTERNS: [
79
+ '.git',
80
+ '.gitignore',
81
+ 'node_modules',
82
+ '.DS_Store',
83
+ '*.log',
84
+ '.env',
85
+ '.env.local',
86
+ 'dist',
87
+ 'build',
88
+ 'coverage'
89
+ ]
90
+ };
91
+
92
+ /**
93
+ * Error codes aligned with interface contracts
94
+ */
95
+ const ERROR_CODES = {
96
+ // Network errors (E1xx)
97
+ NETWORK_ERROR: 'E101',
98
+ GITHUB_RATE_LIMIT: 'E102',
99
+ GITHUB_API_ERROR: 'E103',
100
+ GITHUB_NOT_FOUND: 'E104',
101
+ GITHUB_SERVER_ERROR: 'E105',
102
+ GITHUB_CONNECTION_ERROR: 'E106',
103
+
104
+ // File system errors (E2xx)
105
+ FILE_WRITE_ERROR: 'E201',
106
+ FILE_READ_ERROR: 'E202',
107
+ PERMISSION_DENIED: 'E203',
108
+ DISK_FULL: 'E204',
109
+ FILESYSTEM_ERROR: 'E205',
110
+ FILESYSTEM_NOT_FOUND: 'E206',
111
+ FILESYSTEM_ALREADY_EXISTS: 'E207',
112
+ FILESYSTEM_NO_SPACE: 'E208',
113
+ FILESYSTEM_TOO_MANY_FILES: 'E209',
114
+
115
+ // Validation errors (E3xx)
116
+ INVALID_TARGET_DIR: 'E301',
117
+ DEPENDENCY_MISSING: 'E302',
118
+ INVALID_VERSION: 'E303',
119
+ VALIDATION_ERROR: 'E304',
120
+
121
+ // User errors (E4xx)
122
+ USER_CANCELLED: 'E401',
123
+ INVALID_INPUT: 'E402',
124
+
125
+ // Configuration errors (E5xx)
126
+ CONFIGURATION_ERROR: 'E501',
127
+
128
+ // Unknown/Generic errors
129
+ UNKNOWN_ERROR: 'E999'
130
+ };
131
+
132
+ /**
133
+ * HTTP Status Code mappings
134
+ */
135
+ const HTTP_STATUS = {
136
+ OK: 200,
137
+ NOT_FOUND: 404,
138
+ FORBIDDEN: 403,
139
+ RATE_LIMITED: 429,
140
+ SERVER_ERROR: 500,
141
+ BAD_GATEWAY: 502,
142
+ SERVICE_UNAVAILABLE: 503,
143
+ GATEWAY_TIMEOUT: 504
144
+ };
145
+
146
+ /**
147
+ * Retry and timeout configurations
148
+ */
149
+ const RETRY_CONFIG = {
150
+ DEFAULT_MAX_ATTEMPTS: 3,
151
+ DEFAULT_BASE_DELAY: 1000,
152
+ DEFAULT_MAX_DELAY: 30000,
153
+ DEFAULT_BACKOFF_FACTOR: 2,
154
+ DEFAULT_JITTER_FACTOR: 0.1,
155
+
156
+ // GitHub-specific retry config
157
+ GITHUB: {
158
+ MAX_ATTEMPTS: 5,
159
+ BASE_DELAY: 2000,
160
+ MAX_DELAY: 60000,
161
+ RATE_LIMIT_DELAY: 60000 // 1 minute for rate limits
162
+ },
163
+
164
+ // Network operation retry config
165
+ NETWORK: {
166
+ MAX_ATTEMPTS: 3,
167
+ BASE_DELAY: 500,
168
+ MAX_DELAY: 5000
169
+ },
170
+
171
+ // File system operation retry config
172
+ FILESYSTEM: {
173
+ MAX_ATTEMPTS: 3,
174
+ BASE_DELAY: 100,
175
+ MAX_DELAY: 1000
176
+ }
177
+ };
178
+
179
+ /**
180
+ * File operation configurations
181
+ */
182
+ const FILE_CONFIG = {
183
+ DEFAULT_ENCODING: 'utf8',
184
+ BINARY_ENCODING: 'binary',
185
+ MAX_FILE_SIZE: 10 * 1024 * 1024, // 10MB
186
+ CHUNK_SIZE: 64 * 1024, // 64KB chunks
187
+ CONCURRENT_DOWNLOADS: 5,
188
+ BACKUP_SUFFIX: '.backup',
189
+ TEMP_SUFFIX: '.tmp'
190
+ };
191
+
192
+ /**
193
+ * Logging configuration
194
+ */
195
+ const LOG_CONFIG = {
196
+ LEVELS: {
197
+ DEBUG: 0,
198
+ INFO: 1,
199
+ SUCCESS: 2,
200
+ WARN: 3,
201
+ ERROR: 4
202
+ },
203
+
204
+ DEFAULT_LEVEL: 'INFO',
205
+
206
+ COLORS: {
207
+ DEBUG: 'gray',
208
+ INFO: 'blue',
209
+ SUCCESS: 'green',
210
+ WARN: 'yellow',
211
+ ERROR: 'red',
212
+ SPINNER: 'cyan'
213
+ },
214
+
215
+ SYMBOLS: {
216
+ DEBUG: '🔧',
217
+ INFO: 'ℹ️',
218
+ SUCCESS: '✅',
219
+ WARN: '⚠️',
220
+ ERROR: '❌',
221
+ SPINNER: '⏳'
222
+ }
223
+ };
224
+
225
+ /**
226
+ * Progress reporting configuration
227
+ */
228
+ const PROGRESS_CONFIG = {
229
+ UPDATE_INTERVAL: 100, // milliseconds
230
+ THROTTLE_LIMIT: 10, // max updates per second
231
+ SPINNER_FRAMES: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],
232
+ SPINNER_INTERVAL: 80 // milliseconds
233
+ };
234
+
235
+ /**
236
+ * Cache configuration
237
+ */
238
+ const CACHE_CONFIG = {
239
+ DEFAULT_TTL: 3600000, // 1 hour in milliseconds
240
+ MAX_SIZE: 100 * 1024 * 1024, // 100MB
241
+ CLEANUP_INTERVAL: 300000, // 5 minutes
242
+
243
+ CACHE_KEYS: {
244
+ GITHUB_TREES: 'github:trees',
245
+ GITHUB_CONTENTS: 'github:contents',
246
+ FILE_METADATA: 'file:metadata'
247
+ }
248
+ };
249
+
250
+ /**
251
+ * Dependency requirements
252
+ */
253
+ const DEPENDENCIES = {
254
+ PYTHON: {
255
+ MINIMUM_VERSION: '3.8.0',
256
+ COMMANDS: ['python3', 'python'],
257
+ VERSION_FLAGS: ['--version', '-V']
258
+ },
259
+
260
+ UV: {
261
+ MINIMUM_VERSION: '0.1.0',
262
+ COMMANDS: ['uv'],
263
+ VERSION_FLAGS: ['--version']
264
+ },
265
+
266
+ NODE: {
267
+ MINIMUM_VERSION: '18.0.0',
268
+ COMMANDS: ['node'],
269
+ VERSION_FLAGS: ['--version']
270
+ }
271
+ };
272
+
273
+ /**
274
+ * User interface messages and prompts
275
+ */
276
+ const UI_MESSAGES = {
277
+ WELCOME: '🚀 Claude Code Setup Installer',
278
+ SUCCESS: '✅ Installation complete!',
279
+ CANCELLED: '❌ Installation cancelled by user',
280
+
281
+ PROMPTS: {
282
+ CONFIRM_INSTALL: 'Install Claude setup to this directory?',
283
+ OVERWRITE_CONFIRM: 'Directory contains existing files. Overwrite?',
284
+ BACKUP_CONFIRM: 'Create backup before overwriting?',
285
+ CONTINUE_ON_ERROR: 'Continue installation despite errors?'
286
+ },
287
+
288
+ PROGRESS: {
289
+ FETCHING: 'Fetching files from GitHub...',
290
+ DOWNLOADING: 'Downloading repository contents...',
291
+ WRITING: 'Writing files to disk...',
292
+ VALIDATING: 'Validating installation...',
293
+ BACKING_UP: 'Creating backup...',
294
+ CLEANING_UP: 'Cleaning up temporary files...'
295
+ }
296
+ };
297
+
298
+ /**
299
+ * Platform-specific constants
300
+ */
301
+ const PLATFORM_CONFIG = {
302
+ WINDOWS: {
303
+ LINE_ENDING: '\r\n',
304
+ PATH_SEPARATOR: '\\',
305
+ EXECUTABLE_EXTENSION: '.exe'
306
+ },
307
+
308
+ UNIX: {
309
+ LINE_ENDING: '\n',
310
+ PATH_SEPARATOR: '/',
311
+ EXECUTABLE_EXTENSION: ''
312
+ },
313
+
314
+ CONFIG_DIRS: {
315
+ WINDOWS: '%APPDATA%',
316
+ MACOS: '~/Library/Application Support',
317
+ LINUX: '~/.config'
318
+ }
319
+ };
320
+
321
+ /**
322
+ * Package metadata
323
+ */
324
+ const PACKAGE_INFO = {
325
+ NAME: '@claude-code/setup-installer',
326
+ VERSION: '1.0.0', // Will be replaced by actual package.json
327
+ USER_AGENT: '@claude-code/setup-installer/1.0.0',
328
+ REPOSITORY: 'https://github.com/alexsavage/claude-code-hooks-multi-agent-observability',
329
+ HOMEPAGE: 'https://claude.ai/code',
330
+ BUGS_URL: 'https://github.com/alexsavage/claude-code-hooks-multi-agent-observability/issues'
331
+ };
332
+
333
+ /**
334
+ * Build complete GitHub URLs
335
+ */
336
+ const GITHUB_URLS = {
337
+ // Get repository contents
338
+ getContentsUrl: (path = '', ref = REPOSITORY.BRANCH) =>
339
+ `${GITHUB_API.BASE_URL}${GITHUB_API.CONTENTS}/${path}?ref=${ref}`,
340
+
341
+ // Get git tree (recursive directory listing)
342
+ getTreeUrl: (ref = REPOSITORY.BRANCH, recursive = true) =>
343
+ `${GITHUB_API.BASE_URL}${GITHUB_API.TREES}/${ref}${recursive ? '?recursive=1' : ''}`,
344
+
345
+ // Get raw file content
346
+ getRawUrl: (path, ref = REPOSITORY.BRANCH) =>
347
+ `${GITHUB_API.RAW_BASE}/${ref}/${path}`,
348
+
349
+ // Get archive download
350
+ getArchiveUrl: (format = 'tarball', ref = REPOSITORY.BRANCH) =>
351
+ GITHUB_API[`ARCHIVE_${format.toUpperCase()}`].replace('{branch}', ref),
352
+
353
+ // Get rate limit status
354
+ getRateLimitUrl: () =>
355
+ `${GITHUB_API.BASE_URL}/rate_limit`
356
+ };
357
+
358
+ /**
359
+ * Validation patterns and rules
360
+ */
361
+ const VALIDATION = {
362
+ // Path validation
363
+ SAFE_PATH_PATTERN: /^[a-zA-Z0-9._/-]+$/,
364
+ MAX_PATH_LENGTH: 260, // Windows limitation
365
+ MAX_PATH_DEPTH: 10,
366
+
367
+ // Version patterns
368
+ VERSION_PATTERN: /^v?\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?$/,
369
+ SEMVER_PATTERN: /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,
370
+
371
+ // File size limits
372
+ MAX_SINGLE_FILE_SIZE: 50 * 1024 * 1024, // 50MB
373
+ MAX_TOTAL_SIZE: 500 * 1024 * 1024, // 500MB
374
+
375
+ // GitHub constraints
376
+ MAX_FILES_PER_REQUEST: 100,
377
+ MAX_CONTENT_SIZE: 1024 * 1024 // 1MB for Contents API
378
+ };
379
+
380
+ module.exports = {
381
+ REPOSITORY,
382
+ GITHUB_API,
383
+ GITHUB_URLS,
384
+ FILE_PATHS,
385
+ ERROR_CODES,
386
+ HTTP_STATUS,
387
+ RETRY_CONFIG,
388
+ FILE_CONFIG,
389
+ LOG_CONFIG,
390
+ PROGRESS_CONFIG,
391
+ CACHE_CONFIG,
392
+ DEPENDENCIES,
393
+ UI_MESSAGES,
394
+ PLATFORM_CONFIG,
395
+ PACKAGE_INFO,
396
+ VALIDATION
397
+ };