@hailer/mcp 0.0.1

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 (163) hide show
  1. package/.claude/commands/tool-builder.md +37 -0
  2. package/.claude/commands/ws-pull.md +44 -0
  3. package/.claude/settings.json +8 -0
  4. package/.claude/settings.local.json +49 -0
  5. package/.claude/skills/activity-api/SKILL.md +96 -0
  6. package/.claude/skills/activity-api/references/activity-endpoints.md +845 -0
  7. package/.claude/skills/add-app-member-skill/SKILL.md +977 -0
  8. package/.claude/skills/agent-building/SKILL.md +243 -0
  9. package/.claude/skills/agent-building/references/architecture-patterns.md +446 -0
  10. package/.claude/skills/agent-building/references/code-examples.md +587 -0
  11. package/.claude/skills/agent-building/references/implementation-guide.md +619 -0
  12. package/.claude/skills/app-api/SKILL.md +219 -0
  13. package/.claude/skills/app-api/references/app-endpoints.md +759 -0
  14. package/.claude/skills/building-hailer-apps-skill/SKILL.md +548 -0
  15. package/.claude/skills/create-app-skill/SKILL.md +1101 -0
  16. package/.claude/skills/create-insight-skill/SKILL.md +1317 -0
  17. package/.claude/skills/get-insight-data-skill/SKILL.md +1053 -0
  18. package/.claude/skills/hailer-api/SKILL.md +283 -0
  19. package/.claude/skills/hailer-api/references/activities.md +620 -0
  20. package/.claude/skills/hailer-api/references/authentication.md +216 -0
  21. package/.claude/skills/hailer-api/references/datasets.md +437 -0
  22. package/.claude/skills/hailer-api/references/files.md +301 -0
  23. package/.claude/skills/hailer-api/references/insights.md +469 -0
  24. package/.claude/skills/hailer-api/references/workflows.md +720 -0
  25. package/.claude/skills/hailer-api/references/workspaces-users.md +445 -0
  26. package/.claude/skills/insight-api/SKILL.md +185 -0
  27. package/.claude/skills/insight-api/references/insight-endpoints.md +514 -0
  28. package/.claude/skills/install-workflow-skill/SKILL.md +1056 -0
  29. package/.claude/skills/list-apps-skill/SKILL.md +1010 -0
  30. package/.claude/skills/list-workflows-minimal-skill/SKILL.md +992 -0
  31. package/.claude/skills/local-first-skill/SKILL.md +570 -0
  32. package/.claude/skills/mcp-tools/SKILL.md +419 -0
  33. package/.claude/skills/mcp-tools/references/api-endpoints.md +499 -0
  34. package/.claude/skills/mcp-tools/references/data-structures.md +554 -0
  35. package/.claude/skills/mcp-tools/references/implementation-patterns.md +717 -0
  36. package/.claude/skills/preview-insight-skill/SKILL.md +1290 -0
  37. package/.claude/skills/publish-hailer-app-skill/SKILL.md +453 -0
  38. package/.claude/skills/remove-app-member-skill/SKILL.md +671 -0
  39. package/.claude/skills/remove-app-skill/SKILL.md +985 -0
  40. package/.claude/skills/remove-insight-skill/SKILL.md +1011 -0
  41. package/.claude/skills/remove-workflow-skill/SKILL.md +920 -0
  42. package/.claude/skills/scaffold-hailer-app-skill/SKILL.md +1034 -0
  43. package/.claude/skills/skill-testing/README.md +137 -0
  44. package/.claude/skills/skill-testing/SKILL.md +348 -0
  45. package/.claude/skills/skill-testing/references/test-patterns.md +705 -0
  46. package/.claude/skills/skill-testing/references/testing-guide.md +603 -0
  47. package/.claude/skills/skill-testing/references/validation-checklist.md +537 -0
  48. package/.claude/skills/tool-builder/SKILL.md +328 -0
  49. package/.claude/skills/update-app-skill/SKILL.md +970 -0
  50. package/.claude/skills/update-workflow-field-skill/SKILL.md +1098 -0
  51. package/.env.example +81 -0
  52. package/.mcp.json +13 -0
  53. package/README.md +297 -0
  54. package/dist/app.d.ts +4 -0
  55. package/dist/app.js +74 -0
  56. package/dist/cli.d.ts +3 -0
  57. package/dist/cli.js +5 -0
  58. package/dist/client/adaptive-documentation-bot.d.ts +108 -0
  59. package/dist/client/adaptive-documentation-bot.js +475 -0
  60. package/dist/client/adaptive-documentation-types.d.ts +66 -0
  61. package/dist/client/adaptive-documentation-types.js +9 -0
  62. package/dist/client/agent-activity-bot.d.ts +51 -0
  63. package/dist/client/agent-activity-bot.js +166 -0
  64. package/dist/client/agent-tracker.d.ts +499 -0
  65. package/dist/client/agent-tracker.js +659 -0
  66. package/dist/client/description-updater.d.ts +56 -0
  67. package/dist/client/description-updater.js +259 -0
  68. package/dist/client/log-parser.d.ts +72 -0
  69. package/dist/client/log-parser.js +387 -0
  70. package/dist/client/mcp-client.d.ts +50 -0
  71. package/dist/client/mcp-client.js +532 -0
  72. package/dist/client/message-processor.d.ts +35 -0
  73. package/dist/client/message-processor.js +352 -0
  74. package/dist/client/multi-bot-manager.d.ts +24 -0
  75. package/dist/client/multi-bot-manager.js +74 -0
  76. package/dist/client/providers/anthropic-provider.d.ts +19 -0
  77. package/dist/client/providers/anthropic-provider.js +631 -0
  78. package/dist/client/providers/llm-provider.d.ts +47 -0
  79. package/dist/client/providers/llm-provider.js +367 -0
  80. package/dist/client/providers/openai-provider.d.ts +23 -0
  81. package/dist/client/providers/openai-provider.js +621 -0
  82. package/dist/client/simple-llm-caller.d.ts +19 -0
  83. package/dist/client/simple-llm-caller.js +100 -0
  84. package/dist/client/skill-generator.d.ts +81 -0
  85. package/dist/client/skill-generator.js +386 -0
  86. package/dist/client/test-adaptive-bot.d.ts +9 -0
  87. package/dist/client/test-adaptive-bot.js +82 -0
  88. package/dist/client/token-pricing.d.ts +38 -0
  89. package/dist/client/token-pricing.js +127 -0
  90. package/dist/client/token-tracker.d.ts +232 -0
  91. package/dist/client/token-tracker.js +457 -0
  92. package/dist/client/token-usage-bot.d.ts +53 -0
  93. package/dist/client/token-usage-bot.js +153 -0
  94. package/dist/client/tool-executor.d.ts +69 -0
  95. package/dist/client/tool-executor.js +159 -0
  96. package/dist/client/tool-schema-loader.d.ts +60 -0
  97. package/dist/client/tool-schema-loader.js +178 -0
  98. package/dist/client/types.d.ts +69 -0
  99. package/dist/client/types.js +7 -0
  100. package/dist/config.d.ts +162 -0
  101. package/dist/config.js +296 -0
  102. package/dist/core.d.ts +26 -0
  103. package/dist/core.js +147 -0
  104. package/dist/lib/context-manager.d.ts +111 -0
  105. package/dist/lib/context-manager.js +431 -0
  106. package/dist/lib/logger.d.ts +74 -0
  107. package/dist/lib/logger.js +277 -0
  108. package/dist/lib/materialize.d.ts +3 -0
  109. package/dist/lib/materialize.js +101 -0
  110. package/dist/lib/normalizedName.d.ts +7 -0
  111. package/dist/lib/normalizedName.js +48 -0
  112. package/dist/lib/prompt-length-manager.d.ts +81 -0
  113. package/dist/lib/prompt-length-manager.js +457 -0
  114. package/dist/lib/terminal-prompt.d.ts +9 -0
  115. package/dist/lib/terminal-prompt.js +108 -0
  116. package/dist/mcp/UserContextCache.d.ts +56 -0
  117. package/dist/mcp/UserContextCache.js +163 -0
  118. package/dist/mcp/auth.d.ts +2 -0
  119. package/dist/mcp/auth.js +29 -0
  120. package/dist/mcp/hailer-clients.d.ts +42 -0
  121. package/dist/mcp/hailer-clients.js +246 -0
  122. package/dist/mcp/signal-handler.d.ts +45 -0
  123. package/dist/mcp/signal-handler.js +317 -0
  124. package/dist/mcp/tool-registry.d.ts +100 -0
  125. package/dist/mcp/tool-registry.js +306 -0
  126. package/dist/mcp/tools/activity.d.ts +15 -0
  127. package/dist/mcp/tools/activity.js +955 -0
  128. package/dist/mcp/tools/app.d.ts +20 -0
  129. package/dist/mcp/tools/app.js +1488 -0
  130. package/dist/mcp/tools/discussion.d.ts +19 -0
  131. package/dist/mcp/tools/discussion.js +950 -0
  132. package/dist/mcp/tools/file.d.ts +15 -0
  133. package/dist/mcp/tools/file.js +119 -0
  134. package/dist/mcp/tools/insight.d.ts +17 -0
  135. package/dist/mcp/tools/insight.js +806 -0
  136. package/dist/mcp/tools/skill.d.ts +10 -0
  137. package/dist/mcp/tools/skill.js +279 -0
  138. package/dist/mcp/tools/user.d.ts +10 -0
  139. package/dist/mcp/tools/user.js +108 -0
  140. package/dist/mcp/tools/workflow-template.d.ts +19 -0
  141. package/dist/mcp/tools/workflow-template.js +822 -0
  142. package/dist/mcp/tools/workflow.d.ts +18 -0
  143. package/dist/mcp/tools/workflow.js +1362 -0
  144. package/dist/mcp/utils/api-errors.d.ts +45 -0
  145. package/dist/mcp/utils/api-errors.js +160 -0
  146. package/dist/mcp/utils/data-transformers.d.ts +102 -0
  147. package/dist/mcp/utils/data-transformers.js +194 -0
  148. package/dist/mcp/utils/file-upload.d.ts +33 -0
  149. package/dist/mcp/utils/file-upload.js +148 -0
  150. package/dist/mcp/utils/hailer-api-client.d.ts +120 -0
  151. package/dist/mcp/utils/hailer-api-client.js +323 -0
  152. package/dist/mcp/utils/index.d.ts +13 -0
  153. package/dist/mcp/utils/index.js +39 -0
  154. package/dist/mcp/utils/logger.d.ts +42 -0
  155. package/dist/mcp/utils/logger.js +103 -0
  156. package/dist/mcp/utils/types.d.ts +286 -0
  157. package/dist/mcp/utils/types.js +7 -0
  158. package/dist/mcp/workspace-cache.d.ts +42 -0
  159. package/dist/mcp/workspace-cache.js +97 -0
  160. package/dist/mcp-server.d.ts +42 -0
  161. package/dist/mcp-server.js +280 -0
  162. package/package.json +56 -0
  163. package/tsconfig.json +23 -0
