@cloudstreamsoftware/claude-tools 1.0.0 → 1.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 (189) hide show
  1. package/README.md +152 -37
  2. package/agents/INDEX.md +183 -0
  3. package/agents/architect.md +247 -0
  4. package/agents/build-error-resolver.md +555 -0
  5. package/agents/catalyst-deployer.md +132 -0
  6. package/agents/code-reviewer.md +121 -0
  7. package/agents/compliance-auditor.md +148 -0
  8. package/agents/creator-architect.md +395 -0
  9. package/agents/deluge-reviewer.md +98 -0
  10. package/agents/doc-updater.md +471 -0
  11. package/agents/e2e-runner.md +711 -0
  12. package/agents/planner.md +122 -0
  13. package/agents/refactor-cleaner.md +309 -0
  14. package/agents/security-reviewer.md +582 -0
  15. package/agents/tdd-guide.md +302 -0
  16. package/config/versions.json +63 -0
  17. package/dist/hooks/hooks.json +209 -0
  18. package/dist/index.js +47 -0
  19. package/dist/lib/asset-value.js +609 -0
  20. package/dist/lib/client-manager.js +300 -0
  21. package/dist/lib/command-matcher.js +242 -0
  22. package/dist/lib/cross-session-patterns.js +754 -0
  23. package/dist/lib/intent-classifier.js +1075 -0
  24. package/dist/lib/package-manager.js +374 -0
  25. package/dist/lib/recommendation-engine.js +597 -0
  26. package/dist/lib/session-memory.js +489 -0
  27. package/dist/lib/skill-effectiveness.js +486 -0
  28. package/dist/lib/skill-matcher.js +595 -0
  29. package/dist/lib/tutorial-metrics.js +242 -0
  30. package/dist/lib/tutorial-progress.js +209 -0
  31. package/dist/lib/tutorial-renderer.js +431 -0
  32. package/dist/lib/utils.js +380 -0
  33. package/dist/lib/verify-formatter.js +143 -0
  34. package/dist/lib/workflow-state.js +249 -0
  35. package/hooks/hooks.json +209 -0
  36. package/package.json +5 -1
  37. package/scripts/aggregate-sessions.js +290 -0
  38. package/scripts/branch-name-validator.js +291 -0
  39. package/scripts/build.js +101 -0
  40. package/scripts/commands/client-switch.js +231 -0
  41. package/scripts/deprecate-skill.js +610 -0
  42. package/scripts/diagnose.js +324 -0
  43. package/scripts/doc-freshness.js +168 -0
  44. package/scripts/generate-weekly-digest.js +393 -0
  45. package/scripts/health-check.js +270 -0
  46. package/scripts/hooks/credential-check.js +101 -0
  47. package/scripts/hooks/evaluate-session.js +81 -0
  48. package/scripts/hooks/pre-compact.js +66 -0
  49. package/scripts/hooks/prompt-analyzer.js +276 -0
  50. package/scripts/hooks/prompt-router.js +422 -0
  51. package/scripts/hooks/quality-gate-enforcer.js +371 -0
  52. package/scripts/hooks/session-end.js +156 -0
  53. package/scripts/hooks/session-start.js +195 -0
  54. package/scripts/hooks/skill-injector.js +333 -0
  55. package/scripts/hooks/suggest-compact.js +58 -0
  56. package/scripts/lib/asset-value.js +609 -0
  57. package/scripts/lib/client-manager.js +300 -0
  58. package/scripts/lib/command-matcher.js +242 -0
  59. package/scripts/lib/cross-session-patterns.js +754 -0
  60. package/scripts/lib/intent-classifier.js +1075 -0
  61. package/scripts/lib/package-manager.js +374 -0
  62. package/scripts/lib/recommendation-engine.js +597 -0
  63. package/scripts/lib/session-memory.js +489 -0
  64. package/scripts/lib/skill-effectiveness.js +486 -0
  65. package/scripts/lib/skill-matcher.js +595 -0
  66. package/scripts/lib/tutorial-metrics.js +242 -0
  67. package/scripts/lib/tutorial-progress.js +209 -0
  68. package/scripts/lib/tutorial-renderer.js +431 -0
  69. package/scripts/lib/utils.js +380 -0
  70. package/scripts/lib/verify-formatter.js +143 -0
  71. package/scripts/lib/workflow-state.js +249 -0
  72. package/scripts/onboard.js +363 -0
  73. package/scripts/quarterly-report.js +692 -0
  74. package/scripts/setup-package-manager.js +204 -0
  75. package/scripts/sync-upstream.js +391 -0
  76. package/scripts/test.js +108 -0
  77. package/scripts/tutorial-runner.js +351 -0
  78. package/scripts/validate-all.js +201 -0
  79. package/scripts/verifiers/agents.js +245 -0
  80. package/scripts/verifiers/config.js +186 -0
  81. package/scripts/verifiers/environment.js +123 -0
  82. package/scripts/verifiers/hooks.js +188 -0
  83. package/scripts/verifiers/index.js +38 -0
  84. package/scripts/verifiers/persistence.js +140 -0
  85. package/scripts/verifiers/plugin.js +215 -0
  86. package/scripts/verifiers/skills.js +209 -0
  87. package/scripts/verify-setup.js +164 -0
  88. package/skills/INDEX.md +157 -0
  89. package/skills/backend-patterns/SKILL.md +586 -0
  90. package/skills/backend-patterns/catalyst-patterns.md +128 -0
  91. package/skills/bigquery-patterns/SKILL.md +27 -0
  92. package/skills/bigquery-patterns/performance-optimization.md +518 -0
  93. package/skills/bigquery-patterns/query-patterns.md +372 -0
  94. package/skills/bigquery-patterns/schema-design.md +78 -0
  95. package/skills/cloudstream-project-template/SKILL.md +20 -0
  96. package/skills/cloudstream-project-template/structure.md +65 -0
  97. package/skills/coding-standards/SKILL.md +524 -0
  98. package/skills/coding-standards/deluge-standards.md +83 -0
  99. package/skills/compliance-patterns/SKILL.md +28 -0
  100. package/skills/compliance-patterns/hipaa/audit-requirements.md +251 -0
  101. package/skills/compliance-patterns/hipaa/baa-process.md +298 -0
  102. package/skills/compliance-patterns/hipaa/data-archival-strategy.md +387 -0
  103. package/skills/compliance-patterns/hipaa/phi-handling.md +52 -0
  104. package/skills/compliance-patterns/pci-dss/saq-a-requirements.md +307 -0
  105. package/skills/compliance-patterns/pci-dss/tokenization-patterns.md +382 -0
  106. package/skills/compliance-patterns/pci-dss/zoho-checkout-patterns.md +56 -0
  107. package/skills/compliance-patterns/soc2/access-controls.md +344 -0
  108. package/skills/compliance-patterns/soc2/audit-logging.md +458 -0
  109. package/skills/compliance-patterns/soc2/change-management.md +403 -0
  110. package/skills/compliance-patterns/soc2/deluge-execution-logging.md +407 -0
  111. package/skills/consultancy-workflows/SKILL.md +19 -0
  112. package/skills/consultancy-workflows/client-isolation.md +21 -0
  113. package/skills/consultancy-workflows/documentation-automation.md +454 -0
  114. package/skills/consultancy-workflows/handoff-procedures.md +257 -0
  115. package/skills/consultancy-workflows/knowledge-capture.md +513 -0
  116. package/skills/consultancy-workflows/time-tracking.md +26 -0
  117. package/skills/continuous-learning/SKILL.md +84 -0
  118. package/skills/continuous-learning/config.json +18 -0
  119. package/skills/continuous-learning/evaluate-session.sh +60 -0
  120. package/skills/continuous-learning-v2/SKILL.md +126 -0
  121. package/skills/continuous-learning-v2/config.json +61 -0
  122. package/skills/frontend-patterns/SKILL.md +635 -0
  123. package/skills/frontend-patterns/zoho-widget-patterns.md +103 -0
  124. package/skills/gcp-data-engineering/SKILL.md +36 -0
  125. package/skills/gcp-data-engineering/bigquery/performance-optimization.md +337 -0
  126. package/skills/gcp-data-engineering/dataflow/error-handling.md +496 -0
  127. package/skills/gcp-data-engineering/dataflow/pipeline-patterns.md +444 -0
  128. package/skills/gcp-data-engineering/dbt/model-organization.md +63 -0
  129. package/skills/gcp-data-engineering/dbt/testing-patterns.md +503 -0
  130. package/skills/gcp-data-engineering/medallion-architecture/bronze-layer.md +60 -0
  131. package/skills/gcp-data-engineering/medallion-architecture/gold-layer.md +311 -0
  132. package/skills/gcp-data-engineering/medallion-architecture/layer-transitions.md +517 -0
  133. package/skills/gcp-data-engineering/medallion-architecture/silver-layer.md +305 -0
  134. package/skills/gcp-data-engineering/zoho-to-gcp/data-extraction.md +543 -0
  135. package/skills/gcp-data-engineering/zoho-to-gcp/real-time-vs-batch.md +337 -0
  136. package/skills/security-review/SKILL.md +498 -0
  137. package/skills/security-review/compliance-checklist.md +53 -0
  138. package/skills/strategic-compact/SKILL.md +67 -0
  139. package/skills/tdd-workflow/SKILL.md +413 -0
  140. package/skills/tdd-workflow/zoho-testing.md +124 -0
  141. package/skills/tutorial/SKILL.md +249 -0
  142. package/skills/tutorial/docs/ACCESSIBILITY.md +169 -0
  143. package/skills/tutorial/lessons/00-philosophy-and-workflow.md +198 -0
  144. package/skills/tutorial/lessons/01-basics.md +81 -0
  145. package/skills/tutorial/lessons/02-training.md +86 -0
  146. package/skills/tutorial/lessons/03-commands.md +109 -0
  147. package/skills/tutorial/lessons/04-workflows.md +115 -0
  148. package/skills/tutorial/lessons/05-compliance.md +116 -0
  149. package/skills/tutorial/lessons/06-zoho.md +121 -0
  150. package/skills/tutorial/lessons/07-hooks-system.md +277 -0
  151. package/skills/tutorial/lessons/08-mcp-servers.md +316 -0
  152. package/skills/tutorial/lessons/09-client-management.md +215 -0
  153. package/skills/tutorial/lessons/10-testing-e2e.md +260 -0
  154. package/skills/tutorial/lessons/11-skills-deep-dive.md +272 -0
  155. package/skills/tutorial/lessons/12-rules-system.md +326 -0
  156. package/skills/tutorial/lessons/13-golden-standard-graduation.md +213 -0
  157. package/skills/tutorial/lessons/14-fork-setup-and-sync.md +312 -0
  158. package/skills/tutorial/lessons/15-living-examples-system.md +221 -0
  159. package/skills/tutorial/tracks/accelerated/README.md +134 -0
  160. package/skills/tutorial/tracks/accelerated/assessment/checkpoint-1.md +161 -0
  161. package/skills/tutorial/tracks/accelerated/assessment/checkpoint-2.md +175 -0
  162. package/skills/tutorial/tracks/accelerated/day-1-core-concepts.md +234 -0
  163. package/skills/tutorial/tracks/accelerated/day-2-essential-commands.md +270 -0
  164. package/skills/tutorial/tracks/accelerated/day-3-workflow-mastery.md +305 -0
  165. package/skills/tutorial/tracks/accelerated/day-4-compliance-zoho.md +304 -0
  166. package/skills/tutorial/tracks/accelerated/day-5-hooks-skills.md +344 -0
  167. package/skills/tutorial/tracks/accelerated/day-6-client-testing.md +386 -0
  168. package/skills/tutorial/tracks/accelerated/day-7-graduation.md +369 -0
  169. package/skills/zoho-patterns/CHANGELOG.md +108 -0
  170. package/skills/zoho-patterns/SKILL.md +446 -0
  171. package/skills/zoho-patterns/analytics/dashboard-patterns.md +352 -0
  172. package/skills/zoho-patterns/analytics/zoho-to-bigquery-pipeline.md +427 -0
  173. package/skills/zoho-patterns/catalyst/appsail-deployment.md +349 -0
  174. package/skills/zoho-patterns/catalyst/context-close-patterns.md +354 -0
  175. package/skills/zoho-patterns/catalyst/cron-batch-processing.md +374 -0
  176. package/skills/zoho-patterns/catalyst/function-patterns.md +439 -0
  177. package/skills/zoho-patterns/creator/form-design.md +304 -0
  178. package/skills/zoho-patterns/creator/publish-api-patterns.md +313 -0
  179. package/skills/zoho-patterns/creator/widget-integration.md +306 -0
  180. package/skills/zoho-patterns/creator/workflow-automation.md +253 -0
  181. package/skills/zoho-patterns/deluge/api-patterns.md +468 -0
  182. package/skills/zoho-patterns/deluge/batch-processing.md +403 -0
  183. package/skills/zoho-patterns/deluge/cross-app-integration.md +356 -0
  184. package/skills/zoho-patterns/deluge/error-handling.md +423 -0
  185. package/skills/zoho-patterns/deluge/syntax-reference.md +65 -0
  186. package/skills/zoho-patterns/integration/cors-proxy-architecture.md +426 -0
  187. package/skills/zoho-patterns/integration/crm-books-native-sync.md +277 -0
  188. package/skills/zoho-patterns/integration/oauth-token-management.md +461 -0
  189. package/skills/zoho-patterns/integration/zoho-flow-patterns.md +334 -0
