@qloo/qloo-harness 0.1.18

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/dist/cli.js ADDED
@@ -0,0 +1,95 @@
1
+ import { createRequire as __qlooCreateRequire } from "node:module";
2
+ const require = __qlooCreateRequire(import.meta.url);
3
+
4
+ // apps/qloo-harness/dist/cli.js
5
+ import { launchInteractiveHarness } from "./app.js";
6
+ import { isQlooHarnessProfile, QLOO_DEFAULT_PROFILE, QLOO_HARNESS_PROFILES } from "./profiles.js";
7
+ import { MissingModelAuthenticationError } from "./runtime/pi-adapter.js";
8
+ var HARNESS_VERSION = "0.1.18";
9
+ var HARNESS_HELP = `Qloo terminal harness
10
+
11
+ Usage:
12
+ qloo Start guided Qloo chat
13
+ qloo chat Start guided Qloo chat explicitly
14
+ qloo explore Ask grounded Qloo questions (read-only workspace)
15
+ qloo integrate Inspect and design a Qloo integration
16
+ qloo plan Open interactive read-only planning
17
+ qloo plan "<goal>" --json
18
+ Create a typed, evidence-backed plan
19
+ qloo build Open approval-gated build mode
20
+ qloo build --plan <plan-id>
21
+ Build from a validated integration plan
22
+ qloo chat --mode <explore|integrate|plan|build>
23
+ qloo --help Show this help
24
+ qloo --version Show the harness version
25
+
26
+ The deterministic API CLI and additional harness commands are attached by the
27
+ top-level qloo command router.`;
28
+ var defaultDependencies = {
29
+ launch: (profile) => launchInteractiveHarness({ profile }),
30
+ isInteractiveTerminal: () => process.stdin.isTTY === true && process.stdout.isTTY === true,
31
+ writeOut: (text) => {
32
+ process.stdout.write(text);
33
+ },
34
+ writeError: (text) => {
35
+ process.stderr.write(text);
36
+ }
37
+ };
38
+ function startupErrorMessage(error) {
39
+ if (error instanceof MissingModelAuthenticationError) {
40
+ return `qloo: ${error.message}`;
41
+ }
42
+ const message = error instanceof Error ? error.message : String(error);
43
+ return `qloo: unable to start interactive chat: ${message}`;
44
+ }
45
+ function parseChatProfile(args) {
46
+ if (args.length === 0 || args.length === 1 && args[0] === "chat") {
47
+ return QLOO_DEFAULT_PROFILE;
48
+ }
49
+ if (args.length === 1 && args[0] && isQlooHarnessProfile(args[0]))
50
+ return args[0];
51
+ if (args[0] !== "chat")
52
+ return void 0;
53
+ const modeArgument = args[1];
54
+ const value = modeArgument === "--mode" ? args[2] : modeArgument?.startsWith("--mode=") ? modeArgument.slice("--mode=".length) : void 0;
55
+ const expectedLength = modeArgument === "--mode" ? 3 : 2;
56
+ return args.length === expectedLength && value && isQlooHarnessProfile(value) ? value : void 0;
57
+ }
58
+ async function runHarnessCli(args = process.argv.slice(2), dependencies = defaultDependencies) {
59
+ if (args.length === 1 && (args[0] === "--help" || args[0] === "-h")) {
60
+ dependencies.writeOut(`${HARNESS_HELP}
61
+ `);
62
+ return 0;
63
+ }
64
+ if (args.length === 1 && (args[0] === "--version" || args[0] === "-V")) {
65
+ dependencies.writeOut(`${HARNESS_VERSION}
66
+ `);
67
+ return 0;
68
+ }
69
+ const profile = parseChatProfile(args);
70
+ if (!profile) {
71
+ dependencies.writeError(`qloo: unknown command or invalid chat profile: ${args.join(" ")}
72
+ Choose one of: ${QLOO_HARNESS_PROFILES.join(", ")}
73
+
74
+ ${HARNESS_HELP}
75
+ `);
76
+ return 2;
77
+ }
78
+ if (!dependencies.isInteractiveTerminal()) {
79
+ dependencies.writeError("qloo: interactive chat requires a TTY on stdin and stdout. Use an explicit non-interactive qloo command for scripts.\n");
80
+ return 2;
81
+ }
82
+ try {
83
+ await dependencies.launch(profile);
84
+ return 0;
85
+ } catch (error) {
86
+ dependencies.writeError(`${startupErrorMessage(error)}
87
+ `);
88
+ return 1;
89
+ }
90
+ }
91
+ export {
92
+ HARNESS_HELP,
93
+ HARNESS_VERSION,
94
+ runHarnessCli
95
+ };