@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,5 +0,0 @@
1
- export declare function hasHelpFlag(args: string[]): boolean;
2
- export declare function errorMessage(error: unknown): string;
3
- export declare function runCliMain(main: (argv?: string[]) => Promise<number> | number, options?: {
4
- errorPrefix?: string;
5
- }): Promise<void>;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasHelpFlag = hasHelpFlag;
4
- exports.errorMessage = errorMessage;
5
- exports.runCliMain = runCliMain;
6
- function hasHelpFlag(args) {
7
- return args.includes("--help") || args.includes("-h");
8
- }
9
- function errorMessage(error) {
10
- return error instanceof Error ? error.message : String(error);
11
- }
12
- async function runCliMain(main, options) {
13
- try {
14
- const exitCode = await main(process.argv.slice(2));
15
- process.exit(exitCode);
16
- }
17
- catch (error) {
18
- const prefix = options?.errorPrefix ? `${options.errorPrefix}: ` : "";
19
- console.error(`${prefix}${errorMessage(error)}`);
20
- process.exit(1);
21
- }
22
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Thrown when the user requests --help. Caught in the CLI main function
3
- * to display usage information and exit cleanly.
4
- */
5
- export declare class HelpRequestedError extends Error {
6
- constructor();
7
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HelpRequestedError = void 0;
4
- /**
5
- * Thrown when the user requests --help. Caught in the CLI main function
6
- * to display usage information and exit cleanly.
7
- */
8
- class HelpRequestedError extends Error {
9
- constructor() {
10
- super("__HELP__");
11
- this.name = "HelpRequestedError";
12
- }
13
- }
14
- exports.HelpRequestedError = HelpRequestedError;
@@ -1,19 +0,0 @@
1
- export interface InteractionSelectOption {
2
- value: string;
3
- label: string;
4
- }
5
- interface InteractionSelectRequest {
6
- title: string;
7
- message: string;
8
- options: InteractionSelectOption[];
9
- allowSkip?: boolean;
10
- timeoutMs?: number;
11
- }
12
- /**
13
- * Request a selection from an external automation controller over stdio.
14
- * Protocol:
15
- * - emits a single line to stderr prefixed with "[spekn-interaction] "
16
- * - expects one JSON line on stdin: {"id":"...","value":"..."} or {"id":"...","skip":true}
17
- */
18
- export declare function requestSelectionFromController(req: InteractionSelectRequest): Promise<string | "skip" | null>;
19
- export {};
@@ -1,93 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.requestSelectionFromController = requestSelectionFromController;
4
- function isJsonStdioMode() {
5
- return process.env.SPEKN_INTERACTION_MODE === "json-stdio";
6
- }
7
- function readSingleLine(timeoutMs) {
8
- return new Promise((resolve) => {
9
- if (!process.stdin || process.stdin.destroyed) {
10
- resolve(null);
11
- return;
12
- }
13
- // In subprocess/pipe mode, use direct buffered reads to avoid readline
14
- // edge-cases where line events can be dropped on fast close/EOF.
15
- process.stdin.resume();
16
- let buffer = "";
17
- let settled = false;
18
- const cleanup = () => {
19
- process.stdin.off("data", onData);
20
- process.stdin.off("end", onEnd);
21
- process.stdin.off("error", onError);
22
- };
23
- const settle = (value) => {
24
- if (settled)
25
- return;
26
- settled = true;
27
- clearTimeout(timer);
28
- cleanup();
29
- resolve(value);
30
- };
31
- const onData = (chunk) => {
32
- buffer += String(chunk);
33
- const newlineIndex = buffer.search(/\r?\n|\r/);
34
- if (newlineIndex >= 0) {
35
- const line = buffer.slice(0, newlineIndex).trim();
36
- settle(line);
37
- }
38
- };
39
- const onEnd = () => settle(null);
40
- const onError = () => settle(null);
41
- const timer = setTimeout(() => settle(null), timeoutMs);
42
- process.stdin.on("data", onData);
43
- process.stdin.once("end", onEnd);
44
- process.stdin.once("error", onError);
45
- });
46
- }
47
- /**
48
- * Request a selection from an external automation controller over stdio.
49
- * Protocol:
50
- * - emits a single line to stderr prefixed with "[spekn-interaction] "
51
- * - expects one JSON line on stdin: {"id":"...","value":"..."} or {"id":"...","skip":true}
52
- */
53
- async function requestSelectionFromController(req) {
54
- if (!isJsonStdioMode()) {
55
- return null;
56
- }
57
- const id = `select-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
58
- const timeoutMs = req.timeoutMs ?? 120000;
59
- const payload = {
60
- type: "spekn.interaction.request",
61
- id,
62
- kind: "select",
63
- title: req.title,
64
- message: req.message,
65
- options: req.options,
66
- allowSkip: req.allowSkip === true,
67
- };
68
- process.stderr.write(`[spekn-interaction] ${JSON.stringify(payload)}\n`);
69
- const line = await readSingleLine(timeoutMs);
70
- if (!line) {
71
- return null;
72
- }
73
- let parsed = null;
74
- try {
75
- parsed = JSON.parse(line);
76
- }
77
- catch {
78
- return null;
79
- }
80
- if (!parsed || parsed.id !== id) {
81
- return null;
82
- }
83
- if (parsed.skip === true && req.allowSkip) {
84
- return "skip";
85
- }
86
- if (typeof parsed.value === "string") {
87
- const allowed = new Set(req.options.map((option) => option.value));
88
- if (allowed.has(parsed.value)) {
89
- return parsed.value;
90
- }
91
- }
92
- return null;
93
- }
@@ -1,7 +0,0 @@
1
- export type StructuredLogLevel = "debug" | "info" | "warn" | "error";
2
- export declare function appendCliStructuredLog(input: {
3
- source: string;
4
- level: StructuredLogLevel;
5
- message: string;
6
- details?: Record<string, unknown>;
7
- }): void;
@@ -1,112 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.appendCliStructuredLog = appendCliStructuredLog;
37
- const fs = __importStar(require("node:fs"));
38
- const os = __importStar(require("node:os"));
39
- const path = __importStar(require("node:path"));
40
- const GLOBAL_CONFIG_PATH = path.join(os.homedir(), ".spekn", "config.json");
41
- const DEFAULT_GLOBAL_CONFIG = {
42
- logging: {
43
- enabled: false,
44
- path: "~/.spekn/error.log",
45
- level: "info",
46
- },
47
- };
48
- const LOG_LEVEL_RANK = {
49
- debug: 10,
50
- info: 20,
51
- warn: 30,
52
- error: 40,
53
- };
54
- function expandHomePath(filePath) {
55
- if (filePath === "~")
56
- return os.homedir();
57
- if (filePath.startsWith("~/"))
58
- return path.join(os.homedir(), filePath.slice(2));
59
- return filePath;
60
- }
61
- function loadGlobalContextConfig() {
62
- try {
63
- const raw = fs.readFileSync(GLOBAL_CONFIG_PATH, "utf-8");
64
- const parsed = JSON.parse(raw);
65
- const levelCandidate = parsed?.logging?.level;
66
- const level = levelCandidate === "debug" ||
67
- levelCandidate === "info" ||
68
- levelCandidate === "warn" ||
69
- levelCandidate === "error"
70
- ? levelCandidate
71
- : DEFAULT_GLOBAL_CONFIG.logging.level;
72
- return {
73
- logging: {
74
- enabled: typeof parsed?.logging?.enabled === "boolean"
75
- ? parsed.logging.enabled
76
- : DEFAULT_GLOBAL_CONFIG.logging.enabled,
77
- path: typeof parsed?.logging?.path === "string" && parsed.logging.path.trim().length > 0
78
- ? parsed.logging.path
79
- : DEFAULT_GLOBAL_CONFIG.logging.path,
80
- level,
81
- },
82
- };
83
- }
84
- catch {
85
- return DEFAULT_GLOBAL_CONFIG;
86
- }
87
- }
88
- function appendCliStructuredLog(input) {
89
- try {
90
- const config = loadGlobalContextConfig();
91
- if (!config.logging.enabled)
92
- return;
93
- if (LOG_LEVEL_RANK[input.level] < LOG_LEVEL_RANK[config.logging.level])
94
- return;
95
- const logPath = path.resolve(expandHomePath(config.logging.path));
96
- fs.mkdirSync(path.dirname(logPath), { recursive: true, mode: 0o700 });
97
- const payload = {
98
- timestamp: new Date().toISOString(),
99
- source: input.source,
100
- level: input.level,
101
- message: input.message,
102
- details: input.details ?? {},
103
- };
104
- fs.appendFileSync(logPath, `${JSON.stringify(payload)}\n`, {
105
- encoding: "utf-8",
106
- mode: 0o600,
107
- });
108
- }
109
- catch {
110
- // best effort logging only
111
- }
112
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * Shared utility for normalizing tRPC API URLs.
3
- */
4
- export declare function normalizeTrpcUrl(apiUrl: string): string;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeTrpcUrl = normalizeTrpcUrl;
4
- /**
5
- * Shared utility for normalizing tRPC API URLs.
6
- */
7
- function normalizeTrpcUrl(apiUrl) {
8
- if (apiUrl.endsWith("/trpc")) {
9
- return apiUrl;
10
- }
11
- if (apiUrl.endsWith("/")) {
12
- return `${apiUrl}trpc`;
13
- }
14
- return `${apiUrl}/trpc`;
15
- }