@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,35 @@
1
+ import type { BridgeSummary, DecisionListItem, ExportFormat, ExportPreview, LocalBridgeSummary, NavItemPolicy, SpecListItem, TuiBootContext, TuiScreenId, WorkflowSummary } from '../types';
2
+ export interface TuiState {
3
+ boot: TuiBootContext | null;
4
+ client: any | null;
5
+ loading: boolean;
6
+ error: string | null;
7
+ screen: TuiScreenId;
8
+ navPolicy: NavItemPolicy[];
9
+ specs: SpecListItem[];
10
+ decisions: DecisionListItem[];
11
+ workflow: WorkflowSummary;
12
+ bridge: BridgeSummary | null;
13
+ localBridge: LocalBridgeSummary | null;
14
+ exportFormat: ExportFormat;
15
+ exportPreview: ExportPreview | null;
16
+ statusLine: string;
17
+ logs: string[];
18
+ searchQuery: string;
19
+ showHelp: boolean;
20
+ commandMode: boolean;
21
+ }
22
+ export declare function useAppState(apiUrl: string, initialScreen: TuiScreenId, projectId?: string): {
23
+ state: TuiState;
24
+ refresh: () => Promise<void>;
25
+ setScreen: (screen: TuiScreenId) => void;
26
+ toggleHelp: () => void;
27
+ setSearchQuery: (searchQuery: string) => void;
28
+ setCommandMode: (commandMode: boolean) => void;
29
+ setExportFormat: (exportFormat: ExportFormat) => void;
30
+ previewExport: () => Promise<void>;
31
+ generateExport: () => Promise<void>;
32
+ bridgeStart: () => void;
33
+ bridgeStop: () => Promise<void>;
34
+ appendLog: (entry: string) => void;
35
+ };
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAppState = useAppState;
4
+ const react_1 = require("react");
5
+ const policy_1 = require("../capabilities/policy");
6
+ const context_service_1 = require("../services/context-service");
7
+ const EMPTY_WORKFLOW = {
8
+ currentPhase: null,
9
+ blockedCount: 0,
10
+ hasPlanningArtifacts: false,
11
+ hasVerificationEvidence: false,
12
+ };
13
+ function useAppState(apiUrl, initialScreen, projectId) {
14
+ const service = (0, react_1.useMemo)(() => new context_service_1.TuiContextService(apiUrl), [apiUrl]);
15
+ const [state, setState] = (0, react_1.useState)({
16
+ boot: null,
17
+ client: null,
18
+ loading: true,
19
+ error: null,
20
+ screen: initialScreen,
21
+ navPolicy: [],
22
+ specs: [],
23
+ decisions: [],
24
+ workflow: EMPTY_WORKFLOW,
25
+ bridge: null,
26
+ localBridge: null,
27
+ exportFormat: 'claude-md',
28
+ exportPreview: null,
29
+ statusLine: 'Bootstrapping...',
30
+ logs: [],
31
+ searchQuery: '',
32
+ showHelp: false,
33
+ commandMode: false,
34
+ });
35
+ const appendLog = (0, react_1.useCallback)((entry) => {
36
+ setState((prev) => ({ ...prev, logs: [entry, ...prev.logs].slice(0, 40) }));
37
+ }, []);
38
+ const refresh = (0, react_1.useCallback)(async () => {
39
+ setState((prev) => ({ ...prev, loading: true, statusLine: 'Loading context...' }));
40
+ try {
41
+ const { boot, client } = await service.bootstrap(projectId);
42
+ const [specs, decisions, workflow, bridge, localBridge] = await Promise.all([
43
+ service.loadSpecs(client, boot.projectId),
44
+ service.loadDecisions(client, boot.projectId),
45
+ service.loadWorkflowSummary(client, boot.projectId),
46
+ service.loadBridgeSummary(client),
47
+ service.loadLocalBridgeSummary(),
48
+ ]);
49
+ const capabilityContext = {
50
+ plan: boot.plan,
51
+ role: boot.role,
52
+ workflowPhase: workflow.currentPhase,
53
+ permissions: boot.permissions,
54
+ };
55
+ const navPolicy = (0, policy_1.resolveNavPolicy)(capabilityContext);
56
+ setState((prev) => ({
57
+ ...prev,
58
+ boot,
59
+ client,
60
+ specs,
61
+ decisions,
62
+ workflow,
63
+ bridge,
64
+ localBridge,
65
+ navPolicy,
66
+ loading: false,
67
+ error: null,
68
+ statusLine: 'Ready',
69
+ }));
70
+ }
71
+ catch (error) {
72
+ const message = error instanceof Error ? error.message : String(error);
73
+ setState((prev) => ({ ...prev, loading: false, error: message, statusLine: 'Error' }));
74
+ appendLog(`[error] ${message}`);
75
+ }
76
+ }, [appendLog, projectId, service]);
77
+ (0, react_1.useEffect)(() => {
78
+ void refresh();
79
+ }, [refresh]);
80
+ (0, react_1.useEffect)(() => {
81
+ const timer = setInterval(() => {
82
+ if (!state.client || !state.boot)
83
+ return;
84
+ void Promise.all([
85
+ service.loadWorkflowSummary(state.client, state.boot.projectId),
86
+ service.loadLocalBridgeSummary(),
87
+ ])
88
+ .then(([workflow, localBridge]) => {
89
+ setState((prev) => {
90
+ const ctx = {
91
+ plan: prev.boot?.plan ?? prev.navPolicy[0]?.requiredPlan ?? (prev.boot?.plan ?? 'free'),
92
+ role: prev.boot?.role ?? 'member',
93
+ workflowPhase: workflow.currentPhase,
94
+ permissions: prev.boot?.permissions ?? [],
95
+ };
96
+ return {
97
+ ...prev,
98
+ workflow,
99
+ localBridge,
100
+ navPolicy: (0, policy_1.resolveNavPolicy)(ctx),
101
+ };
102
+ });
103
+ })
104
+ .catch(() => undefined);
105
+ }, 6000);
106
+ return () => clearInterval(timer);
107
+ }, [service, state.boot, state.client, state.navPolicy]);
108
+ const setScreen = (0, react_1.useCallback)((screen) => {
109
+ setState((prev) => ({ ...prev, screen }));
110
+ }, []);
111
+ const toggleHelp = (0, react_1.useCallback)(() => {
112
+ setState((prev) => ({ ...prev, showHelp: !prev.showHelp }));
113
+ }, []);
114
+ const setSearchQuery = (0, react_1.useCallback)((searchQuery) => {
115
+ setState((prev) => ({ ...prev, searchQuery }));
116
+ }, []);
117
+ const setCommandMode = (0, react_1.useCallback)((commandMode) => {
118
+ setState((prev) => ({ ...prev, commandMode }));
119
+ }, []);
120
+ const setExportFormat = (0, react_1.useCallback)((exportFormat) => {
121
+ setState((prev) => ({ ...prev, exportFormat }));
122
+ }, []);
123
+ const previewExport = (0, react_1.useCallback)(async () => {
124
+ if (!state.client || !state.boot)
125
+ return;
126
+ setState((prev) => ({ ...prev, statusLine: 'Previewing export...' }));
127
+ try {
128
+ const preview = await service.previewExport(state.client, state.boot.projectId, state.exportFormat);
129
+ setState((prev) => ({ ...prev, exportPreview: preview, statusLine: 'Export preview ready' }));
130
+ appendLog(`[export] Previewed ${state.exportFormat} (${preview.anchorCount} anchors)`);
131
+ }
132
+ catch (error) {
133
+ const message = error instanceof Error ? error.message : String(error);
134
+ appendLog(`[error] Export preview failed: ${message}`);
135
+ setState((prev) => ({ ...prev, statusLine: 'Export preview failed' }));
136
+ }
137
+ }, [appendLog, service, state.boot, state.client, state.exportFormat]);
138
+ const generateExport = (0, react_1.useCallback)(async () => {
139
+ if (!state.client || !state.boot)
140
+ return;
141
+ setState((prev) => ({ ...prev, statusLine: 'Generating export...' }));
142
+ try {
143
+ const output = await service.generateExport(state.client, state.boot.projectId, state.exportFormat);
144
+ setState((prev) => ({ ...prev, exportPreview: output, statusLine: 'Export generated' }));
145
+ appendLog(`[export] Generated ${state.exportFormat} (${output.anchorCount} anchors)`);
146
+ }
147
+ catch (error) {
148
+ const message = error instanceof Error ? error.message : String(error);
149
+ appendLog(`[error] Export generation failed: ${message}`);
150
+ setState((prev) => ({ ...prev, statusLine: 'Export generation failed' }));
151
+ }
152
+ }, [appendLog, service, state.boot, state.client, state.exportFormat]);
153
+ const bridgeStart = (0, react_1.useCallback)(() => {
154
+ service.startLocalBridgeDetached();
155
+ appendLog('[bridge] Started local bridge process (detached)');
156
+ setState((prev) => ({ ...prev, statusLine: 'Bridge start triggered (detached)' }));
157
+ }, [appendLog, service]);
158
+ const bridgeStop = (0, react_1.useCallback)(async () => {
159
+ await service.stopLocalBridge(state.localBridge?.port);
160
+ appendLog('[bridge] Stop signal sent');
161
+ setState((prev) => ({ ...prev, statusLine: 'Bridge stop signal sent' }));
162
+ }, [appendLog, service, state.localBridge?.port]);
163
+ return {
164
+ state,
165
+ refresh,
166
+ setScreen,
167
+ toggleHelp,
168
+ setSearchQuery,
169
+ setCommandMode,
170
+ setExportFormat,
171
+ previewExport,
172
+ generateExport,
173
+ bridgeStart,
174
+ bridgeStop,
175
+ appendLog,
176
+ };
177
+ }
@@ -0,0 +1,77 @@
1
+ import type { OrganizationPlan, WorkflowPhase } from './shared-enums';
2
+ export type TuiScreenId = 'home' | 'specs' | 'export' | 'decisions' | 'bridge' | 'active-runs' | 'phase-gates' | 'skills-marketplace' | 'org-governance';
3
+ export type TuiRole = 'owner' | 'admin' | 'member' | 'viewer';
4
+ export type ActionState = 'enabled' | 'disabled' | 'locked';
5
+ export interface CapabilityContext {
6
+ plan: OrganizationPlan;
7
+ role: TuiRole;
8
+ workflowPhase: WorkflowPhase | null;
9
+ permissions: string[];
10
+ }
11
+ export interface NavItemPolicy {
12
+ id: TuiScreenId;
13
+ label: string;
14
+ description: string;
15
+ requiredPlan: OrganizationPlan;
16
+ state: ActionState;
17
+ reason?: string;
18
+ }
19
+ export interface TuiBootContext {
20
+ apiUrl: string;
21
+ organizationId: string;
22
+ organizationName: string;
23
+ role: TuiRole;
24
+ plan: OrganizationPlan;
25
+ projectId: string;
26
+ projectName: string;
27
+ permissions: string[];
28
+ }
29
+ export interface SpecListItem {
30
+ id: string;
31
+ title: string;
32
+ status: string;
33
+ version: string;
34
+ updatedAt?: string;
35
+ type?: string;
36
+ }
37
+ export interface DecisionListItem {
38
+ id: string;
39
+ title: string;
40
+ status: string;
41
+ decisionType: string;
42
+ specAnchor?: string | null;
43
+ createdAt?: string;
44
+ }
45
+ export interface WorkflowSummary {
46
+ currentPhase: WorkflowPhase | null;
47
+ blockedCount: number;
48
+ hasVerificationEvidence: boolean;
49
+ hasPlanningArtifacts: boolean;
50
+ }
51
+ export interface BridgeSummary {
52
+ featureEnabled: boolean;
53
+ devices: Array<{
54
+ id: string;
55
+ name: string;
56
+ status: string;
57
+ isDefault: boolean;
58
+ lastSeenAt?: string | null;
59
+ }>;
60
+ connectedDevices: number;
61
+ authFailures: number;
62
+ }
63
+ export interface LocalBridgeSummary {
64
+ paired: boolean;
65
+ deviceId?: string;
66
+ deviceName?: string;
67
+ port: number;
68
+ running: boolean;
69
+ uptimeSec?: number;
70
+ }
71
+ export type ExportFormat = 'claude-md' | 'cursorrules';
72
+ export interface ExportPreview {
73
+ content: string;
74
+ anchorCount: number;
75
+ specVersion?: string;
76
+ warnings?: string[];
77
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export { runTuiCli } from "@spekn/tui";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runTuiCli = void 0;
4
+ var tui_1 = require("@spekn/tui");
5
+ Object.defineProperty(exports, "runTuiCli", { enumerable: true, get: function () { return tui_1.runTuiCli; } });