@camerontaylor/paseo-cli 0.8.0-fork.1
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/bin/paseo +3 -0
- package/dist/classify.d.ts +19 -0
- package/dist/classify.js +49 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +135 -0
- package/dist/commands/agent/archive.d.ts +18 -0
- package/dist/commands/agent/archive.js +102 -0
- package/dist/commands/agent/attach.d.ts +11 -0
- package/dist/commands/agent/attach.js +161 -0
- package/dist/commands/agent/delete.d.ts +15 -0
- package/dist/commands/agent/delete.js +107 -0
- package/dist/commands/agent/detach.d.ts +9 -0
- package/dist/commands/agent/detach.js +38 -0
- package/dist/commands/agent/import.d.ts +14 -0
- package/dist/commands/agent/import.js +122 -0
- package/dist/commands/agent/index.d.ts +3 -0
- package/dist/commands/agent/index.js +56 -0
- package/dist/commands/agent/inspect.d.ts +15 -0
- package/dist/commands/agent/inspect.js +209 -0
- package/dist/commands/agent/logs.d.ts +19 -0
- package/dist/commands/agent/logs.js +180 -0
- package/dist/commands/agent/ls.d.ts +44 -0
- package/dist/commands/agent/ls.js +212 -0
- package/dist/commands/agent/mode.d.ts +18 -0
- package/dist/commands/agent/mode.js +100 -0
- package/dist/commands/agent/open.d.ts +11 -0
- package/dist/commands/agent/open.js +61 -0
- package/dist/commands/agent/reload.d.ts +15 -0
- package/dist/commands/agent/reload.js +75 -0
- package/dist/commands/agent/run.d.ts +78 -0
- package/dist/commands/agent/run.js +554 -0
- package/dist/commands/agent/send.d.ts +19 -0
- package/dist/commands/agent/send.js +187 -0
- package/dist/commands/agent/stop.d.ts +17 -0
- package/dist/commands/agent/stop.js +115 -0
- package/dist/commands/agent/update.d.ts +51 -0
- package/dist/commands/agent/update.js +186 -0
- package/dist/commands/agent/wait.d.ts +17 -0
- package/dist/commands/agent/wait.js +158 -0
- package/dist/commands/clone.d.ts +17 -0
- package/dist/commands/clone.js +65 -0
- package/dist/commands/daemon/index.d.ts +3 -0
- package/dist/commands/daemon/index.js +60 -0
- package/dist/commands/daemon/local-daemon.d.ts +78 -0
- package/dist/commands/daemon/local-daemon.js +547 -0
- package/dist/commands/daemon/pair.d.ts +35 -0
- package/dist/commands/daemon/pair.js +167 -0
- package/dist/commands/daemon/reload.d.ts +10 -0
- package/dist/commands/daemon/reload.js +36 -0
- package/dist/commands/daemon/restart.d.ts +12 -0
- package/dist/commands/daemon/restart.js +99 -0
- package/dist/commands/daemon/runtime-toolchain.d.ts +6 -0
- package/dist/commands/daemon/runtime-toolchain.js +87 -0
- package/dist/commands/daemon/set-password.d.ts +17 -0
- package/dist/commands/daemon/set-password.js +82 -0
- package/dist/commands/daemon/start.d.ts +6 -0
- package/dist/commands/daemon/start.js +57 -0
- package/dist/commands/daemon/status.d.ts +21 -0
- package/dist/commands/daemon/status.js +363 -0
- package/dist/commands/daemon/stop.d.ts +15 -0
- package/dist/commands/daemon/stop.js +60 -0
- package/dist/commands/heartbeat/index.d.ts +3 -0
- package/dist/commands/heartbeat/index.js +139 -0
- package/dist/commands/hooks.d.ts +19 -0
- package/dist/commands/hooks.js +89 -0
- package/dist/commands/hub/authority.d.ts +17 -0
- package/dist/commands/hub/authority.js +18 -0
- package/dist/commands/hub/connect.d.ts +23 -0
- package/dist/commands/hub/connect.js +44 -0
- package/dist/commands/hub/credentials.d.ts +21 -0
- package/dist/commands/hub/credentials.js +143 -0
- package/dist/commands/hub/daemon-client.d.ts +40 -0
- package/dist/commands/hub/daemon-client.js +14 -0
- package/dist/commands/hub/deploy-bundle.d.ts +16 -0
- package/dist/commands/hub/deploy-bundle.js +248 -0
- package/dist/commands/hub/deploy-triggers.d.ts +6 -0
- package/dist/commands/hub/deploy-triggers.js +116 -0
- package/dist/commands/hub/deploy.d.ts +50 -0
- package/dist/commands/hub/deploy.js +159 -0
- package/dist/commands/hub/disconnect.d.ts +16 -0
- package/dist/commands/hub/disconnect.js +24 -0
- package/dist/commands/hub/error.d.ts +6 -0
- package/dist/commands/hub/error.js +9 -0
- package/dist/commands/hub/export.d.ts +28 -0
- package/dist/commands/hub/export.js +80 -0
- package/dist/commands/hub/help.d.ts +3 -0
- package/dist/commands/hub/help.js +5 -0
- package/dist/commands/hub/hub-client/index.d.ts +22 -0
- package/dist/commands/hub/hub-client/index.js +135 -0
- package/dist/commands/hub/hub-client/internal/contracts.d.ts +126 -0
- package/dist/commands/hub/hub-client/internal/contracts.js +85 -0
- package/dist/commands/hub/hub-client/internal/problem.d.ts +3 -0
- package/dist/commands/hub/hub-client/internal/problem.js +85 -0
- package/dist/commands/hub/hub-client/internal/transport.d.ts +15 -0
- package/dist/commands/hub/hub-client/internal/transport.js +30 -0
- package/dist/commands/hub/index.d.ts +20 -0
- package/dist/commands/hub/index.js +94 -0
- package/dist/commands/hub/init-plan.d.ts +33 -0
- package/dist/commands/hub/init-plan.js +94 -0
- package/dist/commands/hub/init.d.ts +35 -0
- package/dist/commands/hub/init.js +524 -0
- package/dist/commands/hub/login-flow.d.ts +34 -0
- package/dist/commands/hub/login-flow.js +78 -0
- package/dist/commands/hub/login.d.ts +23 -0
- package/dist/commands/hub/login.js +40 -0
- package/dist/commands/hub/logout.d.ts +32 -0
- package/dist/commands/hub/logout.js +71 -0
- package/dist/commands/hub/origin.d.ts +2 -0
- package/dist/commands/hub/origin.js +27 -0
- package/dist/commands/hub/permissions.d.ts +21 -0
- package/dist/commands/hub/permissions.js +61 -0
- package/dist/commands/hub/projects.d.ts +24 -0
- package/dist/commands/hub/projects.js +49 -0
- package/dist/commands/hub/reporter.d.ts +10 -0
- package/dist/commands/hub/reporter.js +11 -0
- package/dist/commands/hub/starter-agent-runtime.d.ts +37 -0
- package/dist/commands/hub/starter-agent-runtime.js +49 -0
- package/dist/commands/hub/starter-trigger.d.ts +10 -0
- package/dist/commands/hub/starter-trigger.js +30 -0
- package/dist/commands/hub/status-output.d.ts +13 -0
- package/dist/commands/hub/status-output.js +30 -0
- package/dist/commands/onboard.d.ts +10 -0
- package/dist/commands/onboard.js +400 -0
- package/dist/commands/open.d.ts +4 -0
- package/dist/commands/open.js +89 -0
- package/dist/commands/permit/allow.d.ts +20 -0
- package/dist/commands/permit/allow.js +133 -0
- package/dist/commands/permit/deny.d.ts +12 -0
- package/dist/commands/permit/deny.js +105 -0
- package/dist/commands/permit/index.d.ts +3 -0
- package/dist/commands/permit/index.js +27 -0
- package/dist/commands/permit/ls.d.ts +18 -0
- package/dist/commands/permit/ls.js +66 -0
- package/dist/commands/plugin/index.d.ts +17 -0
- package/dist/commands/plugin/index.js +138 -0
- package/dist/commands/plugin/scaffold.d.ts +6 -0
- package/dist/commands/plugin/scaffold.js +162 -0
- package/dist/commands/plugin/shared.d.ts +5 -0
- package/dist/commands/plugin/shared.js +30 -0
- package/dist/commands/project/create.d.ts +10 -0
- package/dist/commands/project/create.js +41 -0
- package/dist/commands/project/delete.d.ts +9 -0
- package/dist/commands/project/delete.js +33 -0
- package/dist/commands/project/index.d.ts +3 -0
- package/dist/commands/project/index.js +28 -0
- package/dist/commands/project/ls.d.ts +5 -0
- package/dist/commands/project/ls.js +19 -0
- package/dist/commands/project/rename.d.ts +15 -0
- package/dist/commands/project/rename.js +50 -0
- package/dist/commands/project/shared.d.ts +11 -0
- package/dist/commands/project/shared.js +18 -0
- package/dist/commands/provider/add.d.ts +30 -0
- package/dist/commands/provider/add.js +123 -0
- package/dist/commands/provider/diagnostic.d.ts +12 -0
- package/dist/commands/provider/diagnostic.js +31 -0
- package/dist/commands/provider/index.d.ts +3 -0
- package/dist/commands/provider/index.js +38 -0
- package/dist/commands/provider/ls.d.ts +20 -0
- package/dist/commands/provider/ls.js +76 -0
- package/dist/commands/provider/models.d.ts +20 -0
- package/dist/commands/provider/models.js +53 -0
- package/dist/commands/provider/rm.d.ts +10 -0
- package/dist/commands/provider/rm.js +45 -0
- package/dist/commands/provider/shared.d.ts +7 -0
- package/dist/commands/provider/shared.js +10 -0
- package/dist/commands/schedule/create.d.ts +19 -0
- package/dist/commands/schedule/create.js +41 -0
- package/dist/commands/schedule/delete.d.ts +10 -0
- package/dist/commands/schedule/delete.js +32 -0
- package/dist/commands/schedule/index.d.ts +3 -0
- package/dist/commands/schedule/index.js +66 -0
- package/dist/commands/schedule/inspect.d.ts +6 -0
- package/dist/commands/schedule/inspect.js +27 -0
- package/dist/commands/schedule/logs.d.ts +6 -0
- package/dist/commands/schedule/logs.js +24 -0
- package/dist/commands/schedule/ls.d.ts +5 -0
- package/dist/commands/schedule/ls.js +25 -0
- package/dist/commands/schedule/pause.d.ts +5 -0
- package/dist/commands/schedule/pause.js +24 -0
- package/dist/commands/schedule/resume.d.ts +5 -0
- package/dist/commands/schedule/resume.js +24 -0
- package/dist/commands/schedule/run-once.d.ts +5 -0
- package/dist/commands/schedule/run-once.js +24 -0
- package/dist/commands/schedule/schema.d.ts +21 -0
- package/dist/commands/schedule/schema.js +67 -0
- package/dist/commands/schedule/shared.d.ts +59 -0
- package/dist/commands/schedule/shared.js +358 -0
- package/dist/commands/schedule/types.d.ts +165 -0
- package/dist/commands/schedule/types.js +2 -0
- package/dist/commands/schedule/update.d.ts +21 -0
- package/dist/commands/schedule/update.js +40 -0
- package/dist/commands/script/index.d.ts +3 -0
- package/dist/commands/script/index.js +19 -0
- package/dist/commands/script/ls.d.ts +6 -0
- package/dist/commands/script/ls.js +20 -0
- package/dist/commands/script/schema.d.ts +5 -0
- package/dist/commands/script/schema.js +13 -0
- package/dist/commands/script/shared.d.ts +11 -0
- package/dist/commands/script/shared.js +59 -0
- package/dist/commands/script/start.d.ts +6 -0
- package/dist/commands/script/start.js +23 -0
- package/dist/commands/script/stop.d.ts +6 -0
- package/dist/commands/script/stop.js +23 -0
- package/dist/commands/speech/index.d.ts +3 -0
- package/dist/commands/speech/index.js +5 -0
- package/dist/commands/terminal/capture.d.ts +10 -0
- package/dist/commands/terminal/capture.js +68 -0
- package/dist/commands/terminal/create.d.ts +11 -0
- package/dist/commands/terminal/create.js +29 -0
- package/dist/commands/terminal/index.d.ts +3 -0
- package/dist/commands/terminal/index.js +45 -0
- package/dist/commands/terminal/kill.d.ts +6 -0
- package/dist/commands/terminal/kill.js +36 -0
- package/dist/commands/terminal/ls.d.ts +11 -0
- package/dist/commands/terminal/ls.js +21 -0
- package/dist/commands/terminal/schema.d.ts +10 -0
- package/dist/commands/terminal/schema.js +17 -0
- package/dist/commands/terminal/send-keys.d.ts +7 -0
- package/dist/commands/terminal/send-keys.js +45 -0
- package/dist/commands/terminal/shared.d.ts +12 -0
- package/dist/commands/terminal/shared.js +62 -0
- package/dist/commands/workspace/archive.d.ts +12 -0
- package/dist/commands/workspace/archive.js +41 -0
- package/dist/commands/workspace/create.d.ts +49 -0
- package/dist/commands/workspace/create.js +114 -0
- package/dist/commands/workspace/index.d.ts +3 -0
- package/dist/commands/workspace/index.js +45 -0
- package/dist/commands/workspace/ls.d.ts +7 -0
- package/dist/commands/workspace/ls.js +28 -0
- package/dist/commands/workspace/rename.d.ts +22 -0
- package/dist/commands/workspace/rename.js +61 -0
- package/dist/commands/workspace/setup.d.ts +11 -0
- package/dist/commands/workspace/setup.js +41 -0
- package/dist/commands/workspace/shared.d.ts +12 -0
- package/dist/commands/workspace/shared.js +20 -0
- package/dist/commands/worktree/archive.d.ts +20 -0
- package/dist/commands/worktree/archive.js +104 -0
- package/dist/commands/worktree/create-input.d.ts +15 -0
- package/dist/commands/worktree/create-input.js +56 -0
- package/dist/commands/worktree/create.d.ts +11 -0
- package/dist/commands/worktree/create.js +58 -0
- package/dist/commands/worktree/index.d.ts +3 -0
- package/dist/commands/worktree/index.js +25 -0
- package/dist/commands/worktree/ls.d.ts +19 -0
- package/dist/commands/worktree/ls.js +97 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/output/index.d.ts +45 -0
- package/dist/output/index.js +47 -0
- package/dist/output/json.d.ts +11 -0
- package/dist/output/json.js +37 -0
- package/dist/output/pairing.d.ts +8 -0
- package/dist/output/pairing.js +24 -0
- package/dist/output/quiet.d.ts +9 -0
- package/dist/output/quiet.js +22 -0
- package/dist/output/render.d.ts +15 -0
- package/dist/output/render.js +84 -0
- package/dist/output/table.d.ts +13 -0
- package/dist/output/table.js +135 -0
- package/dist/output/types.d.ts +73 -0
- package/dist/output/types.js +8 -0
- package/dist/output/with-output.d.ts +41 -0
- package/dist/output/with-output.js +85 -0
- package/dist/output/yaml.d.ts +11 -0
- package/dist/output/yaml.js +38 -0
- package/dist/run.d.ts +14 -0
- package/dist/run.js +40 -0
- package/dist/ssh/ssh-tunnel.d.ts +9 -0
- package/dist/ssh/ssh-tunnel.js +79 -0
- package/dist/utils/client-id.d.ts +2 -0
- package/dist/utils/client-id.js +37 -0
- package/dist/utils/client.d.ts +54 -0
- package/dist/utils/client.js +363 -0
- package/dist/utils/command-options.d.ts +7 -0
- package/dist/utils/command-options.js +25 -0
- package/dist/utils/duration.d.ts +7 -0
- package/dist/utils/duration.js +39 -0
- package/dist/utils/errors.d.ts +5 -0
- package/dist/utils/errors.js +10 -0
- package/dist/utils/paths.d.ts +12 -0
- package/dist/utils/paths.js +22 -0
- package/dist/utils/provider-model.d.ts +11 -0
- package/dist/utils/provider-model.js +49 -0
- package/dist/utils/timeline.d.ts +11 -0
- package/dist/utils/timeline.js +11 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +10 -0
- package/package.json +50 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output format types for the Paseo CLI.
|
|
3
|
+
*
|
|
4
|
+
* This module defines the structured data types used by the output abstraction layer.
|
|
5
|
+
* Commands return CommandResult<T> which contains both data and rendering metadata.
|
|
6
|
+
*/
|
|
7
|
+
/** Supported output formats */
|
|
8
|
+
export type OutputFormat = "table" | "json" | "yaml";
|
|
9
|
+
/** Options controlling output rendering */
|
|
10
|
+
export interface OutputOptions {
|
|
11
|
+
/** Output format (table, json, yaml) */
|
|
12
|
+
format: OutputFormat;
|
|
13
|
+
/** Minimal output - IDs only */
|
|
14
|
+
quiet: boolean;
|
|
15
|
+
/** Omit table headers */
|
|
16
|
+
noHeaders: boolean;
|
|
17
|
+
/** Disable color output */
|
|
18
|
+
noColor: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** Column definition for table output */
|
|
21
|
+
export interface ColumnDef<T> {
|
|
22
|
+
/** Header text for the column */
|
|
23
|
+
header: string;
|
|
24
|
+
/** Field key or accessor function */
|
|
25
|
+
field: keyof T | ((item: T) => unknown);
|
|
26
|
+
/** Optional width hint (characters) */
|
|
27
|
+
width?: number;
|
|
28
|
+
/** Optional alignment */
|
|
29
|
+
align?: "left" | "right" | "center";
|
|
30
|
+
/** Optional color function - returns chalk color name */
|
|
31
|
+
color?: (value: unknown, item: T) => string | undefined;
|
|
32
|
+
}
|
|
33
|
+
/** Schema describing how to render command output */
|
|
34
|
+
export interface OutputSchema<T> {
|
|
35
|
+
/** Field to use for quiet mode (--quiet outputs just this) */
|
|
36
|
+
idField: keyof T | ((item: T) => string);
|
|
37
|
+
/** Column definitions for table output */
|
|
38
|
+
columns: ColumnDef<T>[];
|
|
39
|
+
/** Optional: custom renderer for human/table output */
|
|
40
|
+
renderHuman?: (result: AnyCommandResult<T>, options: OutputOptions) => string;
|
|
41
|
+
/** Optional: transform data before JSON/YAML output */
|
|
42
|
+
serialize?: (data: T) => unknown;
|
|
43
|
+
}
|
|
44
|
+
/** Result type for commands returning a single item */
|
|
45
|
+
export interface SingleResult<T> {
|
|
46
|
+
type: "single";
|
|
47
|
+
/** The structured data to render */
|
|
48
|
+
data: T;
|
|
49
|
+
/** Schema describing how to render this data (for item type T) */
|
|
50
|
+
schema: OutputSchema<T>;
|
|
51
|
+
}
|
|
52
|
+
/** Result type for commands returning a list */
|
|
53
|
+
export interface ListResult<T> {
|
|
54
|
+
type: "list";
|
|
55
|
+
/** The structured data to render */
|
|
56
|
+
data: T[];
|
|
57
|
+
/** Schema describing how to render this data (for item type T) */
|
|
58
|
+
schema: OutputSchema<T>;
|
|
59
|
+
}
|
|
60
|
+
/** Union type for all command results */
|
|
61
|
+
export type AnyCommandResult<T> = T extends unknown ? SingleResult<T> | ListResult<T> : never;
|
|
62
|
+
/** Base interface for command results (deprecated, use SingleResult or ListResult) */
|
|
63
|
+
export type CommandResult<T> = SingleResult<T> | ListResult<T>;
|
|
64
|
+
/** Structured error for command failures */
|
|
65
|
+
export interface CommandError {
|
|
66
|
+
/** Machine-readable error code */
|
|
67
|
+
code: string;
|
|
68
|
+
/** Human-readable message */
|
|
69
|
+
message: string;
|
|
70
|
+
/** Additional context */
|
|
71
|
+
details?: unknown;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output format types for the Paseo CLI.
|
|
3
|
+
*
|
|
4
|
+
* This module defines the structured data types used by the output abstraction layer.
|
|
5
|
+
* Commands return CommandResult<T> which contains both data and rendering metadata.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command wrapper for automatic output rendering.
|
|
3
|
+
*
|
|
4
|
+
* Wraps command handlers to automatically render results and handle errors.
|
|
5
|
+
*/
|
|
6
|
+
import type { Command } from "commander";
|
|
7
|
+
import type { AnyCommandResult, OutputOptions } from "./types.js";
|
|
8
|
+
/** Options that include output settings from global options */
|
|
9
|
+
export interface CommandOptions extends Partial<OutputOptions> {
|
|
10
|
+
/** Daemon host target from --host option */
|
|
11
|
+
host?: string;
|
|
12
|
+
/** JSON output flag from --json option */
|
|
13
|
+
json?: boolean;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Wrap a command handler to automatically render output.
|
|
18
|
+
*
|
|
19
|
+
* The wrapped handler should return a CommandResult. The wrapper will:
|
|
20
|
+
* 1. Call the handler
|
|
21
|
+
* 2. Render the result using the appropriate format
|
|
22
|
+
* 3. Write to stdout
|
|
23
|
+
* 4. Handle errors by rendering to stderr and exiting with code 1
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* program
|
|
28
|
+
* .command('list')
|
|
29
|
+
* .action(withOutput(async (options) => {
|
|
30
|
+
* const data = await fetchData()
|
|
31
|
+
* return { type: 'list', data, schema }
|
|
32
|
+
* }))
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function withOutput<T, Args extends unknown[]>(handler: (...args: [...Args, CommandOptions, Command]) => Promise<AnyCommandResult<T>>): (...args: [...Args, CommandOptions, Command]) => Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Helper to create output options from partial input.
|
|
38
|
+
* Useful for testing or manual rendering.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createOutputOptions(partial?: Partial<OutputOptions>): OutputOptions;
|
|
41
|
+
//# sourceMappingURL=with-output.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command wrapper for automatic output rendering.
|
|
3
|
+
*
|
|
4
|
+
* Wraps command handlers to automatically render results and handle errors.
|
|
5
|
+
*/
|
|
6
|
+
import { render, renderError, toCommandError, defaultOutputOptions } from "./render.js";
|
|
7
|
+
import { withGlobalOptions } from "../utils/command-options.js";
|
|
8
|
+
function normalizeFormat(raw) {
|
|
9
|
+
const value = typeof raw === "string" ? raw.trim().toLowerCase() : "";
|
|
10
|
+
// Common user expectation: "cli" means "table/human"
|
|
11
|
+
if (value === "cli")
|
|
12
|
+
return "table";
|
|
13
|
+
if (value === "table" || value === "json" || value === "yaml")
|
|
14
|
+
return value;
|
|
15
|
+
const error = {
|
|
16
|
+
code: "INVALID_FORMAT",
|
|
17
|
+
message: `Unsupported output format: ${String(raw)}`,
|
|
18
|
+
details: "Supported formats: table, json, yaml",
|
|
19
|
+
};
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
/** Extract output options from command options */
|
|
23
|
+
function extractOutputOptions(options) {
|
|
24
|
+
const hasStructuredOutputSchema = typeof options.outputSchema === "string" && options.outputSchema.trim().length > 0;
|
|
25
|
+
if (hasStructuredOutputSchema) {
|
|
26
|
+
return {
|
|
27
|
+
format: "json",
|
|
28
|
+
quiet: false,
|
|
29
|
+
noHeaders: options.headers === false,
|
|
30
|
+
noColor: options.color === false,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
format: options.json ? "json" : normalizeFormat(options.format ?? defaultOutputOptions.format),
|
|
35
|
+
quiet: options.quiet ?? defaultOutputOptions.quiet,
|
|
36
|
+
noHeaders: options.headers === false, // Commander uses --no-headers -> headers: false
|
|
37
|
+
noColor: options.color === false, // Commander uses --no-color -> color: false
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Wrap a command handler to automatically render output.
|
|
42
|
+
*
|
|
43
|
+
* The wrapped handler should return a CommandResult. The wrapper will:
|
|
44
|
+
* 1. Call the handler
|
|
45
|
+
* 2. Render the result using the appropriate format
|
|
46
|
+
* 3. Write to stdout
|
|
47
|
+
* 4. Handle errors by rendering to stderr and exiting with code 1
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* program
|
|
52
|
+
* .command('list')
|
|
53
|
+
* .action(withOutput(async (options) => {
|
|
54
|
+
* const data = await fetchData()
|
|
55
|
+
* return { type: 'list', data, schema }
|
|
56
|
+
* }))
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export function withOutput(handler) {
|
|
60
|
+
return withGlobalOptions(async (...args) => {
|
|
61
|
+
const options = args[args.length - 2];
|
|
62
|
+
const outputOptions = extractOutputOptions(options);
|
|
63
|
+
try {
|
|
64
|
+
const result = await handler(...args);
|
|
65
|
+
const output = render(result, outputOptions);
|
|
66
|
+
if (output) {
|
|
67
|
+
process.stdout.write(output + "\n");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
const commandError = toCommandError(error);
|
|
72
|
+
const errorOutput = renderError(commandError, outputOptions);
|
|
73
|
+
process.stderr.write(errorOutput + "\n");
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Helper to create output options from partial input.
|
|
80
|
+
* Useful for testing or manual rendering.
|
|
81
|
+
*/
|
|
82
|
+
export function createOutputOptions(partial = {}) {
|
|
83
|
+
return { ...defaultOutputOptions, ...partial };
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=with-output.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YAML renderer for CLI output.
|
|
3
|
+
*
|
|
4
|
+
* Renders structured data as YAML for machine consumption and human readability.
|
|
5
|
+
*/
|
|
6
|
+
import type { AnyCommandResult, OutputOptions } from "./types.js";
|
|
7
|
+
/** Render command result as YAML */
|
|
8
|
+
export declare function renderYaml<T>(result: AnyCommandResult<T>, _options: OutputOptions): string;
|
|
9
|
+
/** Render a single item as YAML document (for streaming) */
|
|
10
|
+
export declare function renderYamlDoc<T>(item: T, serialize?: (data: T) => unknown): string;
|
|
11
|
+
//# sourceMappingURL=yaml.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YAML renderer for CLI output.
|
|
3
|
+
*
|
|
4
|
+
* Renders structured data as YAML for machine consumption and human readability.
|
|
5
|
+
*/
|
|
6
|
+
import YAML from "yaml";
|
|
7
|
+
/** Render command result as YAML */
|
|
8
|
+
export function renderYaml(result, _options) {
|
|
9
|
+
const { schema } = result;
|
|
10
|
+
// Apply custom serializer if provided
|
|
11
|
+
if (schema.serialize) {
|
|
12
|
+
if (result.type === "list") {
|
|
13
|
+
// If all items serialize to the same object, return just one
|
|
14
|
+
// This handles the case where a list of key-value rows should serialize
|
|
15
|
+
// to a single structured object
|
|
16
|
+
const serialized = result.data.map((item) => schema.serialize(item));
|
|
17
|
+
if (serialized.length > 0) {
|
|
18
|
+
const first = JSON.stringify(serialized[0]);
|
|
19
|
+
const allSame = serialized.every((s) => JSON.stringify(s) === first);
|
|
20
|
+
if (allSame) {
|
|
21
|
+
return YAML.stringify(serialized[0]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return YAML.stringify(serialized);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const serialized = schema.serialize(result.data);
|
|
28
|
+
return YAML.stringify(serialized);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return YAML.stringify(result.data);
|
|
32
|
+
}
|
|
33
|
+
/** Render a single item as YAML document (for streaming) */
|
|
34
|
+
export function renderYamlDoc(item, serialize) {
|
|
35
|
+
const output = serialize ? serialize(item) : item;
|
|
36
|
+
return YAML.stringify(output);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=yaml.js.map
|
package/dist/run.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface RunCliOptions {
|
|
2
|
+
cwd?: string;
|
|
3
|
+
nodeArgv?: [string, string];
|
|
4
|
+
}
|
|
5
|
+
export declare function createCliParseArgv(input: {
|
|
6
|
+
argv: string[];
|
|
7
|
+
cwd: string;
|
|
8
|
+
nodeArgv?: [string, string];
|
|
9
|
+
}): string[] | {
|
|
10
|
+
kind: "open-project";
|
|
11
|
+
resolvedPath: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function runCli(argv: string[], options?: RunCliOptions): Promise<number>;
|
|
14
|
+
//# sourceMappingURL=run.d.ts.map
|
package/dist/run.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createCli } from "./cli.js";
|
|
2
|
+
import { classifyInvocation } from "./classify.js";
|
|
3
|
+
import { openDesktopWithProject } from "./commands/open.js";
|
|
4
|
+
export function createCliParseArgv(input) {
|
|
5
|
+
const program = createCli();
|
|
6
|
+
const knownCommands = new Set(program.commands.map((command) => command.name()));
|
|
7
|
+
const invocation = classifyInvocation({
|
|
8
|
+
argv: input.argv,
|
|
9
|
+
knownCommands,
|
|
10
|
+
cwd: input.cwd,
|
|
11
|
+
});
|
|
12
|
+
if (invocation.kind === "open-project") {
|
|
13
|
+
return invocation;
|
|
14
|
+
}
|
|
15
|
+
const nodeArgv = input.nodeArgv ?? ["paseo", "paseo"];
|
|
16
|
+
const isOnboardRootFlag = invocation.argv[0] === "--relay" || invocation.argv[0] === "--no-relay";
|
|
17
|
+
let cliArgv = invocation.argv;
|
|
18
|
+
if (invocation.argv.length === 0) {
|
|
19
|
+
cliArgv = ["onboard"];
|
|
20
|
+
}
|
|
21
|
+
else if (isOnboardRootFlag) {
|
|
22
|
+
cliArgv = ["onboard", ...invocation.argv];
|
|
23
|
+
}
|
|
24
|
+
return [...nodeArgv, ...cliArgv];
|
|
25
|
+
}
|
|
26
|
+
export async function runCli(argv, options = {}) {
|
|
27
|
+
const parseArgv = createCliParseArgv({
|
|
28
|
+
argv,
|
|
29
|
+
cwd: options.cwd ?? process.cwd(),
|
|
30
|
+
nodeArgv: options.nodeArgv,
|
|
31
|
+
});
|
|
32
|
+
if (!Array.isArray(parseArgv)) {
|
|
33
|
+
await openDesktopWithProject(parseArgv.resolvedPath);
|
|
34
|
+
return typeof process.exitCode === "number" ? process.exitCode : 0;
|
|
35
|
+
}
|
|
36
|
+
const program = createCli();
|
|
37
|
+
await program.parseAsync(parseArgv, { from: "node" });
|
|
38
|
+
return typeof process.exitCode === "number" ? process.exitCode : 0;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type SshTransportTarget } from "@camerontaylor/paseo-protocol/ssh-transport";
|
|
2
|
+
export interface SshTunnel {
|
|
3
|
+
endpoint: string;
|
|
4
|
+
close(): void;
|
|
5
|
+
failureDetail(): string | null;
|
|
6
|
+
}
|
|
7
|
+
export declare function resolveSshFailureDetail(failure: string | null, stderr: string): string | null;
|
|
8
|
+
export declare function createSshTunnel(target: SshTransportTarget): Promise<SshTunnel>;
|
|
9
|
+
//# sourceMappingURL=ssh-tunnel.d.ts.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createServer } from "node:net";
|
|
3
|
+
import { buildSshTunnelArgs } from "@camerontaylor/paseo-protocol/ssh-transport";
|
|
4
|
+
const SSH_STDERR_LIMIT = 8192;
|
|
5
|
+
function formatSshFailure(stderr, code, signal) {
|
|
6
|
+
const detail = stderr.trim();
|
|
7
|
+
if (detail)
|
|
8
|
+
return detail;
|
|
9
|
+
if (signal)
|
|
10
|
+
return `ssh exited with signal ${signal}`;
|
|
11
|
+
return `ssh exited with code ${code ?? "unknown"}`;
|
|
12
|
+
}
|
|
13
|
+
export function resolveSshFailureDetail(failure, stderr) {
|
|
14
|
+
return failure ?? (stderr.trim() || null);
|
|
15
|
+
}
|
|
16
|
+
export function createSshTunnel(target) {
|
|
17
|
+
let server = null;
|
|
18
|
+
let socket = null;
|
|
19
|
+
let child = null;
|
|
20
|
+
let stderr = "";
|
|
21
|
+
let failure = null;
|
|
22
|
+
function close() {
|
|
23
|
+
server?.close();
|
|
24
|
+
server = null;
|
|
25
|
+
socket?.destroy();
|
|
26
|
+
socket = null;
|
|
27
|
+
if (child && !child.killed)
|
|
28
|
+
child.kill();
|
|
29
|
+
child = null;
|
|
30
|
+
}
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
server = createServer((acceptedSocket) => {
|
|
33
|
+
socket = acceptedSocket;
|
|
34
|
+
server?.close();
|
|
35
|
+
server = null;
|
|
36
|
+
child = spawn("ssh", buildSshTunnelArgs(target), {
|
|
37
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
38
|
+
windowsHide: true,
|
|
39
|
+
});
|
|
40
|
+
child.stderr.on("data", (chunk) => {
|
|
41
|
+
stderr = `${stderr}${chunk.toString()}`.slice(-SSH_STDERR_LIMIT);
|
|
42
|
+
});
|
|
43
|
+
child.on("error", (error) => {
|
|
44
|
+
failure = error.message;
|
|
45
|
+
acceptedSocket.destroy(error);
|
|
46
|
+
});
|
|
47
|
+
child.on("exit", (code, signal) => {
|
|
48
|
+
if (code !== 0 || signal)
|
|
49
|
+
failure = formatSshFailure(stderr, code, signal);
|
|
50
|
+
acceptedSocket.destroy(failure ? new Error(failure) : undefined);
|
|
51
|
+
});
|
|
52
|
+
acceptedSocket.on("error", () => undefined);
|
|
53
|
+
acceptedSocket.on("close", () => {
|
|
54
|
+
if (child && !child.killed)
|
|
55
|
+
child.kill();
|
|
56
|
+
});
|
|
57
|
+
acceptedSocket.pipe(child.stdin);
|
|
58
|
+
child.stdout.pipe(acceptedSocket);
|
|
59
|
+
});
|
|
60
|
+
server.once("error", (error) => {
|
|
61
|
+
close();
|
|
62
|
+
reject(error);
|
|
63
|
+
});
|
|
64
|
+
server.listen(0, "127.0.0.1", () => {
|
|
65
|
+
const address = server?.address();
|
|
66
|
+
if (!address || typeof address === "string") {
|
|
67
|
+
close();
|
|
68
|
+
reject(new Error("Failed to allocate the SSH tunnel port"));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
resolve({
|
|
72
|
+
endpoint: `127.0.0.1:${address.port}`,
|
|
73
|
+
close,
|
|
74
|
+
failureDetail: () => resolveSshFailureDetail(failure, stderr),
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=ssh-tunnel.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
const CLIENT_SESSION_KEY_FILE = join(process.env.PASEO_HOME ?? join(homedir(), ".paseo"), "cli-client-id");
|
|
6
|
+
let cachedClientId = null;
|
|
7
|
+
function normalizeClientId(value) {
|
|
8
|
+
const trimmed = value.trim();
|
|
9
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
10
|
+
}
|
|
11
|
+
function generateClientId() {
|
|
12
|
+
return `cid_${randomUUID().replace(/-/g, "")}`;
|
|
13
|
+
}
|
|
14
|
+
export async function getOrCreateCliClientId() {
|
|
15
|
+
if (cachedClientId) {
|
|
16
|
+
return cachedClientId;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const existing = normalizeClientId(await readFile(CLIENT_SESSION_KEY_FILE, "utf8"));
|
|
20
|
+
if (existing) {
|
|
21
|
+
cachedClientId = existing;
|
|
22
|
+
return existing;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
const code = error?.code;
|
|
27
|
+
if (code !== "ENOENT") {
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const nextValue = generateClientId();
|
|
32
|
+
await mkdir(dirname(CLIENT_SESSION_KEY_FILE), { recursive: true });
|
|
33
|
+
await writeFile(CLIENT_SESSION_KEY_FILE, nextValue, { mode: 0o600 });
|
|
34
|
+
cachedClientId = nextValue;
|
|
35
|
+
return nextValue;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=client-id.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { DaemonClient } from "@camerontaylor/paseo-client/internal/daemon-client";
|
|
2
|
+
export interface ConnectOptions {
|
|
3
|
+
host?: string;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface DaemonConnectionCommandError {
|
|
7
|
+
code: "DAEMON_NOT_RUNNING";
|
|
8
|
+
message: string;
|
|
9
|
+
details: string;
|
|
10
|
+
}
|
|
11
|
+
type DaemonTarget = {
|
|
12
|
+
type: "tcp";
|
|
13
|
+
url: string;
|
|
14
|
+
} | {
|
|
15
|
+
type: "ipc";
|
|
16
|
+
url: string;
|
|
17
|
+
socketPath: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Get the daemon host from environment or options
|
|
21
|
+
*/
|
|
22
|
+
export declare function getDaemonHost(options?: ConnectOptions): string;
|
|
23
|
+
export declare function buildDaemonConnectionCommandError(options: {
|
|
24
|
+
host?: string;
|
|
25
|
+
error: unknown;
|
|
26
|
+
}): DaemonConnectionCommandError;
|
|
27
|
+
export declare function normalizeDaemonHost(raw: string): string | null;
|
|
28
|
+
export declare function resolveDefaultDaemonHost(env?: NodeJS.ProcessEnv): string;
|
|
29
|
+
export declare function resolveDefaultDaemonHosts(env?: NodeJS.ProcessEnv): string[];
|
|
30
|
+
export declare function getExplicitDaemonHost(host: string | undefined, env?: NodeJS.ProcessEnv): string | undefined;
|
|
31
|
+
export declare function resolveDaemonTarget(host: string): DaemonTarget;
|
|
32
|
+
export declare function resolveDaemonPassword(host: string): string | undefined;
|
|
33
|
+
export declare function connectToDaemon(options?: ConnectOptions): Promise<DaemonClient>;
|
|
34
|
+
/**
|
|
35
|
+
* Try to connect to the daemon, returns null if connection fails
|
|
36
|
+
*/
|
|
37
|
+
export declare function tryConnectToDaemon(options?: ConnectOptions): Promise<DaemonClient | null>;
|
|
38
|
+
/** Minimal agent type for ID resolution */
|
|
39
|
+
interface AgentLike {
|
|
40
|
+
id: string;
|
|
41
|
+
title?: string | null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resolve an agent ID from a partial ID or name.
|
|
45
|
+
* Supports:
|
|
46
|
+
* - Full ID match
|
|
47
|
+
* - Prefix match (first N characters)
|
|
48
|
+
* - Title/name match (case-insensitive)
|
|
49
|
+
*
|
|
50
|
+
* Returns the full agent ID if found, null otherwise.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveAgentId(idOrName: string, agents: AgentLike[]): string | null;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=client.d.ts.map
|