@spekn/cli 1.0.0

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 (159) hide show
  1. package/dist/__tests__/export-cli.test.d.ts +1 -0
  2. package/dist/__tests__/export-cli.test.js +70 -0
  3. package/dist/__tests__/tui-args-policy.test.d.ts +1 -0
  4. package/dist/__tests__/tui-args-policy.test.js +50 -0
  5. package/dist/acp-S2MHZOAD.mjs +23 -0
  6. package/dist/acp-UCCI44JY.mjs +25 -0
  7. package/dist/auth/credentials-store.d.ts +2 -0
  8. package/dist/auth/credentials-store.js +5 -0
  9. package/dist/auth/device-flow.d.ts +36 -0
  10. package/dist/auth/device-flow.js +189 -0
  11. package/dist/auth/jwt.d.ts +1 -0
  12. package/dist/auth/jwt.js +6 -0
  13. package/dist/auth/session.d.ts +67 -0
  14. package/dist/auth/session.js +86 -0
  15. package/dist/auth-login.d.ts +34 -0
  16. package/dist/auth-login.js +202 -0
  17. package/dist/auth-logout.d.ts +25 -0
  18. package/dist/auth-logout.js +115 -0
  19. package/dist/auth-status.d.ts +24 -0
  20. package/dist/auth-status.js +109 -0
  21. package/dist/backlog-generate.d.ts +11 -0
  22. package/dist/backlog-generate.js +308 -0
  23. package/dist/backlog-health.d.ts +11 -0
  24. package/dist/backlog-health.js +287 -0
  25. package/dist/bridge-login.d.ts +40 -0
  26. package/dist/bridge-login.js +277 -0
  27. package/dist/chunk-3PAYRI4G.mjs +2428 -0
  28. package/dist/chunk-M4CS3A25.mjs +2426 -0
  29. package/dist/commands/auth/login.d.ts +30 -0
  30. package/dist/commands/auth/login.js +164 -0
  31. package/dist/commands/auth/logout.d.ts +25 -0
  32. package/dist/commands/auth/logout.js +115 -0
  33. package/dist/commands/auth/status.d.ts +24 -0
  34. package/dist/commands/auth/status.js +109 -0
  35. package/dist/commands/backlog/generate.d.ts +11 -0
  36. package/dist/commands/backlog/generate.js +308 -0
  37. package/dist/commands/backlog/health.d.ts +11 -0
  38. package/dist/commands/backlog/health.js +287 -0
  39. package/dist/commands/bridge/login.d.ts +36 -0
  40. package/dist/commands/bridge/login.js +258 -0
  41. package/dist/commands/export.d.ts +35 -0
  42. package/dist/commands/export.js +485 -0
  43. package/dist/commands/marketplace-export.d.ts +21 -0
  44. package/dist/commands/marketplace-export.js +214 -0
  45. package/dist/commands/project-clean.d.ts +1 -0
  46. package/dist/commands/project-clean.js +126 -0
  47. package/dist/commands/repo/common.d.ts +105 -0
  48. package/dist/commands/repo/common.js +775 -0
  49. package/dist/commands/repo/detach.d.ts +2 -0
  50. package/dist/commands/repo/detach.js +120 -0
  51. package/dist/commands/repo/register.d.ts +21 -0
  52. package/dist/commands/repo/register.js +175 -0
  53. package/dist/commands/repo/sync.d.ts +22 -0
  54. package/dist/commands/repo/sync.js +873 -0
  55. package/dist/commands/skills-import-local.d.ts +16 -0
  56. package/dist/commands/skills-import-local.js +352 -0
  57. package/dist/commands/spec/drift-check.d.ts +3 -0
  58. package/dist/commands/spec/drift-check.js +186 -0
  59. package/dist/commands/spec/frontmatter.d.ts +11 -0
  60. package/dist/commands/spec/frontmatter.js +219 -0
  61. package/dist/commands/spec/lint.d.ts +11 -0
  62. package/dist/commands/spec/lint.js +499 -0
  63. package/dist/commands/spec/parse.d.ts +11 -0
  64. package/dist/commands/spec/parse.js +162 -0
  65. package/dist/export.d.ts +35 -0
  66. package/dist/export.js +485 -0
  67. package/dist/index.d.ts +11 -0
  68. package/dist/index.js +21 -0
  69. package/dist/main.d.ts +1 -0
  70. package/dist/main.js +115280 -0
  71. package/dist/marketplace-export.d.ts +21 -0
  72. package/dist/marketplace-export.js +214 -0
  73. package/dist/project-clean.d.ts +1 -0
  74. package/dist/project-clean.js +126 -0
  75. package/dist/project-context.d.ts +99 -0
  76. package/dist/project-context.js +376 -0
  77. package/dist/repo-common.d.ts +101 -0
  78. package/dist/repo-common.js +671 -0
  79. package/dist/repo-detach.d.ts +2 -0
  80. package/dist/repo-detach.js +102 -0
  81. package/dist/repo-ingest.d.ts +29 -0
  82. package/dist/repo-ingest.js +305 -0
  83. package/dist/repo-register.d.ts +21 -0
  84. package/dist/repo-register.js +175 -0
  85. package/dist/repo-sync.d.ts +16 -0
  86. package/dist/repo-sync.js +152 -0
  87. package/dist/resources/prompt-loader.d.ts +1 -0
  88. package/dist/resources/prompt-loader.js +62 -0
  89. package/dist/resources/prompts/README.md +21 -0
  90. package/dist/resources/prompts/prompts/repo-analysis.prompt.md +126 -0
  91. package/dist/resources/prompts/repo-analysis.prompt.md +151 -0
  92. package/dist/resources/prompts/repo-sync-analysis.prompt.md +85 -0
  93. package/dist/skills-import-local.d.ts +16 -0
  94. package/dist/skills-import-local.js +352 -0
  95. package/dist/spec-drift-check.d.ts +3 -0
  96. package/dist/spec-drift-check.js +186 -0
  97. package/dist/spec-frontmatter.d.ts +11 -0
  98. package/dist/spec-frontmatter.js +219 -0
  99. package/dist/spec-lint.d.ts +11 -0
  100. package/dist/spec-lint.js +499 -0
  101. package/dist/spec-parse.d.ts +11 -0
  102. package/dist/spec-parse.js +162 -0
  103. package/dist/stubs/dotenv.d.ts +5 -0
  104. package/dist/stubs/dotenv.js +6 -0
  105. package/dist/stubs/typeorm.d.ts +22 -0
  106. package/dist/stubs/typeorm.js +28 -0
  107. package/dist/tui/app.d.ts +7 -0
  108. package/dist/tui/app.js +122 -0
  109. package/dist/tui/args.d.ts +8 -0
  110. package/dist/tui/args.js +57 -0
  111. package/dist/tui/capabilities/policy.d.ts +7 -0
  112. package/dist/tui/capabilities/policy.js +64 -0
  113. package/dist/tui/components/frame.d.ts +8 -0
  114. package/dist/tui/components/frame.js +8 -0
  115. package/dist/tui/components/status-bar.d.ts +8 -0
  116. package/dist/tui/components/status-bar.js +8 -0
  117. package/dist/tui/index.d.ts +2 -0
  118. package/dist/tui/index.js +23 -0
  119. package/dist/tui/index.mjs +7563 -0
  120. package/dist/tui/keymap/use-global-keymap.d.ts +19 -0
  121. package/dist/tui/keymap/use-global-keymap.js +82 -0
  122. package/dist/tui/navigation/nav-items.d.ts +3 -0
  123. package/dist/tui/navigation/nav-items.js +18 -0
  124. package/dist/tui/screens/bridge.d.ts +8 -0
  125. package/dist/tui/screens/bridge.js +19 -0
  126. package/dist/tui/screens/decisions.d.ts +5 -0
  127. package/dist/tui/screens/decisions.js +28 -0
  128. package/dist/tui/screens/export.d.ts +5 -0
  129. package/dist/tui/screens/export.js +16 -0
  130. package/dist/tui/screens/home.d.ts +5 -0
  131. package/dist/tui/screens/home.js +33 -0
  132. package/dist/tui/screens/locked.d.ts +5 -0
  133. package/dist/tui/screens/locked.js +9 -0
  134. package/dist/tui/screens/specs.d.ts +5 -0
  135. package/dist/tui/screens/specs.js +31 -0
  136. package/dist/tui/services/client.d.ts +1 -0
  137. package/dist/tui/services/client.js +18 -0
  138. package/dist/tui/services/context-service.d.ts +19 -0
  139. package/dist/tui/services/context-service.js +246 -0
  140. package/dist/tui/shared-enums.d.ts +16 -0
  141. package/dist/tui/shared-enums.js +19 -0
  142. package/dist/tui/state/use-app-state.d.ts +35 -0
  143. package/dist/tui/state/use-app-state.js +177 -0
  144. package/dist/tui/types.d.ts +77 -0
  145. package/dist/tui/types.js +2 -0
  146. package/dist/tui-bundle.d.ts +1 -0
  147. package/dist/tui-bundle.js +5 -0
  148. package/dist/tui-entry.mjs +1407 -0
  149. package/dist/utils/cli-runtime.d.ts +5 -0
  150. package/dist/utils/cli-runtime.js +22 -0
  151. package/dist/utils/help-error.d.ts +7 -0
  152. package/dist/utils/help-error.js +14 -0
  153. package/dist/utils/interaction.d.ts +19 -0
  154. package/dist/utils/interaction.js +93 -0
  155. package/dist/utils/structured-log.d.ts +7 -0
  156. package/dist/utils/structured-log.js +112 -0
  157. package/dist/utils/trpc-url.d.ts +4 -0
  158. package/dist/utils/trpc-url.js +15 -0
  159. package/package.json +59 -0
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export declare function runRepoDetachCli(args: string[]): Promise<number>;
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.runRepoDetachCli = runRepoDetachCli;
38
+ const fs = __importStar(require("node:fs"));
39
+ const path = __importStar(require("node:path"));
40
+ const project_context_1 = require("../../project-context");
41
+ function printHelp(stderr) {
42
+ stderr(`
43
+ repo detach - Detach the current repository from local Spekn project context
44
+
45
+ USAGE:
46
+ spekn repo detach [options]
47
+
48
+ OPTIONS:
49
+ --path <dir> Repository root path (default: current directory)
50
+ --help Show this help message
51
+
52
+ EXAMPLES:
53
+ spekn repo detach
54
+ spekn repo detach --path /path/to/repo
55
+ `);
56
+ }
57
+ function parseArgs(args) {
58
+ let repoPath = process.cwd();
59
+ for (let index = 0; index < args.length; index += 1) {
60
+ const arg = args[index];
61
+ if (arg === '--help') {
62
+ throw new Error('HELP_REQUESTED');
63
+ }
64
+ if (arg === '--path' && args[index + 1]) {
65
+ repoPath = path.resolve(args[index + 1]);
66
+ index += 1;
67
+ continue;
68
+ }
69
+ if (arg?.startsWith('--path=')) {
70
+ repoPath = path.resolve(arg.slice('--path='.length));
71
+ }
72
+ }
73
+ return { repoPath };
74
+ }
75
+ async function runRepoDetachCli(args) {
76
+ try {
77
+ const options = parseArgs(args);
78
+ const localContextPath = path.join(options.repoPath, '.spekn');
79
+ const localContext = (0, project_context_1.loadLocalContext)(options.repoPath);
80
+ const globalCleanup = (0, project_context_1.clearRepoFromGlobalContext)(options.repoPath, localContext?.projectId);
81
+ const hasLocalContext = fs.existsSync(localContextPath);
82
+ if (hasLocalContext) {
83
+ fs.unlinkSync(localContextPath);
84
+ process.stdout.write(`Detached repository context (${localContextPath}).\n`);
85
+ }
86
+ else {
87
+ process.stdout.write('No local .spekn context file found.\n');
88
+ }
89
+ if (globalCleanup.removedProjectRefs > 0 ||
90
+ globalCleanup.removedSyncCheckpoints > 0 ||
91
+ globalCleanup.removedProjects > 0 ||
92
+ globalCleanup.clearedLastUsedProjectId) {
93
+ process.stdout.write(`Cleared global repo context references: ` +
94
+ `${globalCleanup.removedProjectRefs} project path(s), ` +
95
+ `${globalCleanup.removedSyncCheckpoints} sync checkpoint(s), ` +
96
+ `${globalCleanup.removedProjects} project record(s)` +
97
+ `${globalCleanup.clearedLastUsedProjectId ? ', lastUsedProjectId cleared' : ''}.\n`);
98
+ }
99
+ else {
100
+ process.stdout.write('No global repo context references found.\n');
101
+ }
102
+ return 0;
103
+ }
104
+ catch (error) {
105
+ const message = error instanceof Error ? error.message : String(error);
106
+ if (message === 'HELP_REQUESTED') {
107
+ printHelp(process.stderr.write.bind(process.stderr));
108
+ return 0;
109
+ }
110
+ process.stderr.write(`Error: ${message}\n`);
111
+ return 1;
112
+ }
113
+ }
114
+ async function main() {
115
+ const exitCode = await runRepoDetachCli(process.argv.slice(2));
116
+ process.exit(exitCode);
117
+ }
118
+ if (require.main === module) {
119
+ void main();
120
+ }
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * repo-register CLI command
4
+ *
5
+ * Registers the current git repository with a Spekn project and optionally
6
+ * runs AI-powered analysis to discover specs, assess governance, and create
7
+ * improvement specifications.
8
+ *
9
+ * Usage: spekn repo register --project-id <uuid> [--primary] [--analyze] [--no-analyze]
10
+ * [--agent <name>] [--path <dir>] [--dry-run] [--api-url <url>]
11
+ */
12
+ import { type CommonOptions, type Deps } from "./common";
13
+ export { repoNameFromUrl, resolveDefaultBranch, discoverFiles, buildAnalysisPrompt, executeAcpSession, runAnalysisWithAgent, verifyMcpServer, } from "./common";
14
+ export type { DiscoveredFile } from "./common";
15
+ interface RegisterOptions extends CommonOptions {
16
+ primary: boolean;
17
+ }
18
+ declare function parseArgs(args: string[]): RegisterOptions;
19
+ export declare function runRepoRegisterCli(args: string[], deps?: Deps): Promise<number>;
20
+ declare function main(): Promise<void>;
21
+ export { main, parseArgs };
@@ -0,0 +1,175 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * repo-register CLI command
5
+ *
6
+ * Registers the current git repository with a Spekn project and optionally
7
+ * runs AI-powered analysis to discover specs, assess governance, and create
8
+ * improvement specifications.
9
+ *
10
+ * Usage: spekn repo register --project-id <uuid> [--primary] [--analyze] [--no-analyze]
11
+ * [--agent <name>] [--path <dir>] [--dry-run] [--api-url <url>]
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.verifyMcpServer = exports.runAnalysisWithAgent = exports.executeAcpSession = exports.buildAnalysisPrompt = exports.discoverFiles = exports.resolveDefaultBranch = exports.repoNameFromUrl = void 0;
15
+ exports.runRepoRegisterCli = runRepoRegisterCli;
16
+ exports.main = main;
17
+ exports.parseArgs = parseArgs;
18
+ const common_1 = require("./common");
19
+ const project_context_1 = require("../../project-context");
20
+ const structured_log_1 = require("../../utils/structured-log");
21
+ // Re-export shared utilities for backward compatibility
22
+ var common_2 = require("./common");
23
+ Object.defineProperty(exports, "repoNameFromUrl", { enumerable: true, get: function () { return common_2.repoNameFromUrl; } });
24
+ Object.defineProperty(exports, "resolveDefaultBranch", { enumerable: true, get: function () { return common_2.resolveDefaultBranch; } });
25
+ Object.defineProperty(exports, "discoverFiles", { enumerable: true, get: function () { return common_2.discoverFiles; } });
26
+ Object.defineProperty(exports, "buildAnalysisPrompt", { enumerable: true, get: function () { return common_2.buildAnalysisPrompt; } });
27
+ Object.defineProperty(exports, "executeAcpSession", { enumerable: true, get: function () { return common_2.executeAcpSession; } });
28
+ Object.defineProperty(exports, "runAnalysisWithAgent", { enumerable: true, get: function () { return common_2.runAnalysisWithAgent; } });
29
+ Object.defineProperty(exports, "verifyMcpServer", { enumerable: true, get: function () { return common_2.verifyMcpServer; } });
30
+ // ── Help & Args ─────────────────────────────────────────────────────
31
+ function printHelp(stderr) {
32
+ stderr(`
33
+ repo register - Register the current git repository with a Spekn project
34
+
35
+ USAGE:
36
+ spekn repo register --project-id <uuid> [options]
37
+
38
+ OPTIONS:
39
+ --project-id <uuid> Project ID to register the repo under (optional if .spekn/context is present)
40
+ --primary Set this repository as the primary repo for the project
41
+ --analyze Run AI analysis after registration (default: true)
42
+ --no-analyze Skip AI analysis (metadata-only registration)
43
+ --agent <name> Force a specific agent (claude, codex, opencode, etc.)
44
+ --path <dir> Repository root path (default: current directory)
45
+ --dry-run Discover files only, skip AI analysis
46
+ --api-url <url> API base URL (default: SPEKN_API_URL or https://app.spekn.com)
47
+ --mcp-url <url> MCP HTTP server URL (default: MCP_HTTP_URL or https://app.spekn.com/mcp)
48
+ --debug Show detailed debug output (tokens, HTTP exchanges)
49
+ --help Show this help message
50
+
51
+ ENVIRONMENT:
52
+ SPEKN_API_URL API base URL
53
+ SPEKN_AUTH_TOKEN Bearer token for authentication
54
+ SPEKN_ORGANIZATION_ID Organization ID header
55
+ MCP_HTTP_URL MCP HTTP server URL (default: https://app.spekn.com/mcp)
56
+ AGENT_ARGS Override agent CLI args (skips ACP registry resolution)
57
+
58
+ EXAMPLES:
59
+ spekn repo register --project-id 11111111-1111-4111-8111-111111111111
60
+ spekn repo register --project-id 11111111-1111-4111-8111-111111111111 --primary
61
+ spekn repo register --project-id 11111111-1111-4111-8111-111111111111 --no-analyze
62
+ spekn repo register --project-id 11111111-1111-4111-8111-111111111111 --dry-run
63
+ spekn repo register --project-id 11111111-1111-4111-8111-111111111111 --agent claude
64
+ spekn repo register --project-id 11111111-1111-4111-8111-111111111111 --path /path/to/repo
65
+ `);
66
+ }
67
+ function parseArgs(args) {
68
+ const opts = { ...(0, common_1.commonDefaults)(true), primary: false };
69
+ for (let i = 0; i < args.length;) {
70
+ const consumed = (0, common_1.parseCommonFlag)(args, i, opts);
71
+ if (consumed > 0) {
72
+ i += consumed;
73
+ continue;
74
+ }
75
+ if (args[i] === "--primary") {
76
+ opts.primary = true;
77
+ i++;
78
+ continue;
79
+ }
80
+ i++; // skip unknown
81
+ }
82
+ return (0, common_1.finalizeOptions)(opts);
83
+ }
84
+ // ── Main ────────────────────────────────────────────────────────────
85
+ async function runRepoRegisterCli(args, deps = common_1.defaultDeps) {
86
+ try {
87
+ const options = parseArgs(args);
88
+ (0, structured_log_1.appendCliStructuredLog)({
89
+ source: "cli.repo.register",
90
+ level: "info",
91
+ message: "Starting repo register",
92
+ details: { repoPath: options.repoPath, analyze: options.analyze, apiUrl: options.apiUrl },
93
+ });
94
+ const { authToken, organizationId, projectId } = await (0, common_1.resolveAuth)(deps, {
95
+ projectId: options.projectId,
96
+ repoPath: options.repoPath,
97
+ });
98
+ // ── Phase 1: Register repository metadata ──────────────────────
99
+ const git = (0, common_1.readGitMetadata)(options.repoPath, deps);
100
+ if (!git)
101
+ return 1;
102
+ deps.stdout(`Registering repository "${git.name}" (${git.remoteUrl})\n`);
103
+ deps.stdout(` Default branch : ${git.defaultBranch}\n`);
104
+ deps.stdout(` Project : ${projectId}\n`);
105
+ if (options.primary)
106
+ deps.stdout(" Primary : yes\n");
107
+ const client = (0, common_1.createApiClient)(options.apiUrl, authToken, organizationId);
108
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
109
+ const result = await client.gitRepository.create.mutate({
110
+ projectId,
111
+ name: git.name,
112
+ repositoryUrl: git.remoteUrl,
113
+ defaultBranch: git.defaultBranch,
114
+ isPrimary: options.primary,
115
+ });
116
+ deps.stdout(`Repository registered successfully. ID: ${result.id}\n`);
117
+ (0, structured_log_1.appendCliStructuredLog)({
118
+ source: "cli.repo.register",
119
+ level: "info",
120
+ message: "Repository metadata registered",
121
+ details: { projectId, organizationId, repositoryId: result.id },
122
+ });
123
+ (0, project_context_1.persistProjectContext)(options.repoPath, { projectId, organizationId: organizationId || undefined });
124
+ (0, project_context_1.ensureGitignoreHasSpekn)(options.repoPath);
125
+ // ── Phase 2: AI analysis (optional) ─────────────────────────────
126
+ if (!options.analyze)
127
+ return 0;
128
+ if (!organizationId) {
129
+ deps.stderr("Warning: No organization ID. Skipping AI analysis. Re-run 'spekn auth login' or set SPEKN_ORGANIZATION_ID.\n");
130
+ return 0;
131
+ }
132
+ const exitCode = await (0, common_1.runAnalysisPhase)({ ...options, projectId }, authToken ?? "", deps, organizationId);
133
+ (0, structured_log_1.appendCliStructuredLog)({
134
+ source: "cli.repo.register",
135
+ level: exitCode === 0 ? "info" : "error",
136
+ message: "Repo register completed",
137
+ details: { exitCode, analyzed: options.analyze, projectId },
138
+ });
139
+ return exitCode;
140
+ }
141
+ catch (error) {
142
+ if (error instanceof common_1.HelpRequestedError) {
143
+ printHelp(deps.stderr);
144
+ return 0;
145
+ }
146
+ const message = error instanceof Error ? error.message : String(error);
147
+ deps.stderr(`Error: ${message}\n`);
148
+ // Provide specific guidance for common errors
149
+ if (message.includes('organization') || message.includes('Organization')) {
150
+ deps.stderr(`\n`);
151
+ deps.stderr(`Organization context is required. Try one of:\n`);
152
+ deps.stderr(` 1. Run 'spekn auth login' to authenticate and select an organization\n`);
153
+ deps.stderr(` 2. Set SPEKN_ORGANIZATION_ID environment variable\n`);
154
+ deps.stderr(` 3. Pass --organization-id explicitly (if supported)\n`);
155
+ }
156
+ else if (message.includes('credentials') || message.includes('auth') || message.includes('token')) {
157
+ deps.stderr(`\n`);
158
+ deps.stderr(`Authentication required. Run:\n`);
159
+ deps.stderr(` spekn auth login\n`);
160
+ }
161
+ (0, structured_log_1.appendCliStructuredLog)({
162
+ source: "cli.repo.register",
163
+ level: "error",
164
+ message: message,
165
+ });
166
+ return 1;
167
+ }
168
+ }
169
+ async function main() {
170
+ const exitCode = await runRepoRegisterCli(process.argv.slice(2));
171
+ process.exit(exitCode);
172
+ }
173
+ if (require.main === module) {
174
+ void main();
175
+ }
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * repo-sync CLI command
4
+ *
5
+ * Syncs metadata for the current git repository with Spekn.
6
+ * Looks up the repo by its remote URL and updates name and default branch.
7
+ * By default, also runs ingestion drift analysis against project spec storage.
8
+ * Must be run from inside a local git clone.
9
+ *
10
+ * Usage: spekn repo sync --project-id <uuid> [--analyze|--no-analyze] [--import-to-project] [--api-url <url>]
11
+ */
12
+ import { type CommonOptions, type Deps } from "./common";
13
+ interface SyncOptions extends CommonOptions {
14
+ importToProject: boolean;
15
+ maxFiles: number;
16
+ analysisEngine: "ingestion" | "acp" | "both";
17
+ acpTimeoutMs?: number;
18
+ }
19
+ declare function parseArgs(args: string[]): SyncOptions;
20
+ export declare function runRepoSyncCli(args: string[], deps?: Deps): Promise<number>;
21
+ declare function main(): Promise<void>;
22
+ export { main, parseArgs };