@@ -0,0 +1,380 @@
1
+ /**
2
+ * Cross-platform utility functions for Claude Code hooks and scripts
3
+ * Works on Windows, macOS, and Linux
4
+ */
5
+
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+ const os = require('os');
9
+ const { execSync, spawnSync } = require('child_process');
10
+
11
+ // Platform detection
12
+ const isWindows = process.platform === 'win32';
13
+ const isMacOS = process.platform === 'darwin';
14
+ const isLinux = process.platform === 'linux';
15
+
16
+ /**
17
+ * Get the user's home directory (cross-platform)
18
+ */
19
+ function getHomeDir() {
20
+ return os.homedir();
21
+ }
22
+
23
+ /**
24
+ * Get the Claude config directory
25
+ */
26
+ function getClaudeDir() {
27
+ return path.join(getHomeDir(), '.claude');
28
+ }
29
+
30
+ /**
31
+ * Get the sessions directory
32
+ */
33
+ function getSessionsDir() {
34
+ return path.join(getClaudeDir(), 'sessions');
35
+ }
36
+
37
+ /**
38
+ * Get the learned skills directory
39
+ */
40
+ function getLearnedSkillsDir() {
41
+ return path.join(getClaudeDir(), 'skills', 'learned');
42
+ }
43
+
44
+ /**
45
+ * Get the temp directory (cross-platform)
46
+ */
47
+ function getTempDir() {
48
+ return os.tmpdir();
49
+ }
50
+
51
+ /**
52
+ * Ensure a directory exists (create if not)
53
+ */
54
+ function ensureDir(dirPath) {
55
+ if (!fs.existsSync(dirPath)) {
56
+ fs.mkdirSync(dirPath, { recursive: true });
57
+ }
58
+ return dirPath;
59
+ }
60
+
61
+ /**
62
+ * Get current date in YYYY-MM-DD format
63
+ */
64
+ function getDateString() {
65
+ const now = new Date();
66
+ const year = now.getFullYear();
67
+ const month = String(now.getMonth() + 1).padStart(2, '0');
68
+ const day = String(now.getDate()).padStart(2, '0');
69
+ return `${year}-${month}-${day}`;
70
+ }
71
+
72
+ /**
73
+ * Get current time in HH:MM format
74
+ */
75
+ function getTimeString() {
76
+ const now = new Date();
77
+ const hours = String(now.getHours()).padStart(2, '0');
78
+ const minutes = String(now.getMinutes()).padStart(2, '0');
79
+ return `${hours}:${minutes}`;
80
+ }
81
+
82
+ /**
83
+ * Get current datetime in YYYY-MM-DD HH:MM:SS format
84
+ */
85
+ function getDateTimeString() {
86
+ const now = new Date();
87
+ const year = now.getFullYear();
88
+ const month = String(now.getMonth() + 1).padStart(2, '0');
89
+ const day = String(now.getDate()).padStart(2, '0');
90
+ const hours = String(now.getHours()).padStart(2, '0');
91
+ const minutes = String(now.getMinutes()).padStart(2, '0');
92
+ const seconds = String(now.getSeconds()).padStart(2, '0');
93
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
94
+ }
95
+
96
+ /**
97
+ * Find files matching a pattern in a directory (cross-platform alternative to find)
98
+ * @param {string} dir - Directory to search
99
+ * @param {string} pattern - File pattern (e.g., "*.tmp", "*.md")
100
+ * @param {object} options - Options { maxAge: days, recursive: boolean }
101
+ */
102
+ function findFiles(dir, pattern, options = {}) {
103
+ const { maxAge = null, recursive = false } = options;
104
+ const results = [];
105
+
106
+ if (!fs.existsSync(dir)) {
107
+ return results;
108
+ }
109
+
110
+ const regexPattern = pattern.replace(/\./g, '\\.').replace(/\*/g, '.*').replace(/\?/g, '.');
111
+ const regex = new RegExp(`^${regexPattern}$`);
112
+
113
+ function searchDir(currentDir) {
114
+ try {
115
+ const entries = fs.readdirSync(currentDir, { withFileTypes: true });
116
+
117
+ for (const entry of entries) {
118
+ const fullPath = path.join(currentDir, entry.name);
119
+
120
+ if (entry.isFile() && regex.test(entry.name)) {
121
+ if (maxAge !== null) {
122
+ const stats = fs.statSync(fullPath);
123
+ const ageInDays = (Date.now() - stats.mtimeMs) / (1000 * 60 * 60 * 24);
124
+ if (ageInDays <= maxAge) {
125
+ results.push({ path: fullPath, mtime: stats.mtimeMs });
126
+ }
127
+ } else {
128
+ const stats = fs.statSync(fullPath);
129
+ results.push({ path: fullPath, mtime: stats.mtimeMs });
130
+ }
131
+ } else if (entry.isDirectory() && recursive) {
132
+ searchDir(fullPath);
133
+ }
134
+ }
135
+ } catch (err) {
136
+ // Ignore permission errors
137
+ }
138
+ }
139
+
140
+ searchDir(dir);
141
+
142
+ // Sort by modification time (newest first)
143
+ results.sort((a, b) => b.mtime - a.mtime);
144
+
145
+ return results;
146
+ }
147
+
148
+ /**
149
+ * Read JSON from stdin (for hook input)
150
+ */
151
+ async function readStdinJson() {
152
+ return new Promise((resolve, reject) => {
153
+ let data = '';
154
+
155
+ process.stdin.setEncoding('utf8');
156
+ process.stdin.on('data', (chunk) => {
157
+ data += chunk;
158
+ });
159
+
160
+ process.stdin.on('end', () => {
161
+ try {
162
+ if (data.trim()) {
163
+ resolve(JSON.parse(data));
164
+ } else {
165
+ resolve({});
166
+ }
167
+ } catch (err) {
168
+ reject(err);
169
+ }
170
+ });
171
+
172
+ process.stdin.on('error', reject);
173
+ });
174
+ }
175
+
176
+ /**
177
+ * Log to stderr (visible to user in Claude Code)
178
+ */
179
+ function log(message) {
180
+ console.error(message);
181
+ }
182
+
183
+ /**
184
+ * Output to stdout (returned to Claude)
185
+ */
186
+ function output(data) {
187
+ if (typeof data === 'object') {
188
+ console.log(JSON.stringify(data));
189
+ } else {
190
+ console.log(data);
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Read a text file safely
196
+ */
197
+ function readFile(filePath) {
198
+ try {
199
+ return fs.readFileSync(filePath, 'utf8');
200
+ } catch {
201
+ return null;
202
+ }
203
+ }
204
+
205
+ /**
206
+ * Write a text file
207
+ */
208
+ function writeFile(filePath, content) {
209
+ ensureDir(path.dirname(filePath));
210
+ fs.writeFileSync(filePath, content, 'utf8');
211
+ }
212
+
213
+ /**
214
+ * Append to a text file
215
+ */
216
+ function appendFile(filePath, content) {
217
+ ensureDir(path.dirname(filePath));
218
+ fs.appendFileSync(filePath, content, 'utf8');
219
+ }
220
+
221
+ /**
222
+ * Check if a command exists in PATH
223
+ * Uses execFileSync to prevent command injection
224
+ */
225
+ function commandExists(cmd) {
226
+ // Validate command name - only allow alphanumeric, dash, underscore, dot
227
+ if (!/^[a-zA-Z0-9_.-]+$/.test(cmd)) {
228
+ return false;
229
+ }
230
+
231
+ try {
232
+ if (isWindows) {
233
+ // Use spawnSync to avoid shell interpolation
234
+ const result = spawnSync('where', [cmd], { stdio: 'pipe' });
235
+ return result.status === 0;
236
+ } else {
237
+ const result = spawnSync('which', [cmd], { stdio: 'pipe' });
238
+ return result.status === 0;
239
+ }
240
+ } catch {
241
+ return false;
242
+ }
243
+ }
244
+
245
+ /**
246
+ * Run a command and return output
247
+ *
248
+ * SECURITY NOTE: This function executes shell commands. Only use with
249
+ * trusted, hardcoded commands. Never pass user-controlled input directly.
250
+ * For user input, use spawnSync with argument arrays instead.
251
+ *
252
+ * @param {string} cmd - Command to execute (should be trusted/hardcoded)
253
+ * @param {object} options - execSync options
254
+ */
255
+ function runCommand(cmd, options = {}) {
256
+ try {
257
+ const result = execSync(cmd, {
258
+ encoding: 'utf8',
259
+ stdio: ['pipe', 'pipe', 'pipe'],
260
+ ...options,
261
+ });
262
+ return { success: true, output: result.trim() };
263
+ } catch (err) {
264
+ return { success: false, output: err.stderr || err.message };
265
+ }
266
+ }
267
+
268
+ /**
269
+ * Check if current directory is a git repository
270
+ */
271
+ function isGitRepo() {
272
+ return runCommand('git rev-parse --git-dir').success;
273
+ }
274
+
275
+ /**
276
+ * Get git modified files
277
+ */
278
+ function getGitModifiedFiles(patterns = []) {
279
+ if (!isGitRepo()) return [];
280
+
281
+ const result = runCommand('git diff --name-only HEAD');
282
+ if (!result.success) return [];
283
+
284
+ let files = result.output.split('\n').filter(Boolean);
285
+
286
+ if (patterns.length > 0) {
287
+ files = files.filter((file) => {
288
+ return patterns.some((pattern) => {
289
+ const regex = new RegExp(pattern);
290
+ return regex.test(file);
291
+ });
292
+ });
293
+ }
294
+
295
+ return files;
296
+ }
297
+
298
+ /**
299
+ * Replace text in a file (cross-platform sed alternative)
300
+ */
301
+ function replaceInFile(filePath, search, replace) {
302
+ const content = readFile(filePath);
303
+ if (content === null) return false;
304
+
305
+ const newContent = content.replace(search, replace);
306
+ writeFile(filePath, newContent);
307
+ return true;
308
+ }
309
+
310
+ /**
311
+ * Count occurrences of a pattern in a file
312
+ */
313
+ function countInFile(filePath, pattern) {
314
+ const content = readFile(filePath);
315
+ if (content === null) return 0;
316
+
317
+ const regex = pattern instanceof RegExp ? pattern : new RegExp(pattern, 'g');
318
+ const matches = content.match(regex);
319
+ return matches ? matches.length : 0;
320
+ }
321
+
322
+ /**
323
+ * Search for pattern in file and return matching lines with line numbers
324
+ */
325
+ function grepFile(filePath, pattern) {
326
+ const content = readFile(filePath);
327
+ if (content === null) return [];
328
+
329
+ const regex = pattern instanceof RegExp ? pattern : new RegExp(pattern);
330
+ const lines = content.split('\n');
331
+ const results = [];
332
+
333
+ lines.forEach((line, index) => {
334
+ if (regex.test(line)) {
335
+ results.push({ lineNumber: index + 1, content: line });
336
+ }
337
+ });
338
+
339
+ return results;
340
+ }
341
+
342
+ module.exports = {
343
+ // Platform info
344
+ isWindows,
345
+ isMacOS,
346
+ isLinux,
347
+
348
+ // Directories
349
+ getHomeDir,
350
+ getClaudeDir,
351
+ getSessionsDir,
352
+ getLearnedSkillsDir,
353
+ getTempDir,
354
+ ensureDir,
355
+
356
+ // Date/Time
357
+ getDateString,
358
+ getTimeString,
359
+ getDateTimeString,
360
+
361
+ // File operations
362
+ findFiles,
363
+ readFile,
364
+ writeFile,
365
+ appendFile,
366
+ replaceInFile,
367
+ countInFile,
368
+ grepFile,
369
+
370
+ // Hook I/O
371
+ readStdinJson,
372
+ log,
373
+ output,
374
+
375
+ // System
376
+ commandExists,
377
+ runCommand,
378
+ isGitRepo,
379
+ getGitModifiedFiles,
380
+ };
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Verify Formatter - Output formatting utilities for verification system
3
+ * Following patterns from health-check.js and diagnose.js
4
+ */
5
+
6
+ // Status indicators
7
+ const OK = '[OK]';
8
+ const WARN = '[WARN]';
9
+ const FAIL = '[FAIL]';
10
+ const SKIP = '[SKIP]';
11
+
12
+ // Severity levels
13
+ const SEVERITY = {
14
+ CRITICAL: 'critical',
15
+ HIGH: 'high',
16
+ WARNING: 'warning',
17
+ INFO: 'info',
18
+ };
19
+
20
+ /**
21
+ * Pad string to specified length
22
+ */
23
+ function padRight(str, len) {
24
+ return str.padEnd(len);
25
+ }
26
+
27
+ /**
28
+ * Format ASCII box header
29
+ */
30
+ function formatHeader(title) {
31
+ const width = 47;
32
+ const padding = Math.floor((width - title.length) / 2);
33
+ const paddedTitle = ' '.repeat(padding) + title + ' '.repeat(width - padding - title.length);
34
+
35
+ return [
36
+ '\u2554' + '\u2550'.repeat(width) + '\u2557',
37
+ '\u2551' + paddedTitle + '\u2551',
38
+ '\u255A' + '\u2550'.repeat(width) + '\u255D',
39
+ ].join('\n');
40
+ }
41
+
42
+ /**
43
+ * Format a section with checks
44
+ */
45
+ function formatSection(name, checks) {
46
+ const lines = [`\n${name}:`];
47
+
48
+ for (const check of checks) {
49
+ const status = check.passed ? OK : check.severity === SEVERITY.WARNING ? WARN : FAIL;
50
+ lines.push(
51
+ ` ${padRight(check.name, 24)} ${status}${check.message ? ' ' + check.message : ''}`
52
+ );
53
+ }
54
+
55
+ return lines.join('\n');
56
+ }
57
+
58
+ /**
59
+ * Format issues list with remediation
60
+ */
61
+ function formatIssues(issues) {
62
+ if (issues.length === 0) return '';
63
+
64
+ const lines = ['\n' + '\u2501'.repeat(20) + ' ISSUES FOUND ' + '\u2501'.repeat(20)];
65
+
66
+ issues.forEach((issue, i) => {
67
+ const prefix = issue.severity === SEVERITY.CRITICAL ? FAIL : WARN;
68
+ lines.push(`\n${prefix} ${issue.name}`);
69
+ if (issue.message) {
70
+ lines.push(` ${issue.message}`);
71
+ }
72
+ if (issue.remediation) {
73
+ lines.push(` Fix: ${issue.remediation}`);
74
+ }
75
+ });
76
+
77
+ return lines.join('\n');
78
+ }
79
+
80
+ /**
81
+ * Format final summary box
82
+ */
83
+ function formatSummary(passed, warned, failed) {
84
+ const total = passed + warned + failed;
85
+ const width = 47;
86
+
87
+ const resultLine = `Result: ${passed}/${total} passed, ${warned} warning${warned !== 1 ? 's' : ''}, ${failed} critical`;
88
+ const padding = Math.floor((width - resultLine.length) / 2);
89
+ const paddedResult =
90
+ ' '.repeat(padding) + resultLine + ' '.repeat(width - padding - resultLine.length);
91
+
92
+ return [
93
+ '\n' + '\u2554' + '\u2550'.repeat(width) + '\u2557',
94
+ '\u2551' + paddedResult + '\u2551',
95
+ '\u255A' + '\u2550'.repeat(width) + '\u255D',
96
+ ].join('\n');
97
+ }
98
+
99
+ /**
100
+ * Create a check result object
101
+ */
102
+ function createCheck(name, passed, options = {}) {
103
+ return {
104
+ name,
105
+ passed,
106
+ message: options.message || '',
107
+ severity: options.severity || (passed ? SEVERITY.INFO : SEVERITY.CRITICAL),
108
+ remediation: options.remediation || null,
109
+ };
110
+ }
111
+
112
+ /**
113
+ * Create a verifier result object
114
+ */
115
+ function createResult(name, checks) {
116
+ const passed = checks.filter((c) => c.passed).length;
117
+ const failed = checks.filter((c) => !c.passed && c.severity === SEVERITY.CRITICAL).length;
118
+ const warned = checks.filter((c) => !c.passed && c.severity === SEVERITY.WARNING).length;
119
+
120
+ return {
121
+ name,
122
+ checks,
123
+ passed,
124
+ failed,
125
+ warned,
126
+ issues: checks.filter((c) => !c.passed),
127
+ };
128
+ }
129
+
130
+ module.exports = {
131
+ OK,
132
+ WARN,
133
+ FAIL,
134
+ SKIP,
135
+ SEVERITY,
136
+ padRight,
137
+ formatHeader,
138
+ formatSection,
139
+ formatIssues,
140
+ formatSummary,
141
+ createCheck,
142
+ createResult,
143
+ };