@polterware/polter 0.4.2 → 0.5.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 (45) hide show
  1. package/README.md +70 -184
  2. package/dist/api.js +62 -30
  3. package/dist/app-HGIGWI7F.js +393 -0
  4. package/dist/appPanel-EZOHLTBX.js +1365 -0
  5. package/dist/applier-OEXIUYYO.js +10 -0
  6. package/dist/chunk-3RG5ZIWI.js +10 -0
  7. package/dist/chunk-45CQFZU7.js +262 -0
  8. package/dist/chunk-57CZSEY5.js +5398 -0
  9. package/dist/chunk-6IBRTRLX.js +257 -0
  10. package/dist/chunk-AK3NTS3Y.js +220 -0
  11. package/dist/chunk-BGT5TT2A.js +32 -0
  12. package/dist/chunk-BIN7BDA2.js +77 -0
  13. package/dist/chunk-E2B5FFBU.js +81 -0
  14. package/dist/chunk-EAMHFQKU.js +222 -0
  15. package/dist/chunk-ELSIHPJL.js +455 -0
  16. package/dist/{chunk-XCCKD3RZ.js → chunk-GCS7JEYU.js} +7 -3
  17. package/dist/chunk-GKROVUDG.js +15 -0
  18. package/dist/chunk-GVIKF6UI.js +738 -0
  19. package/dist/chunk-JQB2A3CA.js +72 -0
  20. package/dist/chunk-KEGROLGX.js +50 -0
  21. package/dist/chunk-OKHPN6X7.js +49 -0
  22. package/dist/chunk-RVMOIUSL.js +22 -0
  23. package/dist/chunk-TD6YNU6L.js +22 -0
  24. package/dist/chunk-U64WZOJ3.js +101 -0
  25. package/dist/chunk-U6725U7K.js +138 -0
  26. package/dist/chunk-XNRIN3VM.js +125 -0
  27. package/dist/chunk-ZU5VZHYD.js +28 -0
  28. package/dist/commands-BIIWGCVS.js +15 -0
  29. package/dist/editor-AUFJZ4PE.js +11 -0
  30. package/dist/engine-EZQ26HDJ.js +11 -0
  31. package/dist/globalConf-AGMMIKSL.js +7 -0
  32. package/dist/index.js +49 -7601
  33. package/dist/ipcServer-HXOPKNBP.js +10 -0
  34. package/dist/mcp.js +182 -13892
  35. package/dist/mcpInstaller-J2AGFNWR.js +19 -0
  36. package/dist/parser-4ZBGSI2U.js +10 -0
  37. package/dist/planner-ZVBA66V6.js +9 -0
  38. package/dist/processManager-6T5DBURV.js +37 -0
  39. package/dist/projectConfig-TRCJS3VI.js +21 -0
  40. package/dist/skillSetup-ZQEHJ5ZG.js +14 -0
  41. package/dist/status-QMRCV4XJ.js +8 -0
  42. package/dist/storage-C3D7TLJW.js +17 -0
  43. package/dist/toolResolver-A2BUT3NK.js +17 -0
  44. package/package.json +28 -3
  45. package/dist/chunk-CWBIXRZP.js +0 -2607
