@fieldwork-ai/cli 0.16.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 +64 -0
- package/dist/app-bundle.d.ts +6 -0
- package/dist/app-bundle.js +75 -0
- package/dist/bundle.d.ts +5 -0
- package/dist/bundle.js +38 -0
- package/dist/commands/apps.d.ts +2 -0
- package/dist/commands/apps.js +96 -0
- package/dist/commands/assets.d.ts +2 -0
- package/dist/commands/assets.js +170 -0
- package/dist/commands/auth.d.ts +2 -0
- package/dist/commands/auth.js +113 -0
- package/dist/commands/automations.d.ts +2 -0
- package/dist/commands/automations.js +178 -0
- package/dist/commands/connectors.d.ts +11 -0
- package/dist/commands/connectors.js +272 -0
- package/dist/commands/kb-blobs.d.ts +16 -0
- package/dist/commands/kb-blobs.js +98 -0
- package/dist/commands/kb-pages.d.ts +39 -0
- package/dist/commands/kb-pages.js +97 -0
- package/dist/commands/kb.d.ts +2 -0
- package/dist/commands/kb.js +196 -0
- package/dist/commands/tasks.d.ts +28 -0
- package/dist/commands/tasks.js +320 -0
- package/dist/commands/tool.d.ts +12 -0
- package/dist/commands/tool.js +106 -0
- package/dist/config.d.ts +54 -0
- package/dist/config.js +93 -0
- package/dist/content-kind.d.ts +14 -0
- package/dist/content-kind.js +18 -0
- package/dist/http.d.ts +27 -0
- package/dist/http.js +120 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +46 -0
- package/dist/oauth.d.ts +2 -0
- package/dist/oauth.js +123 -0
- package/dist/output.d.ts +40 -0
- package/dist/output.js +90 -0
- package/package.json +39 -0
package/dist/output.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output conventions (ADR 20260804): stdout carries data only, every message
|
|
3
|
+
* and prompt goes to stderr, --json prints the raw API payload compact —
|
|
4
|
+
* every verb honors it with a stable shape (mutations included: writes print
|
|
5
|
+
* what happened, pulls print what landed where).
|
|
6
|
+
* Exit codes: 0 ok · 1 server/network · 2 usage or 400 · 3 auth (401) ·
|
|
7
|
+
* 4 forbidden (403) · 5 not found (404) · 6 conflict (409) · 7 rate limited.
|
|
8
|
+
* Failures exit non-zero via fail()/exitCodeFor. The one deliberate
|
|
9
|
+
* exception: `tool run` prints tool-error strings as data and exits 0 (chat
|
|
10
|
+
* semantics — a tool error is a result, not a CLI failure); purpose verbs
|
|
11
|
+
* never do that, which is one reason they are REST-backed.
|
|
12
|
+
*/
|
|
13
|
+
export const EXIT = {
|
|
14
|
+
ok: 0,
|
|
15
|
+
server: 1,
|
|
16
|
+
usage: 2,
|
|
17
|
+
auth: 3,
|
|
18
|
+
forbidden: 4,
|
|
19
|
+
notFound: 5,
|
|
20
|
+
conflict: 6,
|
|
21
|
+
rateLimited: 7,
|
|
22
|
+
};
|
|
23
|
+
export function exitCodeFor(status) {
|
|
24
|
+
if (status === 400)
|
|
25
|
+
return EXIT.usage;
|
|
26
|
+
if (status === 401)
|
|
27
|
+
return EXIT.auth;
|
|
28
|
+
if (status === 403)
|
|
29
|
+
return EXIT.forbidden;
|
|
30
|
+
if (status === 404)
|
|
31
|
+
return EXIT.notFound;
|
|
32
|
+
if (status === 409)
|
|
33
|
+
return EXIT.conflict;
|
|
34
|
+
if (status === 429)
|
|
35
|
+
return EXIT.rateLimited;
|
|
36
|
+
return EXIT.server;
|
|
37
|
+
}
|
|
38
|
+
export function printData(value, json) {
|
|
39
|
+
if (typeof value === "string") {
|
|
40
|
+
process.stdout.write(value.endsWith("\n") ? value : `${value}\n`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
process.stdout.write(`${JSON.stringify(value, null, json ? 0 : 2)}\n`);
|
|
44
|
+
}
|
|
45
|
+
export function note(message) {
|
|
46
|
+
process.stderr.write(`${message}\n`);
|
|
47
|
+
}
|
|
48
|
+
/** Query results: --json prints the raw payload; human mode prints TSV (a
|
|
49
|
+
* header row, then rows) with any truncation noted on stderr. Truncation is
|
|
50
|
+
* a successful result — no exit-code change. */
|
|
51
|
+
export function printTabular(result, json) {
|
|
52
|
+
if (json) {
|
|
53
|
+
printData(result, true);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const cell = (v) => v === null || v === undefined ? "" : typeof v === "object" ? JSON.stringify(v) : String(v);
|
|
57
|
+
const lines = [
|
|
58
|
+
result.columns.join("\t"),
|
|
59
|
+
...result.rows.map((row) => result.columns.map((c) => cell(row[c])).join("\t")),
|
|
60
|
+
];
|
|
61
|
+
process.stdout.write(`${lines.join("\n")}\n`);
|
|
62
|
+
}
|
|
63
|
+
if (result.truncated) {
|
|
64
|
+
note(`truncated by ${result.truncatedBy ?? "limit"}: ${result.rowsReturned ?? result.rows.length} rows returned`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function fail(message, code) {
|
|
68
|
+
process.stderr.write(`fieldwork: ${message}\n`);
|
|
69
|
+
process.exit(code);
|
|
70
|
+
}
|
|
71
|
+
/** Confirm a mutation: prompt on a TTY, --yes skips, non-TTY without --yes
|
|
72
|
+
* is a usage error (unattended callers must opt in explicitly). */
|
|
73
|
+
export async function confirm(message, yes) {
|
|
74
|
+
if (yes)
|
|
75
|
+
return;
|
|
76
|
+
if (!process.stdin.isTTY || !process.stderr.isTTY) {
|
|
77
|
+
fail("refusing to mutate without --yes in a non-interactive session", EXIT.usage);
|
|
78
|
+
}
|
|
79
|
+
const readline = await import("node:readline/promises");
|
|
80
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
81
|
+
try {
|
|
82
|
+
const answer = (await rl.question(`${message} [y/N] `)).trim().toLowerCase();
|
|
83
|
+
if (answer !== "y" && answer !== "yes") {
|
|
84
|
+
fail("aborted", EXIT.usage);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
rl.close();
|
|
89
|
+
}
|
|
90
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fieldwork-ai/cli",
|
|
3
|
+
"version": "0.16.0",
|
|
4
|
+
"description": "Fieldwork asset-management CLI",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"fieldwork": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=24"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"commander": "^14.0.2"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^24.0.0",
|
|
21
|
+
"tsx": "^4.19.0",
|
|
22
|
+
"typescript": "~5.9.3",
|
|
23
|
+
"vitest": "^4.1.0"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/fieldwork-ai/app.git",
|
|
28
|
+
"directory": "cli"
|
|
29
|
+
},
|
|
30
|
+
"exports": {
|
|
31
|
+
"./package.json": "./package.json",
|
|
32
|
+
"./*": "./dist/*.js"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "node -e \"require('node:fs').rmSync('dist', {recursive:true,force:true})\" && tsc",
|
|
36
|
+
"dev": "tsx src/index.ts",
|
|
37
|
+
"test": "vitest run"
|
|
38
|
+
}
|
|
39
|
+
}
|