@diafunc/cli 0.1.2 → 0.3.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/README.md CHANGED
@@ -4,19 +4,38 @@ Command-line interface for the [Diafunc](https://diafunc.com) platform.
4
4
 
5
5
  ## Installation
6
6
 
7
+ ### Shell installer (Linux, macOS — recommended)
8
+
9
+ ```bash
10
+ curl -fsSL https://diafunc.com/cli/install.sh | sh
11
+ ```
12
+
13
+ Drops a single self-contained binary into `~/.local/bin/diafunc`. No Node.js required.
14
+
15
+ Environment variables:
16
+
17
+ - `DIAFUNC_CLI_VERSION` — pin to a specific version (e.g. `v0.3.0`). Defaults to the latest release.
18
+ - `DIAFUNC_CLI_INSTALL_DIR` — override the install directory (default `$HOME/.local/bin`).
19
+
20
+ ### npm (if you already have Node.js 20+)
21
+
7
22
  ```bash
8
23
  npm install -g @diafunc/cli
9
24
  ```
10
25
 
11
- Requires Node.js 20+.
26
+ ### Manual download
27
+
28
+ Pre-built binaries for Linux, macOS, and Windows are attached to each release:
29
+
30
+ - Latest from `diafunc.com`: `https://diafunc.com/cli/diafunc-<os>-<arch>.tar.gz` (and `diafunc-windows-x64.zip`)
31
+ - Any version: <https://gitlab.com/diafunc/cli/-/releases>
32
+
33
+ Verify the SHA-256 checksum against `SHA256SUMS` in the same release, then place the binary on your `PATH`.
12
34
 
13
35
  ## Quick Start
14
36
 
15
37
  ```bash
16
- # Authenticate with an API token
17
- diafunc auth login --token dfat_your_token_here
18
-
19
- # Or log in interactively
38
+ # Log in via the browser (OIDC device-code flow — default)
20
39
  diafunc auth login
21
40
 
22
41
  # Set a default project
@@ -28,10 +47,34 @@ diafunc project list
28
47
  # View table data
29
48
  diafunc table view my-table
30
49
 
31
- # Run an automatic analysis
50
+ # Run an automatic analysis and watch it live
32
51
  diafunc analyze data.csv --name "My Analysis" --time 2
52
+ diafunc analyze watch
53
+ ```
54
+
55
+ ## Authentication
56
+
57
+ `diafunc auth login` supports three modes:
58
+
59
+ ```bash
60
+ # OIDC device-code flow (default) — prints a URL and a short user code,
61
+ # you approve in the browser, tokens are cached locally.
62
+ # Uses auth.<your-endpoint> (e.g. auth.diafunc.com for the default endpoint).
63
+ diafunc auth login
64
+
65
+ # Non-interactive, for scripts and CI. Get a token from
66
+ # Settings → API Tokens in the web UI.
67
+ diafunc auth login --token dfat_your_token_here
68
+
69
+ # Legacy username/password, kept for environments without a browser.
70
+ diafunc auth login --password
33
71
  ```
34
72
 
73
+ `diafunc auth logout` clears the local credentials and revokes the refresh
74
+ token at the identity provider for device-code sessions.
75
+
76
+ `diafunc auth status` shows the active profile, endpoint, and user.
77
+
35
78
  ## Configuration
36
79
 
37
80
  Config is stored at `~/.diafunc/config.json` with 0600 permissions.
@@ -96,22 +139,29 @@ diafunc project create --visibility PRIVATE --dry-run
96
139
 
97
140
  | Command | Description |
98
141
  |---------|-------------|
99
- | `diafunc auth` | Login, logout, status, API token management |
142
+ | `diafunc auth` | Login (OIDC device-code, API token, or legacy password), logout, status, API token management |
143
+ | `diafunc whoami` | Show the currently authenticated user |
100
144
  | `diafunc config` | Configuration and profile management |
101
- | `diafunc project` | Project CRUD, lock/unlock, member management |
145
+ | `diafunc project` | Project CRUD, `recent`, `update`, lock/unlock, member management |
102
146
  | `diafunc entity` | Entity CRUD, content upload/download, history, revert |
147
+ | `diafunc entity-branch` | List and create parallel branches of a single entity |
103
148
  | `diafunc link` | Create and manage links between entities |
104
149
  | `diafunc event` | Create and manage events |
105
150
  | `diafunc branch` | Branch management, merge, fork |
106
151
  | `diafunc table` | View data, import CSV/Excel, export, row/column/cell operations |
107
- | `diafunc function` | Execute functions, view evaluations, outputs, logs |
108
- | `diafunc trigger` | Manage function triggers |
109
- | `diafunc schedule` | Schedule function execution |
110
- | `diafunc chat` | AI chat (blocking and streaming), session management |
152
+ | `diafunc function` | Execute functions and develop them: `call`, `create`, `source get/set`, `edit` (opens `$EDITOR`), `evaluations`, `last-evaluation`, `outputs`, `logs`, `stop`, `engines` |
153
+ | `diafunc shell` | Interactive REPL for evaluating function code (multi-line editor, language switching) |
154
+ | `diafunc trigger` | Create, list, inspect, and delete function triggers |
155
+ | `diafunc schedule` | Schedule function execution and list/stop scheduled runs |
156
+ | `diafunc chat` | AI chat REPL (default), plus `send` / `stream` / `upload`, `usage`, and `session list/show/rename/delete` |
111
157
  | `diafunc search` | Search entities across projects |
112
- | `diafunc group` | Group management, members, projects |
113
- | `diafunc admin` | User management, subscription, settings, backups |
114
- | `diafunc analyze` | Automatic analysis wizard |
158
+ | `diafunc group` | Group management: list/get/create/update/delete, members, projects |
159
+ | `diafunc analyze` | Automatic analysis wizard, plus `list`, `get`, `watch` (live progress), `open` (browser) |
160
+ | `diafunc subscription` | View your current and upcoming subscription, plus available plans |
161
+ | `diafunc invoice` | List and download invoices |
162
+ | `diafunc utilization` | Show current credit utilization and historical usage |
163
+ | `diafunc status` | Platform health: summary, per-component status, incidents |
164
+ | `diafunc admin` | User management, subscription, settings, backups, index rebuild, permission inspection |
115
165
  | `diafunc completion` | Generate shell completions |
116
166
 
117
167
  Run `diafunc <command> --help` for detailed usage of any command.
@@ -1,9 +1,114 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- createProgram
4
- } from "../chunk-63FZ6EJP.js";
3
+ createProgram,
4
+ package_default
5
+ } from "../chunk-PEFGWCVH.js";
6
+
7
+ // src/splash.ts
8
+ import chalk from "chalk";
9
+ var MASK = [
10
+ row(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 "),
11
+ // 0 flat top
12
+ row(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 "),
13
+ // 1
14
+ row(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 "),
15
+ // 2
16
+ row("\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588"),
17
+ // 3 shoulder (max width)
18
+ row("\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588"),
19
+ // 4 shoulder
20
+ row(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 "),
21
+ // 5
22
+ row(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 "),
23
+ // 6
24
+ row(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 "),
25
+ // 7
26
+ row(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 "),
27
+ // 8
28
+ row(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 "),
29
+ // 9
30
+ row(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 "),
31
+ // 10
32
+ row(" \u2588\u2588\u2588\u2588\u2588\u2588 "),
33
+ // 11
34
+ row(" \u2588\u2588\u2588\u2588 "),
35
+ // 12
36
+ row(" \u2588\u2588 ")
37
+ // 13 tip
38
+ ];
39
+ function row(s) {
40
+ return Array.from(s).map((c) => c !== " ");
41
+ }
42
+ var LIGHT = [71, 117, 184];
43
+ var DARK = [45, 45, 93];
44
+ function gradientHex(pixelRow, pixelRows) {
45
+ const center = (pixelRows - 1) / 2;
46
+ const t = Math.abs(pixelRow - center) / center;
47
+ const r = Math.round(DARK[0] + (LIGHT[0] - DARK[0]) * t);
48
+ const g = Math.round(DARK[1] + (LIGHT[1] - DARK[1]) * t);
49
+ const b = Math.round(DARK[2] + (LIGHT[2] - DARK[2]) * t);
50
+ return "#" + [r, g, b].map((v) => v.toString(16).padStart(2, "0")).join("");
51
+ }
52
+ function renderGem() {
53
+ const pixelRows = MASK.length;
54
+ const cols = MASK[0].length;
55
+ const charRows = pixelRows / 2;
56
+ const lines = [];
57
+ for (let c = 0; c < charRows; c++) {
58
+ let line = "";
59
+ for (let x = 0; x < cols; x++) {
60
+ const top = MASK[2 * c][x];
61
+ const bot = MASK[2 * c + 1][x];
62
+ const topHex = gradientHex(2 * c, pixelRows);
63
+ const botHex = gradientHex(2 * c + 1, pixelRows);
64
+ if (top && bot) {
65
+ line += chalk.hex(topHex).bgHex(botHex)("\u2580");
66
+ } else if (top) {
67
+ line += chalk.hex(topHex)("\u2580");
68
+ } else if (bot) {
69
+ line += chalk.hex(botHex)("\u2584");
70
+ } else {
71
+ line += " ";
72
+ }
73
+ }
74
+ lines.push(line);
75
+ }
76
+ return lines;
77
+ }
78
+ var WORDMARK = [
79
+ " ____ _ __ ",
80
+ "| _ \\(_) __ _ / _|_ _ _ __ ___ ",
81
+ "| | | | |/ _` | |_| | | | '_ \\ / __|",
82
+ "| |_| | | (_| | _| |_| | | | | (__ ",
83
+ "|____/|_|\\__,_|_| \\__,_|_| |_|\\___|"
84
+ ];
85
+ var GAP = " ";
86
+ function showSplash() {
87
+ const brand = chalk.hex("#4775B8");
88
+ const gem = renderGem();
89
+ const wordmarkOffset = Math.floor((gem.length - WORDMARK.length) / 2);
90
+ console.log();
91
+ for (let i = 0; i < gem.length; i++) {
92
+ const w = i - wordmarkOffset;
93
+ const text = w >= 0 && w < WORDMARK.length ? WORDMARK[w] : "";
94
+ console.log(gem[i] + GAP + brand.bold(text));
95
+ }
96
+ console.log();
97
+ console.log(
98
+ " " + chalk.bold("CLI") + chalk.dim(` v${package_default.version}`) + chalk.dim(" \xB7 https://diafunc.com")
99
+ );
100
+ console.log();
101
+ console.log(
102
+ chalk.dim(" Run 'diafunc --help' for usage, or 'diafunc auth login' to get started.")
103
+ );
104
+ console.log();
105
+ }
5
106
 
6
107
  // bin/diafunc.ts
108
+ if (process.argv.length <= 2 && process.stdout.isTTY) {
109
+ showSplash();
110
+ process.exit(0);
111
+ }
7
112
  var program = createProgram();
8
113
  program.parseAsync(process.argv);
9
114
  //# sourceMappingURL=diafunc.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../bin/diafunc.ts"],"sourcesContent":["import { createProgram } from '../src/index.js';\n\nconst program = createProgram();\nprogram.parseAsync(process.argv);\n"],"mappings":";;;;;AAEA,IAAM,UAAU,cAAc;AAC9B,QAAQ,WAAW,QAAQ,IAAI;","names":[]}
1
+ {"version":3,"sources":["../../src/splash.ts","../../bin/diafunc.ts"],"sourcesContent":["import chalk from 'chalk';\nimport pkg from '../package.json' with { type: 'json' };\n\n// Diafunc gem logo rendered with a pixel mask + vertical gradient.\n//\n// The silhouette approximates app/src/assets/images/logos/icon.svg: flat top at\n// ~60% width, widening to shoulder points, tapering to a bottom tip.\n//\n// Each character cell packs two vertical pixels. By using ▀ with an independent\n// foreground (upper pixel) and background (lower pixel) color, we get 2×\n// vertical color resolution — enough for a smooth gradient across 14 pixel\n// rows in only 7 character rows. The gradient mirrors the SVG's linearGradient\n// stops: lighter at the top and bottom, darker in the middle (polished-gem\n// highlight effect).\n\n// 14 rows × 20 cols pixel mask. true = filled, false = empty.\n// Silhouette: flat top (60% wide), widening to shoulders (row 3, full width),\n// then tapering to a single-pixel tip.\nconst MASK: readonly (readonly boolean[])[] = [\n row(' ████████████ '), // 0 flat top\n row(' ██████████████ '), // 1\n row(' ██████████████████ '), // 2\n row('████████████████████'), // 3 shoulder (max width)\n row('████████████████████'), // 4 shoulder\n row(' ██████████████████ '), // 5\n row(' ████████████████ '), // 6\n row(' ██████████████ '), // 7\n row(' ████████████ '), // 8\n row(' ██████████ '), // 9\n row(' ████████ '), // 10\n row(' ██████ '), // 11\n row(' ████ '), // 12\n row(' ██ '), // 13 tip\n];\n\nfunction row(s: string): boolean[] {\n // Any non-space character counts as filled.\n return Array.from(s).map((c) => c !== ' ');\n}\n\n// Gradient endpoints: light blue from the SVG stops, dark blue in the middle.\nconst LIGHT: readonly [number, number, number] = [0x47, 0x75, 0xb8]; // #4775B8\nconst DARK: readonly [number, number, number] = [0x2d, 0x2d, 0x5d]; // #2D2D5D\n\nfunction gradientHex(pixelRow: number, pixelRows: number): string {\n // t = 0 at vertical center, 1 at top/bottom edges.\n const center = (pixelRows - 1) / 2;\n const t = Math.abs(pixelRow - center) / center;\n const r = Math.round(DARK[0] + (LIGHT[0] - DARK[0]) * t);\n const g = Math.round(DARK[1] + (LIGHT[1] - DARK[1]) * t);\n const b = Math.round(DARK[2] + (LIGHT[2] - DARK[2]) * t);\n return '#' + [r, g, b].map((v) => v.toString(16).padStart(2, '0')).join('');\n}\n\nfunction renderGem(): string[] {\n const pixelRows = MASK.length;\n const cols = MASK[0].length;\n const charRows = pixelRows / 2;\n const lines: string[] = [];\n\n for (let c = 0; c < charRows; c++) {\n let line = '';\n for (let x = 0; x < cols; x++) {\n const top = MASK[2 * c][x];\n const bot = MASK[2 * c + 1][x];\n const topHex = gradientHex(2 * c, pixelRows);\n const botHex = gradientHex(2 * c + 1, pixelRows);\n\n if (top && bot) {\n line += chalk.hex(topHex).bgHex(botHex)('▀');\n } else if (top) {\n line += chalk.hex(topHex)('▀');\n } else if (bot) {\n line += chalk.hex(botHex)('▄');\n } else {\n line += ' ';\n }\n }\n lines.push(line);\n }\n return lines;\n}\n\n// \"Diafunc\" in figlet \"standard\" font, rendered in a single brand color\n// alongside the gem (a gradient on thin text glyphs would look noisy).\nconst WORDMARK: readonly string[] = [\n ' ____ _ __ ',\n '| _ \\\\(_) __ _ / _|_ _ _ __ ___ ',\n \"| | | | |/ _` | |_| | | | '_ \\\\ / __|\",\n '| |_| | | (_| | _| |_| | | | | (__ ',\n '|____/|_|\\\\__,_|_| \\\\__,_|_| |_|\\\\___|',\n];\n\nconst GAP = ' ';\n\nexport function showSplash(): void {\n const brand = chalk.hex('#4775B8');\n const gem = renderGem();\n\n // Center the 5-row wordmark vertically against the 7-row gem.\n const wordmarkOffset = Math.floor((gem.length - WORDMARK.length) / 2);\n\n console.log();\n for (let i = 0; i < gem.length; i++) {\n const w = i - wordmarkOffset;\n const text = w >= 0 && w < WORDMARK.length ? WORDMARK[w] : '';\n console.log(gem[i] + GAP + brand.bold(text));\n }\n console.log();\n console.log(\n ' ' +\n chalk.bold('CLI') +\n chalk.dim(` v${pkg.version}`) +\n chalk.dim(' · https://diafunc.com'),\n );\n console.log();\n console.log(\n chalk.dim(\" Run 'diafunc --help' for usage, or 'diafunc auth login' to get started.\"),\n );\n console.log();\n}\n","import { createProgram } from '../src/index.js';\nimport { showSplash } from '../src/splash.js';\n\nif (process.argv.length <= 2 && process.stdout.isTTY) {\n showSplash();\n process.exit(0);\n}\n\nconst program = createProgram();\nprogram.parseAsync(process.argv);\n"],"mappings":";;;;;;AAAA,OAAO,WAAW;AAkBlB,IAAM,OAAwC;AAAA,EAC5C,IAAI,kFAAsB;AAAA;AAAA,EAC1B,IAAI,4FAAsB;AAAA;AAAA,EAC1B,IAAI,gHAAsB;AAAA;AAAA,EAC1B,IAAI,0HAAsB;AAAA;AAAA,EAC1B,IAAI,0HAAsB;AAAA;AAAA,EAC1B,IAAI,gHAAsB;AAAA;AAAA,EAC1B,IAAI,sGAAsB;AAAA;AAAA,EAC1B,IAAI,4FAAsB;AAAA;AAAA,EAC1B,IAAI,kFAAsB;AAAA;AAAA,EAC1B,IAAI,wEAAsB;AAAA;AAAA,EAC1B,IAAI,8DAAsB;AAAA;AAAA,EAC1B,IAAI,oDAAsB;AAAA;AAAA,EAC1B,IAAI,0CAAsB;AAAA;AAAA,EAC1B,IAAI,gCAAsB;AAAA;AAC5B;AAEA,SAAS,IAAI,GAAsB;AAEjC,SAAO,MAAM,KAAK,CAAC,EAAE,IAAI,CAAC,MAAM,MAAM,GAAG;AAC3C;AAGA,IAAM,QAA2C,CAAC,IAAM,KAAM,GAAI;AAClE,IAAM,OAA0C,CAAC,IAAM,IAAM,EAAI;AAEjE,SAAS,YAAY,UAAkB,WAA2B;AAEhE,QA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