@@ -0,0 +1,393 @@
1
+ import {
2
+ CommandArgs,
3
+ CommandExecution,
4
+ CustomCommand,
5
+ DeclarativePlan,
6
+ DeclarativeStatus,
7
+ FlagSelection,
8
+ GhostBanner,
9
+ InitScaffold,
10
+ McpManage,
11
+ PipelineBuilder,
12
+ PipelineExecution,
13
+ PipelineList,
14
+ ProcessList,
15
+ ProcessLogs,
16
+ ProjectConfig,
17
+ ScriptPicker,
18
+ SelectList,
19
+ SelfUpdate,
20
+ SkillSetup,
21
+ StatusBar,
22
+ ToolStatus,
23
+ buildHomeItems,
24
+ colors,
25
+ getFeatures,
26
+ getPinnedCommands,
27
+ getPinnedRuns,
28
+ inkColors,
29
+ togglePinnedCommand,
30
+ togglePinnedRun,
31
+ useTerminalDimensions
32
+ } from "./chunk-57CZSEY5.js";
33
+ import "./chunk-KEGROLGX.js";
34
+ import "./chunk-AK3NTS3Y.js";
35
+ import "./chunk-XNRIN3VM.js";
36
+ import "./chunk-U64WZOJ3.js";
37
+ import "./chunk-BIN7BDA2.js";
38
+ import "./chunk-GKROVUDG.js";
39
+ import "./chunk-U6725U7K.js";
40
+ import "./chunk-E2B5FFBU.js";
41
+ import "./chunk-OKHPN6X7.js";
42
+ import "./chunk-BGT5TT2A.js";
43
+ import "./chunk-45CQFZU7.js";
44
+ import "./chunk-6IBRTRLX.js";
45
+ import "./chunk-ZU5VZHYD.js";
46
+ import "./chunk-JQB2A3CA.js";
47
+ import {
48
+ findCommandByValue
49
+ } from "./chunk-GVIKF6UI.js";
50
+ import "./chunk-ELSIHPJL.js";
51
+ import "./chunk-RVMOIUSL.js";
52
+ import "./chunk-TD6YNU6L.js";
53
+ import "./chunk-3RG5ZIWI.js";
54
+
55
+ // src/app.tsx
56
+ import { Box as Box3, Text as Text3, useApp } from "ink";
57
+
58
+ // src/hooks/useNavigation.ts
59
+ import { useState, useCallback } from "react";
60
+ function useNavigation() {
61
+ const [stack, setStack] = useState([
62
+ { screen: "home", params: {} }
63
+ ]);
64
+ const current = stack[stack.length - 1];
65
+ const navigate = useCallback((screen, params) => {
66
+ setStack((prev) => [...prev, { screen, params: params ?? {} }]);
67
+ }, []);
68
+ const goBack = useCallback(() => {
69
+ setStack((prev) => {
70
+ if (prev.length <= 1) return [{ screen: "home", params: {} }];
71
+ return prev.slice(0, -1);
72
+ });
73
+ }, []);
74
+ const goHome = useCallback(() => {
75
+ setStack([{ screen: "home", params: {} }]);
76
+ }, []);
77
+ return {
78
+ screen: current.screen,
79
+ params: current.params,
80
+ navigate,
81
+ goBack,
82
+ goHome
83
+ };
84
+ }
85
+
86
+ // src/hooks/useTerminalWidth.ts
87
+ function useTerminalWidth() {
88
+ return useTerminalDimensions().width;
89
+ }
90
+
91
+ // src/hooks/useTerminalHeight.ts
92
+ function useTerminalHeight() {
93
+ return useTerminalDimensions().height;
94
+ }
95
+
96
+ // src/screens/Home.tsx
97
+ import { useEffect, useMemo, useState as useState2 } from "react";
98
+ import { Box as Box2, Text as Text2, useInput } from "ink";
99
+ import ms from "ms";
100
+
101
+ // src/components/TabBar.tsx
102
+ import { Box, Text } from "ink";
103
+ import { jsx, jsxs } from "react/jsx-runtime";
104
+ function TabBar({ tabs, activeIndex, width = 80 }) {
105
+ const narrow = width < 50;
106
+ const medium = width < 80;
107
+ return /* @__PURE__ */ jsx(Box, { gap: 1, children: tabs.map((tab, i) => {
108
+ const isActive = i === activeIndex;
109
+ const showLabel = narrow ? false : medium ? isActive : true;
110
+ const displayText = showLabel ? `${tab.icon} ${tab.label}` : tab.icon;
111
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
112
+ /* @__PURE__ */ jsx(
113
+ Text,
114
+ {
115
+ color: isActive ? inkColors.accent : void 0,
116
+ bold: isActive,
117
+ dimColor: !isActive,
118
+ children: displayText
119
+ }
120
+ ),
121
+ isActive && !narrow && /* @__PURE__ */ jsx(Text, { color: inkColors.accent, children: "\u2550".repeat(displayText.length) })
122
+ ] }, tab.id);
123
+ }) });
124
+ }
125
+
126
+ // src/screens/Home.tsx
127
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
128
+ function Home({
129
+ onNavigate,
130
+ onExit,
131
+ width = 80,
132
+ height = 24
133
+ }) {
134
+ const allFeatures = useMemo(() => getFeatures(), []);
135
+ const [activeTabIndex, setActiveTabIndex] = useState2(0);
136
+ const [pinnedCommands, setPinnedCommands] = useState2(
137
+ () => getPinnedCommands()
138
+ );
139
+ const [pinnedRuns, setPinnedRuns] = useState2(
140
+ () => getPinnedRuns()
141
+ );
142
+ const [pinFeedback, setPinFeedback] = useState2();
143
+ const activeFeature = allFeatures[activeTabIndex];
144
+ useEffect(() => {
145
+ if (!pinFeedback) return;
146
+ const timeout = setTimeout(() => setPinFeedback(void 0), ms("1.4s"));
147
+ return () => clearTimeout(timeout);
148
+ }, [pinFeedback]);
149
+ useInput((_input, key) => {
150
+ if (key.leftArrow && !key.meta) {
151
+ setActiveTabIndex(
152
+ (prev) => prev > 0 ? prev - 1 : allFeatures.length - 1
153
+ );
154
+ }
155
+ if (key.rightArrow && !key.meta) {
156
+ setActiveTabIndex(
157
+ (prev) => prev < allFeatures.length - 1 ? prev + 1 : 0
158
+ );
159
+ }
160
+ if (key.tab) {
161
+ setActiveTabIndex(
162
+ (prev) => prev < allFeatures.length - 1 ? prev + 1 : 0
163
+ );
164
+ }
165
+ });
166
+ const tabs = useMemo(
167
+ () => allFeatures.map((f) => ({ id: f.id, icon: f.icon, label: f.label })),
168
+ [allFeatures]
169
+ );
170
+ const items = useMemo(
171
+ () => buildHomeItems({
172
+ activeFeature,
173
+ pinnedCommands,
174
+ pinnedRuns
175
+ }),
176
+ [activeFeature, pinnedCommands, pinnedRuns]
177
+ );
178
+ const pinnedCommandSet = useMemo(
179
+ () => new Set(pinnedCommands),
180
+ [pinnedCommands]
181
+ );
182
+ const pinnedRunSet = useMemo(() => new Set(pinnedRuns), [pinnedRuns]);
183
+ const refreshPins = () => {
184
+ setPinnedCommands(getPinnedCommands());
185
+ setPinnedRuns(getPinnedRuns());
186
+ };
187
+ const handleSelect = (value, item) => {
188
+ if (!item) return;
189
+ if (item.kind === "command") {
190
+ const cmdDef = findCommandByValue(value);
191
+ if (cmdDef) {
192
+ onNavigate("command-args", {
193
+ command: value,
194
+ commandId: cmdDef.id,
195
+ tool: cmdDef.tool
196
+ });
197
+ } else {
198
+ onNavigate("command-args", { command: value, tool: "supabase" });
199
+ }
200
+ return;
201
+ }
202
+ if (item.kind === "run") {
203
+ const args = value.split(" ").filter(Boolean);
204
+ if (args.length > 0) {
205
+ const basePart = args[0] ?? "";
206
+ const cmdDef = findCommandByValue(basePart);
207
+ const tool = cmdDef?.tool ?? "supabase";
208
+ onNavigate("confirm-execute", { args, tool, interactive: cmdDef?.interactive });
209
+ }
210
+ return;
211
+ }
212
+ switch (value) {
213
+ case "__action_custom__":
214
+ onNavigate("custom-command");
215
+ break;
216
+ case "__action_pipelines__":
217
+ onNavigate("pipeline-list");
218
+ break;
219
+ case "__action_tools__":
220
+ onNavigate("tool-status");
221
+ break;
222
+ case "__action_config__":
223
+ onNavigate("project-config");
224
+ break;
225
+ case "__action_skill_setup__":
226
+ onNavigate("skill-setup");
227
+ break;
228
+ case "__action_update__":
229
+ onNavigate("self-update");
230
+ break;
231
+ case "__action_declarative_plan__":
232
+ onNavigate("declarative-plan");
233
+ break;
234
+ case "__action_declarative_status__":
235
+ onNavigate("declarative-status");
236
+ break;
237
+ case "__action_init_scaffold__":
238
+ onNavigate("init-scaffold");
239
+ break;
240
+ case "__action_exit__":
241
+ onExit();
242
+ break;
243
+ }
244
+ };
245
+ const handleRightAction = (item) => {
246
+ if (item.kind === "command") {
247
+ const wasPinned = pinnedCommandSet.has(item.value);
248
+ togglePinnedCommand(item.value);
249
+ refreshPins();
250
+ setPinFeedback(
251
+ wasPinned ? `Unpinned "${item.value}"` : `Pinned "${item.value}"`
252
+ );
253
+ return;
254
+ }
255
+ if (item.kind === "run") {
256
+ const wasPinned = pinnedRunSet.has(item.value);
257
+ togglePinnedRun(item.value);
258
+ refreshPins();
259
+ setPinFeedback(
260
+ wasPinned ? `Unpinned run "${item.value}"` : `Pinned run "${item.value}"`
261
+ );
262
+ }
263
+ };
264
+ return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", children: [
265
+ /* @__PURE__ */ jsx2(Box2, { marginBottom: 1, children: /* @__PURE__ */ jsx2(TabBar, { tabs, activeIndex: activeTabIndex, width }) }),
266
+ pinFeedback && /* @__PURE__ */ jsx2(Box2, { marginBottom: 1, children: /* @__PURE__ */ jsxs2(Text2, { color: inkColors.accent, children: [
267
+ "\u2713 ",
268
+ pinFeedback
269
+ ] }) }),
270
+ /* @__PURE__ */ jsx2(
271
+ SelectList,
272
+ {
273
+ items,
274
+ onSelect: handleSelect,
275
+ onRightAction: handleRightAction,
276
+ boxedSections: true,
277
+ width,
278
+ maxVisible: Math.max(8, height - 14)
279
+ }
280
+ ),
281
+ /* @__PURE__ */ jsx2(StatusBar, { hint: "\u2190\u2192 tab \xB7 \u2191\u2193 navigate \xB7 Enter select \xB7 p pin", width })
282
+ ] });
283
+ }
284
+
285
+ // src/app.tsx
286
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
287
+ function AppClassic() {
288
+ const { screen, params, navigate, goBack, goHome } = useNavigation();
289
+ const { exit } = useApp();
290
+ const width = useTerminalWidth();
291
+ const height = useTerminalHeight();
292
+ const handleExit = () => {
293
+ process.stdout.write(
294
+ "\n" + colors.dim("Thank you for using ") + colors.primaryBold("Polter") + colors.dim("!") + "\n\n"
295
+ );
296
+ exit();
297
+ };
298
+ const renderScreen = () => {
299
+ switch (screen) {
300
+ case "home":
301
+ return /* @__PURE__ */ jsx3(Home, { onNavigate: navigate, onExit: handleExit, width, height });
302
+ case "command-args":
303
+ return /* @__PURE__ */ jsx3(
304
+ CommandArgs,
305
+ {
306
+ command: params.command ?? "",
307
+ tool: params.tool,
308
+ onNavigate: navigate,
309
+ onBack: goBack,
310
+ width
311
+ }
312
+ );
313
+ case "custom-command":
314
+ return /* @__PURE__ */ jsx3(CustomCommand, { onNavigate: navigate, onBack: goBack, width });
315
+ case "flag-selection":
316
+ return /* @__PURE__ */ jsx3(
317
+ FlagSelection,
318
+ {
319
+ args: params.args ?? [],
320
+ tool: params.tool,
321
+ onNavigate: navigate,
322
+ onBack: goBack,
323
+ width
324
+ }
325
+ );
326
+ case "confirm-execute":
327
+ case "command-execution":
328
+ return /* @__PURE__ */ jsx3(
329
+ CommandExecution,
330
+ {
331
+ args: params.args ?? [],
332
+ tool: params.tool,
333
+ rawCommand: params.rawCommand,
334
+ onBack: goBack,
335
+ onExit: handleExit,
336
+ onRunSuggestion: (sugTool, sugArgs) => {
337
+ goHome();
338
+ navigate("confirm-execute", { tool: sugTool, args: sugArgs });
339
+ },
340
+ width
341
+ }
342
+ );
343
+ case "self-update":
344
+ return /* @__PURE__ */ jsx3(SelfUpdate, { onBack: goBack, onExit: handleExit, width });
345
+ case "tool-status":
346
+ return /* @__PURE__ */ jsx3(ToolStatus, { onBack: goBack, onNavigate: navigate, width });
347
+ case "mcp-manage":
348
+ return /* @__PURE__ */ jsx3(McpManage, { onBack: goBack, width });
349
+ case "process-list":
350
+ return /* @__PURE__ */ jsx3(ProcessList, { onNavigate: navigate, onBack: goBack, width, height });
351
+ case "process-logs":
352
+ return /* @__PURE__ */ jsx3(ProcessLogs, { processId: params.processId ?? "", onBack: goBack, width, height });
353
+ case "project-config":
354
+ return /* @__PURE__ */ jsx3(ProjectConfig, { onBack: goBack, width });
355
+ case "pipeline-list":
356
+ return /* @__PURE__ */ jsx3(PipelineList, { onNavigate: navigate, onBack: goBack, width });
357
+ case "pipeline-builder":
358
+ return /* @__PURE__ */ jsx3(PipelineBuilder, { onBack: goBack, width, height });
359
+ case "pipeline-execution":
360
+ return /* @__PURE__ */ jsx3(
361
+ PipelineExecution,
362
+ {
363
+ pipelineId: params.pipelineId ?? "",
364
+ onBack: goBack,
365
+ onExit: handleExit,
366
+ width
367
+ }
368
+ );
369
+ case "declarative-plan":
370
+ return /* @__PURE__ */ jsx3(DeclarativePlan, { onBack: goBack, onNavigate: navigate, width, height });
371
+ case "declarative-status":
372
+ return /* @__PURE__ */ jsx3(DeclarativeStatus, { onBack: goBack, width, height });
373
+ case "init-scaffold":
374
+ return /* @__PURE__ */ jsx3(InitScaffold, { onBack: goBack, onNavigate: navigate, width, height });
375
+ case "script-picker":
376
+ return /* @__PURE__ */ jsx3(ScriptPicker, { onNavigate: navigate, onBack: goBack, width, height });
377
+ case "skill-setup":
378
+ return /* @__PURE__ */ jsx3(SkillSetup, { onBack: goBack, width, height });
379
+ default:
380
+ return /* @__PURE__ */ jsx3(Box3, { children: /* @__PURE__ */ jsxs3(Text3, { color: "red", children: [
381
+ "Unknown screen: ",
382
+ screen
383
+ ] }) });
384
+ }
385
+ };
386
+ return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", children: [
387
+ /* @__PURE__ */ jsx3(GhostBanner, { width }),
388
+ renderScreen()
389
+ ] });
390
+ }
391
+ export {
392
+ AppClassic
393
+ };