@spekn/cli 1.0.0 → 1.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 (154) hide show
  1. package/README.md +58 -0
  2. package/dist/main.js +3707 -611
  3. package/dist/tui/index.mjs +2 -2
  4. package/package.json +29 -12
  5. package/dist/__tests__/export-cli.test.d.ts +0 -1
  6. package/dist/__tests__/export-cli.test.js +0 -70
  7. package/dist/__tests__/tui-args-policy.test.d.ts +0 -1
  8. package/dist/__tests__/tui-args-policy.test.js +0 -50
  9. package/dist/acp-S2MHZOAD.mjs +0 -23
  10. package/dist/acp-UCCI44JY.mjs +0 -25
  11. package/dist/auth/credentials-store.d.ts +0 -2
  12. package/dist/auth/credentials-store.js +0 -5
  13. package/dist/auth/device-flow.d.ts +0 -36
  14. package/dist/auth/device-flow.js +0 -189
  15. package/dist/auth/jwt.d.ts +0 -1
  16. package/dist/auth/jwt.js +0 -6
  17. package/dist/auth/session.d.ts +0 -67
  18. package/dist/auth/session.js +0 -86
  19. package/dist/auth-login.d.ts +0 -34
  20. package/dist/auth-login.js +0 -202
  21. package/dist/auth-logout.d.ts +0 -25
  22. package/dist/auth-logout.js +0 -115
  23. package/dist/auth-status.d.ts +0 -24
  24. package/dist/auth-status.js +0 -109
  25. package/dist/backlog-generate.d.ts +0 -11
  26. package/dist/backlog-generate.js +0 -308
  27. package/dist/backlog-health.d.ts +0 -11
  28. package/dist/backlog-health.js +0 -287
  29. package/dist/bridge-login.d.ts +0 -40
  30. package/dist/bridge-login.js +0 -277
  31. package/dist/chunk-3PAYRI4G.mjs +0 -2428
  32. package/dist/chunk-M4CS3A25.mjs +0 -2426
  33. package/dist/commands/auth/login.d.ts +0 -30
  34. package/dist/commands/auth/login.js +0 -164
  35. package/dist/commands/auth/logout.d.ts +0 -25
  36. package/dist/commands/auth/logout.js +0 -115
  37. package/dist/commands/auth/status.d.ts +0 -24
  38. package/dist/commands/auth/status.js +0 -109
  39. package/dist/commands/backlog/generate.d.ts +0 -11
  40. package/dist/commands/backlog/generate.js +0 -308
  41. package/dist/commands/backlog/health.d.ts +0 -11
  42. package/dist/commands/backlog/health.js +0 -287
  43. package/dist/commands/bridge/login.d.ts +0 -36
  44. package/dist/commands/bridge/login.js +0 -258
  45. package/dist/commands/export.d.ts +0 -35
  46. package/dist/commands/export.js +0 -485
  47. package/dist/commands/marketplace-export.d.ts +0 -21
  48. package/dist/commands/marketplace-export.js +0 -214
  49. package/dist/commands/project-clean.d.ts +0 -1
  50. package/dist/commands/project-clean.js +0 -126
  51. package/dist/commands/repo/common.d.ts +0 -105
  52. package/dist/commands/repo/common.js +0 -775
  53. package/dist/commands/repo/detach.d.ts +0 -2
  54. package/dist/commands/repo/detach.js +0 -120
  55. package/dist/commands/repo/register.d.ts +0 -21
  56. package/dist/commands/repo/register.js +0 -175
  57. package/dist/commands/repo/sync.d.ts +0 -22
  58. package/dist/commands/repo/sync.js +0 -873
  59. package/dist/commands/skills-import-local.d.ts +0 -16
  60. package/dist/commands/skills-import-local.js +0 -352
  61. package/dist/commands/spec/drift-check.d.ts +0 -3
  62. package/dist/commands/spec/drift-check.js +0 -186
  63. package/dist/commands/spec/frontmatter.d.ts +0 -11
  64. package/dist/commands/spec/frontmatter.js +0 -219
  65. package/dist/commands/spec/lint.d.ts +0 -11
  66. package/dist/commands/spec/lint.js +0 -499
  67. package/dist/commands/spec/parse.d.ts +0 -11
  68. package/dist/commands/spec/parse.js +0 -162
  69. package/dist/export.d.ts +0 -35
  70. package/dist/export.js +0 -485
  71. package/dist/main.d.ts +0 -1
  72. package/dist/marketplace-export.d.ts +0 -21
  73. package/dist/marketplace-export.js +0 -214
  74. package/dist/project-clean.d.ts +0 -1
  75. package/dist/project-clean.js +0 -126
  76. package/dist/project-context.d.ts +0 -99
  77. package/dist/project-context.js +0 -376
  78. package/dist/repo-common.d.ts +0 -101
  79. package/dist/repo-common.js +0 -671
  80. package/dist/repo-detach.d.ts +0 -2
  81. package/dist/repo-detach.js +0 -102
  82. package/dist/repo-ingest.d.ts +0 -29
  83. package/dist/repo-ingest.js +0 -305
  84. package/dist/repo-register.d.ts +0 -21
  85. package/dist/repo-register.js +0 -175
  86. package/dist/repo-sync.d.ts +0 -16
  87. package/dist/repo-sync.js +0 -152
  88. package/dist/resources/prompt-loader.d.ts +0 -1
  89. package/dist/resources/prompt-loader.js +0 -62
  90. package/dist/skills-import-local.d.ts +0 -16
  91. package/dist/skills-import-local.js +0 -352
  92. package/dist/spec-drift-check.d.ts +0 -3
  93. package/dist/spec-drift-check.js +0 -186
  94. package/dist/spec-frontmatter.d.ts +0 -11
  95. package/dist/spec-frontmatter.js +0 -219
  96. package/dist/spec-lint.d.ts +0 -11
  97. package/dist/spec-lint.js +0 -499
  98. package/dist/spec-parse.d.ts +0 -11
  99. package/dist/spec-parse.js +0 -162
  100. package/dist/stubs/dotenv.d.ts +0 -5
  101. package/dist/stubs/dotenv.js +0 -6
  102. package/dist/stubs/typeorm.d.ts +0 -22
  103. package/dist/stubs/typeorm.js +0 -28
  104. package/dist/tui/app.d.ts +0 -7
  105. package/dist/tui/app.js +0 -122
  106. package/dist/tui/args.d.ts +0 -8
  107. package/dist/tui/args.js +0 -57
  108. package/dist/tui/capabilities/policy.d.ts +0 -7
  109. package/dist/tui/capabilities/policy.js +0 -64
  110. package/dist/tui/components/frame.d.ts +0 -8
  111. package/dist/tui/components/frame.js +0 -8
  112. package/dist/tui/components/status-bar.d.ts +0 -8
  113. package/dist/tui/components/status-bar.js +0 -8
  114. package/dist/tui/index.d.ts +0 -2
  115. package/dist/tui/index.js +0 -23
  116. package/dist/tui/keymap/use-global-keymap.d.ts +0 -19
  117. package/dist/tui/keymap/use-global-keymap.js +0 -82
  118. package/dist/tui/navigation/nav-items.d.ts +0 -3
  119. package/dist/tui/navigation/nav-items.js +0 -18
  120. package/dist/tui/screens/bridge.d.ts +0 -8
  121. package/dist/tui/screens/bridge.js +0 -19
  122. package/dist/tui/screens/decisions.d.ts +0 -5
  123. package/dist/tui/screens/decisions.js +0 -28
  124. package/dist/tui/screens/export.d.ts +0 -5
  125. package/dist/tui/screens/export.js +0 -16
  126. package/dist/tui/screens/home.d.ts +0 -5
  127. package/dist/tui/screens/home.js +0 -33
  128. package/dist/tui/screens/locked.d.ts +0 -5
  129. package/dist/tui/screens/locked.js +0 -9
  130. package/dist/tui/screens/specs.d.ts +0 -5
  131. package/dist/tui/screens/specs.js +0 -31
  132. package/dist/tui/services/client.d.ts +0 -1
  133. package/dist/tui/services/client.js +0 -18
  134. package/dist/tui/services/context-service.d.ts +0 -19
  135. package/dist/tui/services/context-service.js +0 -246
  136. package/dist/tui/shared-enums.d.ts +0 -16
  137. package/dist/tui/shared-enums.js +0 -19
  138. package/dist/tui/state/use-app-state.d.ts +0 -35
  139. package/dist/tui/state/use-app-state.js +0 -177
  140. package/dist/tui/types.d.ts +0 -77
  141. package/dist/tui/types.js +0 -2
  142. package/dist/tui-bundle.d.ts +0 -1
  143. package/dist/tui-bundle.js +0 -5
  144. package/dist/tui-entry.mjs +0 -1407
  145. package/dist/utils/cli-runtime.d.ts +0 -5
  146. package/dist/utils/cli-runtime.js +0 -22
  147. package/dist/utils/help-error.d.ts +0 -7
  148. package/dist/utils/help-error.js +0 -14
  149. package/dist/utils/interaction.d.ts +0 -19
  150. package/dist/utils/interaction.js +0 -93
  151. package/dist/utils/structured-log.d.ts +0 -7
  152. package/dist/utils/structured-log.js +0 -112
  153. package/dist/utils/trpc-url.d.ts +0 -4
  154. package/dist/utils/trpc-url.js +0 -15
