@cloudstreamsoftware/claude-tools 1.0.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.
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # @cloudstream/claude-tools
2
+
3
+ CloudStream Software's Claude Code productivity tools for Zoho development.
4
+
5
+ ## Features
6
+
7
+ - **Prompt Routing**: Intelligent classification of your requests
8
+ - **Quality Gates**: Automatic credential scanning and code validation
9
+ - **Knowledge Server**: Access to CloudStream's Zoho/Deluge pattern library
10
+ - **Compliance Support**: HIPAA, SOC2, PCI-DSS workflow guidance
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @cloudstream/claude-tools
16
+ npx cloudstream-setup
17
+ ```
18
+
19
+ ## Setup Wizard
20
+
21
+ The setup wizard will:
22
+
23
+ 1. **Detect installation type** - Internal (CloudStream employee) or Client
24
+ 2. **Validate license** - Verify your CloudStream license key
25
+ 3. **Configure MCP** - Connect to the CloudStream Knowledge Server
26
+ 4. **Install tools** - Set up hooks, skills, and agents in ~/.claude/
27
+
28
+ ## Usage
29
+
30
+ After setup, start a new Claude Code session in any project:
31
+
32
+ ```bash
33
+ claude
34
+ ```
35
+
36
+ The CloudStream tools are now available globally.
37
+
38
+ ### Knowledge Server
39
+
40
+ Ask about Zoho/Deluge patterns and the knowledge server will provide synthesized guidance:
41
+
42
+ ```
43
+ "How do I create a workflow that syncs CRM to Books?"
44
+ "What's the best practice for API calls in Deluge?"
45
+ "How do I handle errors in scheduled functions?"
46
+ ```
47
+
48
+ ### Available Commands
49
+
50
+ - `/help` - Show available commands
51
+ - `/diagnose` - Check system status
52
+ - `/checkpoint` - Create a session checkpoint
53
+ - `/handoff` - Generate session handoff notes
54
+
55
+ ## Security
56
+
57
+ - **No local caching** of proprietary knowledge data
58
+ - **Synthesized responses only** - raw patterns never leave the server
59
+ - **Short-lived tokens** - 15-minute OAuth 2.1 access tokens
60
+ - **Audit trail** - all queries logged for compliance
61
+
62
+ ## Requirements
63
+
64
+ - Node.js 18.0.0 or higher
65
+ - Claude Code CLI installed
66
+ - Valid CloudStream license key
67
+
68
+ ## Support
69
+
70
+ Contact your CloudStream administrator for license keys and support.
71
+
72
+ ## License
73
+
74
+ UNLICENSED - CloudStream Software proprietary.
@@ -0,0 +1,467 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * CloudStream Claude Tools Setup Wizard
5
+ *
6
+ * This wizard handles:
7
+ * 1. Detecting existing installations (git clone → npm migration)
8
+ * 2. Creating directory structure in ~/.claude/
9
+ * 3. Copying config with merge strategy (never overwrite user customizations)
10
+ * 4. Updating hook paths to absolute paths
11
+ * 5. Configuring MCP server connection
12
+ * 6. Validating license
13
+ * 7. Storing credentials securely
14
+ */
15
+
16
+ const readline = require('readline');
17
+ const fs = require('fs').promises;
18
+ const path = require('path');
19
+ const os = require('os');
20
+ const https = require('https');
21
+
22
+ // Configuration
23
+ const CONFIG = {
24
+ claudeDir: path.join(os.homedir(), '.claude'),
25
+ knowledgeApiUrl: 'https://knowledge.cloudstreamsoftware.com',
26
+ requiredDirs: [
27
+ 'hooks/scripts',
28
+ 'skills',
29
+ 'agents',
30
+ 'commands',
31
+ 'rules',
32
+ 'config',
33
+ 'sessions',
34
+ 'memory',
35
+ 'analytics'
36
+ ],
37
+ skipOnMerge: [
38
+ 'sessions/*',
39
+ 'memory/*',
40
+ 'analytics/*',
41
+ 'config/*.local.json'
42
+ ]
43
+ };
44
+
45
+ // ANSI color codes for terminal output
46
+ const colors = {
47
+ reset: '\x1b[0m',
48
+ bright: '\x1b[1m',
49
+ green: '\x1b[32m',
50
+ yellow: '\x1b[33m',
51
+ red: '\x1b[31m',
52
+ cyan: '\x1b[36m'
53
+ };
54
+
55
+ function log(message, color = '') {
56
+ console.log(`${color}${message}${colors.reset}`);
57
+ }
58
+
59
+ function logSuccess(message) {
60
+ log(` ✓ ${message}`, colors.green);
61
+ }
62
+
63
+ function logWarning(message) {
64
+ log(` ⚠ ${message}`, colors.yellow);
65
+ }
66
+
67
+ function logError(message) {
68
+ log(` ✗ ${message}`, colors.red);
69
+ }
70
+
71
+ function logStep(step, message) {
72
+ log(`\n[${step}] ${message}`, colors.cyan + colors.bright);
73
+ }
74
+
75
+ /**
76
+ * Create readline interface for user input
77
+ */
78
+ function createInterface() {
79
+ return readline.createInterface({
80
+ input: process.stdin,
81
+ output: process.stdout
82
+ });
83
+ }
84
+
85
+ /**
86
+ * Prompt user for input
87
+ */
88
+ function question(rl, prompt) {
89
+ return new Promise(resolve => rl.question(prompt, resolve));
90
+ }
91
+
92
+ /**
93
+ * Detect existing git clone installation
94
+ */
95
+ async function detectExistingInstallation() {
96
+ const claudeDir = CONFIG.claudeDir;
97
+
98
+ try {
99
+ await fs.access(claudeDir);
100
+
101
+ // Check for markers of existing installation
102
+ const markers = [
103
+ path.join(claudeDir, 'hooks', 'hooks.json'),
104
+ path.join(claudeDir, 'CLAUDE.md'),
105
+ path.join(claudeDir, 'skills')
106
+ ];
107
+
108
+ for (const marker of markers) {
109
+ try {
110
+ await fs.access(marker);
111
+ return true;
112
+ } catch {
113
+ // Continue checking
114
+ }
115
+ }
116
+ } catch {
117
+ // Directory doesn't exist
118
+ }
119
+
120
+ return false;
121
+ }
122
+
123
+ /**
124
+ * Create required directory structure
125
+ */
126
+ async function createDirectoryStructure() {
127
+ const claudeDir = CONFIG.claudeDir;
128
+
129
+ for (const dir of CONFIG.requiredDirs) {
130
+ const fullPath = path.join(claudeDir, dir);
131
+ await fs.mkdir(fullPath, { recursive: true });
132
+ }
133
+
134
+ logSuccess('Directory structure created');
135
+ }
136
+
137
+ /**
138
+ * Copy configuration files with merge strategy
139
+ */
140
+ async function copyConfigWithMerge(sourceDir, targetDir) {
141
+ const entries = await fs.readdir(sourceDir, { withFileTypes: true });
142
+
143
+ for (const entry of entries) {
144
+ const sourcePath = path.join(sourceDir, entry.name);
145
+ const targetPath = path.join(targetDir, entry.name);
146
+
147
+ if (entry.isDirectory()) {
148
+ await fs.mkdir(targetPath, { recursive: true });
149
+ await copyConfigWithMerge(sourcePath, targetPath);
150
+ } else {
151
+ // Check if this is a user customization file that should be preserved
152
+ const shouldSkip = CONFIG.skipOnMerge.some(pattern => {
153
+ const relativePath = path.relative(CONFIG.claudeDir, targetPath);
154
+ if (pattern.endsWith('*')) {
155
+ return relativePath.startsWith(pattern.slice(0, -1));
156
+ }
157
+ return relativePath === pattern;
158
+ });
159
+
160
+ if (shouldSkip) {
161
+ try {
162
+ await fs.access(targetPath);
163
+ // File exists, skip it
164
+ continue;
165
+ } catch {
166
+ // File doesn't exist, copy it
167
+ }
168
+ }
169
+
170
+ // For .default.json files, always overwrite
171
+ // For .json files (user config), only copy if doesn't exist
172
+ if (entry.name.endsWith('.default.json')) {
173
+ await fs.copyFile(sourcePath, targetPath);
174
+ } else if (entry.name.endsWith('.json')) {
175
+ try {
176
+ await fs.access(targetPath);
177
+ // User config exists, don't overwrite
178
+ } catch {
179
+ // User config doesn't exist, copy default as user config
180
+ await fs.copyFile(sourcePath, targetPath);
181
+ }
182
+ } else {
183
+ // Non-config files, copy normally
184
+ await fs.copyFile(sourcePath, targetPath);
185
+ }
186
+ }
187
+ }
188
+ }
189
+
190
+ /**
191
+ * Update hook paths to use absolute paths
192
+ */
193
+ async function updateHookPaths() {
194
+ const hooksJsonPath = path.join(CONFIG.claudeDir, 'hooks', 'hooks.json');
195
+
196
+ try {
197
+ const content = await fs.readFile(hooksJsonPath, 'utf8');
198
+ let hooksConfig = JSON.parse(content);
199
+
200
+ // Replace ${CLAUDE_PLUGIN_ROOT} with actual home directory path
201
+ const homeDir = os.homedir().replace(/\\/g, '/');
202
+ const updatedContent = JSON.stringify(hooksConfig, null, 2)
203
+ .replace(/\$\{CLAUDE_PLUGIN_ROOT\}/g, `${homeDir}/.claude`)
204
+ .replace(/\$\{HOME\}/g, homeDir);
205
+
206
+ await fs.writeFile(hooksJsonPath, updatedContent);
207
+ logSuccess('Hook paths updated to absolute paths');
208
+ } catch (error) {
209
+ logWarning(`Could not update hook paths: ${error.message}`);
210
+ }
211
+ }
212
+
213
+ /**
214
+ * Validate license with server
215
+ */
216
+ async function validateLicense(licenseKey) {
217
+ return new Promise((resolve) => {
218
+ const url = `${CONFIG.knowledgeApiUrl}/api/v1/license/validate`;
219
+
220
+ const postData = JSON.stringify({ key: licenseKey });
221
+
222
+ const options = {
223
+ method: 'POST',
224
+ headers: {
225
+ 'Content-Type': 'application/json',
226
+ 'Content-Length': Buffer.byteLength(postData)
227
+ },
228
+ timeout: 10000
229
+ };
230
+
231
+ const req = https.request(url, options, (res) => {
232
+ let data = '';
233
+ res.on('data', chunk => data += chunk);
234
+ res.on('end', () => {
235
+ try {
236
+ const result = JSON.parse(data);
237
+ resolve(result.valid === true);
238
+ } catch {
239
+ resolve(false);
240
+ }
241
+ });
242
+ });
243
+
244
+ req.on('error', () => {
245
+ // Server unavailable, accept license for offline mode
246
+ logWarning('Could not reach license server, continuing in offline mode');
247
+ resolve(true);
248
+ });
249
+
250
+ req.on('timeout', () => {
251
+ req.destroy();
252
+ logWarning('License validation timed out, continuing in offline mode');
253
+ resolve(true);
254
+ });
255
+
256
+ req.write(postData);
257
+ req.end();
258
+ });
259
+ }
260
+
261
+ /**
262
+ * Store credentials securely using platform-specific methods
263
+ */
264
+ async function storeCredentials(licenseKey, installType) {
265
+ const credentialsDir = path.join(CONFIG.claudeDir, 'credentials');
266
+ await fs.mkdir(credentialsDir, { recursive: true });
267
+
268
+ // For now, store in a config file
269
+ // TODO: Integrate with keytar for secure storage
270
+ const credentials = {
271
+ licenseKey,
272
+ installType,
273
+ createdAt: new Date().toISOString()
274
+ };
275
+
276
+ const credentialsPath = path.join(credentialsDir, 'cloudstream.json');
277
+ await fs.writeFile(credentialsPath, JSON.stringify(credentials, null, 2));
278
+
279
+ // Set restrictive permissions (Unix only)
280
+ if (process.platform !== 'win32') {
281
+ await fs.chmod(credentialsPath, 0o600);
282
+ }
283
+
284
+ logSuccess('Credentials stored securely');
285
+ }
286
+
287
+ /**
288
+ * Configure MCP server connection
289
+ */
290
+ async function configureMcpServer(licenseKey) {
291
+ const mcpConfigPath = path.join(CONFIG.claudeDir, 'mcp.json');
292
+
293
+ let existingConfig = { mcpServers: {} };
294
+ try {
295
+ const content = await fs.readFile(mcpConfigPath, 'utf8');
296
+ existingConfig = JSON.parse(content);
297
+ } catch {
298
+ // File doesn't exist or is invalid
299
+ }
300
+
301
+ // Add CloudStream knowledge server
302
+ existingConfig.mcpServers = existingConfig.mcpServers || {};
303
+ existingConfig.mcpServers['cloudstream-knowledge'] = {
304
+ command: 'npx',
305
+ args: ['@cloudstream/knowledge-mcp-client'],
306
+ env: {
307
+ CLOUDSTREAM_LICENSE: licenseKey,
308
+ CLOUDSTREAM_API: CONFIG.knowledgeApiUrl
309
+ }
310
+ };
311
+
312
+ await fs.writeFile(mcpConfigPath, JSON.stringify(existingConfig, null, 2));
313
+ logSuccess('MCP server configured');
314
+ }
315
+
316
+ /**
317
+ * Verify connection to knowledge server
318
+ */
319
+ async function verifyConnection(licenseKey) {
320
+ return new Promise((resolve) => {
321
+ const url = `${CONFIG.knowledgeApiUrl}/api/v1/health`;
322
+
323
+ const options = {
324
+ headers: {
325
+ 'Authorization': `Bearer ${licenseKey}`
326
+ },
327
+ timeout: 5000
328
+ };
329
+
330
+ https.get(url, options, (res) => {
331
+ resolve(res.statusCode === 200);
332
+ }).on('error', () => {
333
+ resolve(false);
334
+ }).on('timeout', () => {
335
+ resolve(false);
336
+ });
337
+ });
338
+ }
339
+
340
+ /**
341
+ * Main setup function
342
+ */
343
+ async function setup() {
344
+ console.log('\n' + '='.repeat(50));
345
+ log(' CloudStream Claude Tools Setup', colors.bright + colors.cyan);
346
+ console.log('='.repeat(50) + '\n');
347
+
348
+ const rl = createInterface();
349
+
350
+ try {
351
+ // Step 1: Check for existing installation
352
+ logStep('1/7', 'Checking for existing installation...');
353
+ const existingInstall = await detectExistingInstallation();
354
+
355
+ if (existingInstall) {
356
+ logWarning('Existing installation detected');
357
+ const migrate = await question(rl, ' Migrate existing configuration? [Y/n]: ');
358
+ if (migrate.toLowerCase() === 'n') {
359
+ log('\nSetup cancelled by user.', colors.yellow);
360
+ rl.close();
361
+ process.exit(0);
362
+ }
363
+ logSuccess('Will migrate existing configuration');
364
+ } else {
365
+ logSuccess('Fresh installation');
366
+ }
367
+
368
+ // Step 2: Select installation type
369
+ logStep('2/7', 'Select installation type');
370
+ console.log(' 1. Internal (CloudStream employee)');
371
+ console.log(' 2. Client');
372
+ const installTypeInput = await question(rl, '\n Select [1/2]: ');
373
+ const installType = installTypeInput === '1' ? 'internal' : 'client';
374
+ logSuccess(`Installation type: ${installType}`);
375
+
376
+ // Step 3: Get license key
377
+ logStep('3/7', 'License validation');
378
+ const licenseKey = await question(rl, ' Enter your license key: ');
379
+
380
+ if (!licenseKey.trim()) {
381
+ logError('License key is required');
382
+ rl.close();
383
+ process.exit(1);
384
+ }
385
+
386
+ const isValid = await validateLicense(licenseKey);
387
+ if (!isValid) {
388
+ logError('Invalid license key');
389
+ rl.close();
390
+ process.exit(1);
391
+ }
392
+ logSuccess('License validated');
393
+
394
+ // Step 4: Create directory structure
395
+ logStep('4/7', 'Creating directory structure...');
396
+ await createDirectoryStructure();
397
+
398
+ // Step 5: Copy configuration files
399
+ logStep('5/7', 'Installing configuration files...');
400
+ const packageConfigDir = path.join(__dirname, '..', 'config');
401
+ try {
402
+ await copyConfigWithMerge(packageConfigDir, CONFIG.claudeDir);
403
+ logSuccess('Configuration files installed');
404
+ } catch (error) {
405
+ logWarning(`Some configuration files could not be copied: ${error.message}`);
406
+ }
407
+
408
+ // Copy hook scripts
409
+ const packageHooksDir = path.join(__dirname, '..', 'dist', 'hooks');
410
+ const targetHooksDir = path.join(CONFIG.claudeDir, 'hooks', 'scripts');
411
+ try {
412
+ await copyConfigWithMerge(packageHooksDir, targetHooksDir);
413
+ await updateHookPaths();
414
+ } catch (error) {
415
+ logWarning(`Hook scripts could not be copied: ${error.message}`);
416
+ }
417
+
418
+ // Step 6: Configure MCP server
419
+ logStep('6/7', 'Configuring MCP server connection...');
420
+ await configureMcpServer(licenseKey);
421
+ await storeCredentials(licenseKey, installType);
422
+
423
+ // Step 7: Verify connection
424
+ logStep('7/7', 'Verifying knowledge server connection...');
425
+ const connected = await verifyConnection(licenseKey);
426
+
427
+ if (connected) {
428
+ logSuccess('Connected to CloudStream Knowledge Server');
429
+ } else {
430
+ logWarning('Could not connect to knowledge server');
431
+ console.log(' The tools will work offline with local skills.');
432
+ console.log(' Knowledge server features will be available when connected.');
433
+ }
434
+
435
+ // Complete
436
+ console.log('\n' + '='.repeat(50));
437
+ log(' Setup Complete!', colors.bright + colors.green);
438
+ console.log('='.repeat(50));
439
+ console.log('\nThe CloudStream tools are now available globally.');
440
+ console.log('Start a new Claude Code session to begin.\n');
441
+
442
+ if (installType === 'internal') {
443
+ console.log('Internal features enabled:');
444
+ console.log(' - Full pattern access');
445
+ console.log(' - Submit learned patterns');
446
+ console.log(' - Admin tools');
447
+ } else {
448
+ console.log('Client features enabled:');
449
+ console.log(' - Pattern guidance (synthesized)');
450
+ console.log(' - Best practice recommendations');
451
+ }
452
+
453
+ console.log('\nRun "claude" in any project to get started.\n');
454
+
455
+ } catch (error) {
456
+ logError(`Setup failed: ${error.message}`);
457
+ process.exit(1);
458
+ } finally {
459
+ rl.close();
460
+ }
461
+ }
462
+
463
+ // Run setup
464
+ setup().catch(error => {
465
+ console.error('Fatal error:', error);
466
+ process.exit(1);
467
+ });
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * CloudStream Claude Tools - Postinstall Script
5
+ *
6
+ * This script runs automatically after npm install.
7
+ * It displays setup instructions without running the full wizard automatically.
8
+ */
9
+
10
+ const colors = {
11
+ reset: '\x1b[0m',
12
+ bright: '\x1b[1m',
13
+ cyan: '\x1b[36m',
14
+ yellow: '\x1b[33m'
15
+ };
16
+
17
+ console.log(`
18
+ ${colors.cyan}${colors.bright}╔════════════════════════════════════════════════════════════╗
19
+ ║ ║
20
+ ║ CloudStream Claude Tools installed successfully! ║
21
+ ║ ║
22
+ ╚════════════════════════════════════════════════════════════╝${colors.reset}
23
+
24
+ ${colors.yellow}To complete setup, run:${colors.reset}
25
+
26
+ ${colors.bright}npx cloudstream-setup${colors.reset}
27
+
28
+ This will:
29
+ 1. Configure your installation type (internal/client)
30
+ 2. Validate your license key
31
+ 3. Set up the knowledge server connection
32
+ 4. Install hooks and skills to ~/.claude/
33
+
34
+ ${colors.cyan}Need a license key? Contact your CloudStream administrator.${colors.reset}
35
+ `);
@@ -0,0 +1,295 @@
1
+ # CloudStream Software LLC - Claude Code Configuration
2
+
3
+ ## Company Context
4
+ - Zoho One consultancy + full-stack development firm
5
+ - Primary verticals: Healthcare (HIPAA), Finance (PCI-DSS), Enterprise (SOC2)
6
+ - This is BILLABLE CLIENT WORK. Every action must be auditable, defensible, handoff-ready.
7
+
8
+ ## Technology Stack
9
+ - **Zoho Platform:** CRM, Books, Creator, Analytics, Catalyst
10
+ - **Full-Stack:** React/Next.js widgets, Node.js backends (Zoho + standalone)
11
+ - **Google Cloud:** BigQuery, Dataflow, Cloud Functions, Cloud Storage
12
+ - **Data Engineering:** Medallion architecture (bronze/silver/gold), dbt, Looker
13
+ - **Languages:** JavaScript/TypeScript, Deluge, Python, SQL
14
+
15
+ ## Compliance Modes (set per-client in client CLAUDE.md)
16
+ - `hipaa` - Healthcare clients (ePHI field handling, BAA, audit archival)
17
+ - `soc2` - Enterprise clients (audit logging, change management, access controls)
18
+ - `pci-dss` - Financial clients (Zoho Checkout only, tokenization, SAQ-A)
19
+ - `standard` - Non-regulated clients
20
+
21
+ ## User Settings (configure in CLAUDE.local.md)
22
+
23
+ The following settings are user-specific and should NOT be set in this parent repo.
24
+ Create a `CLAUDE.local.md` file in your fork for personal preferences:
25
+
26
+ - **Training Mode**: Set `enabled` or `disabled` based on your experience level
27
+ - **Training Verbosity**: Set `minimal`, `standard`, or `detailed`
28
+ - **Personal shortcuts**: Client-specific aliases, custom workflows
29
+
30
+ See [docs/LOCAL-SETTINGS.md](docs/LOCAL-SETTINGS.md) for setup instructions.
31
+
32
+ ## Commit Convention
33
+ [CLIENT-ID] type(scope): description | Time: Xh Xm
34
+
35
+ ## Zoho Critical Constraints (ALWAYS REMEMBER)
36
+ - Deluge: 5000 statement limit per execution
37
+ - Deluge invokeUrl: 40-second hard timeout
38
+ - Catalyst I/O functions: 30-second timeout (use Cron for batch: 15min)
39
+ - Catalyst: context.close() MANDATORY at end of ALL functions
40
+ - Widgets: Do NOT work on published pages (use Publish API instead)
41
+ - OAuth tokens: Expire in 1 hour (implement refresh logic)
42
+ - Creator audit data: Retained only 1 year (implement archival)
43
+ - CRM→Books sync: Native 2-hour cycle exists (don't rebuild)
44
+
45
+ ---
46
+
47
+ ## Available Skills (15)
48
+
49
+ Skills are domain knowledge patterns automatically injected based on context.
50
+
51
+ | Skill | Purpose |
52
+ |-------|---------|
53
+ | backend-patterns | Node.js, Express, API design, database optimization |
54
+ | bigquery-patterns | BigQuery schema design, query optimization, partitioning |
55
+ | cloudstream-project-template | New project scaffolding, directory layout, compliance mode |
56
+ | coding-standards | Universal TypeScript/JS standards, best practices |
57
+ | compliance-patterns | HIPAA, SOC2, PCI-DSS implementation patterns |
58
+ | consultancy-workflows | Client isolation, time tracking, handoff procedures |
59
+ | continuous-learning | Session-end pattern extraction and skill capture |
60
+ | continuous-learning-v2 | Instinct-based pattern extraction and skill learning |
61
+ | frontend-patterns | React, Next.js, state management, UI optimization |
62
+ | gcp-data-engineering | Medallion architecture, Dataflow, dbt patterns |
63
+ | security-review | OWASP Top 10, vulnerability detection, secret scanning |
64
+ | strategic-compact | Context compaction at logical intervals |
65
+ | tdd-workflow | Test-driven development, 80%+ coverage enforcement |
66
+ | tutorial | Interactive onboarding system, lessons, accelerated track |
67
+ | zoho-patterns | Creator, Catalyst, Deluge, Analytics, integrations |
68
+
69
+ ---
70
+
71
+ ## Available Agents (13)
72
+
73
+ Agents are specialized subprocesses triggered for delegated tasks.
74
+
75
+ | Agent | Purpose | Suggested Model |
76
+ |-------|---------|-----------------|
77
+ | planner | Implementation planning for complex features | Opus |
78
+ | architect | System design, scalability, technical decisions | Opus |
79
+ | creator-architect | Zoho Creator app architecture, form hierarchies | Opus |
80
+ | security-reviewer | Security vulnerability detection, OWASP Top 10 | Opus |
81
+ | compliance-auditor | HIPAA/SOC2/PCI-DSS regulatory audits | Opus |
82
+ | code-reviewer | Code quality, maintainability, best practices | Sonnet |
83
+ | deluge-reviewer | Deluge validation, 5000-statement limit awareness | Sonnet |
84
+ | tdd-guide | Test-driven development enforcement | Sonnet |
85
+ | build-error-resolver | Build and TypeScript error fixes | Sonnet |
86
+ | catalyst-deployer | Catalyst AppSail/Functions deployment | Sonnet |
87
+ | e2e-runner | Playwright E2E test generation and execution | Sonnet |
88
+ | refactor-cleaner | Dead code cleanup with knip/depcheck/ts-prune | Sonnet |
89
+ | doc-updater | Documentation sync, codemap generation | Sonnet |
90
+
91
+ > **Note:** Model selection is suggested by the prompt router but not programmatically enforced. See [docs/MODEL-SELECTION.md](docs/MODEL-SELECTION.md) for guidance.
92
+
93
+ ---
94
+
95
+ ## Hooks System
96
+
97
+ Hooks are automated scripts triggered at specific lifecycle points.
98
+
99
+ | Event | Count | Purpose |
100
+ |-------|-------|---------|
101
+ | SessionStart | 1 | Load context, detect package manager |
102
+ | SessionEnd | 2 | Persist state, evaluate session for patterns |
103
+ | UserPromptSubmit | 2 | Prompt routing, correction detection |
104
+ | PreToolUse | 8 | Credential scan, quality gates, skill injection, tmux reminders |
105
+ | PostToolUse | 4 | Prettier format, TypeScript check, console.log warnings |
106
+ | PreCompact | 1 | Save state before context compaction |
107
+ | Stop | 1 | Check console.log in modified files |
108
+
109
+ **Total: 19 hooks across 7 events**
110
+
111
+ See `hooks/hooks.json` for full configuration.
112
+
113
+ ---
114
+
115
+ ## Agent Triggers
116
+
117
+ When to use which agent:
118
+ - Complex features → `planner`
119
+ - System design → `architect` + `creator-architect` (for Zoho)
120
+ - New/modified code → `code-reviewer`
121
+ - Deluge scripts → `deluge-reviewer`
122
+ - Security concerns → `security-reviewer`
123
+ - Compliance audit → `compliance-auditor`
124
+ - Build/deploy failures → `build-error-resolver` + `catalyst-deployer`
125
+ - Standalone widget testing → `e2e-runner`
126
+ - Documentation → `doc-updater`
127
+ - Dead code cleanup → `refactor-cleaner`
128
+
129
+ ---
130
+
131
+ ## Interactive Prompt Routing (Golden Standard)
132
+
133
+ **ENFORCED BY:** `rules/prompt-routing.md` and `rules/hook-awareness.md` (always active)
134
+
135
+ Claude MUST analyze every user prompt and offer appropriate routing options using AskUserQuestion.
136
+
137
+ ### Routing Indicator (Visual Feedback)
138
+
139
+ When the routing system processes a prompt, Claude shows a visual indicator in the AskUserQuestion header:
140
+
141
+ ```
142
+ ✅ Routed → TESTING (85%)
143
+
144
+ "Which approach would you like?"
145
+ - Use tdd-guide agent (Recommended)
146
+ - Proceed directly
147
+ ```
148
+
149
+ The `✅ Routed →` prefix confirms the prompt was analyzed by the intent classifier. The intent type and confidence percentage follow.
150
+
151
+ **Multi-intent example:**
152
+ ```
153
+ ✅ Routed → PLANNING + TESTING + SECURITY
154
+
155
+ "I've identified 3 objectives. How should we proceed?"
156
+ ```
157
+
158
+ ### Hook Integration
159
+
160
+ The `prompt-router.js` hook outputs `[ROUTING SUGGESTION]` blocks that Claude must act on:
161
+ - Check for these blocks in conversation context
162
+ - Use the detected intent and recommended agent
163
+ - Present options via AskUserQuestion as specified in the block
164
+ - See `rules/hook-awareness.md` for full block types
165
+
166
+ ### Step 1: Analyze Prompt Complexity
167
+
168
+ Before processing ANY user prompt, analyze for:
169
+ 1. **Single Intent** - One clear objective (e.g., "Fix this bug")
170
+ 2. **Multi-Intent** - Multiple objectives (e.g., "Plan the feature, write tests, and review security")
171
+ 3. **Compound Task** - One objective requiring multiple phases (e.g., "Build a full authentication system")
172
+
173
+ **Complexity Indicators:**
174
+ - Lists (numbered, bulleted, comma-separated)
175
+ - Conjunctions: "and", "also", "then", "after that"
176
+ - Multiple questions in one prompt
177
+ - Words like "comprehensive", "full", "complete", "everything"
178
+
179
+ ### Step 2: For Single-Intent Prompts
180
+
181
+ Detect intent and offer appropriate options via AskUserQuestion:
182
+
183
+ | Intent | Triggers | Recommended Agent | Model |
184
+ |--------|----------|-------------------|-------|
185
+ | PLANNING | "plan", "design", "architect", "strategy" | planner | Opus |
186
+ | SECURITY | "security", "audit", "vulnerabilities", "HIPAA" | security-reviewer | Opus |
187
+ | COMPLIANCE | "compliance", "SOC2", "PCI", "regulations" | compliance-auditor | Opus |
188
+ | REVIEW | "review", "check", "look over", "feedback" | code-reviewer | Sonnet |
189
+ | TESTING | "test", "TDD", "coverage", "write tests" | tdd-guide | Sonnet |
190
+ | DEBUG | "fix", "error", "bug", "broken", "failing" | build-error-resolver | Sonnet |
191
+ | REFACTOR | "refactor", "clean up", "optimize", "improve" | refactor-cleaner | Sonnet |
192
+ | ZOHO | "Zoho", "Creator", "Deluge", "Catalyst" | creator-architect | Opus |
193
+ | DEPLOY | "deploy", "release", "ship", "production" | catalyst-deployer | Sonnet |
194
+ | E2E | "e2e", "playwright", "end-to-end", "journey" | e2e-runner | Sonnet |
195
+ | LEARNING | "learn", "extract", "pattern", "capture" | - | - |
196
+ | SETUP | "setup", "configure", "install", "onboard" | - | - |
197
+ | HANDOFF | "handoff", "transfer", "deliverable" | doc-updater | Sonnet |
198
+ | DOCUMENTATION | "docs", "document", "readme", "update docs" | doc-updater | Sonnet |
199
+
200
+ **Options to present:**
201
+ 1. "Use [agent] with [model] (Recommended)" - Specialized handling
202
+ 2. "Proceed directly" - Quick response without agent
203
+ 3. "Show all available agents" - Browse options
204
+
205
+ ### Step 3: For Multi-Intent Prompts (CRITICAL)
206
+
207
+ When multiple objectives detected:
208
+
209
+ 1. **Present Breakdown** - Show user what tasks were detected
210
+ 2. **Offer Orchestration Options:**
211
+ - "Create a plan first (recommended)" - Uses planner to sequence tasks
212
+ - "Execute tasks in order" - Process sequentially as listed
213
+ - "Let me choose which tasks" - Multi-select for user control
214
+ - "Focus on one task first" - User picks priority
215
+
216
+ 3. **Use Multi-Select AskUserQuestion** when appropriate for task selection
217
+
218
+ ### Step 4: For Compound Tasks
219
+
220
+ Large tasks requiring multiple phases (e.g., "Build full auth system"):
221
+
222
+ 1. **Always recommend planner first** - Complex tasks need a plan
223
+ 2. **Offer phased approach:**
224
+ - Phase 1: Architecture design (architect agent)
225
+ - Phase 2: Implementation (with TDD)
226
+ - Phase 3: Security review
227
+ - Phase 4: Documentation
228
+
229
+ ### Step 5: Context-Aware Suggestions
230
+
231
+ Also consider:
232
+ - **Current file context** - If editing a test file, suggest tdd-guide
233
+ - **Recent activity** - If just finished planning, suggest implementation
234
+ - **Compliance mode** - If HIPAA client, always suggest compliance check
235
+ - **Error state** - If build failing, suggest build-error-resolver
236
+
237
+ ### Example: Complex Prompt Handling
238
+
239
+ **User says:** "I need to add user authentication with OAuth, make sure it's HIPAA compliant, write comprehensive tests, and document the API."
240
+
241
+ **Claude detects:** 4 objectives (Auth, HIPAA, tests, docs) + Compound nature
242
+
243
+ **Claude responds with AskUserQuestion:**
244
+ - Header: "✅ Routed → PLANNING + SECURITY + TESTING + DOCUMENTATION"
245
+ - Question: "I've identified 4 objectives. How would you like to proceed?"
246
+ - Options:
247
+ 1. "Create a comprehensive plan first (Recommended)" - Uses planner agent
248
+ 2. "Address each objective in order" - Auth → Compliance → Tests → Docs
249
+ 3. "Let me prioritize these objectives" - Opens multi-select
250
+ 4. "Focus on authentication first, handle rest later" - Narrows scope
251
+
252
+ ---
253
+
254
+ ## Quick Commands Reference
255
+
256
+ | Command | Description |
257
+ |---------|-------------|
258
+ | `/plan` | Implementation planning before coding |
259
+ | `/tdd` | Test-driven development workflow |
260
+ | `/code-review` | Quality and security review |
261
+ | `/verify` | Run verification loop |
262
+ | `/build-fix` | Fix build and deployment errors |
263
+ | `/e2e` | E2E test generation (Playwright) |
264
+ | `/zoho-scaffold` | Scaffold Creator/Catalyst/Widget projects |
265
+ | `/deluge` | Generate and fix Deluge scripts |
266
+ | `/compliance-check` | Run HIPAA/SOC2/PCI-DSS audit |
267
+ | `/client-switch` | Switch active client context |
268
+ | `/handoff` | Generate client handoff documentation |
269
+ | `/learn` | Extract reusable patterns mid-session |
270
+ | `/health-check` | System health verification |
271
+ | `/diagnose` | Deep diagnostic troubleshooting |
272
+ | `/onboard` | Interactive setup wizard |
273
+ | `/team-admin` | Team administration tools |
274
+
275
+ See README.md for full command list (36 commands).
276
+
277
+ ---
278
+
279
+ ## Documentation
280
+
281
+ - [README.md](README.md) - Quick start and full component overview
282
+ - [GETTING-STARTED.md](GETTING-STARTED.md) - New employee onboarding
283
+ - [CLIENT-SETUP-GUIDE.md](CLIENT-SETUP-GUIDE.md) - Setting up new client projects
284
+ - [MCP-SETUP-GUIDE.md](MCP-SETUP-GUIDE.md) - Installing and configuring MCP servers
285
+ - [ZOHO-QUICK-REFERENCE.md](ZOHO-QUICK-REFERENCE.md) - Zoho constraints and decision matrices
286
+ - [CONTRIBUTING.md](CONTRIBUTING.md) - How to contribute to this repository
287
+
288
+ ---
289
+
290
+ ## Plan File Management
291
+
292
+ Plans must only show current work. When a phase completes:
293
+ 1. Remove completed content from plan file
294
+ 2. Document completion in CHANGELOG.md
295
+ 3. Keep plan concise and scannable (<100 lines)
@@ -0,0 +1,142 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "name": "cloudstream-knowledge",
4
+ "description": "CloudStream Knowledge Server - Zoho/Deluge patterns and best practices",
5
+ "version": "1.0.0",
6
+ "server": {
7
+ "command": "npx",
8
+ "args": ["@cloudstream/knowledge-mcp-client"],
9
+ "env": {
10
+ "CLOUDSTREAM_LICENSE": "${LICENSE_KEY}",
11
+ "CLOUDSTREAM_API": "https://knowledge.cloudstreamsoftware.com"
12
+ }
13
+ },
14
+ "tools": [
15
+ {
16
+ "name": "get_deluge_guidance",
17
+ "description": "Get synthesized guidance for a Deluge task (pattern code processed server-side, never sent to client)",
18
+ "parameters": {
19
+ "task_type": {
20
+ "type": "string",
21
+ "enum": ["api_call", "record_create", "record_update", "workflow", "scheduled_function", "widget_backend", "custom_function"],
22
+ "required": true
23
+ },
24
+ "context": {
25
+ "type": "string",
26
+ "description": "What the code needs to accomplish",
27
+ "required": true
28
+ },
29
+ "module": {
30
+ "type": "string",
31
+ "enum": ["crm", "books", "creator", "analytics", "catalyst", "desk"],
32
+ "required": false
33
+ }
34
+ }
35
+ },
36
+ {
37
+ "name": "get_workflow_guidance",
38
+ "description": "Get workflow automation guidance (synthesized, not raw templates)",
39
+ "parameters": {
40
+ "source": {
41
+ "type": "string",
42
+ "description": "Source module (e.g., crm)",
43
+ "required": true
44
+ },
45
+ "target": {
46
+ "type": "string",
47
+ "description": "Target module (e.g., books)",
48
+ "required": false
49
+ },
50
+ "trigger": {
51
+ "type": "string",
52
+ "enum": ["record_create", "record_update", "field_change", "scheduled", "button"],
53
+ "required": true
54
+ }
55
+ }
56
+ },
57
+ {
58
+ "name": "get_schedule_guidance",
59
+ "description": "Get scheduled function guidance (synthesized, not raw templates)",
60
+ "parameters": {
61
+ "frequency": {
62
+ "type": "string",
63
+ "enum": ["minutely", "hourly", "daily", "weekly", "monthly"],
64
+ "required": true
65
+ },
66
+ "task_type": {
67
+ "type": "string",
68
+ "description": "Type of task (sync, cleanup, report, notification)",
69
+ "required": true
70
+ }
71
+ }
72
+ },
73
+ {
74
+ "name": "search_knowledge",
75
+ "description": "Search the CloudStream knowledge base for relevant information",
76
+ "parameters": {
77
+ "query": {
78
+ "type": "string",
79
+ "description": "Search query",
80
+ "required": true
81
+ },
82
+ "category": {
83
+ "type": "string",
84
+ "enum": ["deluge", "workflow", "integration", "compliance", "all"],
85
+ "required": false,
86
+ "default": "all"
87
+ },
88
+ "limit": {
89
+ "type": "number",
90
+ "required": false,
91
+ "default": 5
92
+ }
93
+ }
94
+ },
95
+ {
96
+ "name": "get_best_practice",
97
+ "description": "Get CloudStream-approved best practice for a topic",
98
+ "parameters": {
99
+ "topic": {
100
+ "type": "string",
101
+ "description": "Topic to get best practice for",
102
+ "required": true
103
+ },
104
+ "compliance_mode": {
105
+ "type": "string",
106
+ "enum": ["hipaa", "soc2", "pci-dss", "standard"],
107
+ "required": false,
108
+ "default": "standard"
109
+ }
110
+ }
111
+ },
112
+ {
113
+ "name": "submit_learned_pattern",
114
+ "description": "Submit a new pattern learned during a session (internal users only)",
115
+ "parameters": {
116
+ "pattern_type": {
117
+ "type": "string",
118
+ "required": true
119
+ },
120
+ "code": {
121
+ "type": "string",
122
+ "required": true
123
+ },
124
+ "explanation": {
125
+ "type": "string",
126
+ "required": true
127
+ },
128
+ "context": {
129
+ "type": "string",
130
+ "required": false
131
+ }
132
+ },
133
+ "internal_only": true
134
+ }
135
+ ],
136
+ "security": {
137
+ "no_cache": true,
138
+ "cache_control": "private, no-store, no-cache, max-age=0",
139
+ "synthesized_responses_only": true,
140
+ "token_ttl_minutes": 15
141
+ }
142
+ }
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@cloudstreamsoftware/claude-tools",
3
+ "version": "1.0.0",
4
+ "description": "CloudStream Claude Code productivity tools - hooks, skills, agents, and knowledge server integration",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "cloudstream-setup": "./bin/cloudstream-setup.js"
8
+ },
9
+ "scripts": {
10
+ "postinstall": "node ./bin/postinstall.js",
11
+ "setup": "node ./bin/cloudstream-setup.js",
12
+ "build": "node ./scripts/build.js",
13
+ "test": "node ./scripts/test.js"
14
+ },
15
+ "keywords": [
16
+ "claude",
17
+ "claude-code",
18
+ "zoho",
19
+ "deluge",
20
+ "productivity",
21
+ "ai-tools",
22
+ "mcp",
23
+ "cloudstream"
24
+ ],
25
+ "author": "CloudStream Software",
26
+ "license": "UNLICENSED",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/cloudstream-dev/flowstate.git"
30
+ },
31
+ "engines": {
32
+ "node": ">=18.0.0"
33
+ },
34
+ "files": [
35
+ "bin/",
36
+ "dist/",
37
+ "config/",
38
+ "mcp/",
39
+ "README.md"
40
+ ],
41
+ "dependencies": {
42
+ "keytar": "^7.9.0"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ }
47
+ }