@flint-dev/cli 0.2.2
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 +22 -0
- package/bin/flint.js +104 -0
- package/package.json +24 -0
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @flint-dev/cli
|
|
2
|
+
|
|
3
|
+
Flint command-line entrypoint.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @flint-dev/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or run without installing globally:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx @flint-dev/cli --help
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Commands
|
|
18
|
+
|
|
19
|
+
- `flint tui`
|
|
20
|
+
- `flint gateway`
|
|
21
|
+
- `flint app-server`
|
|
22
|
+
- `flint pi-app-server`
|
package/bin/flint.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
import { readFileSync } from "node:fs";
|
|
6
|
+
import { createRequire } from "node:module";
|
|
7
|
+
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
|
|
10
|
+
const COMMANDS = {
|
|
11
|
+
tui: {
|
|
12
|
+
description: "Run Flint terminal UI",
|
|
13
|
+
packageName: "@flint-dev/tui",
|
|
14
|
+
binName: "flint-tui",
|
|
15
|
+
},
|
|
16
|
+
gateway: {
|
|
17
|
+
description: "Run Flint HTTP gateway",
|
|
18
|
+
packageName: "@flint-dev/gateway",
|
|
19
|
+
binName: "flint-gateway",
|
|
20
|
+
},
|
|
21
|
+
"app-server": {
|
|
22
|
+
description: "Run Claude app server",
|
|
23
|
+
packageName: "@flint-dev/claude-app-server",
|
|
24
|
+
binName: "claude-app-server",
|
|
25
|
+
},
|
|
26
|
+
"pi-app-server": {
|
|
27
|
+
description: "Run Pi app server",
|
|
28
|
+
packageName: "@flint-dev/pi-app-server",
|
|
29
|
+
binName: "pi-app-server",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function printHelp() {
|
|
34
|
+
console.log("flint <command> [args]");
|
|
35
|
+
console.log("");
|
|
36
|
+
console.log("Commands:");
|
|
37
|
+
for (const [name, command] of Object.entries(COMMANDS)) {
|
|
38
|
+
console.log(` ${name.padEnd(16)} ${command.description}`);
|
|
39
|
+
}
|
|
40
|
+
console.log("");
|
|
41
|
+
console.log("Examples:");
|
|
42
|
+
console.log(" flint tui");
|
|
43
|
+
console.log(" flint gateway");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function resolveCommandBinary(packageName, binName) {
|
|
47
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
48
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
49
|
+
|
|
50
|
+
const binField = packageJson.bin;
|
|
51
|
+
const relativeBinPath =
|
|
52
|
+
typeof binField === "string"
|
|
53
|
+
? binField
|
|
54
|
+
: binField && typeof binField === "object"
|
|
55
|
+
? binField[binName]
|
|
56
|
+
: undefined;
|
|
57
|
+
|
|
58
|
+
if (!relativeBinPath) {
|
|
59
|
+
throw new Error(`Could not resolve binary "${binName}" in ${packageName}`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return resolve(dirname(packageJsonPath), relativeBinPath);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function runCommand(binaryPath, args) {
|
|
66
|
+
const child = spawn(binaryPath, args, {
|
|
67
|
+
stdio: "inherit",
|
|
68
|
+
env: process.env,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
child.on("error", (error) => {
|
|
72
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
73
|
+
console.error("Flint requires Bun installed and available on PATH.");
|
|
74
|
+
console.error("Install Bun: https://bun.sh");
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
78
|
+
process.exit(1);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
child.on("exit", (code) => process.exit(code ?? 1));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function main() {
|
|
85
|
+
const [, , commandName, ...rest] = process.argv;
|
|
86
|
+
|
|
87
|
+
if (!commandName || commandName === "help" || commandName === "--help" || commandName === "-h") {
|
|
88
|
+
printHelp();
|
|
89
|
+
process.exit(0);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const command = COMMANDS[commandName];
|
|
93
|
+
if (!command) {
|
|
94
|
+
console.error(`Unknown command: ${commandName}`);
|
|
95
|
+
console.error("");
|
|
96
|
+
printHelp();
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const binaryPath = resolveCommandBinary(command.packageName, command.binName);
|
|
101
|
+
runCommand(binaryPath, rest);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flint-dev/cli",
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "Flint command-line entrypoint",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Aaron Escalona",
|
|
7
|
+
"files": [
|
|
8
|
+
"bin",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"bin": {
|
|
12
|
+
"flint": "./bin/flint.js"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@flint-dev/claude-app-server": "^0.2.2",
|
|
20
|
+
"@flint-dev/gateway": "^0.2.2",
|
|
21
|
+
"@flint-dev/pi-app-server": "^0.2.2",
|
|
22
|
+
"@flint-dev/tui": "^0.2.0"
|
|
23
|
+
}
|
|
24
|
+
}
|