trelly 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +191 -0
  2. package/bin/run-ts +31 -0
  3. package/bin/trelly +2 -0
  4. package/bin/trelly-mcp +2 -0
  5. package/package.json +64 -0
  6. package/src/api/client.ts +332 -0
  7. package/src/api/http.ts +86 -0
  8. package/src/auth/browser-flow.ts +217 -0
  9. package/src/auth/profiles.ts +163 -0
  10. package/src/cli/commands/actions.ts +17 -0
  11. package/src/cli/commands/api.ts +46 -0
  12. package/src/cli/commands/auth.ts +248 -0
  13. package/src/cli/commands/boards.ts +152 -0
  14. package/src/cli/commands/cards.ts +194 -0
  15. package/src/cli/commands/checklists.ts +79 -0
  16. package/src/cli/commands/custom-fields.ts +75 -0
  17. package/src/cli/commands/labels.ts +47 -0
  18. package/src/cli/commands/lists.ts +54 -0
  19. package/src/cli/commands/members.ts +14 -0
  20. package/src/cli/commands/orgs.ts +23 -0
  21. package/src/cli/commands/run.ts +32 -0
  22. package/src/cli/commands/search.ts +23 -0
  23. package/src/cli/commands/ui.ts +48 -0
  24. package/src/cli/commands/webhooks.ts +44 -0
  25. package/src/cli/context.ts +70 -0
  26. package/src/cli/index.ts +47 -0
  27. package/src/cli/ui/app.tsx +753 -0
  28. package/src/cli/ui/custom-fields.ts +75 -0
  29. package/src/cli/ui/palette.ts +69 -0
  30. package/src/cli/ui/shapes.ts +68 -0
  31. package/src/cli/ui/static.tsx +382 -0
  32. package/src/index.test.ts +117 -0
  33. package/src/mcp/handlers.ts +61 -0
  34. package/src/mcp/server.ts +17 -0
  35. package/src/mcp/tools/api.ts +27 -0
  36. package/src/mcp/tools/boards.ts +116 -0
  37. package/src/mcp/tools/cards.ts +138 -0
  38. package/src/mcp/tools/checklists.ts +40 -0
  39. package/src/mcp/tools/index.ts +22 -0
  40. package/src/mcp/tools/labels.ts +40 -0
  41. package/src/mcp/tools/lists.ts +37 -0
  42. package/src/mcp/tools/profiles.ts +40 -0
  43. package/src/mcp/tools/search.ts +31 -0
  44. package/src/mcp/tools/webhooks.ts +52 -0
  45. package/src/util/runtime.ts +39 -0
  46. package/src/version.ts +15 -0
@@ -0,0 +1,52 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { z } from "zod";
3
+ import { profileField, toolEnvelopeSchema, withClient } from "../handlers.ts";
4
+
5
+ export function registerWebhookTools(server: McpServer): void {
6
+ const outputSchema = toolEnvelopeSchema;
7
+
8
+ server.registerTool(
9
+ "trello_webhooks_list",
10
+ {
11
+ description: "List webhooks registered for the current token.",
12
+ inputSchema: { profile: profileField },
13
+ annotations: { readOnlyHint: true },
14
+ outputSchema,
15
+ },
16
+ async ({ profile }) => withClient(profile, (client) => client.webhooksForToken()),
17
+ );
18
+
19
+ server.registerTool(
20
+ "trello_webhook_create",
21
+ {
22
+ description: "Create a webhook on a board or card model.",
23
+ inputSchema: {
24
+ profile: profileField,
25
+ callbackUrl: z.string().url(),
26
+ modelId: z.string().min(1),
27
+ description: z.string().optional(),
28
+ },
29
+ outputSchema,
30
+ },
31
+ async ({ profile, callbackUrl, modelId, description }) =>
32
+ withClient(profile, (client) =>
33
+ client.webhookCreate({
34
+ callbackURL: callbackUrl,
35
+ idModel: modelId,
36
+ description,
37
+ }),
38
+ ),
39
+ );
40
+
41
+ server.registerTool(
42
+ "trello_webhook_delete",
43
+ {
44
+ description: "Delete a webhook by id.",
45
+ inputSchema: { profile: profileField, webhookId: z.string().min(1) },
46
+ annotations: { destructiveHint: true },
47
+ outputSchema,
48
+ },
49
+ async ({ profile, webhookId }) =>
50
+ withClient(profile, (client) => client.webhookDelete(webhookId)),
51
+ );
52
+ }
@@ -0,0 +1,39 @@
1
+ import { spawn } from "node:child_process";
2
+ import { createInterface } from "node:readline";
3
+
4
+ export async function readLine(): Promise<string> {
5
+ if (!process.stdin.isTTY) {
6
+ const chunks: Buffer[] = [];
7
+ for await (const chunk of process.stdin) {
8
+ chunks.push(Buffer.from(chunk));
9
+ }
10
+ return Buffer.concat(chunks).toString("utf8").trim();
11
+ }
12
+
13
+ const rl = createInterface({ input: process.stdin, output: process.stderr });
14
+ return new Promise((resolve) => {
15
+ rl.once("line", (line) => {
16
+ rl.close();
17
+ resolve(line.trim());
18
+ });
19
+ });
20
+ }
21
+
22
+ export async function openInBrowser(url: string): Promise<void> {
23
+ const platform = process.platform;
24
+ const cmd =
25
+ platform === "darwin"
26
+ ? ["open", url]
27
+ : platform === "win32"
28
+ ? ["cmd", "/c", "start", "", url]
29
+ : ["xdg-open", url];
30
+
31
+ await new Promise<void>((resolve, reject) => {
32
+ const child = spawn(cmd[0]!, cmd.slice(1), { stdio: "ignore" });
33
+ child.on("error", reject);
34
+ child.on("close", (code) => {
35
+ if (code === 0) resolve();
36
+ else reject(new Error(`open browser exited with code ${code}`));
37
+ });
38
+ });
39
+ }
package/src/version.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ let cachedVersion: string | undefined;
6
+
7
+ export function packageVersion(): string {
8
+ if (cachedVersion) return cachedVersion;
9
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
10
+ const pkg = JSON.parse(readFileSync(join(root, "package.json"), "utf8")) as {
11
+ version: string;
12
+ };
13
+ cachedVersion = pkg.version;
14
+ return cachedVersion;
15
+ }