opensteer 0.6.13 → 0.7.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.
Files changed (62) hide show
  1. package/README.md +256 -184
  2. package/dist/chunk-7QTHGTGN.js +32589 -0
  3. package/dist/chunk-7QTHGTGN.js.map +1 -0
  4. package/dist/cli/bin.cjs +38219 -0
  5. package/dist/cli/bin.cjs.map +1 -0
  6. package/dist/cli/bin.d.cts +1 -0
  7. package/dist/cli/bin.d.ts +1 -0
  8. package/dist/cli/bin.js +5612 -0
  9. package/dist/cli/bin.js.map +1 -0
  10. package/dist/index.cjs +31327 -16009
  11. package/dist/index.cjs.map +1 -0
  12. package/dist/index.d.cts +4440 -670
  13. package/dist/index.d.ts +4440 -670
  14. package/dist/index.js +438 -378
  15. package/dist/index.js.map +1 -0
  16. package/package.json +58 -62
  17. package/skills/README.md +21 -20
  18. package/skills/opensteer/SKILL.md +60 -194
  19. package/skills/opensteer/references/cli-reference.md +69 -113
  20. package/skills/opensteer/references/request-workflow.md +81 -0
  21. package/skills/opensteer/references/sdk-reference.md +101 -154
  22. package/CHANGELOG.md +0 -75
  23. package/bin/opensteer.mjs +0 -1423
  24. package/dist/browser-profile-client-CGXc0-P9.d.cts +0 -228
  25. package/dist/browser-profile-client-DHLzMf-K.d.ts +0 -228
  26. package/dist/chunk-2ES46WCO.js +0 -1437
  27. package/dist/chunk-3H5RRIMZ.js +0 -69
  28. package/dist/chunk-AVXUMEDG.js +0 -62
  29. package/dist/chunk-DN3GI5CH.js +0 -57
  30. package/dist/chunk-FAHE5DB2.js +0 -190
  31. package/dist/chunk-HBTSQ2V4.js +0 -15259
  32. package/dist/chunk-K5CL76MG.js +0 -81
  33. package/dist/chunk-U724TBY6.js +0 -1262
  34. package/dist/chunk-ZRCFF546.js +0 -77
  35. package/dist/cli/auth.cjs +0 -2022
  36. package/dist/cli/auth.d.cts +0 -114
  37. package/dist/cli/auth.d.ts +0 -114
  38. package/dist/cli/auth.js +0 -15
  39. package/dist/cli/local-profile.cjs +0 -197
  40. package/dist/cli/local-profile.d.cts +0 -18
  41. package/dist/cli/local-profile.d.ts +0 -18
  42. package/dist/cli/local-profile.js +0 -97
  43. package/dist/cli/profile.cjs +0 -18548
  44. package/dist/cli/profile.d.cts +0 -79
  45. package/dist/cli/profile.d.ts +0 -79
  46. package/dist/cli/profile.js +0 -1328
  47. package/dist/cli/server.cjs +0 -17232
  48. package/dist/cli/server.d.cts +0 -2
  49. package/dist/cli/server.d.ts +0 -2
  50. package/dist/cli/server.js +0 -977
  51. package/dist/cli/skills-installer.cjs +0 -230
  52. package/dist/cli/skills-installer.d.cts +0 -28
  53. package/dist/cli/skills-installer.d.ts +0 -28
  54. package/dist/cli/skills-installer.js +0 -201
  55. package/dist/extractor-4Q3TFZJB.js +0 -8
  56. package/dist/resolver-MGN64KCP.js +0 -7
  57. package/dist/types-Cr10igF3.d.cts +0 -345
  58. package/dist/types-Cr10igF3.d.ts +0 -345
  59. package/skills/electron/SKILL.md +0 -87
  60. package/skills/electron/references/opensteer-electron-recipes.md +0 -88
  61. package/skills/electron/references/opensteer-electron-workflow.md +0 -85
  62. package/skills/opensteer/references/examples.md +0 -118
