@delega-dev/cli 1.0.5 → 1.0.6

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/src/config.ts DELETED
@@ -1,72 +0,0 @@
1
- import node_fs from "node:fs";
2
- import node_path from "node:path";
3
- import node_os from "node:os";
4
-
5
- export interface DelegaConfig {
6
- api_key?: string;
7
- api_url?: string;
8
- }
9
-
10
- const LOCAL_API_HOSTS = new Set(["localhost", "127.0.0.1"]);
11
-
12
- function getConfigDir(): string {
13
- return node_path.join(node_os.homedir(), ".delega");
14
- }
15
-
16
- function getConfigPath(): string {
17
- return node_path.join(getConfigDir(), "config.json");
18
- }
19
-
20
- export function loadConfig(): DelegaConfig {
21
- const configPath = getConfigPath();
22
- if (!node_fs.existsSync(configPath)) {
23
- return {};
24
- }
25
- try {
26
- const raw = node_fs.readFileSync(configPath, "utf-8");
27
- return JSON.parse(raw) as DelegaConfig;
28
- } catch {
29
- return {};
30
- }
31
- }
32
-
33
- export function saveConfig(config: DelegaConfig): void {
34
- const configDir = getConfigDir();
35
- if (!node_fs.existsSync(configDir)) {
36
- node_fs.mkdirSync(configDir, { recursive: true, mode: 0o700 });
37
- }
38
- node_fs.chmodSync(configDir, 0o700);
39
- node_fs.writeFileSync(
40
- getConfigPath(),
41
- JSON.stringify(config, null, 2) + "\n",
42
- { encoding: "utf-8", mode: 0o600 },
43
- );
44
- node_fs.chmodSync(getConfigPath(), 0o600);
45
- }
46
-
47
- export function normalizeApiUrl(rawUrl: string): string {
48
- let parsed: URL;
49
- try {
50
- parsed = new URL(rawUrl);
51
- } catch {
52
- throw new Error("Invalid Delega API URL");
53
- }
54
-
55
- if (parsed.protocol !== "https:" && !LOCAL_API_HOSTS.has(parsed.hostname)) {
56
- throw new Error("Delega API URL must use HTTPS unless it points to localhost");
57
- }
58
-
59
- return rawUrl.replace(/\/+$/, "");
60
- }
61
-
62
- export function getApiKey(): string | undefined {
63
- return process.env.DELEGA_API_KEY || loadConfig().api_key;
64
- }
65
-
66
- export function getApiUrl(): string {
67
- return normalizeApiUrl(
68
- process.env.DELEGA_API_URL ||
69
- loadConfig().api_url ||
70
- "https://api.delega.dev"
71
- );
72
- }
package/src/index.ts DELETED
@@ -1,41 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { Command } from "commander";
4
- import { loginCommand } from "./commands/login.js";
5
- import { whoamiCommand } from "./commands/whoami.js";
6
- import { tasksCommand } from "./commands/tasks.js";
7
- import { agentsCommand } from "./commands/agents.js";
8
- import { statsCommand } from "./commands/stats.js";
9
- import { printBanner } from "./ui.js";
10
-
11
- const program = new Command();
12
-
13
- program
14
- .name("delega")
15
- .description("CLI for Delega task API")
16
- .version("1.0.0")
17
- .option("--api-url <url>", "Override API URL")
18
- .hook("preAction", (thisCommand) => {
19
- const apiUrl = thisCommand.opts().apiUrl as string | undefined;
20
- if (apiUrl) {
21
- process.env.DELEGA_API_URL = apiUrl;
22
- }
23
- });
24
-
25
- program.addCommand(loginCommand);
26
- program.addCommand(whoamiCommand);
27
- program.addCommand(tasksCommand);
28
- program.addCommand(agentsCommand);
29
- program.addCommand(statsCommand);
30
-
31
- program.on("command:*", () => {
32
- printBanner();
33
- program.help();
34
- });
35
-
36
- if (process.argv.length <= 2) {
37
- printBanner();
38
- program.help();
39
- }
40
-
41
- program.parse();
package/src/ui.ts DELETED
@@ -1,92 +0,0 @@
1
- import chalk from "chalk";
2
-
3
- const BANNER = `
4
- ____ __
5
- / __ \\___ / /__ ____ _____ _
6
- / / / / _ \\/ / _ \\/ __ \`/ __ \`/
7
- / /_/ / __/ / __/ /_/ / /_/ /
8
- /_____/\\___/_/\\___/\\__, /\\__,_/
9
- /____/
10
- Task infrastructure for AI agents
11
- `;
12
-
13
- export function printBanner(): void {
14
- console.log(chalk.cyan(BANNER));
15
- }
16
-
17
- export function printTable(headers: string[], rows: string[][]): void {
18
- if (rows.length === 0) return;
19
-
20
- const colWidths = headers.map((h, i) => {
21
- const maxRow = rows.reduce(
22
- (max, row) => Math.max(max, (row[i] || "").length),
23
- 0,
24
- );
25
- return Math.max(h.length, maxRow);
26
- });
27
-
28
- const headerLine = headers
29
- .map((h, i) => h.padEnd(colWidths[i]))
30
- .join(" ");
31
- console.log(chalk.cyan.bold(headerLine));
32
-
33
- const separator = colWidths.map((w) => "─".repeat(w)).join("──");
34
- console.log(chalk.dim(separator));
35
-
36
- for (const row of rows) {
37
- const line = row
38
- .map((cell, i) => (cell || "").padEnd(colWidths[i]))
39
- .join(" ");
40
- console.log(line);
41
- }
42
- }
43
-
44
- export function formatDate(iso: string): string {
45
- if (!iso) return "—";
46
- const d = new Date(iso);
47
- return d.toLocaleDateString("en-US", {
48
- month: "short",
49
- day: "numeric",
50
- year: "numeric",
51
- });
52
- }
53
-
54
- export function formatId(id: string): string {
55
- return id.slice(0, 8);
56
- }
57
-
58
- export function priorityBadge(n: number): string {
59
- switch (n) {
60
- case 1:
61
- return chalk.red.bold("P1");
62
- case 2:
63
- return chalk.yellow.bold("P2");
64
- case 3:
65
- return chalk.green("P3");
66
- case 4:
67
- return chalk.dim("P4");
68
- default:
69
- return chalk.dim(`P${n}`);
70
- }
71
- }
72
-
73
- export function statusBadge(s: string): string {
74
- switch (s?.toLowerCase()) {
75
- case "completed":
76
- return chalk.green("completed");
77
- case "in_progress":
78
- case "in progress":
79
- return chalk.yellow("in_progress");
80
- case "pending":
81
- return chalk.blue("pending");
82
- case "cancelled":
83
- case "canceled":
84
- return chalk.dim("cancelled");
85
- default:
86
- return s || "—";
87
- }
88
- }
89
-
90
- export function label(key: string, value: string): void {
91
- console.log(`${chalk.cyan.bold(key + ":")} ${value}`);
92
- }
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "outDir": "dist",
7
- "rootDir": "src",
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "declaration": true,
11
- "skipLibCheck": true
12
- },
13
- "include": ["src"]
14
- }