@keystrokehq/cli 0.0.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 (122) hide show
  1. package/AGENTS-blurb.md +123 -0
  2. package/LICENSE +42 -0
  3. package/README.md +177 -0
  4. package/THIRD_PARTY_NOTICES.md +16 -0
  5. package/bin/keystroke.mjs +107 -0
  6. package/dist/_manifest-JSRE3H8k.mjs +385 -0
  7. package/dist/agent-bundle-package-DWV6B_5q-BtV7Xycc.mjs +2344 -0
  8. package/dist/agent-manifest-CDnbkR2f.mjs +245 -0
  9. package/dist/agents-CZJGxVqV.mjs +228 -0
  10. package/dist/api-keys-D2lgguuY.mjs +40 -0
  11. package/dist/auth-DN2VusyU.mjs +59 -0
  12. package/dist/auth.handler-CT1BQUvu.mjs +340 -0
  13. package/dist/browser-qwFrUH82.mjs +24 -0
  14. package/dist/build-agents-BmM_AsSd-BGi9wtzt.mjs +514 -0
  15. package/dist/build-metadata-BWS7uhd_-DR8gJjTX.mjs +1422 -0
  16. package/dist/build-progress-DgYKb4hB.mjs +183 -0
  17. package/dist/build-tasks-CdihpudT-D5r5HUHe.mjs +91 -0
  18. package/dist/build-workflows-CfxBnIWh-CdYPv8w2.mjs +370 -0
  19. package/dist/build.handler-4799CjWH.mjs +36 -0
  20. package/dist/chunk-CH6r78ws.mjs +37 -0
  21. package/dist/clear-cache.handler-B9tqSoSM.mjs +11 -0
  22. package/dist/clear.handler-BTIXXPTJ.mjs +42 -0
  23. package/dist/clear.handler-BydlX-zE.mjs +11 -0
  24. package/dist/commander-DfTVqQ-3.mjs +133 -0
  25. package/dist/concurrency-gXn9Rw8x-DNl2YtrS.mjs +20 -0
  26. package/dist/connect-BUXkeH0F.mjs +43 -0
  27. package/dist/connect.handler-CYel9cy6.mjs +430 -0
  28. package/dist/constants-CPpPdSNg.mjs +8 -0
  29. package/dist/context-T7HZuB97.mjs +138 -0
  30. package/dist/credential-env-map-CI8yWHVy.mjs +28 -0
  31. package/dist/credential-schema-mismatch-BKo5PjcQ.mjs +76 -0
  32. package/dist/credentials-CvmjU0lK.mjs +171 -0
  33. package/dist/credentials-OfVHOtG3.mjs +151216 -0
  34. package/dist/current-deployment-workflow-poHt27i3.mjs +94 -0
  35. package/dist/current.handler-B8zKzfPp.mjs +21 -0
  36. package/dist/delete.handler-bAu1iXVQ.mjs +17 -0
  37. package/dist/deploy-7Jjls436.mjs +26 -0
  38. package/dist/deploy-BOPIpRWm.mjs +74 -0
  39. package/dist/deploy-progress-BmGUNFKg.mjs +70 -0
  40. package/dist/deploy.handler-BAzgiNhd.mjs +370 -0
  41. package/dist/detect-env-access-CwkOYeYM-D_BCZqV6.mjs +209 -0
  42. package/dist/diff-utils-NEfcjqxt.mjs +185 -0
  43. package/dist/diff.handler-Du7SY8K4.mjs +47 -0
  44. package/dist/dist-BkJUoBiG.mjs +1116 -0
  45. package/dist/dist-CUK7yBM0.mjs +308 -0
  46. package/dist/env-91KwMKov.mjs +140 -0
  47. package/dist/env.handler-BAzBuMzQ.mjs +277 -0
  48. package/dist/error-boundary-VL-JLfIa.mjs +34 -0
  49. package/dist/file-metadata-D1vm-XY2.mjs +191 -0
  50. package/dist/get-intrinsic-zLxwtrLK.mjs +658 -0
  51. package/dist/import-module-CV84H5fZ-B_CBCmb4.mjs +1747 -0
  52. package/dist/init-DpMCotSK.mjs +45 -0
  53. package/dist/init.handler-CPRnif52.mjs +585 -0
  54. package/dist/inspect.handler-DT_cD036.mjs +146 -0
  55. package/dist/integration-catalog-Bt-L3GjF.mjs +104 -0
  56. package/dist/integrations-DlatPK4W.mjs +79 -0
  57. package/dist/keystroke.d.mts +3 -0
  58. package/dist/keystroke.mjs +707 -0
  59. package/dist/layout-CbMtQ2tm.mjs +67 -0
  60. package/dist/list-enrichment-y-cwizLr.mjs +189 -0
  61. package/dist/list.handler-BTWvCyjA.mjs +52 -0
  62. package/dist/list.handler-CWF_Dj15.mjs +24 -0
  63. package/dist/list.handler-CZ6G2x_G.mjs +75 -0
  64. package/dist/list.handler-DWaQkJaR.mjs +51 -0
  65. package/dist/list.handler-DqbFcBW7.mjs +180 -0
  66. package/dist/list.handler-lq3ZGAn4.mjs +104 -0
  67. package/dist/logs-BEg9L5l8.mjs +28 -0
  68. package/dist/logs.handler-6hoMBzqw.mjs +35 -0
  69. package/dist/logs.handler-BD_dXiL1.mjs +231 -0
  70. package/dist/metadata-layout-GUYIUo0i-_aG2zjue.mjs +5877 -0
  71. package/dist/normalize-path-CojS-CgQ-DLCOvnD1.mjs +20 -0
  72. package/dist/options-CeaTcFxP.mjs +43 -0
  73. package/dist/org-xLzBtt2_.mjs +41 -0
  74. package/dist/output-DM4b7KgY.mjs +72 -0
  75. package/dist/oxc-B3KI3rf_-n9d1hKNq.mjs +119 -0
  76. package/dist/paused.handler-BMFm9Cff.mjs +94 -0
  77. package/dist/project-config-D1qsQlO7.mjs +107 -0
  78. package/dist/projects-CHkRE9rS.mjs +1574 -0
  79. package/dist/projects-Cjb7sovS.mjs +30 -0
  80. package/dist/read-credential-keys-77a91T8M-KA0Iw0Z1.mjs +9 -0
  81. package/dist/register.handler-BPCdor1_.mjs +86 -0
  82. package/dist/requirements.handler-DPXdSks3.mjs +201 -0
  83. package/dist/resolve-project-DDJ29sCF.mjs +35 -0
  84. package/dist/rolldown-runtime-twds-ZHy-BWWzu8VG.mjs +15 -0
  85. package/dist/run-polling-CAgFRdK3.mjs +20 -0
  86. package/dist/runs-D9hNLb9A.mjs +259 -0
  87. package/dist/schedule-BXx3uXwr.mjs +1142 -0
  88. package/dist/schema-17qMfNyI.mjs +18 -0
  89. package/dist/schema-display-CgmeKigW.mjs +130 -0
  90. package/dist/schemas-CDib1RhE.mjs +125 -0
  91. package/dist/skills-sync.handler-DIy8GR16.mjs +34 -0
  92. package/dist/skills.command-CrjI2dN9.mjs +35 -0
  93. package/dist/skills.handler-Bz8bJKql.mjs +9 -0
  94. package/dist/source-analysis-Cj-ADyu--BJQcFPCG.mjs +144 -0
  95. package/dist/spinner-progress-DMVwgqO9.mjs +173 -0
  96. package/dist/src-C0X6u_Mw.mjs +1340 -0
  97. package/dist/src-eHwu-Gfw.mjs +369 -0
  98. package/dist/status.handler-BO4nwvWn.mjs +101 -0
  99. package/dist/switch.handler-D_9213Vf.mjs +51 -0
  100. package/dist/sync-BL_Mo5st.mjs +39 -0
  101. package/dist/sync-keystroke-agent-skills-Kx_H7UTd.mjs +70 -0
  102. package/dist/sync.handler-BUFPdzWz.mjs +82 -0
  103. package/dist/task-B2sZMaZu.mjs +8 -0
  104. package/dist/task-target-build-CBeCKbu2.mjs +432 -0
  105. package/dist/task-target-deploy-C5X-USeR.mjs +4 -0
  106. package/dist/task-target-deploy-CA6elFpF-BEr4gkol.mjs +271 -0
  107. package/dist/task-target-deploy-runner.d.mts +3 -0
  108. package/dist/task-target-deploy-runner.mjs +202 -0
  109. package/dist/test-BHTgR3UA.mjs +698 -0
  110. package/dist/test.handler-BcPQ8b74.mjs +13 -0
  111. package/dist/trigger-artifacts-DQPbQNqC-B4yeeFBY.mjs +239 -0
  112. package/dist/trigger-manifest-CY7brZeg.mjs +30 -0
  113. package/dist/try-deploy.handler-DqybNhXx.mjs +490 -0
  114. package/dist/upload-CkU--iDC.mjs +207 -0
  115. package/dist/upload.handler-DCtiznQp.mjs +441 -0
  116. package/dist/utils-CywxCDM7.mjs +14 -0
  117. package/dist/validate.handler-DOcTaJL0.mjs +280 -0
  118. package/dist/workflow-build-DBQaBfnn.mjs +1819 -0
  119. package/dist/workflow-bundler-BPiqVscj-X1PFFAuP.mjs +167 -0
  120. package/dist/workflows-g9z87AJJ.mjs +799 -0
  121. package/dist/writer-BG8poUm3-BbXlU2kI.mjs +426 -0
  122. package/package.json +87 -0
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { createRequire } from "node:module";
4
+ //#region \0rolldown/runtime.js
5
+ var __create = Object.create;
6
+ var __defProp = Object.defineProperty;
7
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
+ var __getOwnPropNames = Object.getOwnPropertyNames;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
12
+ var __exportAll = (all, no_symbols) => {
13
+ let target = {};
14
+ for (var name in all) __defProp(target, name, {
15
+ get: all[name],
16
+ enumerable: true
17
+ });
18
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
19
+ return target;
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
23
+ key = keys[i];
24
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
25
+ get: ((k) => from[k]).bind(null, key),
26
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
27
+ });
28
+ }
29
+ return to;
30
+ };
31
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
32
+ value: mod,
33
+ enumerable: true
34
+ }) : target, mod));
35
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
36
+ //#endregion
37
+ export { __toESM as i, __exportAll as n, __require as r, __commonJSMin as t };
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { t as ui } from "./keystroke.mjs";
4
+ import { n as clearStoredProjects } from "./dist-CUK7yBM0.mjs";
5
+ //#region src/commands/projects/clear-cache.handler.ts
6
+ async function handleProjectsClearCache(_options, _ctx) {
7
+ if (await clearStoredProjects()) ui.success("Projects cache cleared.");
8
+ else ui.text("No projects cache found. Nothing to clear.");
9
+ }
10
+ //#endregion
11
+ export { handleProjectsClearCache };
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { h as toErrorMessage, i as logger, l as AUTH_HINT, t as ui } from "./keystroke.mjs";
4
+ import { c as removeOrgCredentials, r as deleteStoredCredentials } from "./dist-CUK7yBM0.mjs";
5
+ import { createClient } from "./src-eHwu-Gfw.mjs";
6
+ //#region src/commands/auth/clear.handler.ts
7
+ async function tryRevokeKey(apiKey, apiKeyId, baseUrl, organizationId) {
8
+ try {
9
+ await createClient({
10
+ apiKey,
11
+ baseUrl,
12
+ organizationId
13
+ }).public.auth.revoke({ apiKeyId });
14
+ logger.info("API key revoked on server", { apiKeyId });
15
+ } catch (error) {
16
+ logger.error("Failed to revoke API key on server", { error: toErrorMessage(error) });
17
+ ui.warn(`Could not revoke API key on server: ${toErrorMessage(error)}`);
18
+ }
19
+ }
20
+ async function handleAuthClear(_options, ctx) {
21
+ const creds = ctx.storedCredentials;
22
+ if (!creds || creds.orgs.length === 0) {
23
+ if (await deleteStoredCredentials()) ui.success("Local credentials removed.");
24
+ else ui.text(`No credentials found. ${AUTH_HINT}`);
25
+ return;
26
+ }
27
+ if (ctx.organizationId && ctx.orgSource === "flag") {
28
+ const removed = await removeOrgCredentials(ctx.organizationId);
29
+ if (!removed) {
30
+ ui.warn(`No stored credentials for organization ${ctx.organizationId}.`);
31
+ return;
32
+ }
33
+ if (removed.apiKeyId && creds.serverUrl) await tryRevokeKey(removed.apiKey, removed.apiKeyId, creds.serverUrl, removed.organizationId);
34
+ ui.success(`Credentials removed for ${removed.organizationName}.`);
35
+ return;
36
+ }
37
+ for (const org of creds.orgs) if (org.apiKeyId && creds.serverUrl) await tryRevokeKey(org.apiKey, org.apiKeyId, creds.serverUrl, org.organizationId);
38
+ await deleteStoredCredentials();
39
+ ui.success("All local credentials removed.");
40
+ }
41
+ //#endregion
42
+ export { handleAuthClear };
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { t as clearLogFile } from "./dist-CUK7yBM0.mjs";
4
+ import { log } from "@clack/prompts";
5
+ //#region src/commands/logs/clear.handler.ts
6
+ async function handleLogsClear(_options, _ctx) {
7
+ if (await clearLogFile()) log.success("Log file cleared.");
8
+ else log.message("No log file found. Nothing to clear.");
9
+ }
10
+ //#endregion
11
+ export { handleLogsClear };
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { C as CliExitError, h as toErrorMessage, i as logger, l as AUTH_HINT, n as createHiddenGlobalOptions, p as isAuthError, r as captureCliTelemetryResolvedContext, t as ui, w as InputValidationError } from "./keystroke.mjs";
4
+ import { a as writeJsonError, r as isJsonMode } from "./output-DM4b7KgY.mjs";
5
+ import { Command } from "commander";
6
+ //#region src/lib/commander.ts
7
+ /**
8
+ * Applies typed options to a Commander command from a schema and configuration
9
+ * Type-safe: ensures all schema keys have corresponding option configurations
10
+ *
11
+ * @param command - Commander command to apply options to
12
+ * @param schema - Zod schema for option validation
13
+ * @param optionsConfig - Configuration mapping schema keys to Commander flags/descriptions
14
+ * @returns The command with options applied
15
+ */
16
+ function applyTypedOptionsToCommand(command, schema, optionsConfig, skipKeys) {
17
+ const schemaKeys = Object.keys(schema.shape);
18
+ for (const key of schemaKeys) {
19
+ if (skipKeys?.has(String(key))) continue;
20
+ const config = optionsConfig[key];
21
+ if (!config) throw new Error(`Missing option configuration for key: ${String(key)}`);
22
+ if (config.collect) {
23
+ command.option(config.flag, config.description, (value, previous) => [...previous ?? [], value], []);
24
+ continue;
25
+ }
26
+ command.option(config.flag, config.description);
27
+ }
28
+ return command;
29
+ }
30
+ /**
31
+ * Creates a fully type-safe Commander command from a schema and configuration.
32
+ * Combines option application and action handler creation into a single function.
33
+ *
34
+ * Every handler receives a `CliContext` (with nullable client) by default.
35
+ * Global options (`--api-key`, `--base-url`) defined on the root program are
36
+ * automatically picked up and passed to `resolveBaseContext`.
37
+ *
38
+ * Provide a `resolve` function to narrow/extend the context for specialized needs.
39
+ * The handler's `ctx` type is **inferred** from `resolve`'s return type.
40
+ *
41
+ * @param params - Command parameters
42
+ * @param params.resolve - Optional context resolver; narrows or extends the base CliContext
43
+ * @param params.subcommands - Optional array of subcommands to register under this command
44
+ * @returns Fully configured Commander command
45
+ */
46
+ function createTypedCommand(params) {
47
+ const { name, description, schema, optionsConfig, resolve, subcommands } = params;
48
+ const command = new Command(name).description(description);
49
+ for (const opt of createHiddenGlobalOptions()) command.addOption(opt);
50
+ if (params.argument) {
51
+ const bracket = params.argument.required === false ? ["[", "]"] : ["<", ">"];
52
+ command.argument(`${bracket[0]}${params.argument.name}${bracket[1]}`, params.argument.description);
53
+ }
54
+ applyTypedOptionsToCommand(command, schema, optionsConfig, params.argument ? new Set([params.argument.key]) : void 0);
55
+ command.action(async (...args) => {
56
+ let jsonMode = false;
57
+ try {
58
+ let rawOptions;
59
+ let cmd;
60
+ if (params.argument) {
61
+ const argValue = args[0];
62
+ rawOptions = args[1];
63
+ cmd = args[2];
64
+ rawOptions[params.argument.key] = argValue;
65
+ } else {
66
+ rawOptions = args[0];
67
+ cmd = args[1];
68
+ }
69
+ const parseResult = schema.safeParse(rawOptions);
70
+ if (!parseResult.success) {
71
+ ui.error("Invalid options provided:");
72
+ for (const issue of parseResult.error.issues) ui.hint(`${issue.path.join(".")}: ${issue.message}`);
73
+ throw new InputValidationError("Invalid options provided", { reported: true });
74
+ }
75
+ const parsed = parseResult.data;
76
+ if ("json" in parsed) jsonMode = isJsonMode(parsed);
77
+ const globalOpts = cmd.optsWithGlobals();
78
+ if (globalOpts.debug) logger.setDebug(true);
79
+ const contextMode = params.contextMode ?? "full";
80
+ const contextModule = await import("./context-T7HZuB97.mjs").then((n) => n.n);
81
+ const base = contextMode === "auth" ? await contextModule.resolveAuthContext({
82
+ apiKey: globalOpts.apiKey,
83
+ baseUrl: globalOpts.baseUrl,
84
+ org: globalOpts.org
85
+ }) : await contextModule.resolveBaseContext({
86
+ apiKey: globalOpts.apiKey,
87
+ baseUrl: globalOpts.baseUrl,
88
+ org: globalOpts.org
89
+ });
90
+ captureCliTelemetryResolvedContext(base);
91
+ base.jsonMode = jsonMode;
92
+ const typedBase = base;
93
+ const ctx = resolve ? await resolve(parseResult.data, typedBase) : typedBase;
94
+ const handler = params.handler ?? await params.loadHandler?.();
95
+ if (!handler) throw new CliExitError(`Command "${name}" has no handler configured.`);
96
+ await handler(parseResult.data, ctx);
97
+ } catch (error) {
98
+ if (error instanceof CliExitError) {
99
+ if (!error.reported) {
100
+ const message = toErrorMessage(error);
101
+ const authError = isAuthError(error);
102
+ if (jsonMode) writeJsonError(message, {
103
+ code: authError ? "AUTH_ERROR" : "UNHANDLED_ERROR",
104
+ hint: authError ? AUTH_HINT : void 0
105
+ });
106
+ if (authError) {
107
+ ui.error(`Authentication failed: ${message}`);
108
+ ui.hint(AUTH_HINT);
109
+ } else ui.error(`Uncaught error in command handler: ${message}`);
110
+ }
111
+ throw error.markReported();
112
+ }
113
+ const message = toErrorMessage(error);
114
+ const authError = isAuthError(error);
115
+ if (jsonMode) writeJsonError(message, {
116
+ code: authError ? "AUTH_ERROR" : "UNHANDLED_ERROR",
117
+ hint: authError ? AUTH_HINT : void 0
118
+ });
119
+ if (authError) {
120
+ ui.error(`Authentication failed: ${message}`);
121
+ ui.hint(AUTH_HINT);
122
+ } else ui.error(`Uncaught error in command handler: ${message}`);
123
+ throw new CliExitError(message, {
124
+ cause: error,
125
+ reported: true
126
+ });
127
+ }
128
+ });
129
+ for (const sub of subcommands ?? []) command.addCommand(sub);
130
+ return command;
131
+ }
132
+ //#endregion
133
+ export { createTypedCommand as t };
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+
3
+ //#region ../../packages/workflow-builder/dist/concurrency-gXn9Rw8x.mjs
4
+ /**
5
+ * Runs async work over `items` with at most `concurrency` tasks in flight at once.
6
+ */
7
+ async function runWithConcurrency(items, concurrency, fn) {
8
+ if (items.length === 0) return;
9
+ const queue = [...items];
10
+ const workerCount = Math.min(concurrency, queue.length);
11
+ await Promise.all(Array.from({ length: workerCount }, async () => {
12
+ for (;;) {
13
+ const next = queue.shift();
14
+ if (next === void 0) return;
15
+ await fn(next);
16
+ }
17
+ }));
18
+ }
19
+ //#endregion
20
+ export { runWithConcurrency as t };
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { n as JsonOptionSchema, t as JSON_OPTION_CONFIG } from "./output-DM4b7KgY.mjs";
4
+ import { t as createTypedCommand } from "./commander-DfTVqQ-3.mjs";
5
+ import { z } from "zod";
6
+ //#region src/commands/connect/connect.command.ts
7
+ const ConnectOptionsSchema = JsonOptionSchema.extend({
8
+ integrationId: z.string().optional(),
9
+ shop: z.string().optional().describe("Shopify store domain (required for keystroke connect shopify)"),
10
+ timeout: z.coerce.number().int().min(30).max(600).default(300).describe("Timeout in seconds (default: 5 minutes)"),
11
+ noOpen: z.boolean().optional().describe("Print the authorization URL instead of opening a browser")
12
+ });
13
+ const CONNECT_OPTIONS_CONFIG = {
14
+ shop: {
15
+ flag: "--shop <domain>",
16
+ description: "Shopify store domain, for example example.myshopify.com"
17
+ },
18
+ timeout: {
19
+ flag: "--timeout <seconds>",
20
+ description: "Timeout in seconds (default: 300)"
21
+ },
22
+ noOpen: {
23
+ flag: "--no-open",
24
+ description: "Do not open a browser automatically; print the authorization URL instead"
25
+ },
26
+ ...JSON_OPTION_CONFIG
27
+ };
28
+ function createConnectCommand() {
29
+ return createTypedCommand({
30
+ name: "connect",
31
+ description: "Connect an official integration via OAuth (e.g., keystroke connect slack)",
32
+ schema: ConnectOptionsSchema,
33
+ optionsConfig: CONNECT_OPTIONS_CONFIG,
34
+ loadHandler: async () => (await import("./connect.handler-CYel9cy6.mjs")).handleConnect,
35
+ argument: {
36
+ name: "integrationId",
37
+ description: "Integration to connect (e.g., slack, linear)",
38
+ key: "integrationId"
39
+ }
40
+ });
41
+ }
42
+ //#endregion
43
+ export { createConnectCommand };