@donkeylabs/cli 2.0.18 → 2.0.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donkeylabs/cli",
3
- "version": "2.0.18",
3
+ "version": "2.0.20",
4
4
  "type": "module",
5
5
  "description": "CLI for @donkeylabs/server - project scaffolding and code generation",
6
6
  "main": "./src/index.ts",
@@ -23,35 +23,30 @@ interface DocsCommandOptions {
23
23
  }
24
24
 
25
25
  /**
26
- * Find the docs directory from installed @donkeylabs/server
26
+ * Find the server package directory from installed @donkeylabs/server
27
27
  */
28
- function findDocsPath(): string | null {
29
- // Try common locations
28
+ function findServerPkgDir(): string | null {
30
29
  const possiblePaths = [
31
- // node_modules (standard install)
32
- join(process.cwd(), "node_modules", "@donkeylabs", "server", "docs"),
33
- // bun's .bun cache
34
- join(process.cwd(), "node_modules", ".bun", "@donkeylabs", "server", "docs"),
35
- // Workspace/monorepo
36
- join(process.cwd(), "..", "server", "docs"),
37
- join(process.cwd(), "..", "..", "packages", "server", "docs"),
30
+ join(process.cwd(), "node_modules", "@donkeylabs", "server"),
31
+ join(process.cwd(), "node_modules", ".bun", "@donkeylabs", "server"),
32
+ join(process.cwd(), "..", "server"),
33
+ join(process.cwd(), "..", "..", "packages", "server"),
38
34
  ];
39
35
 
40
36
  for (const path of possiblePaths) {
41
- if (existsSync(path) && statSync(path).isDirectory()) {
37
+ const docsDir = join(path, "docs");
38
+ if (existsSync(docsDir) && statSync(docsDir).isDirectory()) {
42
39
  return path;
43
40
  }
44
41
  }
45
42
 
46
- // Try to resolve from require
47
43
  try {
48
44
  const serverPkgPath = require.resolve("@donkeylabs/server/package.json", {
49
45
  paths: [process.cwd()],
50
46
  });
51
47
  const serverDir = dirname(serverPkgPath);
52
- const docsPath = join(serverDir, "docs");
53
- if (existsSync(docsPath)) {
54
- return docsPath;
48
+ if (existsSync(join(serverDir, "docs"))) {
49
+ return serverDir;
55
50
  }
56
51
  } catch {
57
52
  // Package not found
@@ -60,6 +55,30 @@ function findDocsPath(): string | null {
60
55
  return null;
61
56
  }
62
57
 
58
+ /**
59
+ * Find the docs directory from installed @donkeylabs/server
60
+ */
61
+ function findDocsPath(): string | null {
62
+ const serverDir = findServerPkgDir();
63
+ if (!serverDir) return null;
64
+ return join(serverDir, "docs");
65
+ }
66
+
67
+ /**
68
+ * Sync agents.md from the server package root to the project root
69
+ */
70
+ function syncAgentsMd(): void {
71
+ const serverDir = findServerPkgDir();
72
+ if (!serverDir) return;
73
+
74
+ const agentsMdSrc = join(serverDir, "agents.md");
75
+ if (!existsSync(agentsMdSrc)) return;
76
+
77
+ const content = readFileSync(agentsMdSrc, "utf-8");
78
+ writeFileSync(join(process.cwd(), "agents.md"), content);
79
+ console.log(pc.green("✓ Synced agents.md"));
80
+ }
81
+
63
82
  /**
64
83
  * Get list of available doc files
65
84
  */
@@ -201,6 +220,7 @@ export async function docsCommand(args: string[], options: DocsCommandOptions =
201
220
  console.log(pc.dim(`Target: ${outputDir}/\n`));
202
221
 
203
222
  const synced = syncAllDocs(docsPath, outputDir);
223
+ syncAgentsMd();
204
224
 
205
225
  console.log(pc.green(`\n✓ Synced ${synced} documentation files to ${outputDir}/`));
206
226
  console.log(pc.dim(`\nTip: Add ${outputDir}/ to your .gitignore if you don't want to commit docs.`));
@@ -374,6 +374,7 @@ function createPackageJson(projectDir: string, options: InitOptions) {
374
374
  "prepare": "bun --bun svelte-kit sync && bun run gen:types || echo ''",
375
375
  "check": "bun --bun svelte-kit sync && bun --bun svelte-check --tsconfig ./tsconfig.json",
376
376
  "gen:types": "donkeylabs generate",
377
+ "update": "donkeylabs update",
377
378
  "cli": "donkeylabs",
378
379
  "test": "bun test",
379
380
  ...(options.deployment === "docker" && {
@@ -386,6 +387,7 @@ function createPackageJson(projectDir: string, options: InitOptions) {
386
387
  "build": "bun build src/server/index.ts --outdir=dist",
387
388
  "start": "bun run dist/index.js",
388
389
  "gen:types": "bunx donkeylabs generate",
390
+ "update": "bunx donkeylabs update",
389
391
  "test": "bun test",
390
392
  "lint": "bun --bun tsc --noEmit",
391
393
  ...(options.deployment === "docker" && {
@@ -167,7 +167,7 @@ export async function initCommand(args: string[]) {
167
167
  } else {
168
168
  console.log(pc.green("\n✓ Dependencies installed\n"));
169
169
 
170
- // Copy CLAUDE.md and docs/ from @donkeylabs/server to project root
170
+ // Copy agents.md and docs/ from @donkeylabs/server to project root
171
171
  await copyDocsFromServer(targetDir);
172
172
  }
173
173
 
@@ -324,7 +324,7 @@ async function copyDirectory(src: string, dest: string): Promise<void> {
324
324
  }
325
325
 
326
326
  /**
327
- * Copy CLAUDE.md and docs/ from @donkeylabs/server to project root
327
+ * Copy agents.md and docs/ from @donkeylabs/server to project root
328
328
  * for AI-assisted development
329
329
  */
330
330
  async function copyDocsFromServer(targetDir: string): Promise<void> {
@@ -334,19 +334,19 @@ async function copyDocsFromServer(targetDir: string): Promise<void> {
334
334
  return; // Server package not installed
335
335
  }
336
336
 
337
- // Copy CLAUDE.md
338
- const claudeMdSrc = join(serverPkgPath, "CLAUDE.md");
339
- if (existsSync(claudeMdSrc)) {
340
- const claudeMdDest = join(targetDir, "CLAUDE.md");
341
- await copyFile(claudeMdSrc, claudeMdDest);
342
- console.log(pc.green(" Created:"), "CLAUDE.md (AI instructions)");
337
+ // Copy agents.md
338
+ const agentsMdSrc = join(serverPkgPath, "agents.md");
339
+ if (existsSync(agentsMdSrc)) {
340
+ const agentsMdDest = join(targetDir, "agents.md");
341
+ await copyFile(agentsMdSrc, agentsMdDest);
342
+ console.log(pc.green(" Created:"), "agents.md (AI instructions)");
343
343
  }
344
344
 
345
345
  // Copy docs/ directory
346
346
  const docsSrc = join(serverPkgPath, "docs");
347
347
  if (existsSync(docsSrc)) {
348
- const docsDest = join(targetDir, "docs");
348
+ const docsDest = join(targetDir, "docs", "donkeylabs");
349
349
  await copyDirectory(docsSrc, docsDest);
350
- console.log(pc.green(" Created:"), "docs/ (detailed documentation)");
350
+ console.log(pc.green(" Created:"), "docs/donkeylabs/ (detailed documentation)");
351
351
  }
352
352
  }
@@ -0,0 +1 @@
1
+ export default {};
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "donkeylabs-starter",
3
+ "type": "module",
4
+ "dependencies": {
5
+ "@donkeylabs/server": "workspace:*"
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ import { AppServer } from "@donkeylabs/server";
2
+
3
+ const server = new AppServer({
4
+ db: undefined as any,
5
+ });
6
+
7
+ server.start().catch((err) => {
8
+ console.error("Failed to start server", err);
9
+ });
@@ -0,0 +1,35 @@
1
+ import type { ServerContext } from "@donkeylabs/server";
2
+
3
+ type AppContext = ServerContext;
4
+
5
+ interface Handler<TInput = any, TOutput = any> {
6
+ handle(input: TInput): TOutput | Promise<TOutput>;
7
+ }
8
+
9
+ type PingInput = {
10
+ name: string;
11
+ cool: number;
12
+ echo?: string;
13
+ };
14
+
15
+ type PingOutput = {
16
+ status: "ok";
17
+ timestamp: string;
18
+ echo?: string;
19
+ };
20
+
21
+ export class PingHandler implements Handler {
22
+ ctx: AppContext;
23
+
24
+ constructor(ctx: AppContext) {
25
+ this.ctx = ctx;
26
+ }
27
+
28
+ async handle(input: PingInput): Promise<PingOutput> {
29
+ return {
30
+ status: "ok",
31
+ timestamp: new Date().toISOString(),
32
+ echo: input.echo,
33
+ };
34
+ }
35
+ }
@@ -0,0 +1,19 @@
1
+ import type { ServerContext } from "@donkeylabs/server";
2
+
3
+ type AppContext = ServerContext;
4
+
5
+ interface Handler<TInput = any, TOutput = any> {
6
+ handle(input: TInput): TOutput | Promise<TOutput>;
7
+ }
8
+
9
+ export class CounterDecrementHandler implements Handler {
10
+ ctx: AppContext;
11
+
12
+ constructor(ctx: AppContext) {
13
+ this.ctx = ctx;
14
+ }
15
+
16
+ async handle(): Promise<{ count: number }> {
17
+ return { count: -1 };
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ import type { ServerContext } from "@donkeylabs/server";
2
+
3
+ type AppContext = ServerContext;
4
+
5
+ interface Handler<TInput = any, TOutput = any> {
6
+ handle(input: TInput): TOutput | Promise<TOutput>;
7
+ }
8
+
9
+ export class CounterGetHandler implements Handler {
10
+ ctx: AppContext;
11
+
12
+ constructor(ctx: AppContext) {
13
+ this.ctx = ctx;
14
+ }
15
+
16
+ async handle(): Promise<{ count: number }> {
17
+ return { count: 0 };
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ import type { ServerContext } from "@donkeylabs/server";
2
+
3
+ type AppContext = ServerContext;
4
+
5
+ interface Handler<TInput = any, TOutput = any> {
6
+ handle(input: TInput): TOutput | Promise<TOutput>;
7
+ }
8
+
9
+ export class CounterIncrementHandler implements Handler {
10
+ ctx: AppContext;
11
+
12
+ constructor(ctx: AppContext) {
13
+ this.ctx = ctx;
14
+ }
15
+
16
+ async handle(): Promise<{ count: number }> {
17
+ return { count: 1 };
18
+ }
19
+ }
@@ -0,0 +1,11 @@
1
+ import { createRouter } from "@donkeylabs/server";
2
+ import { CounterGetHandler } from "./handlers/get";
3
+ import { CounterIncrementHandler } from "./handlers/increment";
4
+ import { CounterDecrementHandler } from "./handlers/decrement";
5
+
6
+ export const counterRouter = createRouter("counter")
7
+ .route("counter.get").typed({ handle: CounterGetHandler })
8
+ .route("counter.increment").typed({ handle: CounterIncrementHandler })
9
+ .route("counter.decrement").typed({ handle: CounterDecrementHandler });
10
+
11
+ export default counterRouter;