@delega-dev/cli 1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Delega Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ ```
2
+ ____ __
3
+ / __ \___ / /__ ____ _____ _
4
+ / / / / _ \/ / _ \/ __ `/ __ `/
5
+ / /_/ / __/ / __/ /_/ / /_/ /
6
+ /_____/\___/_/\___/\__, /\__,_/
7
+ /____/
8
+ Task infrastructure for AI agents
9
+ ```
10
+
11
+ # delega-cli
12
+
13
+ CLI for the Delega task API. Manage tasks, agents, and delegations from your terminal.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install -g delega-cli
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```bash
24
+ # Authenticate with your API key
25
+ delega login
26
+
27
+ # Create a task
28
+ delega tasks create "Review pull request #42" --priority 1
29
+
30
+ # List your tasks
31
+ delega tasks list
32
+
33
+ # Complete a task
34
+ delega tasks complete <task-id>
35
+ ```
36
+
37
+ ## Commands
38
+
39
+ ### Authentication
40
+
41
+ ```bash
42
+ delega login # Authenticate with your API key
43
+ delega whoami # Show current authenticated agent
44
+ ```
45
+
46
+ ### Tasks
47
+
48
+ ```bash
49
+ delega tasks list # List tasks
50
+ delega tasks list --completed # Include completed tasks
51
+ delega tasks list --limit 10 # Limit results
52
+ delega tasks create "content" # Create a task
53
+ delega tasks create "content" --priority 1 # Create with priority (1-4)
54
+ delega tasks create "content" --labels "bug,urgent"
55
+ delega tasks create "content" --due "2026-03-15"
56
+ delega tasks show <id> # Show task details
57
+ delega tasks complete <id> # Mark task as completed
58
+ delega tasks delete <id> # Delete a task
59
+ delega tasks delegate <task-id> <agent-id> # Delegate to another agent
60
+ delega tasks delegate <task-id> <agent-id> --content "subtask description"
61
+ ```
62
+
63
+ ### Agents
64
+
65
+ ```bash
66
+ delega agents list # List agents
67
+ delega agents create <name> # Create an agent
68
+ delega agents create <name> --display-name "Friendly Name"
69
+ delega agents rotate <id> # Rotate an agent's API key
70
+ ```
71
+
72
+ ### Stats
73
+
74
+ ```bash
75
+ delega stats # Show usage statistics
76
+ ```
77
+
78
+ ## Global Options
79
+
80
+ ```bash
81
+ --json # Output raw JSON for any command
82
+ --api-url <url> # Override API URL (for self-hosted instances)
83
+ --version # Show version
84
+ --help # Show help
85
+ ```
86
+
87
+ ## Configuration
88
+
89
+ Config is stored in `~/.delega/config.json`:
90
+
91
+ ```json
92
+ {
93
+ "api_key": "dlg_...",
94
+ "api_url": "https://api.delega.dev"
95
+ }
96
+ ```
97
+
98
+ ## Environment Variables
99
+
100
+ | Variable | Description |
101
+ |---|---|
102
+ | `DELEGA_API_KEY` | API key (overrides config file) |
103
+ | `DELEGA_API_URL` | API base URL (overrides config file) |
104
+
105
+ Environment variables take precedence over the config file.
106
+
107
+ ## License
108
+
109
+ MIT
package/dist/api.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export interface ApiError {
2
+ error?: string;
3
+ message?: string;
4
+ }
5
+ export declare function apiCall<T = unknown>(method: string, path: string, body?: unknown): Promise<T>;
package/dist/api.js ADDED
@@ -0,0 +1,45 @@
1
+ import { getApiKey, getApiUrl } from "./config.js";
2
+ export async function apiCall(method, path, body) {
3
+ const apiKey = getApiKey();
4
+ if (!apiKey) {
5
+ console.error("Not authenticated. Run: delega login");
6
+ process.exit(1);
7
+ }
8
+ const url = getApiUrl() + path;
9
+ const headers = {
10
+ "X-Agent-Key": apiKey,
11
+ "Content-Type": "application/json",
12
+ };
13
+ const options = { method, headers };
14
+ if (body !== undefined) {
15
+ options.body = JSON.stringify(body);
16
+ }
17
+ let res;
18
+ try {
19
+ res = await fetch(url, options);
20
+ }
21
+ catch (err) {
22
+ const msg = err instanceof Error ? err.message : String(err);
23
+ console.error(`Connection error: ${msg}`);
24
+ process.exit(1);
25
+ }
26
+ if (res.status === 401) {
27
+ console.error("Authentication failed. Run: delega login");
28
+ process.exit(1);
29
+ }
30
+ let data;
31
+ const text = await res.text();
32
+ try {
33
+ data = text ? JSON.parse(text) : {};
34
+ }
35
+ catch {
36
+ data = { message: text };
37
+ }
38
+ if (!res.ok) {
39
+ const errData = data;
40
+ const msg = errData.error || errData.message || `Request failed (${res.status})`;
41
+ console.error(`Error: ${msg}`);
42
+ process.exit(1);
43
+ }
44
+ return data;
45
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const agentsCommand: Command;
@@ -0,0 +1,86 @@
1
+ import { Command } from "commander";
2
+ import node_readline from "node:readline";
3
+ import chalk from "chalk";
4
+ import { apiCall } from "../api.js";
5
+ import { printTable, formatDate, label } from "../ui.js";
6
+ function confirm(question) {
7
+ const rl = node_readline.createInterface({
8
+ input: process.stdin,
9
+ output: process.stdout,
10
+ });
11
+ return new Promise((resolve) => {
12
+ rl.question(question, (answer) => {
13
+ rl.close();
14
+ resolve(answer.trim().toLowerCase() === "y");
15
+ });
16
+ });
17
+ }
18
+ const agentsList = new Command("list")
19
+ .description("List agents")
20
+ .option("--json", "Output raw JSON")
21
+ .action(async (opts) => {
22
+ const data = await apiCall("GET", "/v1/agents");
23
+ if (opts.json) {
24
+ console.log(JSON.stringify(data, null, 2));
25
+ return;
26
+ }
27
+ const agents = Array.isArray(data) ? data : [data];
28
+ if (agents.length === 0) {
29
+ console.log("No agents found.");
30
+ return;
31
+ }
32
+ const headers = ["Name", "Display Name", "Active", "Created"];
33
+ const rows = agents.map((a) => [
34
+ a.name,
35
+ a.display_name || "—",
36
+ a.active !== false ? "yes" : "no",
37
+ formatDate(a.created_at || ""),
38
+ ]);
39
+ printTable(headers, rows);
40
+ });
41
+ const agentsCreate = new Command("create")
42
+ .description("Create a new agent")
43
+ .argument("<name>", "Agent name")
44
+ .option("--display-name <name>", "Friendly display name")
45
+ .option("--json", "Output raw JSON")
46
+ .action(async (name, opts) => {
47
+ const body = { name };
48
+ if (opts.displayName)
49
+ body.display_name = opts.displayName;
50
+ const agent = await apiCall("POST", "/v1/agents", body);
51
+ if (opts.json) {
52
+ console.log(JSON.stringify(agent, null, 2));
53
+ return;
54
+ }
55
+ console.log();
56
+ label("Agent Created", agent.name);
57
+ if (agent.display_name)
58
+ label("Display Name", agent.display_name);
59
+ label("ID", agent.id);
60
+ if (agent.api_key) {
61
+ console.log();
62
+ console.log(` API Key: ${chalk.cyan.bold(agent.api_key)}`);
63
+ console.log(chalk.yellow(" Save this key — it will not be shown again."));
64
+ }
65
+ console.log();
66
+ });
67
+ const agentsRotate = new Command("rotate")
68
+ .description("Rotate an agent's API key")
69
+ .argument("<id>", "Agent ID")
70
+ .action(async (id) => {
71
+ const yes = await confirm(`Rotate key for agent ${id}? Old key will stop working immediately. (y/N) `);
72
+ if (!yes) {
73
+ console.log("Cancelled.");
74
+ return;
75
+ }
76
+ const result = await apiCall("POST", `/v1/agents/${id}/rotate-key`);
77
+ console.log();
78
+ console.log(` New API Key: ${chalk.cyan.bold(result.api_key)}`);
79
+ console.log(chalk.yellow(" Save this key — it will not be shown again."));
80
+ console.log();
81
+ });
82
+ export const agentsCommand = new Command("agents")
83
+ .description("Manage agents")
84
+ .addCommand(agentsList)
85
+ .addCommand(agentsCreate)
86
+ .addCommand(agentsRotate);
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const loginCommand: Command;
@@ -0,0 +1,66 @@
1
+ import { Command } from "commander";
2
+ import node_readline from "node:readline";
3
+ import { saveConfig, loadConfig } from "../config.js";
4
+ import { printBanner } from "../ui.js";
5
+ async function prompt(question) {
6
+ const rl = node_readline.createInterface({
7
+ input: process.stdin,
8
+ output: process.stdout,
9
+ });
10
+ return new Promise((resolve) => {
11
+ rl.question(question, (answer) => {
12
+ rl.close();
13
+ resolve(answer.trim());
14
+ });
15
+ });
16
+ }
17
+ export const loginCommand = new Command("login")
18
+ .description("Authenticate with the Delega API")
19
+ .action(async () => {
20
+ printBanner();
21
+ const key = await prompt("Enter your API key (starts with dlg_): ");
22
+ if (!key) {
23
+ console.error("No key provided.");
24
+ process.exit(1);
25
+ }
26
+ if (!key.startsWith("dlg_")) {
27
+ console.error("Invalid key format. Keys start with dlg_");
28
+ process.exit(1);
29
+ }
30
+ // Validate by calling the API
31
+ const config = loadConfig();
32
+ const apiUrl = config.api_url || process.env.DELEGA_API_URL || "https://api.delega.dev";
33
+ let res;
34
+ try {
35
+ res = await fetch(`${apiUrl}/v1/agents`, {
36
+ headers: {
37
+ "X-Agent-Key": key,
38
+ "Content-Type": "application/json",
39
+ },
40
+ });
41
+ }
42
+ catch (err) {
43
+ const msg = err instanceof Error ? err.message : String(err);
44
+ console.error(`Connection error: ${msg}`);
45
+ process.exit(1);
46
+ }
47
+ if (!res.ok) {
48
+ console.error("Invalid API key. Authentication failed.");
49
+ process.exit(1);
50
+ }
51
+ let agentName = "agent";
52
+ try {
53
+ const data = (await res.json());
54
+ if (Array.isArray(data) && data.length > 0) {
55
+ agentName = data[0].display_name || data[0].name;
56
+ }
57
+ else if (!Array.isArray(data) && data.name) {
58
+ agentName = data.display_name || data.name;
59
+ }
60
+ }
61
+ catch {
62
+ // Proceed with default name
63
+ }
64
+ saveConfig({ ...config, api_key: key });
65
+ console.log(`\nLogged in as ${agentName}. Key saved to ~/.delega/config.json`);
66
+ });
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const statsCommand: Command;
@@ -0,0 +1,40 @@
1
+ import { Command } from "commander";
2
+ import { apiCall } from "../api.js";
3
+ import { label } from "../ui.js";
4
+ export const statsCommand = new Command("stats")
5
+ .description("Show usage statistics")
6
+ .option("--json", "Output raw JSON")
7
+ .action(async (opts) => {
8
+ const data = await apiCall("GET", "/v1/stats");
9
+ if (opts.json) {
10
+ console.log(JSON.stringify(data, null, 2));
11
+ return;
12
+ }
13
+ console.log();
14
+ if (data.total_tasks !== undefined)
15
+ label("Total Tasks", String(data.total_tasks));
16
+ if (data.completed_tasks !== undefined)
17
+ label("Completed", String(data.completed_tasks));
18
+ if (data.pending_tasks !== undefined)
19
+ label("Pending", String(data.pending_tasks));
20
+ if (data.total_agents !== undefined)
21
+ label("Total Agents", String(data.total_agents));
22
+ if (data.active_agents !== undefined)
23
+ label("Active Agents", String(data.active_agents));
24
+ // Print any additional stats fields
25
+ const knownKeys = new Set([
26
+ "total_tasks",
27
+ "completed_tasks",
28
+ "pending_tasks",
29
+ "total_agents",
30
+ "active_agents",
31
+ ]);
32
+ for (const [key, value] of Object.entries(data)) {
33
+ if (!knownKeys.has(key) && value !== undefined) {
34
+ const displayKey = key.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
35
+ const displayVal = typeof value === "object" ? JSON.stringify(value) : String(value);
36
+ label(displayKey, displayVal);
37
+ }
38
+ }
39
+ console.log();
40
+ });
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const tasksCommand: Command;
@@ -0,0 +1,153 @@
1
+ import { Command } from "commander";
2
+ import node_readline from "node:readline";
3
+ import { apiCall } from "../api.js";
4
+ import { printTable, formatDate, formatId, priorityBadge, statusBadge, label, } from "../ui.js";
5
+ function confirm(question) {
6
+ const rl = node_readline.createInterface({
7
+ input: process.stdin,
8
+ output: process.stdout,
9
+ });
10
+ return new Promise((resolve) => {
11
+ rl.question(question, (answer) => {
12
+ rl.close();
13
+ resolve(answer.trim().toLowerCase() === "y");
14
+ });
15
+ });
16
+ }
17
+ const tasksList = new Command("list")
18
+ .description("List tasks")
19
+ .option("--completed", "Include completed tasks")
20
+ .option("--limit <n>", "Limit results", parseInt)
21
+ .option("--json", "Output raw JSON")
22
+ .action(async (opts) => {
23
+ let path = "/v1/tasks";
24
+ const params = [];
25
+ if (opts.completed)
26
+ params.push("completed=true");
27
+ if (opts.limit)
28
+ params.push(`limit=${opts.limit}`);
29
+ if (params.length > 0)
30
+ path += "?" + params.join("&");
31
+ const data = await apiCall("GET", path);
32
+ if (opts.json) {
33
+ console.log(JSON.stringify(data, null, 2));
34
+ return;
35
+ }
36
+ const tasks = Array.isArray(data) ? data : [];
37
+ if (tasks.length === 0) {
38
+ console.log("No tasks found.");
39
+ return;
40
+ }
41
+ const headers = ["ID", "Priority", "Status", "Content"];
42
+ const rows = tasks.map((t) => [
43
+ formatId(t.id),
44
+ priorityBadge(t.priority),
45
+ statusBadge(t.status),
46
+ t.content.length > 50 ? t.content.slice(0, 47) + "..." : t.content,
47
+ ]);
48
+ printTable(headers, rows);
49
+ });
50
+ const tasksCreate = new Command("create")
51
+ .description("Create a new task")
52
+ .argument("<content>", "Task content")
53
+ .option("--priority <n>", "Priority 1-4 (default: 1)", parseInt, 1)
54
+ .option("--labels <labels>", "Comma-separated labels")
55
+ .option("--due <date>", "Due date (YYYY-MM-DD)")
56
+ .option("--json", "Output raw JSON")
57
+ .action(async (content, opts) => {
58
+ const body = { content };
59
+ if (opts.priority)
60
+ body.priority = opts.priority;
61
+ if (opts.labels)
62
+ body.labels = opts.labels.split(",").map((l) => l.trim());
63
+ if (opts.due)
64
+ body.due_date = opts.due;
65
+ const task = await apiCall("POST", "/v1/tasks", body);
66
+ if (opts.json) {
67
+ console.log(JSON.stringify(task, null, 2));
68
+ return;
69
+ }
70
+ console.log(`Task created: ${task.id}`);
71
+ console.log();
72
+ label("Content", task.content);
73
+ label("Priority", priorityBadge(task.priority));
74
+ label("Status", statusBadge(task.status));
75
+ if (task.due_date)
76
+ label("Due", formatDate(task.due_date));
77
+ });
78
+ const tasksShow = new Command("show")
79
+ .description("Show task details")
80
+ .argument("<id>", "Task ID")
81
+ .option("--json", "Output raw JSON")
82
+ .action(async (id, opts) => {
83
+ const task = await apiCall("GET", `/v1/tasks/${id}`);
84
+ if (opts.json) {
85
+ console.log(JSON.stringify(task, null, 2));
86
+ return;
87
+ }
88
+ console.log();
89
+ label("ID", task.id);
90
+ label("Content", task.content);
91
+ label("Status", statusBadge(task.status));
92
+ label("Priority", priorityBadge(task.priority));
93
+ const labels = typeof task.labels === "string" ? JSON.parse(task.labels) : task.labels;
94
+ if (labels && labels.length > 0) {
95
+ label("Labels", labels.join(", "));
96
+ }
97
+ if (task.due_date)
98
+ label("Due", formatDate(task.due_date));
99
+ if (task.assigned_to_agent_id)
100
+ label("Assigned To", task.assigned_to_agent_id);
101
+ label("Created", formatDate(task.created_at || ""));
102
+ if (task.updated_at)
103
+ label("Updated", formatDate(task.updated_at));
104
+ if (task.completed_at)
105
+ label("Completed", formatDate(task.completed_at));
106
+ if (task.comments && task.comments.length > 0) {
107
+ console.log();
108
+ console.log("Comments:");
109
+ for (const c of task.comments) {
110
+ console.log(` [${formatDate(c.created_at || "")}] ${c.content}`);
111
+ }
112
+ }
113
+ console.log();
114
+ });
115
+ const tasksComplete = new Command("complete")
116
+ .description("Mark a task as completed")
117
+ .argument("<id>", "Task ID")
118
+ .action(async (id) => {
119
+ await apiCall("POST", `/v1/tasks/${id}/complete`);
120
+ console.log(`Task ${id} completed.`);
121
+ });
122
+ const tasksDelete = new Command("delete")
123
+ .description("Delete a task")
124
+ .argument("<id>", "Task ID")
125
+ .action(async (id) => {
126
+ const yes = await confirm(`Delete task ${id}? (y/N) `);
127
+ if (!yes) {
128
+ console.log("Cancelled.");
129
+ return;
130
+ }
131
+ await apiCall("DELETE", `/v1/tasks/${id}`);
132
+ console.log(`Task ${id} deleted.`);
133
+ });
134
+ const tasksDelegate = new Command("delegate")
135
+ .description("Delegate a task to another agent")
136
+ .argument("<task_id>", "Task ID")
137
+ .argument("<agent_id>", "Agent ID to delegate to")
138
+ .requiredOption("--content <content>", "Subtask description (required)")
139
+ .action(async (taskId, agentId, opts) => {
140
+ const body = { assigned_to_agent_id: agentId };
141
+ if (opts.content)
142
+ body.content = opts.content;
143
+ await apiCall("POST", `/v1/tasks/${taskId}/delegate`, body);
144
+ console.log(`Task delegated to ${agentId}.`);
145
+ });
146
+ export const tasksCommand = new Command("tasks")
147
+ .description("Manage tasks")
148
+ .addCommand(tasksList)
149
+ .addCommand(tasksCreate)
150
+ .addCommand(tasksShow)
151
+ .addCommand(tasksComplete)
152
+ .addCommand(tasksDelete)
153
+ .addCommand(tasksDelegate);
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const whoamiCommand: Command;
@@ -0,0 +1,32 @@
1
+ import { Command } from "commander";
2
+ import { apiCall } from "../api.js";
3
+ import { label } from "../ui.js";
4
+ export const whoamiCommand = new Command("whoami")
5
+ .description("Show current authenticated agent")
6
+ .action(async () => {
7
+ const data = await apiCall("GET", "/v1/agents");
8
+ let agent;
9
+ if (Array.isArray(data)) {
10
+ if (data.length === 0) {
11
+ console.error("No agent found.");
12
+ process.exit(1);
13
+ }
14
+ agent = data[0];
15
+ }
16
+ else {
17
+ agent = data;
18
+ }
19
+ console.log();
20
+ label("Agent", agent.name);
21
+ if (agent.display_name) {
22
+ label("Display Name", agent.display_name);
23
+ }
24
+ if (agent.user?.email || agent.email) {
25
+ label("Email", agent.user?.email || agent.email || "");
26
+ }
27
+ if (agent.user?.plan || agent.plan) {
28
+ label("Plan", agent.user?.plan || agent.plan || "");
29
+ }
30
+ label("Active", agent.active !== false ? "yes" : "no");
31
+ console.log();
32
+ });
@@ -0,0 +1,8 @@
1
+ export interface DelegaConfig {
2
+ api_key?: string;
3
+ api_url?: string;
4
+ }
5
+ export declare function loadConfig(): DelegaConfig;
6
+ export declare function saveConfig(config: DelegaConfig): void;
7
+ export declare function getApiKey(): string | undefined;
8
+ export declare function getApiUrl(): string;
package/dist/config.js ADDED
@@ -0,0 +1,37 @@
1
+ import node_fs from "node:fs";
2
+ import node_path from "node:path";
3
+ import node_os from "node:os";
4
+ function getConfigDir() {
5
+ return node_path.join(node_os.homedir(), ".delega");
6
+ }
7
+ function getConfigPath() {
8
+ return node_path.join(getConfigDir(), "config.json");
9
+ }
10
+ export function loadConfig() {
11
+ const configPath = getConfigPath();
12
+ if (!node_fs.existsSync(configPath)) {
13
+ return {};
14
+ }
15
+ try {
16
+ const raw = node_fs.readFileSync(configPath, "utf-8");
17
+ return JSON.parse(raw);
18
+ }
19
+ catch {
20
+ return {};
21
+ }
22
+ }
23
+ export function saveConfig(config) {
24
+ const configDir = getConfigDir();
25
+ if (!node_fs.existsSync(configDir)) {
26
+ node_fs.mkdirSync(configDir, { recursive: true });
27
+ }
28
+ node_fs.writeFileSync(getConfigPath(), JSON.stringify(config, null, 2) + "\n", "utf-8");
29
+ }
30
+ export function getApiKey() {
31
+ return process.env.DELEGA_API_KEY || loadConfig().api_key;
32
+ }
33
+ export function getApiUrl() {
34
+ return (process.env.DELEGA_API_URL ||
35
+ loadConfig().api_url ||
36
+ "https://api.delega.dev");
37
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import { loginCommand } from "./commands/login.js";
4
+ import { whoamiCommand } from "./commands/whoami.js";
5
+ import { tasksCommand } from "./commands/tasks.js";
6
+ import { agentsCommand } from "./commands/agents.js";
7
+ import { statsCommand } from "./commands/stats.js";
8
+ import { printBanner } from "./ui.js";
9
+ const program = new Command();
10
+ program
11
+ .name("delega")
12
+ .description("CLI for Delega task API")
13
+ .version("1.0.0")
14
+ .option("--api-url <url>", "Override API URL")
15
+ .hook("preAction", (thisCommand) => {
16
+ const apiUrl = thisCommand.opts().apiUrl;
17
+ if (apiUrl) {
18
+ process.env.DELEGA_API_URL = apiUrl;
19
+ }
20
+ });
21
+ program.addCommand(loginCommand);
22
+ program.addCommand(whoamiCommand);
23
+ program.addCommand(tasksCommand);
24
+ program.addCommand(agentsCommand);
25
+ program.addCommand(statsCommand);
26
+ program.on("command:*", () => {
27
+ printBanner();
28
+ program.help();
29
+ });
30
+ if (process.argv.length <= 2) {
31
+ printBanner();
32
+ program.help();
33
+ }
34
+ program.parse();
package/dist/ui.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export declare function printBanner(): void;
2
+ export declare function printTable(headers: string[], rows: string[][]): void;
3
+ export declare function formatDate(iso: string): string;
4
+ export declare function formatId(id: string): string;
5
+ export declare function priorityBadge(n: number): string;
6
+ export declare function statusBadge(s: string): string;
7
+ export declare function label(key: string, value: string): void;