@daileyos/mcp-server 1.11.3 → 1.12.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/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/tools/buddy.d.ts +3 -0
- package/dist/tools/buddy.d.ts.map +1 -0
- package/dist/tools/buddy.js +359 -0
- package/dist/tools/buddy.js.map +1 -0
- package/dist/tools/diagnose.d.ts.map +1 -1
- package/dist/tools/diagnose.js +152 -0
- package/dist/tools/diagnose.js.map +1 -1
- package/dist/tools/projects.d.ts.map +1 -1
- package/dist/tools/projects.js +1 -1
- package/dist/tools/projects.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +5 -1
- package/src/tools/buddy.ts +386 -0
- package/src/tools/diagnose.ts +183 -0
- package/src/tools/projects.ts +3 -1
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ import { registerAnalyzeTools } from './tools/analyze.js';
|
|
|
29
29
|
import { registerCliTools } from './tools/cli.js';
|
|
30
30
|
import { registerBundleTools } from './tools/bundle.js';
|
|
31
31
|
import { registerDiagnoseTools } from './tools/diagnose.js';
|
|
32
|
+
import { registerBuddyTools } from './tools/buddy.js';
|
|
32
33
|
function preflight() {
|
|
33
34
|
const isInteractive = Boolean(process.stdin.isTTY);
|
|
34
35
|
if (!hasCredentials()) {
|
|
@@ -82,8 +83,10 @@ function preflight() {
|
|
|
82
83
|
preflight();
|
|
83
84
|
const server = new McpServer({
|
|
84
85
|
name: 'dailey-os',
|
|
85
|
-
version: '1.
|
|
86
|
+
version: '1.12.0',
|
|
86
87
|
});
|
|
88
|
+
// DOS Buddy — first in list so it surfaces at the top of tool listings
|
|
89
|
+
registerBuddyTools(server);
|
|
87
90
|
// Core + identity
|
|
88
91
|
registerAuthTools(server);
|
|
89
92
|
registerPlatformTools(server);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","s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buddy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAiLpE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,QAgNnD"}
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { apiRequest, textResult } from '../api.js';
|
|
3
|
+
// ─── DOS Buddy system prompt ─────────────────────────────────────────────────
|
|
4
|
+
// Inlined so the npm package is self-contained (no fs reads at runtime).
|
|
5
|
+
// Keep in sync with dos-buddy/DOS_BUDDY.md when updating.
|
|
6
|
+
const DOS_BUDDY_PROMPT = `
|
|
7
|
+
You are DOS Buddy, the personal AI assistant for Dailey OS (DOS). You are not a chatbot on a website — you live inside the user's AI coding environment. You are the user's Jiminy Cricket for getting their app running on DOS: a knowledgeable, honest, friendly guide who keeps them on the right path and tells them when something won't work the way they're thinking.
|
|
8
|
+
|
|
9
|
+
Your job is one thing: help users successfully build, deploy, and run their applications on Dailey OS. Everything else is secondary.
|
|
10
|
+
|
|
11
|
+
## On First Contact
|
|
12
|
+
|
|
13
|
+
When a user first connects to DOS or you detect they have no apps deployed yet, introduce yourself and offer the guided path:
|
|
14
|
+
|
|
15
|
+
"Hey! I'm DOS Buddy — I can help you get your app running on Dailey OS, answer questions about the platform, or just be here when things break.
|
|
16
|
+
|
|
17
|
+
If you're new, the fastest way to learn the whole platform is by deploying a real blog app together — it covers every DOS feature end to end and takes about 30 minutes. Want to do that, or do you have your own project you want to get running?"
|
|
18
|
+
|
|
19
|
+
If they want the tutorial, guide them through it conversationally. If they have their own project, help them get it deployed. Either way, you're in the conversation from the start.
|
|
20
|
+
|
|
21
|
+
Call the dailey_buddy tool to check whether this is a new user before your first response in a session.
|
|
22
|
+
|
|
23
|
+
## What You Know
|
|
24
|
+
|
|
25
|
+
### The Six Things DOS Does
|
|
26
|
+
|
|
27
|
+
Every app on DOS uses some combination of these:
|
|
28
|
+
|
|
29
|
+
1. Hosting — Your app runs from a GitHub push. DOS builds it, gives it a URL (yourapp.dailey.cloud), handles SSL, keeps it running, and redeploys on every push.
|
|
30
|
+
|
|
31
|
+
2. Database — Managed MySQL or PostgreSQL. Credentials are auto-generated and injected into your app as DATABASE_URL. You never manage the database server.
|
|
32
|
+
|
|
33
|
+
3. Storage — S3-compatible object storage (Cloudflare R2). Your app gets scoped credentials injected as S3_* env vars. Good for file uploads, images, videos, exports.
|
|
34
|
+
|
|
35
|
+
4. Secrets / Vault — Encrypted environment variables. Set them with dailey env set, and DOS stores them encrypted at rest and injects them into your running app. Values are never visible in logs or build output.
|
|
36
|
+
|
|
37
|
+
5. Cron — Scheduled tasks that POST to an endpoint in your app. You write a route, DOS calls it on a schedule. No separate workers or infrastructure.
|
|
38
|
+
|
|
39
|
+
6. Marketplace — One-click apps (databases, monitoring, CMS tools, dev tools) that deploy into your account pre-configured.
|
|
40
|
+
|
|
41
|
+
### The Build Pipeline
|
|
42
|
+
|
|
43
|
+
Push to GitHub → DOS detects the push → builds a container (tries Dockerfile first, then auto-detects your stack) → runs it → hits your /health endpoint → routes traffic. Build timeout is 10 minutes. First build is 60–90 seconds; incremental builds are faster.
|
|
44
|
+
|
|
45
|
+
Important: DOS does not auto-run database migrations. After a schema change, run: dailey run node scripts/migrate.js (or whatever your migration command is).
|
|
46
|
+
|
|
47
|
+
### The CLI
|
|
48
|
+
|
|
49
|
+
npm install -g dailey
|
|
50
|
+
dailey login
|
|
51
|
+
|
|
52
|
+
dailey apps # list your apps
|
|
53
|
+
dailey create # new app, interactive
|
|
54
|
+
dailey deploy <app> # manual deploy trigger
|
|
55
|
+
dailey logs <app> # live logs
|
|
56
|
+
dailey logs <app> --build # build logs
|
|
57
|
+
dailey status <app> # health, URL, deploy info
|
|
58
|
+
dailey rollback <app> # back to previous version (seconds, no rebuild)
|
|
59
|
+
|
|
60
|
+
dailey env set <app> KEY=VALUE # set a secret
|
|
61
|
+
dailey env get <app> # list env vars (masked)
|
|
62
|
+
dailey env get <app> KEY # get one value
|
|
63
|
+
dailey env unset <app> KEY # remove a secret
|
|
64
|
+
|
|
65
|
+
dailey creds <app> # database credentials
|
|
66
|
+
dailey link <app> <other-app> # connect two apps internally
|
|
67
|
+
dailey scale <app> --replicas N # scale replicas
|
|
68
|
+
dailey exec <app> -- <command> # run a command in a live pod
|
|
69
|
+
dailey run <app> -- <command> # run a one-off job
|
|
70
|
+
dailey marketplace # browse one-click apps
|
|
71
|
+
dailey marketplace install <name> # install a marketplace app
|
|
72
|
+
|
|
73
|
+
### Platform-Injected Environment Variables
|
|
74
|
+
|
|
75
|
+
DOS automatically injects these — the user never sets them manually:
|
|
76
|
+
|
|
77
|
+
DATABASE_URL Full connection string for the database
|
|
78
|
+
S3_ENDPOINT Storage endpoint
|
|
79
|
+
S3_BUCKET_NAME Storage bucket
|
|
80
|
+
S3_ACCESS_KEY_ID Storage access key
|
|
81
|
+
S3_SECRET_ACCESS_KEY Storage secret
|
|
82
|
+
S3_PREFIX App's isolated path in the bucket
|
|
83
|
+
S3_REGION Storage region
|
|
84
|
+
NODE_ENV "production" in deployed apps
|
|
85
|
+
PORT Port the app must listen on
|
|
86
|
+
|
|
87
|
+
### The Blog Template
|
|
88
|
+
|
|
89
|
+
There's a ready-to-deploy blog app at github.com/jonndailey/dailey-template-blog that covers every DOS feature. Fork it and you have a starting point that's already wired up correctly. It uses Express + MySQL + R2 storage, has an admin panel, auto-runs migrations on startup, handles CSRF, rate-limits login attempts, and includes example cron endpoint handlers.
|
|
90
|
+
|
|
91
|
+
When someone asks "what should I build first" or "how do I learn DOS" — this is the answer.
|
|
92
|
+
|
|
93
|
+
To deploy it:
|
|
94
|
+
1. Fork github.com/jonndailey/dailey-template-blog to the user's GitHub
|
|
95
|
+
2. dailey create → point it at the fork
|
|
96
|
+
3. It auto-provisions database + storage and generates secrets from dailey.json
|
|
97
|
+
4. It's live in under 2 minutes
|
|
98
|
+
|
|
99
|
+
Use dailey_deploy_bundle to do this in one MCP call.
|
|
100
|
+
|
|
101
|
+
### The dailey.json Manifest
|
|
102
|
+
|
|
103
|
+
This file in the repo tells DOS what the app needs:
|
|
104
|
+
|
|
105
|
+
{
|
|
106
|
+
"name": "My App",
|
|
107
|
+
"services": { "database": true, "storage": true },
|
|
108
|
+
"env": {
|
|
109
|
+
"MY_SECRET": { "autoGenerate": true, "length": 32 }
|
|
110
|
+
},
|
|
111
|
+
"cron": {
|
|
112
|
+
"cleanup": { "schedule": "0 2 * * *", "endpoint": "/cron/cleanup" }
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
- services.database: true → DOS provisions MySQL and injects DATABASE_URL
|
|
117
|
+
- services.storage: true → DOS provisions R2 and injects S3_* vars
|
|
118
|
+
- env.* with autoGenerate → DOS generates a secure random value on first deploy and vaults it
|
|
119
|
+
- cron.* → DOS creates a scheduled job that POSTs to that endpoint on schedule
|
|
120
|
+
|
|
121
|
+
### Pricing Tiers
|
|
122
|
+
|
|
123
|
+
Free: $0/mo — 0.5 vCPU, 512 MB RAM, 500 MB DB, 1 GB storage, 1 app
|
|
124
|
+
Builder: $49/mo — 4 vCPU, 4 GB RAM, 5 GB DB, 10 GB storage, 10 apps, custom domains
|
|
125
|
+
Pro: $149/mo — 8 vCPU, 16 GB RAM, 25 GB DB, 50 GB storage, 25 apps
|
|
126
|
+
Scale: $349/mo — 16 vCPU, 32 GB RAM, 100 GB DB, 200 GB storage, unlimited apps
|
|
127
|
+
|
|
128
|
+
Free tier is enough to deploy the blog template and explore everything.
|
|
129
|
+
|
|
130
|
+
## How to Help
|
|
131
|
+
|
|
132
|
+
Match the user's pace. If they ask a short question, give a short answer. If they're stuck and frustrated, go deeper. Don't dump the whole platform on someone who asked "how do I set an env var."
|
|
133
|
+
|
|
134
|
+
Be honest about limits. If something doesn't work on DOS, say so. Don't invent workarounds or pretend a feature exists. If you're not sure, say so.
|
|
135
|
+
|
|
136
|
+
Steer toward what works. If someone is about to do something that will cause them pain (like skipping migrations, setting secrets in source code, or hardcoding ports), tell them before they do it.
|
|
137
|
+
|
|
138
|
+
When someone hits an error, do this in order:
|
|
139
|
+
1. Read the error message carefully — it usually says what's wrong
|
|
140
|
+
2. Ask them to share dailey logs <app> output if they haven't
|
|
141
|
+
3. Check if it's a known pattern (see below)
|
|
142
|
+
4. Help them fix the root cause, not patch the symptom
|
|
143
|
+
|
|
144
|
+
Common issues and what they actually mean:
|
|
145
|
+
|
|
146
|
+
- ECONNREFUSED on startup → env vars probably weren't injected. Check dailey env get <app> and verify DATABASE_URL exists.
|
|
147
|
+
- Login succeeds but next request is 401 → session cookie issue, usually because the app isn't getting HTTPS from request headers. Make sure trust proxy is set in Express.
|
|
148
|
+
- ER_WRONG_ARGUMENTS on paginated MySQL queries → mysql2's execute() doesn't accept LIMIT/OFFSET as bound parameters; embed them as integer literals in the SQL string after validating they're integers.
|
|
149
|
+
- Build timed out → dependencies installing too slowly; make sure package-lock.json is committed.
|
|
150
|
+
- 520 error when running long exec commands → Cloudflare has a body size limit; write the script to /tmp/script.js first, then run node /tmp/script.js as a separate exec call.
|
|
151
|
+
- "Migrations not applied" on first deploy → DOS doesn't auto-run migrations; use dailey run <app> -- node scripts/migrate.js
|
|
152
|
+
|
|
153
|
+
## What You Don't Talk About
|
|
154
|
+
|
|
155
|
+
You are the user's assistant, not a window into the platform's internals. Do not discuss or reveal:
|
|
156
|
+
|
|
157
|
+
- Internal infrastructure topology (node names, cluster layout, IP addresses)
|
|
158
|
+
- How the build system works internally
|
|
159
|
+
- Database server configuration or internal hostnames
|
|
160
|
+
- Ingress or proxy configuration details
|
|
161
|
+
- Internal service names or how platform services communicate
|
|
162
|
+
- Security architecture at the implementation level
|
|
163
|
+
- Other customers or their apps
|
|
164
|
+
|
|
165
|
+
If asked about something internal, redirect to what matters to the user: "That's handled by the platform — from your app's perspective, here's what you control..."
|
|
166
|
+
|
|
167
|
+
## Tone
|
|
168
|
+
|
|
169
|
+
You're a senior engineer who genuinely enjoys helping people ship things. You're warm but not corporate-cheery. You celebrate wins. You're direct when something is wrong. You don't pad answers with disclaimers. You don't start every sentence with "Great question!"
|
|
170
|
+
|
|
171
|
+
When someone gets their first deploy working, act like it's a real thing that happened. It is.
|
|
172
|
+
`.trim();
|
|
173
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
174
|
+
export function registerBuddyTools(server) {
|
|
175
|
+
// ── MCP Prompt resource ──────────────────────────────────────────────────
|
|
176
|
+
// Surfaced as /mcp__dailey-os__dos-buddy in Claude Code.
|
|
177
|
+
// Users add this to their CLAUDE.md:
|
|
178
|
+
// @mcp__dailey-os__dos-buddy
|
|
179
|
+
// or reference it in project instructions to load DOS Buddy as system context
|
|
180
|
+
// automatically for every session on a Dailey OS project.
|
|
181
|
+
server.prompt('dos-buddy', 'Load DOS Buddy as your AI guide for Dailey OS. Add @mcp__dailey-os__dos-buddy to your CLAUDE.md to activate it automatically for every session.', async () => ({
|
|
182
|
+
messages: [
|
|
183
|
+
{
|
|
184
|
+
role: 'user',
|
|
185
|
+
content: {
|
|
186
|
+
type: 'text',
|
|
187
|
+
text: DOS_BUDDY_PROMPT,
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
}));
|
|
192
|
+
// ── dailey_buddy tool ────────────────────────────────────────────────────
|
|
193
|
+
// The human-callable entry point. Always call this at the start of a new
|
|
194
|
+
// DOS session to greet the user correctly (new vs returning). Also useful
|
|
195
|
+
// for explicit "ask DOS Buddy" invocations about platform topics.
|
|
196
|
+
server.tool('dailey_buddy', 'Your first call in any DOS session. Greets new users with an onboarding offer and returning users with a status summary. Also answers any question about Dailey OS — how to deploy, fix errors, use features, or understand the platform. Call with no topic for the session greeting.', {
|
|
197
|
+
topic: z.string().optional().describe('Specific topic or question about Dailey OS. Leave empty for the session greeting / onboarding check.'),
|
|
198
|
+
}, async ({ topic }) => {
|
|
199
|
+
// Check first-use state by looking at project count.
|
|
200
|
+
const projectsRes = await apiRequest('GET', '/projects');
|
|
201
|
+
const projects = projectsRes.ok ? (projectsRes.data.projects ?? []) : [];
|
|
202
|
+
const isNewUser = projects.length === 0;
|
|
203
|
+
if (!topic) {
|
|
204
|
+
// ── Session greeting ─────────────────────────────────────────────
|
|
205
|
+
if (isNewUser) {
|
|
206
|
+
return textResult([
|
|
207
|
+
`Hey! I'm DOS Buddy — I'm here to help you get your app running on Dailey OS.`,
|
|
208
|
+
``,
|
|
209
|
+
`You don't have any projects yet. A few ways to get started:`,
|
|
210
|
+
``,
|
|
211
|
+
` 1. Deploy the blog template (covers every DOS feature in ~30 min)`,
|
|
212
|
+
` → Say "deploy the blog template for me" and I'll handle it`,
|
|
213
|
+
``,
|
|
214
|
+
` 2. Deploy your own GitHub repo`,
|
|
215
|
+
` → Share your repo URL and I'll set it up`,
|
|
216
|
+
``,
|
|
217
|
+
` 3. Just explore — ask me anything about the platform`,
|
|
218
|
+
``,
|
|
219
|
+
`What would you like to do?`,
|
|
220
|
+
].join('\n'));
|
|
221
|
+
}
|
|
222
|
+
const activeCount = projects.filter(p => p.status === 'active').length;
|
|
223
|
+
const lines = [
|
|
224
|
+
`Hey! I'm DOS Buddy — your guide for Dailey OS.`,
|
|
225
|
+
``,
|
|
226
|
+
`You have ${projects.length} project${projects.length === 1 ? '' : 's'}${activeCount > 0 ? ` (${activeCount} active)` : ''}.`,
|
|
227
|
+
``,
|
|
228
|
+
`I can help you:`,
|
|
229
|
+
` • Debug something that's broken → share the error and I'll walk through it`,
|
|
230
|
+
` • Add a database, storage, cron, or custom domain to an existing app`,
|
|
231
|
+
` • Deploy a new project`,
|
|
232
|
+
` • Understand what any DOS tool or feature does`,
|
|
233
|
+
``,
|
|
234
|
+
`What do you need?`,
|
|
235
|
+
];
|
|
236
|
+
return textResult(lines.join('\n'));
|
|
237
|
+
}
|
|
238
|
+
// ── Topic-based response ─────────────────────────────────────────────
|
|
239
|
+
// The LLM handles knowledge questions naturally from the system prompt.
|
|
240
|
+
// This branch handles explicit tool invocations with a topic so the
|
|
241
|
+
// response is grounded in the user's current state.
|
|
242
|
+
const t = topic.toLowerCase();
|
|
243
|
+
if (t.includes('blog') || t.includes('template') || t.includes('start') || t.includes('tutorial')) {
|
|
244
|
+
return textResult([
|
|
245
|
+
`The fastest way to learn Dailey OS end-to-end is the blog template.`,
|
|
246
|
+
``,
|
|
247
|
+
`It's a full Express + MySQL + R2 blog with admin panel, migrations, cron endpoints,`,
|
|
248
|
+
`and CSRF/session security — all pre-wired to work on DOS out of the box.`,
|
|
249
|
+
``,
|
|
250
|
+
`To deploy it: call dailey_deploy_bundle with:`,
|
|
251
|
+
` repo_url: https://github.com/jonndailey/dailey-template-blog`,
|
|
252
|
+
` name: (whatever you'd like)`,
|
|
253
|
+
` needs_database: true`,
|
|
254
|
+
``,
|
|
255
|
+
`DOS will provision the database, generate your admin password, and have it live`,
|
|
256
|
+
`in under 2 minutes. After deploy, run your first migration:`,
|
|
257
|
+
` dailey run <app> -- node scripts/migrate.js`,
|
|
258
|
+
``,
|
|
259
|
+
`Then get your admin password: dailey env get <app> ADMIN_PASSWORD`,
|
|
260
|
+
].join('\n'));
|
|
261
|
+
}
|
|
262
|
+
if (t.includes('database') || t.includes('db') || t.includes('mysql') || t.includes('postgres')) {
|
|
263
|
+
return textResult([
|
|
264
|
+
`DOS manages your database entirely — you never touch the server.`,
|
|
265
|
+
``,
|
|
266
|
+
`When your app includes "services": { "database": true } in dailey.json,`,
|
|
267
|
+
`DOS provisions a database and injects DATABASE_URL into your container.`,
|
|
268
|
+
``,
|
|
269
|
+
`Key things to know:`,
|
|
270
|
+
` • Migrations don't run automatically — run them with:`,
|
|
271
|
+
` dailey run <app> -- node scripts/migrate.js`,
|
|
272
|
+
` • To inspect or query: use dailey_db_recall (read) or dailey_db_schema`,
|
|
273
|
+
` • To run DDL/migrations via MCP: use dailey_db_exec`,
|
|
274
|
+
` • To connect a GUI tool: dailey db connect <app> (no VPN needed)`,
|
|
275
|
+
` • mysql2's execute() rejects LIMIT/OFFSET as bound params — embed`,
|
|
276
|
+
` them as integer literals in the SQL string after validating they're ints`,
|
|
277
|
+
].join('\n'));
|
|
278
|
+
}
|
|
279
|
+
if (t.includes('env') || t.includes('secret') || t.includes('variable')) {
|
|
280
|
+
return textResult([
|
|
281
|
+
`DOS stores env vars encrypted at rest. They're injected into your container at runtime.`,
|
|
282
|
+
``,
|
|
283
|
+
` Set: dailey env set <app> KEY=VALUE`,
|
|
284
|
+
` List: dailey env get <app>`,
|
|
285
|
+
` Get one: dailey env get <app> KEY`,
|
|
286
|
+
` Remove: dailey env unset <app> KEY`,
|
|
287
|
+
``,
|
|
288
|
+
`Changes take effect on the next deploy. Some vars are auto-injected by DOS`,
|
|
289
|
+
`and should not be set manually: DATABASE_URL, S3_*, NODE_ENV, PORT.`,
|
|
290
|
+
``,
|
|
291
|
+
`To auto-generate a secret on first deploy, add it to dailey.json:`,
|
|
292
|
+
` "env": { "MY_KEY": { "autoGenerate": true, "length": 32 } }`,
|
|
293
|
+
].join('\n'));
|
|
294
|
+
}
|
|
295
|
+
if (t.includes('deploy') || t.includes('build') || t.includes('push')) {
|
|
296
|
+
return textResult([
|
|
297
|
+
`Deployments on DOS are triggered by GitHub pushes (automatic) or manually.`,
|
|
298
|
+
``,
|
|
299
|
+
` Manual deploy: dailey deploy <app> or dailey_deploy in MCP`,
|
|
300
|
+
` Watch progress: dailey logs <app> --build`,
|
|
301
|
+
` Check status: dailey status <app> or dailey_deploy_status in MCP`,
|
|
302
|
+
` Roll back: dailey rollback <app> (seconds, no rebuild)`,
|
|
303
|
+
``,
|
|
304
|
+
`Build timeout is 10 minutes. Make sure package-lock.json is committed`,
|
|
305
|
+
`(speeds up installs significantly). Dockerfile is used if present;`,
|
|
306
|
+
`otherwise DOS auto-detects your stack.`,
|
|
307
|
+
``,
|
|
308
|
+
`After deploy: DOS does NOT auto-run migrations. Run them manually:`,
|
|
309
|
+
` dailey run <app> -- node scripts/migrate.js`,
|
|
310
|
+
].join('\n'));
|
|
311
|
+
}
|
|
312
|
+
if (t.includes('storage') || t.includes('s3') || t.includes('r2') || t.includes('upload') || t.includes('file')) {
|
|
313
|
+
return textResult([
|
|
314
|
+
`DOS provides S3-compatible object storage (Cloudflare R2).`,
|
|
315
|
+
``,
|
|
316
|
+
`Enable it: set "services": { "storage": true } in dailey.json.`,
|
|
317
|
+
`DOS injects S3_ENDPOINT, S3_BUCKET_NAME, S3_ACCESS_KEY_ID,`,
|
|
318
|
+
`S3_SECRET_ACCESS_KEY, S3_PREFIX, S3_REGION into your container.`,
|
|
319
|
+
``,
|
|
320
|
+
`Your app's prefix is scoped — it can only read/write its own files.`,
|
|
321
|
+
`Use any S3-compatible SDK (AWS SDK v3 works perfectly).`,
|
|
322
|
+
``,
|
|
323
|
+
`For presigned URLs (serve files without exposing credentials):`,
|
|
324
|
+
` dailey_storage_presign_download / dailey_storage_presign_upload`,
|
|
325
|
+
].join('\n'));
|
|
326
|
+
}
|
|
327
|
+
if (t.includes('cron') || t.includes('schedule') || t.includes('job')) {
|
|
328
|
+
return textResult([
|
|
329
|
+
`DOS cron jobs POST to an HTTP endpoint in your running app on a schedule.`,
|
|
330
|
+
``,
|
|
331
|
+
`Add to dailey.json:`,
|
|
332
|
+
` "cron": {`,
|
|
333
|
+
` "cleanup": {`,
|
|
334
|
+
` "schedule": "0 2 * * *",`,
|
|
335
|
+
` "endpoint": "/cron/cleanup",`,
|
|
336
|
+
` "headers": { "x-cron-secret": "{{CRON_SECRET}}" }`,
|
|
337
|
+
` }`,
|
|
338
|
+
` }`,
|
|
339
|
+
``,
|
|
340
|
+
`In your app, add a POST route at /cron/cleanup that verifies the secret`,
|
|
341
|
+
`and runs the job. Keep it fast — if it needs to be long-running, queue`,
|
|
342
|
+
`the work and return 200 immediately.`,
|
|
343
|
+
``,
|
|
344
|
+
`Set the secret: dailey env set <app> CRON_SECRET=$(openssl rand -hex 32)`,
|
|
345
|
+
].join('\n'));
|
|
346
|
+
}
|
|
347
|
+
// Generic fallback — the LLM has full context from the prompt resource
|
|
348
|
+
return textResult([
|
|
349
|
+
`I'm DOS Buddy — ask me anything about Dailey OS.`,
|
|
350
|
+
``,
|
|
351
|
+
`You asked about: ${topic}`,
|
|
352
|
+
``,
|
|
353
|
+
`I have full context on deployments, databases, storage, secrets, cron,`,
|
|
354
|
+
`marketplace, CLI commands, and common errors. Just ask naturally and I'll`,
|
|
355
|
+
`walk you through it.`,
|
|
356
|
+
].join('\n'));
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
//# sourceMappingURL=buddy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buddy.js","sourceRoot":"","sources":["../../src/tools/buddy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEnD,gFAAgF;AAChF,yEAAyE;AACzE,0DAA0D;AAC1D,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsKxB,CAAC,IAAI,EAAE,CAAC;AAET,gFAAgF;AAEhF,MAAM,UAAU,kBAAkB,CAAC,MAAiB;IAClD,4EAA4E;IAC5E,yDAAyD;IACzD,qCAAqC;IACrC,+BAA+B;IAC/B,8EAA8E;IAC9E,0DAA0D;IAC1D,MAAM,CAAC,MAAM,CACX,WAAW,EACX,iJAAiJ,EACjJ,KAAK,IAAI,EAAE,CAAC,CAAC;QACX,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAe;gBACrB,OAAO,EAAE;oBACP,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,gBAAgB;iBACvB;aACF;SACF;KACF,CAAC,CACH,CAAC;IAEF,4EAA4E;IAC5E,yEAAyE;IACzE,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,gEAAgE;gBAChE,4DAA4D;gBAC5D,iEAAiE;gBACjE,EAAE;gBACF,qEAAqE;gBACrE,yDAAyD;gBACzD,EAAE;gBACF,gEAAgE;gBAChE,mEAAmE;aACpE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAChB,CAAC;QAED,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACtE,OAAO,UAAU,CAAC;gBAChB,2EAA2E;gBAC3E,EAAE;gBACF,qBAAqB;gBACrB,aAAa;gBACb,kBAAkB;gBAClB,gCAAgC;gBAChC,oCAAoC;gBACpC,yDAAyD;gBACzD,OAAO;gBACP,KAAK;gBACL,EAAE;gBACF,yEAAyE;gBACzE,wEAAwE;gBACxE,sCAAsC;gBACtC,EAAE;gBACF,0EAA0E;aAC3E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAChB,CAAC;QAED,uEAAuE;QACvE,OAAO,UAAU,CAAC;YAChB,kDAAkD;YAClD,EAAE;YACF,oBAAoB,KAAK,EAAE;YAC3B,EAAE;YACF,wEAAwE;YACxE,2EAA2E;YAC3E,sBAAsB;SACvB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChB,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnose.d.ts","sourceRoot":"","sources":["../../src/tools/diagnose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"diagnose.d.ts","sourceRoot":"","sources":["../../src/tools/diagnose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAqepE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,QAiFtD"}
|
package/dist/tools/diagnose.js
CHANGED
|
@@ -1,6 +1,118 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { apiRequest, textResult } from '../api.js';
|
|
3
3
|
const ERROR_LINE_PATTERN = /(error|fatal|panic|exception|uncaught|unhandled)/i;
|
|
4
|
+
const KNOWN_PATTERNS = [
|
|
5
|
+
{
|
|
6
|
+
pattern: /P3009|migrate found failed migrations|applied migration.*is not recorded/i,
|
|
7
|
+
issue: {
|
|
8
|
+
id: 'prisma_failed_migration',
|
|
9
|
+
name: 'Prisma: failed migration in history',
|
|
10
|
+
plain_english: 'Your database has a migration that started but never finished — usually because the app crashed mid-deploy or you restored a dump on top of an existing schema. Prisma refuses to start until it is resolved.',
|
|
11
|
+
fix: 'Run: dailey db exec <project> "UPDATE _prisma_migrations SET finished_at = started_at, logs = NULL WHERE finished_at IS NULL AND rolled_back_at IS NULL;" --confirm\nThen redeploy: dailey deploy <project>',
|
|
12
|
+
severity: 'fail',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
pattern: /PrismaClientInitializationError|prisma\.generate|@prisma\/client did not initialize/i,
|
|
17
|
+
issue: {
|
|
18
|
+
id: 'prisma_client_not_generated',
|
|
19
|
+
name: 'Prisma: client not generated',
|
|
20
|
+
plain_english: 'The Prisma client was not generated during the build step. Your Dockerfile or build command is missing "prisma generate" before "node" starts.',
|
|
21
|
+
fix: 'Add "npx prisma generate" to your build step. In package.json: "build": "prisma generate && tsc" (or whatever your build command is). Then redeploy: dailey deploy <project>',
|
|
22
|
+
severity: 'fail',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
pattern: /exit code 137|OOMKilled|out of memory kill|memory limit exceeded/i,
|
|
27
|
+
issue: {
|
|
28
|
+
id: 'oom_killed',
|
|
29
|
+
name: 'Pod killed: out of memory (OOM)',
|
|
30
|
+
plain_english: 'Your app used more memory than its limit and the platform killed it. The default limit is 512 MB per replica.',
|
|
31
|
+
fix: 'Check memory usage: dailey usage <project>\nIncrease the limit: dailey resource-config <project> --memory-limit 1024\nOr reduce memory use (Node.js tip: set NODE_OPTIONS="--max-old-space-size=900" in your env vars).',
|
|
32
|
+
severity: 'fail',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
pattern: /FATAL ERROR:.*JavaScript heap out of memory|heap out of memory/i,
|
|
37
|
+
issue: {
|
|
38
|
+
id: 'node_heap_oom',
|
|
39
|
+
name: 'Node.js heap out of memory',
|
|
40
|
+
plain_english: "Your Node.js process ran out of heap space. It didn't hit the container memory limit — the V8 heap limit (default ~512 MB) was hit first.",
|
|
41
|
+
fix: 'Set NODE_OPTIONS env var: dailey env set <project> NODE_OPTIONS "--max-old-space-size=1024"\nThen redeploy: dailey deploy <project>',
|
|
42
|
+
severity: 'fail',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
pattern: /ECONNREFUSED.*(?:3306|5432|27017)|connect ECONNREFUSED.*database|database connection refused/i,
|
|
47
|
+
issue: {
|
|
48
|
+
id: 'db_connection_refused',
|
|
49
|
+
name: 'Database connection refused',
|
|
50
|
+
plain_english: 'Your app tried to connect to the database but got "connection refused." Either the database is not provisioned, or the connection URL is wrong.',
|
|
51
|
+
fix: 'Check if a database is provisioned: dailey db info <project>\nIf not provisioned: dailey db provision <project> --type mysql (or postgres)\nIf provisioned, verify DATABASE_URL is correct: dailey env list <project>',
|
|
52
|
+
severity: 'fail',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
pattern: /EADDRINUSE|address already in use|port.*already in use/i,
|
|
57
|
+
issue: {
|
|
58
|
+
id: 'port_in_use',
|
|
59
|
+
name: 'Port already in use',
|
|
60
|
+
plain_english: "Your app tried to listen on a port that's already occupied. On Dailey OS you must listen on the PORT env var (always 3000) — never hardcode a port number.",
|
|
61
|
+
fix: 'Update your app to bind to process.env.PORT (not a hardcoded number). Example: app.listen(process.env.PORT || 3000)\nThen redeploy: dailey deploy <project>',
|
|
62
|
+
severity: 'fail',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
pattern: /Cannot find module|MODULE_NOT_FOUND|Error: Cannot find|module not found/i,
|
|
67
|
+
issue: {
|
|
68
|
+
id: 'module_not_found',
|
|
69
|
+
name: 'Module not found',
|
|
70
|
+
plain_english: 'A package your app depends on is missing from the build. This usually means a dependency was not installed during the build, or was accidentally added to devDependencies instead of dependencies.',
|
|
71
|
+
fix: 'Check your package.json: make sure the missing package is in "dependencies" (not "devDependencies").\nThen redeploy: dailey deploy <project>\nIf the build is failing: dailey build-logs <project>',
|
|
72
|
+
severity: 'fail',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
pattern: /TypeError: Cannot read propert(?:y|ies) of undefined|TypeError: Cannot read propert(?:y|ies) of null|ReferenceError: process is not defined/i,
|
|
77
|
+
issue: {
|
|
78
|
+
id: 'missing_env_var',
|
|
79
|
+
name: 'Missing environment variable (likely)',
|
|
80
|
+
plain_english: 'Your app crashed trying to read a value that was undefined or null. This is often a missing environment variable — your code references process.env.SOMETHING that was never set.',
|
|
81
|
+
fix: 'Check which env vars are set: dailey env list <project>\nSet a missing var: dailey env set <project> MY_VAR "my value"\nThen redeploy: dailey deploy <project>',
|
|
82
|
+
severity: 'warn',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
pattern: /secretOrPrivateKey must have a value|jwt.*secret.*undefined|invalid signature/i,
|
|
87
|
+
issue: {
|
|
88
|
+
id: 'missing_jwt_secret',
|
|
89
|
+
name: 'Missing JWT secret',
|
|
90
|
+
plain_english: 'Your app uses JWT (JSON Web Tokens) but the secret key env var is not set. Sessions and auth will fail.',
|
|
91
|
+
fix: 'Set your JWT secret: dailey env set <project> JWT_SECRET "$(openssl rand -hex 32)"\nThen redeploy: dailey deploy <project>',
|
|
92
|
+
severity: 'fail',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
pattern: /SSL SYSCALL error|SSL connection has been closed|EPROTO.*SSL|certificate verify failed/i,
|
|
97
|
+
issue: {
|
|
98
|
+
id: 'ssl_db_error',
|
|
99
|
+
name: 'Database SSL error',
|
|
100
|
+
plain_english: 'Your app failed to establish a secure connection to the database. This usually means the SSL mode in your connection string does not match what the server requires.',
|
|
101
|
+
fix: 'If using PostgreSQL, add ?sslmode=require to DATABASE_URL.\nIf using MySQL, add ?ssl=true.\nCheck current DATABASE_URL: dailey env list <project>',
|
|
102
|
+
severity: 'fail',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
pattern: /SIGTERM|graceful shutdown|terminating connection|Gracefully stopping/i,
|
|
107
|
+
issue: {
|
|
108
|
+
id: 'sigterm_restart',
|
|
109
|
+
name: 'Pod restarting (SIGTERM)',
|
|
110
|
+
plain_english: 'Your app is being stopped and restarted by the platform. This is normal during deploys, but if it is happening repeatedly it means the app is not starting up properly after being stopped.',
|
|
111
|
+
fix: 'Check pod restart count and crash reasons: dailey processes <project>\nCheck if the latest deploy succeeded: dailey deploy-status <project>',
|
|
112
|
+
severity: 'warn',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
];
|
|
4
116
|
async function resolveProjectId(projectOrSlug) {
|
|
5
117
|
// Try as ID first — a UUID-shaped string is almost always a real ID.
|
|
6
118
|
const looksLikeId = /^[0-9a-f-]{8,}$/i.test(projectOrSlug);
|
|
@@ -234,6 +346,41 @@ async function checkRecentErrors(projectId) {
|
|
|
234
346
|
detail: { matches: matches.slice(0, 5) },
|
|
235
347
|
};
|
|
236
348
|
}
|
|
349
|
+
async function checkKnownPatterns(projectId) {
|
|
350
|
+
const res = await apiRequest('GET', `/projects/${projectId}/logs?tail=100`);
|
|
351
|
+
if (!res.ok) {
|
|
352
|
+
return { name: 'known_issues', status: 'skip', summary: 'No logs available to scan for known issues.' };
|
|
353
|
+
}
|
|
354
|
+
const lines = res.data.logs || [];
|
|
355
|
+
const logText = lines.join('\n');
|
|
356
|
+
const matched = [];
|
|
357
|
+
const seen = new Set();
|
|
358
|
+
for (const rule of KNOWN_PATTERNS) {
|
|
359
|
+
if (rule.pattern.test(logText) && !seen.has(rule.issue.id)) {
|
|
360
|
+
seen.add(rule.issue.id);
|
|
361
|
+
matched.push(rule.issue);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (matched.length === 0) {
|
|
365
|
+
return { name: 'known_issues', status: 'ok', summary: 'No known crash patterns detected in last 100 log lines.' };
|
|
366
|
+
}
|
|
367
|
+
const hasFail = matched.some((i) => i.severity === 'fail');
|
|
368
|
+
const laneStatus = hasFail ? 'fail' : 'warn';
|
|
369
|
+
const names = matched.map((i) => i.name).join('; ');
|
|
370
|
+
return {
|
|
371
|
+
name: 'known_issues',
|
|
372
|
+
status: laneStatus,
|
|
373
|
+
summary: `${matched.length} known issue(s) detected: ${names}`,
|
|
374
|
+
detail: {
|
|
375
|
+
issues: matched.map((i) => ({
|
|
376
|
+
id: i.id,
|
|
377
|
+
name: i.name,
|
|
378
|
+
plain_english: i.plain_english,
|
|
379
|
+
fix: i.fix,
|
|
380
|
+
})),
|
|
381
|
+
},
|
|
382
|
+
};
|
|
383
|
+
}
|
|
237
384
|
function aggregateVerdict(lanes) {
|
|
238
385
|
const hasFail = lanes.some((l) => l.status === 'fail');
|
|
239
386
|
const hasWarn = lanes.some((l) => l.status === 'warn');
|
|
@@ -309,6 +456,11 @@ export function registerDiagnoseTools(server) {
|
|
|
309
456
|
status: 'fail',
|
|
310
457
|
summary: `lane crashed: ${err.message}`,
|
|
311
458
|
})),
|
|
459
|
+
checkKnownPatterns(projectId).catch((err) => ({
|
|
460
|
+
name: 'known_issues',
|
|
461
|
+
status: 'fail',
|
|
462
|
+
summary: `lane crashed: ${err.message}`,
|
|
463
|
+
})),
|
|
312
464
|
]);
|
|
313
465
|
const { verdict, summary } = aggregateVerdict(lanes);
|
|
314
466
|
const payload = {
|