@@ -0,0 +1,1034 @@
1
+ ---
2
+ name: scaffold-hailer-app-skill
3
+ description: Complete guide to ONE-SHOT Hailer app creation - scaffolds project, creates dev app, shares with workspace, and starts dev server all in one command
4
+ ---
5
+
6
+ # Scaffold Hailer App Skill (ONE-SHOT SETUP)
7
+
8
+ Complete guide to using the `scaffold_hailer_app` tool - a ONE-SHOT solution that scaffolds your project, creates the dev app entry in Hailer, shares it with your workspace, updates manifest.json, and starts the dev server automatically.
9
+
10
+ ## Table of Contents
11
+ - [Quick Reference](#quick-reference)
12
+ - [Overview](#overview)
13
+ - [What's Different: One-Shot Setup](#whats-different-one-shot-setup)
14
+ - [Core Concepts](#core-concepts)
15
+ - [Available Templates](#available-templates)
16
+ - [Basic Usage](#basic-usage)
17
+ - [Common Scenarios](#common-scenarios)
18
+ - [Best Practices](#best-practices)
19
+ - [Troubleshooting](#troubleshooting)
20
+ - [Advanced Options](#advanced-options)
21
+ - [Additional Resources](#additional-resources)
22
+
23
+ ## Quick Reference
24
+
25
+ ### Create app with one command (recommended)
26
+ ```javascript
27
+ scaffold_hailer_app({
28
+ projectName: "task-manager",
29
+ template: "react-ts",
30
+ description: "Task management application"
31
+ })
32
+ // ✅ Project scaffolded
33
+ // ✅ Dependencies installed
34
+ // ✅ Dev app created in Hailer
35
+ // ✅ App shared with workspace
36
+ // ✅ manifest.json configured
37
+ // ✅ Dev server started on port 3000
38
+ // 🎉 App ready to open in Hailer!
39
+ ```
40
+
41
+ ### Minimal one-shot setup
42
+ ```javascript
43
+ scaffold_hailer_app({
44
+ projectName: "my-app",
45
+ template: "react-ts"
46
+ })
47
+ // Everything done automatically!
48
+ ```
49
+
50
+ ### Fast builds with SWC
51
+ ```javascript
52
+ scaffold_hailer_app({
53
+ projectName: "enterprise-app",
54
+ template: "react-swc-ts",
55
+ description: "Enterprise dashboard with fast builds"
56
+ })
57
+ ```
58
+
59
+ ### Simple vanilla app
60
+ ```javascript
61
+ scaffold_hailer_app({
62
+ projectName: "quick-tool",
63
+ template: "vanilla",
64
+ description: "Lightweight utility"
65
+ })
66
+ ```
67
+
68
+ ### Custom options
69
+ ```javascript
70
+ scaffold_hailer_app({
71
+ projectName: "analytics-dashboard",
72
+ template: "react-ts",
73
+ description: "Analytics and reporting dashboard",
74
+ targetDirectory: "/path/to/projects",
75
+ autoCreateDevApp: true, // Create dev app (default)
76
+ autoShareWithWorkspace: true, // Share with workspace (default)
77
+ autoStartDevServer: true, // Start dev server (default)
78
+ installDependencies: true // Install npm packages (default)
79
+ })
80
+ ```
81
+
82
+ ## Overview
83
+
84
+ The `scaffold_hailer_app` tool is a **ONE-SHOT SOLUTION** that handles the entire app setup process automatically:
85
+
86
+ **What happens in ONE command:**
87
+ 1. ✅ Scaffolds project from official template
88
+ 2. ✅ Installs all npm dependencies
89
+ 3. ✅ Configures CORS in vite.config.ts for Hailer access
90
+ 4. ✅ Creates dev app entry in Hailer (pointing to localhost:3000)
91
+ 5. ✅ Shares app with entire workspace
92
+ 6. ✅ Updates manifest.json with app ID
93
+ 7. ✅ Starts dev server in background on port 3000
94
+ 8. ✅ **App immediately ready to open in Hailer!**
95
+
96
+ **Requirements:**
97
+ - Node.js 18+ installed
98
+ - npm available in PATH
99
+ - Write permissions in target directory
100
+ - Internet connection
101
+ - Active Hailer workspace
102
+
103
+ **Time savings:**
104
+ - **Before:** 7 manual steps (~5-10 minutes)
105
+ - **After:** 1 command (~1-2 minutes)
106
+
107
+ ## What's Different: One-Shot Setup
108
+
109
+ ### Old Way (Manual - 7 Steps)
110
+ ```javascript
111
+ // Step 1: Scaffold
112
+ scaffold_hailer_app({ projectName: "my-app", template: "react-ts" })
113
+
114
+ // Step 2: Navigate
115
+ // cd my-app
116
+
117
+ // Step 3: Install dependencies
118
+ // npm install
119
+
120
+ // Step 4: Start dev server
121
+ // npm run dev
122
+
123
+ // Step 5: Create dev app in Hailer
124
+ create_app({ name: "My App (Dev)", url: "http://localhost:3000" })
125
+
126
+ // Step 6: Update manifest.json with app ID
127
+ // (manually edit file)
128
+
129
+ // Step 7: Share with workspace
130
+ add_app_member({ appId: "xxx", member: "network_xxx" })
131
+ ```
132
+
133
+ ### New Way (ONE-SHOT - 1 Step)
134
+ ```javascript
135
+ scaffold_hailer_app({
136
+ projectName: "my-app",
137
+ template: "react-ts",
138
+ description: "My awesome app"
139
+ })
140
+ // Done! App ready to open in Hailer immediately! 🎉
141
+ ```
142
+
143
+ ### What Gets Automated
144
+
145
+ | Step | Manual Approach | One-Shot Approach |
146
+ |------|-----------------|-------------------|
147
+ | **Scaffold project** | ✅ Manual command | ✅ Automatic |
148
+ | **Install dependencies** | ⏱️ Run `npm install` | ✅ Automatic |
149
+ | **Configure CORS** | ⏱️ Edit vite.config.ts | ✅ Automatic |
150
+ | **Create dev app** | ⏱️ Call `create_app` tool | ✅ Automatic |
151
+ | **Share with workspace** | ⏱️ Call `add_app_member` | ✅ Automatic |
152
+ | **Update manifest** | ⏱️ Edit file manually | ✅ Automatic |
153
+ | **Start dev server** | ⏱️ Run `npm run dev` | ✅ Automatic |
154
+ | **Total time** | ~5-10 minutes | ~1-2 minutes |
155
+ | **Commands needed** | 6+ commands | **1 command** |
156
+
157
+ ## Core Concepts
158
+
159
+ ### Templates
160
+
161
+ Three official templates are available:
162
+
163
+ | Template | Technology | Use Case | Build Speed |
164
+ |----------|-----------|----------|-------------|
165
+ | **react-ts** | React + TypeScript | Production apps, recommended | Standard |
166
+ | **react-swc-ts** | React + SWC + TypeScript | Large apps needing fast builds | Fast |
167
+ | **vanilla** | Vanilla JS/TS | Simple apps, learning | Fast |
168
+
169
+ ### One-Shot Parameters
170
+
171
+ **Required:**
172
+ - `projectName` - Project folder name
173
+ - `template` - "react-ts", "react-swc-ts", or "vanilla"
174
+
175
+ **Optional:**
176
+ - `description` - App description shown in Hailer
177
+ - `targetDirectory` - Custom location (defaults to current directory)
178
+ - `autoCreateDevApp` - Create dev app entry (default: true)
179
+ - `autoShareWithWorkspace` - Share with workspace (default: true)
180
+ - `autoStartDevServer` - Start dev server (default: true)
181
+ - `installDependencies` - Install npm packages (default: true)
182
+
183
+ ### What Gets Created
184
+
185
+ ```
186
+ project-name/
187
+ ├── src/ # Source code
188
+ ├── public/ # Static assets
189
+ │ └── manifest.json # ✅ Auto-configured with app ID
190
+ ├── vite.config.ts # Vite configuration
191
+ ├── tsconfig.json # TypeScript configuration
192
+ ├── package.json # Dependencies and scripts
193
+ └── node_modules/ # ✅ Auto-installed dependencies
194
+ ```
195
+
196
+ **Plus:**
197
+ - ✅ Dev app entry in Hailer
198
+ - ✅ App shared with workspace
199
+ - ✅ Dev server running in background
200
+
201
+ ## Available Templates
202
+
203
+ ### react-ts (Recommended)
204
+
205
+ **Best for:**
206
+ - Production applications
207
+ - Teams familiar with React
208
+ - Most use cases
209
+
210
+ **Example:**
211
+ ```javascript
212
+ scaffold_hailer_app({
213
+ projectName: "customer-portal",
214
+ template: "react-ts",
215
+ description: "Customer management portal"
216
+ })
217
+ ```
218
+
219
+ ### react-swc-ts (High Performance)
220
+
221
+ **Best for:**
222
+ - Large applications
223
+ - Fast build times (2-10x faster)
224
+ - Enterprise apps
225
+
226
+ **Example:**
227
+ ```javascript
228
+ scaffold_hailer_app({
229
+ projectName: "enterprise-dashboard",
230
+ template: "react-swc-ts",
231
+ description: "Enterprise analytics dashboard"
232
+ })
233
+ ```
234
+
235
+ ### vanilla (Lightweight)
236
+
237
+ **Best for:**
238
+ - Simple utilities
239
+ - Learning Hailer development
240
+ - Minimal dependencies
241
+
242
+ **Example:**
243
+ ```javascript
244
+ scaffold_hailer_app({
245
+ projectName: "quick-report",
246
+ template: "vanilla",
247
+ description: "Quick reporting tool"
248
+ })
249
+ ```
250
+
251
+ ## Basic Usage
252
+
253
+ ### Complete Setup in One Command
254
+
255
+ ```javascript
256
+ scaffold_hailer_app({
257
+ projectName: "sales-dashboard",
258
+ template: "react-ts",
259
+ description: "Sales analytics and reporting"
260
+ })
261
+ ```
262
+
263
+ **Output:**
264
+ ```
265
+ 🚀 ONE-SHOT HAILER APP SETUP
266
+
267
+ Project: sales-dashboard
268
+ Template: react-ts
269
+ Location: /current/directory/sales-dashboard
270
+
271
+ ⏳ Step 1/7: Creating project from template...
272
+ ✅ Project scaffolded
273
+
274
+ ⏳ Step 2/7: Installing dependencies...
275
+ ✅ Dependencies installed
276
+
277
+ ⏳ Step 3/7: Creating dev app entry in Hailer...
278
+ ✅ App created: 691ed3fa98ebad373bbe98de
279
+ URL: http://localhost:3000
280
+
281
+ ⏳ Step 4/7: Sharing app with workspace...
282
+ ✅ App shared with entire workspace
283
+
284
+ ⏳ Step 5/7: Updating manifest.json with app ID...
285
+ ✅ manifest.json updated with appId
286
+
287
+ ⏳ Step 6/7: Starting dev server on port 3000...
288
+ ✅ Dev server started in background
289
+ PID: 12345
290
+ URL: http://localhost:3000
291
+
292
+ ✅ Step 7/7: Setup Complete!
293
+
294
+ ## 🎉 Your Hailer App is Ready!
295
+
296
+ **What was done:**
297
+ - ✅ Project scaffolded from react-ts template
298
+ - ✅ Dependencies installed
299
+ - ✅ Dev app entry created in Hailer (ID: 691ed3fa98ebad373bbe98de)
300
+ - ✅ App shared with entire workspace
301
+ - ✅ manifest.json configured with app ID
302
+ - ✅ Dev server started on http://localhost:3000
303
+
304
+ ## 🚀 Next Steps
305
+
306
+ 1. **Open the app in Hailer** - Look for "sales-dashboard" in your apps menu
307
+ 2. **Start coding** - Files in /path/to/sales-dashboard/src will hot-reload
308
+ 3. **View logs** - Check dev server output if needed
309
+
310
+ ## 🔗 App Info
311
+
312
+ - **App ID:** 691ed3fa98ebad373bbe98de
313
+ - **Dev URL:** http://localhost:3000
314
+ - **Shared with:** Entire workspace
315
+ ```
316
+
317
+ ### That's It!
318
+
319
+ Just open the app in Hailer and start coding. All setup is done automatically.
320
+
321
+ ## Common Scenarios
322
+
323
+ ### Scenario 1: Quick Dashboard App
324
+
325
+ ```javascript
326
+ // One command, ready immediately
327
+ scaffold_hailer_app({
328
+ projectName: "analytics-dashboard",
329
+ template: "react-ts",
330
+ description: "Analytics and metrics dashboard"
331
+ })
332
+
333
+ // Open app in Hailer and start coding!
334
+ ```
335
+
336
+ ### Scenario 2: Enterprise App with Fast Builds
337
+
338
+ ```javascript
339
+ scaffold_hailer_app({
340
+ projectName: "enterprise-crm",
341
+ template: "react-swc-ts",
342
+ description: "Enterprise CRM system"
343
+ })
344
+
345
+ // SWC provides 2-10x faster builds automatically
346
+ ```
347
+
348
+ ### Scenario 3: Simple Utility
349
+
350
+ ```javascript
351
+ scaffold_hailer_app({
352
+ projectName: "csv-exporter",
353
+ template: "vanilla",
354
+ description: "CSV export utility"
355
+ })
356
+
357
+ // Lightweight app ready immediately
358
+ ```
359
+
360
+ ### Scenario 4: Multiple Apps in Directory
361
+
362
+ ```javascript
363
+ // All apps in dedicated directory
364
+ scaffold_hailer_app({
365
+ projectName: "app-one",
366
+ template: "react-ts",
367
+ description: "First application",
368
+ targetDirectory: "/home/user/hailer-apps"
369
+ })
370
+
371
+ scaffold_hailer_app({
372
+ projectName: "app-two",
373
+ template: "react-swc-ts",
374
+ description: "Second application",
375
+ targetDirectory: "/home/user/hailer-apps"
376
+ })
377
+
378
+ // Result:
379
+ // /home/user/hailer-apps/
380
+ // app-one/ (running on port 3000, first one)
381
+ // app-two/ (needs manual start on different port)
382
+ ```
383
+
384
+ ### Scenario 5: Custom Automation Options
385
+
386
+ ```javascript
387
+ // Control what gets automated
388
+ scaffold_hailer_app({
389
+ projectName: "custom-app",
390
+ template: "react-ts",
391
+ description: "Custom configuration",
392
+ autoCreateDevApp: true, // Create dev app
393
+ autoShareWithWorkspace: false, // Don't share (dev only)
394
+ autoStartDevServer: false, // Start manually later
395
+ installDependencies: true // Install packages
396
+ })
397
+
398
+ // Dev app created but not shared, server not started
399
+ // Good for testing before sharing
400
+ ```
401
+
402
+ ## Best Practices
403
+
404
+ ### 1. Use Descriptive Names and Descriptions
405
+
406
+ ```javascript
407
+ // ❌ Bad: Generic, no description
408
+ scaffold_hailer_app({
409
+ projectName: "app1",
410
+ template: "react-ts"
411
+ })
412
+
413
+ // ✅ Good: Clear name and description
414
+ scaffold_hailer_app({
415
+ projectName: "customer-feedback-dashboard",
416
+ template: "react-ts",
417
+ description: "Customer feedback collection and analysis"
418
+ })
419
+ ```
420
+
421
+ ### 2. Let Automation Handle Setup
422
+
423
+ ```javascript
424
+ // ✅ Recommended: Use defaults (everything automatic)
425
+ scaffold_hailer_app({
426
+ projectName: "my-app",
427
+ template: "react-ts",
428
+ description: "My application"
429
+ })
430
+
431
+ // Only disable automation for specific reasons:
432
+ scaffold_hailer_app({
433
+ projectName: "team-only-app",
434
+ template: "react-ts",
435
+ description: "Team-specific tool",
436
+ autoShareWithWorkspace: false // Don't share publicly
437
+ })
438
+ ```
439
+
440
+ ### 3. Choose Appropriate Template
441
+
442
+ Decision tree:
443
+ ```
444
+ Is this a complex UI app?
445
+ ├─ Yes → Is performance critical?
446
+ │ ├─ Yes → Use react-swc-ts (fastest)
447
+ │ └─ No → Use react-ts (recommended)
448
+ └─ No → Use vanilla (simple)
449
+ ```
450
+
451
+ ### 4. Organize Multiple Apps
452
+
453
+ ```javascript
454
+ // Consistent directory structure
455
+ const appsDir = "/home/user/workspace/hailer-apps";
456
+
457
+ scaffold_hailer_app({
458
+ projectName: "customer-portal",
459
+ template: "react-ts",
460
+ description: "Customer portal",
461
+ targetDirectory: appsDir
462
+ })
463
+
464
+ scaffold_hailer_app({
465
+ projectName: "admin-dashboard",
466
+ template: "react-swc-ts",
467
+ description: "Admin dashboard",
468
+ targetDirectory: appsDir
469
+ })
470
+ ```
471
+
472
+ ### 5. Start Coding Immediately
473
+
474
+ ```javascript
475
+ // 1. Run one command
476
+ scaffold_hailer_app({
477
+ projectName: "my-app",
478
+ template: "react-ts",
479
+ description: "My awesome app"
480
+ })
481
+
482
+ // 2. Open app in Hailer (find in apps menu)
483
+
484
+ // 3. Edit code in my-app/src/
485
+ // Changes appear live in Hailer!
486
+
487
+ // No manual setup needed!
488
+ ```
489
+
490
+ ## Troubleshooting
491
+
492
+ ### Error: "Directory Already Exists"
493
+
494
+ **Solution:**
495
+ ```javascript
496
+ // Choose different name
497
+ scaffold_hailer_app({
498
+ projectName: "my-app-v2", // Different name
499
+ template: "react-ts",
500
+ description: "My app (version 2)"
501
+ })
502
+
503
+ // Or use different directory
504
+ scaffold_hailer_app({
505
+ projectName: "my-app",
506
+ template: "react-ts",
507
+ description: "My app",
508
+ targetDirectory: "/different/path"
509
+ })
510
+ ```
511
+
512
+ ### Error: "Workspace cache not available"
513
+
514
+ **Problem:** Not connected to Hailer workspace.
515
+
516
+ **Solution:**
517
+ 1. Verify Hailer connection
518
+ 2. Check .env.local credentials
519
+ 3. Restart MCP server if needed
520
+
521
+ ### Error: "Failed to create app in Hailer"
522
+
523
+ **Problem:** Permission or API issue.
524
+
525
+ **Solution:**
526
+ ```javascript
527
+ // Disable automatic app creation
528
+ scaffold_hailer_app({
529
+ projectName: "my-app",
530
+ template: "react-ts",
531
+ autoCreateDevApp: false // Skip app creation
532
+ })
533
+
534
+ // Create app manually later:
535
+ create_app({
536
+ name: "my-app",
537
+ url: "http://localhost:3000"
538
+ })
539
+ ```
540
+
541
+ ### Port 3000 Already in Use
542
+
543
+ **Problem:** Dev server can't start on port 3000.
544
+
545
+ **Solution:**
546
+ 1. First app gets port 3000 automatically
547
+ 2. Additional apps: start manually on different ports
548
+ 3. Or stop existing server first
549
+
550
+ ```bash
551
+ # Manual start on different port
552
+ cd my-app
553
+ PORT=3001 npm run dev
554
+
555
+ # Then update app URL:
556
+ update_app({
557
+ appId: "xxx",
558
+ name: "My App",
559
+ url: "http://localhost:3001"
560
+ })
561
+ ```
562
+
563
+ ### Dependencies Fail to Install
564
+
565
+ **Workaround:**
566
+ Project still created successfully. Install manually:
567
+ ```bash
568
+ cd my-app
569
+ npm install
570
+ npm run dev
571
+ ```
572
+
573
+ ### Dev Server Fails to Start
574
+
575
+ **Problem:** Background server didn't start.
576
+
577
+ **Solution:**
578
+ Start manually:
579
+ ```bash
580
+ cd my-app
581
+ npm run dev
582
+ ```
583
+
584
+ App is already created in Hailer, just needs server running.
585
+
586
+ ### CORS Error When Opening App in Hailer
587
+
588
+ **Problem:** Browser console shows "Access to fetch at 'http://localhost:3000/manifest.json' from origin 'https://next.hailer.com' has been blocked by CORS policy"
589
+
590
+ **Solution:**
591
+ The `scaffold_hailer_app` tool automatically configures CORS in vite.config.ts. If you scaffolded the app manually or CORS is not working:
592
+
593
+ ```typescript
594
+ // vite.config.ts
595
+ import { defineConfig } from 'vite'
596
+ import react from '@vitejs/plugin-react'
597
+ import dns from 'dns'
598
+
599
+ dns.setDefaultResultOrder('verbatim');
600
+
601
+ export default defineConfig({
602
+ plugins: [react()],
603
+ base: '',
604
+ server: {
605
+ port: 3000,
606
+ cors: {
607
+ origin: '*', // Allow all origins
608
+ credentials: true // Allow credentials
609
+ }
610
+ },
611
+ })
612
+ ```
613
+
614
+ **Why this is needed:**
615
+ - Hailer loads your app from `https://next.hailer.com` (or your Hailer domain)
616
+ - Your dev server runs on `http://localhost:3000`
617
+ - Without CORS configuration, browsers block cross-origin requests
618
+ - The CORS config allows Hailer to fetch your app's manifest.json and assets
619
+
620
+ **Note:** The scaffold tool now automatically adds this configuration, so new apps should work immediately!
621
+
622
+ ## Advanced Options
623
+
624
+ ### Minimal Automation
625
+
626
+ ```javascript
627
+ // Just scaffold project
628
+ scaffold_hailer_app({
629
+ projectName: "my-app",
630
+ template: "react-ts",
631
+ installDependencies: false,
632
+ autoCreateDevApp: false,
633
+ autoStartDevServer: false
634
+ })
635
+
636
+ // Then do manual setup as needed
637
+ ```
638
+
639
+ ### Dev-Only Setup (Not Shared)
640
+
641
+ ```javascript
642
+ // Create app but don't share
643
+ scaffold_hailer_app({
644
+ projectName: "experimental-app",
645
+ template: "react-ts",
646
+ description: "Experimental features",
647
+ autoShareWithWorkspace: false // Only visible to you
648
+ })
649
+
650
+ // Share later when ready:
651
+ add_app_member({
652
+ appId: "xxx",
653
+ member: "network_workspace-id"
654
+ })
655
+ ```
656
+
657
+ ### Custom Target Directory
658
+
659
+ ```javascript
660
+ // Use environment variable or custom path
661
+ scaffold_hailer_app({
662
+ projectName: "my-app",
663
+ template: "react-ts",
664
+ description: "My app",
665
+ targetDirectory: process.env.DEV_APPS_PATH || "/custom/path"
666
+ })
667
+ ```
668
+
669
+ ## Hailer SDK API Reference
670
+
671
+ ### Critical: Correct API Usage
672
+
673
+ When developing Hailer apps, you MUST use the correct Hailer SDK API patterns:
674
+
675
+ #### ✅ CORRECT: Activity API
676
+
677
+ ```typescript
678
+ // ✅ Use hailer.activity (SINGULAR)
679
+ const activities = await hailer.activity.list(
680
+ processId, // First parameter: workflow ID
681
+ phaseId, // Second parameter: phase ID
682
+ options // Third parameter: options object
683
+ );
684
+
685
+ // Example with real IDs
686
+ const activities = await hailer.activity.list(
687
+ '69087299c0e0b9944c620172', // Matches workflow
688
+ '69087299c0e0b9944c620173', // Scheduled phase
689
+ {
690
+ sortBy: 'created',
691
+ sortOrder: 'asc',
692
+ limit: 20
693
+ }
694
+ );
695
+ ```
696
+
697
+ #### ❌ WRONG: Common Mistakes
698
+
699
+ ```typescript
700
+ // ❌ WRONG: Using 'activities' (plural)
701
+ const result = await hailer.activities.list({ ... }) // activities is undefined!
702
+
703
+ // ❌ WRONG: Single object parameter
704
+ const activities = await hailer.activity.list({
705
+ workflowId: 'xxx',
706
+ phaseId: 'yyy'
707
+ }) // Wrong signature!
708
+
709
+ // ❌ WRONG: Accessing fields directly
710
+ match.opponent // undefined!
711
+ match.matchDate // undefined!
712
+ ```
713
+
714
+ ### Activity Data Structure
715
+
716
+ Activities have a specific structure - custom fields are in the `fields` object:
717
+
718
+ ```typescript
719
+ interface Activity {
720
+ _id: string; // Activity ID
721
+ name: string; // Activity name/title
722
+ process: string; // Workflow ID
723
+ currentPhase: string; // Phase ID
724
+ created: number; // Timestamp
725
+ updated?: number; // Timestamp
726
+ fields?: { // ✅ Custom fields are here!
727
+ [fieldKey: string]: any
728
+ };
729
+ }
730
+ ```
731
+
732
+ #### ✅ CORRECT: Accessing Custom Fields
733
+
734
+ ```typescript
735
+ // ✅ Access via fields object
736
+ const opponent = match.fields?.opponent;
737
+ const matchDate = match.fields?.matchDate;
738
+ const competition = match.fields?.competition;
739
+
740
+ // ✅ Display with fallbacks
741
+ <span>{match.fields?.opponent?.name || match.name}</span>
742
+ ```
743
+
744
+ #### ❌ WRONG: Direct Field Access
745
+
746
+ ```typescript
747
+ // ❌ These will be undefined!
748
+ const opponent = match.opponent; // undefined
749
+ const matchDate = match.matchDate; // undefined
750
+ const competition = match.competition; // undefined
751
+ ```
752
+
753
+ ### Complete Working Example
754
+
755
+ ```typescript
756
+ import { useEffect, useState } from 'react';
757
+ import useHailer from './hailer/use-hailer';
758
+
759
+ interface Match {
760
+ _id: string;
761
+ name: string;
762
+ fields?: {
763
+ opponent?: { _id: string; name: string };
764
+ matchDate?: number;
765
+ competition?: string;
766
+ venue?: string;
767
+ };
768
+ }
769
+
770
+ export default function MatchesList() {
771
+ const { hailer, inside } = useHailer();
772
+ const [matches, setMatches] = useState<Match[]>([]);
773
+ const [loading, setLoading] = useState(true);
774
+
775
+ useEffect(() => {
776
+ if (!hailer || !inside) return;
777
+
778
+ async function fetchMatches() {
779
+ try {
780
+ // ✅ CORRECT: activity.list with separate parameters
781
+ const activities = await hailer.activity.list(
782
+ '69087299c0e0b9944c620172', // processId
783
+ '69087299c0e0b9944c620173', // phaseId
784
+ {
785
+ sortBy: 'created',
786
+ sortOrder: 'asc',
787
+ limit: 20
788
+ }
789
+ );
790
+
791
+ setMatches(activities || []);
792
+ } catch (err) {
793
+ console.error('Failed to fetch:', err);
794
+ } finally {
795
+ setLoading(false);
796
+ }
797
+ }
798
+
799
+ fetchMatches();
800
+ }, [hailer, inside]);
801
+
802
+ if (loading) return <div>Loading...</div>;
803
+
804
+ return (
805
+ <div>
806
+ {matches.map((match) => (
807
+ <div key={match._id}>
808
+ {/* ✅ CORRECT: Access via fields */}
809
+ <h3>{match.fields?.opponent?.name || match.name}</h3>
810
+ <p>Competition: {match.fields?.competition}</p>
811
+ <p>Venue: {match.fields?.venue}</p>
812
+ </div>
813
+ ))}
814
+ </div>
815
+ );
816
+ }
817
+ ```
818
+
819
+ ### Other Hailer SDK APIs
820
+
821
+ #### Activity Operations
822
+
823
+ ```typescript
824
+ // Get single activity
825
+ const activity = await hailer.activity.get(activityId);
826
+
827
+ // Create activities
828
+ const created = await hailer.activity.create(
829
+ processId,
830
+ [
831
+ { name: 'Activity 1', fields: { status: 'Active' } },
832
+ { name: 'Activity 2', fields: { status: 'Pending' } }
833
+ ]
834
+ );
835
+
836
+ // Update activities
837
+ await hailer.activity.update(
838
+ [
839
+ { _id: 'xxx', fields: { status: 'Completed' } },
840
+ { _id: 'yyy', name: 'New Name' }
841
+ ],
842
+ {} // options
843
+ );
844
+
845
+ // Remove activities
846
+ await hailer.activity.remove(['activity-id-1', 'activity-id-2']);
847
+ ```
848
+
849
+ #### Workflow/Process Operations
850
+
851
+ ```typescript
852
+ // Get workflow phases
853
+ const phases = await hailer.process.getPhases(processId);
854
+
855
+ // Get workflow fields
856
+ const fields = await hailer.process.getFields(processId, phaseId);
857
+ ```
858
+
859
+ #### User Operations
860
+
861
+ ```typescript
862
+ // Get current user
863
+ const user = await hailer.user.getCurrent();
864
+
865
+ // Get workspace info
866
+ const workspace = await hailer.workspace.get();
867
+ ```
868
+
869
+ ### Common Patterns
870
+
871
+ #### Pattern 1: List Activities with Filtering
872
+
873
+ ```typescript
874
+ const activities = await hailer.activity.list(
875
+ workflowId,
876
+ phaseId,
877
+ {
878
+ sortBy: 'created',
879
+ sortOrder: 'desc',
880
+ limit: 50,
881
+ filters: {
882
+ // Custom filters based on field IDs
883
+ fieldId: { operator: 'equals', value: 'someValue' }
884
+ }
885
+ }
886
+ );
887
+ ```
888
+
889
+ #### Pattern 2: Display Activity with Custom Fields
890
+
891
+ ```typescript
892
+ function ActivityCard({ activity }: { activity: Activity }) {
893
+ return (
894
+ <div>
895
+ <h3>{activity.name}</h3>
896
+ {/* Access custom fields via fields object */}
897
+ <p>Status: {activity.fields?.status}</p>
898
+ <p>Priority: {activity.fields?.priority}</p>
899
+ <p>Due Date: {formatDate(activity.fields?.dueDate)}</p>
900
+ </div>
901
+ );
902
+ }
903
+ ```
904
+
905
+ #### Pattern 3: Handle ActivityLink Fields
906
+
907
+ ```typescript
908
+ // ActivityLink fields are objects with _id and name
909
+ const linkedActivity = activity.fields?.linkedField;
910
+
911
+ if (linkedActivity) {
912
+ console.log(linkedActivity._id); // Activity ID
913
+ console.log(linkedActivity.name); // Activity name
914
+ }
915
+ ```
916
+
917
+ ### TypeScript Types
918
+
919
+ For better type safety, extend the Activity interface:
920
+
921
+ ```typescript
922
+ interface CustomActivity extends Activity {
923
+ fields?: {
924
+ status?: string;
925
+ priority?: string;
926
+ dueDate?: number;
927
+ assignedTo?: { _id: string; name: string };
928
+ relatedActivity?: { _id: string; name: string };
929
+ };
930
+ }
931
+ ```
932
+
933
+ ### Key Takeaways
934
+
935
+ 1. **Always use `hailer.activity` (singular), never `hailer.activities`**
936
+ 2. **Pass parameters separately**: `list(processId, phaseId, options)`
937
+ 3. **Access custom fields via `activity.fields?.fieldName`**
938
+ 4. **ActivityLink fields are objects with `_id` and `name` properties**
939
+ 5. **Use optional chaining (`?.`) to safely access nested fields**
940
+
941
+ ## Additional Resources
942
+
943
+ ### Related Skills
944
+ - **create-app-skill** - Create Hailer app entries (now automatic!)
945
+ - **publish-hailer-app-skill** - Deploy apps to production
946
+ - **add-app-member-skill** - Share apps with users (now automatic!)
947
+ - **list-apps-skill** - View and manage apps
948
+
949
+ ### Related Tools
950
+ - `create_app` - Create app entry (now automatic!)
951
+ - `publish_hailer_app` - Deploy to production
952
+ - `add_app_member` - Share access (now automatic!)
953
+ - `update_app` - Modify app properties
954
+ - `list_apps` - View all workspace apps
955
+
956
+ ### Key Improvements
957
+
958
+ **Before (Manual):**
959
+ - 7 separate steps
960
+ - 5-10 minutes
961
+ - Error-prone
962
+ - Easy to forget steps
963
+
964
+ **After (One-Shot):**
965
+ - 1 command
966
+ - 1-2 minutes
967
+ - Automated
968
+ - Nothing to forget!
969
+
970
+ ### Template Comparison
971
+
972
+ | Feature | react-ts | react-swc-ts | vanilla |
973
+ |---------|----------|--------------|---------|
974
+ | **Framework** | React 18 | React 18 | None |
975
+ | **TypeScript** | ✅ Yes | ✅ Yes | ✅ Yes |
976
+ | **Compiler** | Babel/esbuild | SWC (Rust) | esbuild |
977
+ | **Build Speed** | Standard | 2-10x faster | Fast |
978
+ | **Bundle Size** | ~150KB | ~150KB | ~10KB |
979
+ | **Best For** | Most apps | Large apps | Simple apps |
980
+
981
+ ### Complete Workflow
982
+
983
+ **Development:**
984
+ ```javascript
985
+ // 1. Create app (one command!)
986
+ scaffold_hailer_app({
987
+ projectName: "my-app",
988
+ template: "react-ts",
989
+ description: "My application"
990
+ })
991
+
992
+ // 2. Open in Hailer and start coding
993
+ // App already running, shared, configured!
994
+
995
+ // 3. Edit files in my-app/src/
996
+ // Changes appear live
997
+
998
+ // 4. When ready, publish
999
+ publish_hailer_app({
1000
+ email: "user@example.com",
1001
+ password: "password",
1002
+ projectDirectory: "./my-app"
1003
+ })
1004
+ ```
1005
+
1006
+ That's it! The one-shot approach eliminates all manual setup steps.
1007
+
1008
+ ---
1009
+
1010
+ ## Next Steps: Building Your App
1011
+
1012
+ After scaffolding, you need to load data from Hailer workflows. **IMPORTANT:** The Hailer App SDK has specific patterns you must follow!
1013
+
1014
+ ### ⚠️ Critical: Load the Building Hailer Apps Skill
1015
+
1016
+ ```typescript
1017
+ // Load comprehensive guide for data loading
1018
+ await get_skill({ skillName: "building-hailer-apps-skill" })
1019
+ ```
1020
+
1021
+ **This skill covers:**
1022
+ - ✅ How to properly call `hailer.activity.list()` (3 positional params)
1023
+ - ✅ How field access works (fields are keyed by IDs, not readable keys)
1024
+ - ✅ How to use MCP tools to get workflow schema
1025
+ - ✅ Complete working examples with TypeScript
1026
+ - ✅ Common pitfalls and how to avoid them
1027
+ - ✅ Debugging techniques when data won't load
1028
+
1029
+ **Why you need it:** The Hailer App SDK is different from the MCP API. Without this knowledge, you'll get errors like:
1030
+ - `Cannot read properties of undefined (reading 'activity')`
1031
+ - `"processId" must be a string`
1032
+ - Fields showing as `undefined` even though data loads
1033
+
1034
+ **Load it before writing any data-loading code!**