@@ -1,114 +0,0 @@
1
- import { O as OpensteerAuthScheme } from '../types-Cr10igF3.cjs';
2
- import 'playwright';
3
-
4
- interface StoredMachineCloudCredential {
5
- baseUrl: string;
6
- scope: string[];
7
- accessToken: string;
8
- refreshToken: string;
9
- obtainedAt: number;
10
- expiresAt: number;
11
- }
12
- interface WriteMachineCloudCredentialArgs {
13
- baseUrl: string;
14
- scope: string[];
15
- accessToken: string;
16
- refreshToken: string;
17
- obtainedAt: number;
18
- expiresAt: number;
19
- }
20
- interface CloudCredentialStoreTarget {
21
- baseUrl: string;
22
- }
23
-
24
- type AuthFetchFn = (input: string, init?: RequestInit) => Promise<Response>;
25
- type OpenExternalUrlFn = (url: string) => boolean | Promise<boolean>;
26
- interface CloudCredentialStore {
27
- readCloudCredential(target: CloudCredentialStoreTarget): StoredMachineCloudCredential | null;
28
- writeCloudCredential(args: WriteMachineCloudCredentialArgs): void;
29
- readActiveCloudTarget(): CloudCredentialStoreTarget | null;
30
- writeActiveCloudTarget(target: CloudCredentialStoreTarget): void;
31
- clearCloudCredential(target: CloudCredentialStoreTarget): void;
32
- }
33
- interface EnsuredCloudAuthContext {
34
- token: string;
35
- authScheme: OpensteerAuthScheme;
36
- source: 'flag' | 'env' | 'saved';
37
- kind: 'api-key' | 'access-token';
38
- baseUrl: string;
39
- }
40
- interface EnsureCloudCredentialsOptions {
41
- commandName: string;
42
- env?: Record<string, string | undefined>;
43
- store?: CloudCredentialStore;
44
- apiKeyFlag?: string;
45
- accessTokenFlag?: string;
46
- baseUrl?: string;
47
- interactive?: boolean;
48
- autoLoginIfNeeded?: boolean;
49
- writeProgress?: (message: string) => void;
50
- writeStdout?: (message: string) => void;
51
- writeStderr?: (message: string) => void;
52
- fetchFn?: AuthFetchFn;
53
- sleep?: (ms: number) => Promise<void>;
54
- now?: () => number;
55
- openExternalUrl?: OpenExternalUrlFn;
56
- }
57
- interface EnsureCloudCredentialsForOpenOptions {
58
- scopeDir: string;
59
- env?: Record<string, string | undefined>;
60
- store?: CloudCredentialStore;
61
- apiKeyFlag?: string;
62
- accessTokenFlag?: string;
63
- interactive?: boolean;
64
- writeProgress?: (message: string) => void;
65
- writeStderr?: (message: string) => void;
66
- fetchFn?: AuthFetchFn;
67
- sleep?: (ms: number) => Promise<void>;
68
- now?: () => number;
69
- openExternalUrl?: OpenExternalUrlFn;
70
- }
71
- interface AuthCliDeps {
72
- env: Record<string, string | undefined>;
73
- store: CloudCredentialStore;
74
- fetchFn: AuthFetchFn;
75
- writeStdout: (message: string) => void;
76
- writeStderr: (message: string) => void;
77
- isInteractive: () => boolean;
78
- sleep: (ms: number) => Promise<void>;
79
- now: () => number;
80
- openExternalUrl: OpenExternalUrlFn;
81
- }
82
- interface AuthCommonArgs {
83
- baseUrl?: string;
84
- json?: boolean;
85
- }
86
- interface AuthLoginArgs extends AuthCommonArgs {
87
- openBrowser: boolean;
88
- }
89
- interface AuthStatusArgs extends AuthCommonArgs {
90
- }
91
- interface AuthLogoutArgs extends AuthCommonArgs {
92
- }
93
- type ParsedAuthArgs = {
94
- mode: 'help';
95
- } | {
96
- mode: 'error';
97
- error: string;
98
- } | {
99
- mode: 'login';
100
- args: AuthLoginArgs;
101
- } | {
102
- mode: 'status';
103
- args: AuthStatusArgs;
104
- } | {
105
- mode: 'logout';
106
- args: AuthLogoutArgs;
107
- };
108
- declare function parseOpensteerAuthArgs(rawArgs: string[]): ParsedAuthArgs;
109
- declare function isCloudModeEnabledForRootDir(rootDir: string, env?: Record<string, string | undefined>): boolean;
110
- declare function ensureCloudCredentialsForOpenCommand(options: EnsureCloudCredentialsForOpenOptions): Promise<EnsuredCloudAuthContext | null>;
111
- declare function ensureCloudCredentialsForCommand(options: EnsureCloudCredentialsOptions): Promise<EnsuredCloudAuthContext>;
112
- declare function runOpensteerAuthCli(rawArgs: string[], overrideDeps?: Partial<AuthCliDeps>): Promise<number>;
113
-
114
- export { type AuthFetchFn, type CloudCredentialStore, type EnsureCloudCredentialsForOpenOptions, type EnsureCloudCredentialsOptions, type EnsuredCloudAuthContext, type OpenExternalUrlFn, ensureCloudCredentialsForCommand, ensureCloudCredentialsForOpenCommand, isCloudModeEnabledForRootDir, parseOpensteerAuthArgs, runOpensteerAuthCli };
@@ -1,114 +0,0 @@
1
- import { O as OpensteerAuthScheme } from '../types-Cr10igF3.js';
2
- import 'playwright';
3
-
4
- interface StoredMachineCloudCredential {
5
- baseUrl: string;
6
- scope: string[];
7
- accessToken: string;
8
- refreshToken: string;
9
- obtainedAt: number;
10
- expiresAt: number;
11
- }
12
- interface WriteMachineCloudCredentialArgs {
13
- baseUrl: string;
14
- scope: string[];
15
- accessToken: string;
16
- refreshToken: string;
17
- obtainedAt: number;
18
- expiresAt: number;
19
- }
20
- interface CloudCredentialStoreTarget {
21
- baseUrl: string;
22
- }
23
-
24
- type AuthFetchFn = (input: string, init?: RequestInit) => Promise<Response>;
25
- type OpenExternalUrlFn = (url: string) => boolean | Promise<boolean>;
26
- interface CloudCredentialStore {
27
- readCloudCredential(target: CloudCredentialStoreTarget): StoredMachineCloudCredential | null;
28
- writeCloudCredential(args: WriteMachineCloudCredentialArgs): void;
29
- readActiveCloudTarget(): CloudCredentialStoreTarget | null;
30
- writeActiveCloudTarget(target: CloudCredentialStoreTarget): void;
31
- clearCloudCredential(target: CloudCredentialStoreTarget): void;
32
- }
33
- interface EnsuredCloudAuthContext {
34
- token: string;
35
- authScheme: OpensteerAuthScheme;
36
- source: 'flag' | 'env' | 'saved';
37
- kind: 'api-key' | 'access-token';
38
- baseUrl: string;
39
- }
40
- interface EnsureCloudCredentialsOptions {
41
- commandName: string;
42
- env?: Record<string, string | undefined>;
43
- store?: CloudCredentialStore;
44
- apiKeyFlag?: string;
45
- accessTokenFlag?: string;
46
- baseUrl?: string;
47
- interactive?: boolean;
48
- autoLoginIfNeeded?: boolean;
49
- writeProgress?: (message: string) => void;
50
- writeStdout?: (message: string) => void;
51
- writeStderr?: (message: string) => void;
52
- fetchFn?: AuthFetchFn;
53
- sleep?: (ms: number) => Promise<void>;
54
- now?: () => number;
55
- openExternalUrl?: OpenExternalUrlFn;
56
- }
57
- interface EnsureCloudCredentialsForOpenOptions {
58
- scopeDir: string;
59
- env?: Record<string, string | undefined>;
60
- store?: CloudCredentialStore;
61
- apiKeyFlag?: string;
62
- accessTokenFlag?: string;
63
- interactive?: boolean;
64
- writeProgress?: (message: string) => void;
65
- writeStderr?: (message: string) => void;
66
- fetchFn?: AuthFetchFn;
67
- sleep?: (ms: number) => Promise<void>;
68
- now?: () => number;
69
- openExternalUrl?: OpenExternalUrlFn;
70
- }
71
- interface AuthCliDeps {
72
- env: Record<string, string | undefined>;
73
- store: CloudCredentialStore;
74
- fetchFn: AuthFetchFn;
75
- writeStdout: (message: string) => void;
76
- writeStderr: (message: string) => void;
77
- isInteractive: () => boolean;
78
- sleep: (ms: number) => Promise<void>;
79
- now: () => number;
80
- openExternalUrl: OpenExternalUrlFn;
81
- }
82
- interface AuthCommonArgs {
83
- baseUrl?: string;
84
- json?: boolean;
85
- }
86
- interface AuthLoginArgs extends AuthCommonArgs {
87
- openBrowser: boolean;
88
- }
89
- interface AuthStatusArgs extends AuthCommonArgs {
90
- }
91
- interface AuthLogoutArgs extends AuthCommonArgs {
92
- }
93
- type ParsedAuthArgs = {
94
- mode: 'help';
95
- } | {
96
- mode: 'error';
97
- error: string;
98
- } | {
99
- mode: 'login';
100
- args: AuthLoginArgs;
101
- } | {
102
- mode: 'status';
103
- args: AuthStatusArgs;
104
- } | {
105
- mode: 'logout';
106
- args: AuthLogoutArgs;
107
- };
108
- declare function parseOpensteerAuthArgs(rawArgs: string[]): ParsedAuthArgs;
109
- declare function isCloudModeEnabledForRootDir(rootDir: string, env?: Record<string, string | undefined>): boolean;
110
- declare function ensureCloudCredentialsForOpenCommand(options: EnsureCloudCredentialsForOpenOptions): Promise<EnsuredCloudAuthContext | null>;
111
- declare function ensureCloudCredentialsForCommand(options: EnsureCloudCredentialsOptions): Promise<EnsuredCloudAuthContext>;
112
- declare function runOpensteerAuthCli(rawArgs: string[], overrideDeps?: Partial<AuthCliDeps>): Promise<number>;
113
-
114
- export { type AuthFetchFn, type CloudCredentialStore, type EnsureCloudCredentialsForOpenOptions, type EnsureCloudCredentialsOptions, type EnsuredCloudAuthContext, type OpenExternalUrlFn, ensureCloudCredentialsForCommand, ensureCloudCredentialsForOpenCommand, isCloudModeEnabledForRootDir, parseOpensteerAuthArgs, runOpensteerAuthCli };
package/dist/cli/auth.js DELETED
@@ -1,15 +0,0 @@
1
- import {
2
- ensureCloudCredentialsForCommand,
3
- ensureCloudCredentialsForOpenCommand,
4
- isCloudModeEnabledForRootDir,
5
- parseOpensteerAuthArgs,
6
- runOpensteerAuthCli
7
- } from "../chunk-U724TBY6.js";
8
- import "../chunk-2ES46WCO.js";
9
- export {
10
- ensureCloudCredentialsForCommand,
11
- ensureCloudCredentialsForOpenCommand,
12
- isCloudModeEnabledForRootDir,
13
- parseOpensteerAuthArgs,
14
- runOpensteerAuthCli
15
- };
@@ -1,197 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/cli/local-profile.ts
21
- var local_profile_exports = {};
22
- __export(local_profile_exports, {
23
- parseOpensteerLocalProfileArgs: () => parseOpensteerLocalProfileArgs,
24
- runOpensteerLocalProfileCli: () => runOpensteerLocalProfileCli
25
- });
26
- module.exports = __toCommonJS(local_profile_exports);
27
-
28
- // src/browser/chrome.ts
29
- var import_os = require("os");
30
- var import_path = require("path");
31
- var import_fs = require("fs");
32
- function detectChromePaths() {
33
- const os = (0, import_os.platform)();
34
- if (os === "darwin") {
35
- const executable2 = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
36
- return {
37
- executable: (0, import_fs.existsSync)(executable2) ? executable2 : null,
38
- defaultUserDataDir: (0, import_path.join)(
39
- (0, import_os.homedir)(),
40
- "Library",
41
- "Application Support",
42
- "Google",
43
- "Chrome"
44
- )
45
- };
46
- }
47
- if (os === "win32") {
48
- const executable2 = (0, import_path.join)(
49
- process.env.PROGRAMFILES || "C:\\Program Files",
50
- "Google",
51
- "Chrome",
52
- "Application",
53
- "chrome.exe"
54
- );
55
- return {
56
- executable: (0, import_fs.existsSync)(executable2) ? executable2 : null,
57
- defaultUserDataDir: (0, import_path.join)(
58
- process.env.LOCALAPPDATA || (0, import_path.join)((0, import_os.homedir)(), "AppData", "Local"),
59
- "Google",
60
- "Chrome",
61
- "User Data"
62
- )
63
- };
64
- }
65
- const executable = "/usr/bin/google-chrome";
66
- return {
67
- executable: (0, import_fs.existsSync)(executable) ? executable : null,
68
- defaultUserDataDir: (0, import_path.join)((0, import_os.homedir)(), ".config", "google-chrome")
69
- };
70
- }
71
- function expandHome(p) {
72
- if (p.startsWith("~/") || p === "~") {
73
- return (0, import_path.join)((0, import_os.homedir)(), p.slice(1));
74
- }
75
- return p;
76
- }
77
- function listLocalChromeProfiles(userDataDir = detectChromePaths().defaultUserDataDir) {
78
- const resolvedUserDataDir = expandHome(userDataDir);
79
- const localStatePath = (0, import_path.join)(resolvedUserDataDir, "Local State");
80
- if (!(0, import_fs.existsSync)(localStatePath)) {
81
- return [];
82
- }
83
- try {
84
- const raw = JSON.parse((0, import_fs.readFileSync)(localStatePath, "utf-8"));
85
- const infoCache = raw && typeof raw === "object" && !Array.isArray(raw) && raw.profile && typeof raw.profile === "object" && !Array.isArray(raw.profile) ? raw.profile.info_cache : void 0;
86
- if (!infoCache || typeof infoCache !== "object") {
87
- return [];
88
- }
89
- return Object.entries(infoCache).map(([directory, info]) => {
90
- const record = info && typeof info === "object" && !Array.isArray(info) ? info : {};
91
- const name = typeof record.name === "string" && record.name.trim() ? record.name.trim() : directory;
92
- return {
93
- directory,
94
- name
95
- };
96
- }).filter((profile) => profile.directory.trim().length > 0).sort(
97
- (left, right) => left.directory.localeCompare(right.directory)
98
- );
99
- } catch {
100
- return [];
101
- }
102
- }
103
-
104
- // src/cli/local-profile.ts
105
- var HELP_TEXT = `Usage: opensteer local-profile <command> [options]
106
-
107
- Inspect local Chrome profiles for real-browser mode.
108
-
109
- Commands:
110
- list List available local Chrome profiles
111
-
112
- Options:
113
- --json JSON output
114
- --user-data-dir <path> Override Chrome user-data root
115
- -h, --help Show this help
116
- `;
117
- function parseOpensteerLocalProfileArgs(argv) {
118
- const [command, ...rest] = argv;
119
- if (!command || command === "help" || command === "--help" || command === "-h") {
120
- return { mode: "help" };
121
- }
122
- if (command !== "list") {
123
- return {
124
- mode: "error",
125
- error: `Unsupported local-profile command "${command}".`
126
- };
127
- }
128
- let json = false;
129
- let userDataDir;
130
- for (let index = 0; index < rest.length; index += 1) {
131
- const arg = rest[index];
132
- if (arg === "--json") {
133
- json = true;
134
- continue;
135
- }
136
- if (arg === "--help" || arg === "-h") {
137
- return { mode: "help" };
138
- }
139
- if (arg === "--user-data-dir") {
140
- const value = rest[index + 1];
141
- if (!value) {
142
- return {
143
- mode: "error",
144
- error: "--user-data-dir requires a path value."
145
- };
146
- }
147
- userDataDir = value;
148
- index += 1;
149
- continue;
150
- }
151
- return {
152
- mode: "error",
153
- error: `Unsupported option "${arg}" for "opensteer local-profile list".`
154
- };
155
- }
156
- return {
157
- mode: "list",
158
- json,
159
- userDataDir
160
- };
161
- }
162
- async function runOpensteerLocalProfileCli(argv, overrides = {}) {
163
- const deps = {
164
- writeStdout: (message) => process.stdout.write(message),
165
- writeStderr: (message) => process.stderr.write(message),
166
- ...overrides
167
- };
168
- const parsed = parseOpensteerLocalProfileArgs(argv);
169
- if (parsed.mode === "help") {
170
- deps.writeStdout(HELP_TEXT);
171
- return 0;
172
- }
173
- if (parsed.mode === "error") {
174
- deps.writeStderr(`${parsed.error}
175
- `);
176
- return 1;
177
- }
178
- const profiles = listLocalChromeProfiles(parsed.userDataDir);
179
- if (parsed.json) {
180
- deps.writeStdout(JSON.stringify({ profiles }, null, 2));
181
- return 0;
182
- }
183
- if (!profiles.length) {
184
- deps.writeStdout("No local Chrome profiles found.\n");
185
- return 0;
186
- }
187
- for (const profile of profiles) {
188
- deps.writeStdout(`${profile.directory} ${profile.name}
189
- `);
190
- }
191
- return 0;
192
- }
193
- // Annotate the CommonJS export names for ESM import in node:
194
- 0 && (module.exports = {
195
- parseOpensteerLocalProfileArgs,
196
- runOpensteerLocalProfileCli
197
- });
@@ -1,18 +0,0 @@
1
- interface LocalProfileCliDeps {
2
- writeStdout: (message: string) => void;
3
- writeStderr: (message: string) => void;
4
- }
5
- type ParsedLocalProfileArgs = {
6
- mode: 'help';
7
- } | {
8
- mode: 'error';
9
- error: string;
10
- } | {
11
- mode: 'list';
12
- json: boolean;
13
- userDataDir?: string;
14
- };
15
- declare function parseOpensteerLocalProfileArgs(argv: string[]): ParsedLocalProfileArgs;
16
- declare function runOpensteerLocalProfileCli(argv: string[], overrides?: Partial<LocalProfileCliDeps>): Promise<number>;
17
-
18
- export { type LocalProfileCliDeps, type ParsedLocalProfileArgs, parseOpensteerLocalProfileArgs, runOpensteerLocalProfileCli };
@@ -1,18 +0,0 @@
1
- interface LocalProfileCliDeps {
2
- writeStdout: (message: string) => void;
3
- writeStderr: (message: string) => void;
4
- }
5
- type ParsedLocalProfileArgs = {
6
- mode: 'help';
7
- } | {
8
- mode: 'error';
9
- error: string;
10
- } | {
11
- mode: 'list';
12
- json: boolean;
13
- userDataDir?: string;
14
- };
15
- declare function parseOpensteerLocalProfileArgs(argv: string[]): ParsedLocalProfileArgs;
16
- declare function runOpensteerLocalProfileCli(argv: string[], overrides?: Partial<LocalProfileCliDeps>): Promise<number>;
17
-
18
- export { type LocalProfileCliDeps, type ParsedLocalProfileArgs, parseOpensteerLocalProfileArgs, runOpensteerLocalProfileCli };
@@ -1,97 +0,0 @@
1
- import {
2
- listLocalChromeProfiles
3
- } from "../chunk-K5CL76MG.js";
4
-
5
- // src/cli/local-profile.ts
6
- var HELP_TEXT = `Usage: opensteer local-profile <command> [options]
7
-
8
- Inspect local Chrome profiles for real-browser mode.
9
-
10
- Commands:
11
- list List available local Chrome profiles
12
-
13
- Options:
14
- --json JSON output
15
- --user-data-dir <path> Override Chrome user-data root
16
- -h, --help Show this help
17
- `;
18
- function parseOpensteerLocalProfileArgs(argv) {
19
- const [command, ...rest] = argv;
20
- if (!command || command === "help" || command === "--help" || command === "-h") {
21
- return { mode: "help" };
22
- }
23
- if (command !== "list") {
24
- return {
25
- mode: "error",
26
- error: `Unsupported local-profile command "${command}".`
27
- };
28
- }
29
- let json = false;
30
- let userDataDir;
31
- for (let index = 0; index < rest.length; index += 1) {
32
- const arg = rest[index];
33
- if (arg === "--json") {
34
- json = true;
35
- continue;
36
- }
37
- if (arg === "--help" || arg === "-h") {
38
- return { mode: "help" };
39
- }
40
- if (arg === "--user-data-dir") {
41
- const value = rest[index + 1];
42
- if (!value) {
43
- return {
44
- mode: "error",
45
- error: "--user-data-dir requires a path value."
46
- };
47
- }
48
- userDataDir = value;
49
- index += 1;
50
- continue;
51
- }
52
- return {
53
- mode: "error",
54
- error: `Unsupported option "${arg}" for "opensteer local-profile list".`
55
- };
56
- }
57
- return {
58
- mode: "list",
59
- json,
60
- userDataDir
61
- };
62
- }
63
- async function runOpensteerLocalProfileCli(argv, overrides = {}) {
64
- const deps = {
65
- writeStdout: (message) => process.stdout.write(message),
66
- writeStderr: (message) => process.stderr.write(message),
67
- ...overrides
68
- };
69
- const parsed = parseOpensteerLocalProfileArgs(argv);
70
- if (parsed.mode === "help") {
71
- deps.writeStdout(HELP_TEXT);
72
- return 0;
73
- }
74
- if (parsed.mode === "error") {
75
- deps.writeStderr(`${parsed.error}
76
- `);
77
- return 1;
78
- }
79
- const profiles = listLocalChromeProfiles(parsed.userDataDir);
80
- if (parsed.json) {
81
- deps.writeStdout(JSON.stringify({ profiles }, null, 2));
82
- return 0;
83
- }
84
- if (!profiles.length) {
85
- deps.writeStdout("No local Chrome profiles found.\n");
86
- return 0;
87
- }
88
- for (const profile of profiles) {
89
- deps.writeStdout(`${profile.directory} ${profile.name}
90
- `);
91
- }
92
- return 0;
93
- }
94
- export {
95
- parseOpensteerLocalProfileArgs,
96
- runOpensteerLocalProfileCli
97
- };