@@ -1,258 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- /**
4
- * bridge login CLI command
5
- *
6
- * Authenticates the CLI user via the Keycloak Device Authorization Grant,
7
- * then registers the bridge device with the Spekn SaaS API. This combines
8
- * `auth login` (credentials) with bridge device registration in a single step.
9
- *
10
- * Usage: spekn bridge login [--name <device-name>] [--api-url <url>] [--force]
11
- */
12
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- var desc = Object.getOwnPropertyDescriptor(m, k);
15
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
- desc = { enumerable: true, get: function() { return m[k]; } };
17
- }
18
- Object.defineProperty(o, k2, desc);
19
- }) : (function(o, m, k, k2) {
20
- if (k2 === undefined) k2 = k;
21
- o[k2] = m[k];
22
- }));
23
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
- Object.defineProperty(o, "default", { enumerable: true, value: v });
25
- }) : function(o, v) {
26
- o["default"] = v;
27
- });
28
- var __importStar = (this && this.__importStar) || (function () {
29
- var ownKeys = function(o) {
30
- ownKeys = Object.getOwnPropertyNames || function (o) {
31
- var ar = [];
32
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
- return ar;
34
- };
35
- return ownKeys(o);
36
- };
37
- return function (mod) {
38
- if (mod && mod.__esModule) return mod;
39
- var result = {};
40
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
- __setModuleDefault(result, mod);
42
- return result;
43
- };
44
- })();
45
- Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.decodeJwtPayload = void 0;
47
- exports.runBridgeLoginCli = runBridgeLoginCli;
48
- exports.main = main;
49
- exports.parseArgs = parseArgs;
50
- const os = __importStar(require("node:os"));
51
- const client_1 = require("@trpc/client");
52
- const device_flow_js_1 = require("../../auth/device-flow.js");
53
- const credentials_store_js_1 = require("../../auth/credentials-store.js");
54
- const session_js_1 = require("../../auth/session.js");
55
- const bridge_1 = require("@spekn/bridge");
56
- const trpc_url_1 = require("../../utils/trpc-url");
57
- const help_error_1 = require("../../utils/help-error");
58
- const structured_log_1 = require("../../utils/structured-log");
59
- const defaultDeps = {
60
- stdout: process.stdout,
61
- stderr: process.stderr,
62
- performDeviceFlow: device_flow_js_1.performDeviceFlow,
63
- credentialsStore: new credentials_store_js_1.CredentialsStore(),
64
- bridgeConfigStore: new bridge_1.BridgeConfigStore(),
65
- };
66
- function resolveDeps(deps) {
67
- return {
68
- stdout: deps?.stdout ?? defaultDeps.stdout,
69
- stderr: deps?.stderr ?? defaultDeps.stderr,
70
- performDeviceFlow: deps?.performDeviceFlow ?? defaultDeps.performDeviceFlow,
71
- credentialsStore: deps?.credentialsStore ?? defaultDeps.credentialsStore,
72
- bridgeConfigStore: deps?.bridgeConfigStore ?? defaultDeps.bridgeConfigStore,
73
- };
74
- }
75
- function printHelp(stderr) {
76
- stderr.write(`
77
- bridge login - Authenticate and register the bridge with Spekn SaaS
78
-
79
- USAGE:
80
- spekn bridge login [options]
81
-
82
- OPTIONS:
83
- --name <name> Device name (default: system hostname)
84
- --api-url <url> API base URL (default: SPEKN_API_URL or https://app.spekn.com)
85
- --keycloak-url <url> Keycloak base URL (default: KEYCLOAK_URL or https://auth.spekn.com)
86
- --realm <realm> Keycloak realm name (default: KEYCLOAK_REALM or spekn)
87
- --force Re-register even if bridge is already paired
88
- --help Show this help message
89
-
90
- ENVIRONMENT:
91
- SPEKN_API_URL API base URL
92
- KEYCLOAK_URL Keycloak base URL
93
- KEYCLOAK_REALM Keycloak realm name
94
-
95
- EXAMPLES:
96
- spekn bridge login
97
- spekn bridge login --name my-dev-machine
98
- spekn bridge login --api-url https://api.spekn.dev --force
99
- `);
100
- }
101
- function parseArgs(args) {
102
- let deviceName = os.hostname();
103
- let apiUrl = process.env["SPEKN_API_URL"] ?? "https://app.spekn.com";
104
- let keycloakUrl = process.env["KEYCLOAK_URL"] ?? "https://auth.spekn.com";
105
- let realm = process.env["KEYCLOAK_REALM"] ?? "spekn";
106
- let force = false;
107
- for (let index = 0; index < args.length; index++) {
108
- const arg = args[index];
109
- if (arg === "--help" || arg === "-h") {
110
- throw new help_error_1.HelpRequestedError();
111
- }
112
- if (arg === "--name" && args[index + 1]) {
113
- deviceName = args[++index];
114
- continue;
115
- }
116
- if (arg?.startsWith("--name=")) {
117
- deviceName = arg.slice("--name=".length);
118
- continue;
119
- }
120
- if (arg === "--api-url" && args[index + 1]) {
121
- apiUrl = args[++index];
122
- continue;
123
- }
124
- if (arg?.startsWith("--api-url=")) {
125
- apiUrl = arg.slice("--api-url=".length);
126
- continue;
127
- }
128
- if (arg === "--keycloak-url" && args[index + 1]) {
129
- keycloakUrl = args[++index];
130
- continue;
131
- }
132
- if (arg?.startsWith("--keycloak-url=")) {
133
- keycloakUrl = arg.slice("--keycloak-url=".length);
134
- continue;
135
- }
136
- if (arg === "--realm" && args[index + 1]) {
137
- realm = args[++index];
138
- continue;
139
- }
140
- if (arg?.startsWith("--realm=")) {
141
- realm = arg.slice("--realm=".length);
142
- continue;
143
- }
144
- if (arg === "--force") {
145
- force = true;
146
- continue;
147
- }
148
- }
149
- return { deviceName, apiUrl, keycloakUrl, realm, force };
150
- }
151
- async function runBridgeLoginCli(args, deps) {
152
- const resolved = resolveDeps(deps);
153
- try {
154
- const options = parseArgs(args);
155
- (0, structured_log_1.appendCliStructuredLog)({
156
- source: "cli.bridge.login",
157
- level: "info",
158
- message: "Starting bridge login",
159
- details: { deviceName: options.deviceName, apiUrl: options.apiUrl, force: options.force },
160
- });
161
- // Load bridge config
162
- resolved.bridgeConfigStore.load();
163
- // Check if already paired — require --force to re-register
164
- if (resolved.bridgeConfigStore.isPaired() && !options.force) {
165
- resolved.stderr.write("Bridge is already registered. Use --force to re-register.\n");
166
- return 1;
167
- }
168
- const auth = await (0, session_js_1.ensureAuthenticated)({
169
- keycloakUrl: options.keycloakUrl,
170
- realm: options.realm,
171
- credentialsStore: resolved.credentialsStore,
172
- performDeviceFlow: resolved.performDeviceFlow,
173
- stdout: resolved.stdout,
174
- stderr: resolved.stderr,
175
- forceDeviceFlow: false,
176
- });
177
- if (auth.source === "existing") {
178
- resolved.stdout.write(`Using existing credentials (${auth.user.email})\n`);
179
- }
180
- else {
181
- resolved.stdout.write(`Authenticated as ${auth.user.email}\n`);
182
- }
183
- // Step 3: Resolve organization context
184
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
185
- const client = (0, client_1.createTRPCProxyClient)({
186
- links: [
187
- (0, client_1.httpBatchLink)({
188
- url: (0, trpc_url_1.normalizeTrpcUrl)(options.apiUrl),
189
- headers: {
190
- authorization: `Bearer ${auth.accessToken}`,
191
- },
192
- }),
193
- ],
194
- });
195
- const organizationId = await (0, session_js_1.resolveOrganizationId)({
196
- existingOrganizationId: auth.credentials.organizationId,
197
- envOrganizationId: process.env.SPEKN_ORGANIZATION_ID,
198
- fetchOrganizations: async () => (await client.organization.list.query()),
199
- stdout: resolved.stdout,
200
- });
201
- // Step 4: POST to bridge.registerWithToken
202
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
203
- const clientWithOrg = (0, client_1.createTRPCProxyClient)({
204
- links: [
205
- (0, client_1.httpBatchLink)({
206
- url: (0, trpc_url_1.normalizeTrpcUrl)(options.apiUrl),
207
- headers: {
208
- authorization: `Bearer ${auth.accessToken}`,
209
- "x-organization-id": organizationId ?? "",
210
- },
211
- }),
212
- ],
213
- });
214
- const result = await clientWithOrg.bridge.registerWithToken.mutate({
215
- deviceName: options.deviceName,
216
- });
217
- // Step 4: Save result to BridgeConfigStore
218
- resolved.bridgeConfigStore.setPairing({
219
- deviceId: result.deviceId,
220
- deviceName: options.deviceName,
221
- credential: result.credential,
222
- pairedAt: new Date().toISOString(),
223
- saasOrigin: result.saasOrigin,
224
- });
225
- resolved.bridgeConfigStore.update({ saasWsUrl: result.saasWsUrl });
226
- resolved.stdout.write(`\nBridge registered as '${options.deviceName}'. Run: spekn bridge start\n`);
227
- (0, structured_log_1.appendCliStructuredLog)({
228
- source: "cli.bridge.login",
229
- level: "info",
230
- message: "Bridge login completed",
231
- details: { deviceId: result.deviceId, organizationId: result.organizationId },
232
- });
233
- return 0;
234
- }
235
- catch (error) {
236
- if (error instanceof help_error_1.HelpRequestedError) {
237
- printHelp(resolved.stderr);
238
- return 0;
239
- }
240
- const message = error instanceof Error ? error.message : String(error);
241
- resolved.stderr.write(`Error: ${message}\n`);
242
- (0, structured_log_1.appendCliStructuredLog)({
243
- source: "cli.bridge.login",
244
- level: "error",
245
- message,
246
- });
247
- return 1;
248
- }
249
- }
250
- async function main() {
251
- const exitCode = await runBridgeLoginCli(process.argv.slice(2));
252
- process.exit(exitCode);
253
- }
254
- if (require.main === module) {
255
- void main();
256
- }
257
- var jwt_js_1 = require("../../auth/jwt.js");
258
- Object.defineProperty(exports, "decodeJwtPayload", { enumerable: true, get: function () { return jwt_js_1.decodeJwtPayload; } });
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env node
2
- import { CredentialsStore } from '../auth/credentials-store';
3
- type ExportFormat = 'agents-md' | 'claude-md' | 'cursorrules' | 'gemini-md';
4
- type ExportMode = 'global' | 'scoped';
5
- type ExportDeliveryMode = 'download' | 'copy' | 'commit' | 'pr';
6
- type ExportCommand = 'generate' | 'status' | 'discover' | 'preview';
7
- interface CLIOptions {
8
- command: ExportCommand;
9
- projectId?: string;
10
- format?: ExportFormat;
11
- output?: string;
12
- anchors?: string[];
13
- mode: ExportMode;
14
- scope?: string;
15
- delivery: ExportDeliveryMode;
16
- json: boolean;
17
- branch?: string;
18
- baseBranch?: string;
19
- commitMessage?: string;
20
- prTitle?: string;
21
- prBody?: string;
22
- apiUrl: string;
23
- }
24
- interface Deps {
25
- createClient: (apiUrl: string, organizationId: string, authToken?: string) => any;
26
- writeFile: (filePath: string, content: string) => void;
27
- stdout: (content: string) => void;
28
- stderr: (content: string) => void;
29
- credentialsStore: CredentialsStore;
30
- }
31
- declare function normalizeTrpcUrl(apiUrl: string): string;
32
- declare function parseArgs(args: string[]): CLIOptions;
33
- export declare function runExportCli(args: string[], deps?: Deps): Promise<number>;
34
- declare function main(): Promise<void>;
35
- export { main, parseArgs, normalizeTrpcUrl };