@spekn/cli 1.0.0 → 1.0.2

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 +40540 -32176
  3. package/dist/prompts/governance-analysis.prompt.md +109 -0
  4. package/dist/resources/prompts/repo-analysis.prompt.md +28 -136
  5. package/dist/resources/prompts/repo-sync-analysis.prompt.md +31 -68
  6. package/dist/tui/chunk-4WEASLXY.mjs +3444 -0
  7. package/dist/tui/chunk-755CADEG.mjs +3401 -0
  8. package/dist/tui/chunk-BUJQVTY5.mjs +3409 -0
  9. package/dist/tui/chunk-BZKKMGFB.mjs +1959 -0
  10. package/dist/tui/chunk-DJYOBCNM.mjs +3159 -0
  11. package/dist/tui/chunk-GTFTFDY4.mjs +3417 -0
  12. package/dist/tui/chunk-IMEBD2KA.mjs +3444 -0
  13. package/dist/tui/chunk-IX6DR5SW.mjs +3433 -0
  14. package/dist/tui/chunk-JKFOY4IF.mjs +2003 -0
  15. package/dist/tui/chunk-OXXZ3O5L.mjs +3378 -0
  16. package/dist/tui/chunk-SHJNIAAJ.mjs +1697 -0
  17. package/dist/tui/chunk-V4SNDRUS.mjs +1666 -0
  18. package/dist/tui/chunk-VXVHNZST.mjs +1666 -0
  19. package/dist/tui/chunk-WCTSFKTA.mjs +3459 -0
  20. package/dist/tui/chunk-X2XP5ACW.mjs +3443 -0
  21. package/dist/tui/chunk-YUYJ7VBG.mjs +2029 -0
  22. package/dist/tui/chunk-ZM3EI5IA.mjs +3384 -0
  23. package/dist/tui/chunk-ZYOX64HP.mjs +1653 -0
  24. package/dist/tui/index.mjs +6999 -6938
  25. package/dist/tui/prompts/spec-creation-system.prompt.md +47 -0
  26. package/dist/tui/prompts/spec-refinement-system.prompt.md +72 -0
  27. package/dist/tui/use-session-store-63YUGUFA.mjs +8 -0
  28. package/dist/tui/use-session-store-ACO2SMJC.mjs +8 -0
  29. package/dist/tui/use-session-store-BVFDAWOB.mjs +8 -0
  30. package/dist/tui/use-session-store-DJIZ3FQZ.mjs +9 -0
  31. package/dist/tui/use-session-store-EAIQA4UG.mjs +9 -0
  32. package/dist/tui/use-session-store-EFBAXC3G.mjs +8 -0
  33. package/dist/tui/use-session-store-FJOR4KTG.mjs +8 -0
  34. package/dist/tui/use-session-store-IJE5KVOC.mjs +8 -0
  35. package/dist/tui/use-session-store-KGAFXCKI.mjs +8 -0
  36. package/dist/tui/use-session-store-KS4DPNDY.mjs +8 -0
  37. package/dist/tui/use-session-store-MMHJENNL.mjs +8 -0
  38. package/dist/tui/use-session-store-OZ6HC4I2.mjs +9 -0
  39. package/dist/tui/use-session-store-PTMWISNJ.mjs +8 -0
  40. package/dist/tui/use-session-store-VCDECQMW.mjs +8 -0
  41. package/dist/tui/use-session-store-VOK5ML5J.mjs +9 -0
  42. package/package.json +33 -13
  43. package/dist/__tests__/export-cli.test.d.ts +0 -1
  44. package/dist/__tests__/export-cli.test.js +0 -70
  45. package/dist/__tests__/tui-args-policy.test.d.ts +0 -1
  46. package/dist/__tests__/tui-args-policy.test.js +0 -50
  47. package/dist/acp-S2MHZOAD.mjs +0 -23
  48. package/dist/acp-UCCI44JY.mjs +0 -25
  49. package/dist/auth/credentials-store.d.ts +0 -2
  50. package/dist/auth/credentials-store.js +0 -5
  51. package/dist/auth/device-flow.d.ts +0 -36
  52. package/dist/auth/device-flow.js +0 -189
  53. package/dist/auth/jwt.d.ts +0 -1
  54. package/dist/auth/jwt.js +0 -6
  55. package/dist/auth/session.d.ts +0 -67
  56. package/dist/auth/session.js +0 -86
  57. package/dist/auth-login.d.ts +0 -34
  58. package/dist/auth-login.js +0 -202
  59. package/dist/auth-logout.d.ts +0 -25
  60. package/dist/auth-logout.js +0 -115
  61. package/dist/auth-status.d.ts +0 -24
  62. package/dist/auth-status.js +0 -109
  63. package/dist/backlog-generate.d.ts +0 -11
  64. package/dist/backlog-generate.js +0 -308
  65. package/dist/backlog-health.d.ts +0 -11
  66. package/dist/backlog-health.js +0 -287
  67. package/dist/bridge-login.d.ts +0 -40
  68. package/dist/bridge-login.js +0 -277
  69. package/dist/chunk-3PAYRI4G.mjs +0 -2428
  70. package/dist/chunk-M4CS3A25.mjs +0 -2426
  71. package/dist/commands/auth/login.d.ts +0 -30
  72. package/dist/commands/auth/login.js +0 -164
  73. package/dist/commands/auth/logout.d.ts +0 -25
  74. package/dist/commands/auth/logout.js +0 -115
  75. package/dist/commands/auth/status.d.ts +0 -24
  76. package/dist/commands/auth/status.js +0 -109
  77. package/dist/commands/backlog/generate.d.ts +0 -11
  78. package/dist/commands/backlog/generate.js +0 -308
  79. package/dist/commands/backlog/health.d.ts +0 -11
  80. package/dist/commands/backlog/health.js +0 -287
  81. package/dist/commands/bridge/login.d.ts +0 -36
  82. package/dist/commands/bridge/login.js +0 -258
  83. package/dist/commands/export.d.ts +0 -35
  84. package/dist/commands/export.js +0 -485
  85. package/dist/commands/marketplace-export.d.ts +0 -21
  86. package/dist/commands/marketplace-export.js +0 -214
  87. package/dist/commands/project-clean.d.ts +0 -1
  88. package/dist/commands/project-clean.js +0 -126
  89. package/dist/commands/repo/common.d.ts +0 -105
  90. package/dist/commands/repo/common.js +0 -775
  91. package/dist/commands/repo/detach.d.ts +0 -2
  92. package/dist/commands/repo/detach.js +0 -120
  93. package/dist/commands/repo/register.d.ts +0 -21
  94. package/dist/commands/repo/register.js +0 -175
  95. package/dist/commands/repo/sync.d.ts +0 -22
  96. package/dist/commands/repo/sync.js +0 -873
  97. package/dist/commands/skills-import-local.d.ts +0 -16
  98. package/dist/commands/skills-import-local.js +0 -352
  99. package/dist/commands/spec/drift-check.d.ts +0 -3
  100. package/dist/commands/spec/drift-check.js +0 -186
  101. package/dist/commands/spec/frontmatter.d.ts +0 -11
  102. package/dist/commands/spec/frontmatter.js +0 -219
  103. package/dist/commands/spec/lint.d.ts +0 -11
  104. package/dist/commands/spec/lint.js +0 -499
  105. package/dist/commands/spec/parse.d.ts +0 -11
  106. package/dist/commands/spec/parse.js +0 -162
  107. package/dist/export.d.ts +0 -35
  108. package/dist/export.js +0 -485
  109. package/dist/main.d.ts +0 -1
  110. package/dist/marketplace-export.d.ts +0 -21
  111. package/dist/marketplace-export.js +0 -214
  112. package/dist/project-clean.d.ts +0 -1
  113. package/dist/project-clean.js +0 -126
  114. package/dist/project-context.d.ts +0 -99
  115. package/dist/project-context.js +0 -376
  116. package/dist/repo-common.d.ts +0 -101
  117. package/dist/repo-common.js +0 -671
  118. package/dist/repo-detach.d.ts +0 -2
  119. package/dist/repo-detach.js +0 -102
  120. package/dist/repo-ingest.d.ts +0 -29
  121. package/dist/repo-ingest.js +0 -305
  122. package/dist/repo-register.d.ts +0 -21
  123. package/dist/repo-register.js +0 -175
  124. package/dist/repo-sync.d.ts +0 -16
  125. package/dist/repo-sync.js +0 -152
  126. package/dist/resources/prompt-loader.d.ts +0 -1
  127. package/dist/resources/prompt-loader.js +0 -62
  128. package/dist/skills-import-local.d.ts +0 -16
  129. package/dist/skills-import-local.js +0 -352
  130. package/dist/spec-drift-check.d.ts +0 -3
  131. package/dist/spec-drift-check.js +0 -186
  132. package/dist/spec-frontmatter.d.ts +0 -11
  133. package/dist/spec-frontmatter.js +0 -219
  134. package/dist/spec-lint.d.ts +0 -11
  135. package/dist/spec-lint.js +0 -499
  136. package/dist/spec-parse.d.ts +0 -11
  137. package/dist/spec-parse.js +0 -162
  138. package/dist/stubs/dotenv.d.ts +0 -5
  139. package/dist/stubs/dotenv.js +0 -6
  140. package/dist/stubs/typeorm.d.ts +0 -22
  141. package/dist/stubs/typeorm.js +0 -28
  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
- }