wepscli 0.1.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.
- package/README.md +293 -0
- package/dist/WEPSCLI-shell/agent-runtime.js +824 -0
- package/dist/WEPSCLI-shell/agent-runtime.js.map +1 -0
- package/dist/WEPSCLI-shell/approval-overlay.js +275 -0
- package/dist/WEPSCLI-shell/approval-overlay.js.map +1 -0
- package/dist/WEPSCLI-shell/chat-components.js +760 -0
- package/dist/WEPSCLI-shell/chat-components.js.map +1 -0
- package/dist/WEPSCLI-shell/components.js +850 -0
- package/dist/WEPSCLI-shell/components.js.map +1 -0
- package/dist/WEPSCLI-shell/config-overlays.js +205 -0
- package/dist/WEPSCLI-shell/config-overlays.js.map +1 -0
- package/dist/WEPSCLI-shell/debug-log.js +16 -0
- package/dist/WEPSCLI-shell/debug-log.js.map +1 -0
- package/dist/WEPSCLI-shell/file-change-preview.js +261 -0
- package/dist/WEPSCLI-shell/file-change-preview.js.map +1 -0
- package/dist/WEPSCLI-shell/helpers.js +112 -0
- package/dist/WEPSCLI-shell/helpers.js.map +1 -0
- package/dist/WEPSCLI-shell/index.js +3 -0
- package/dist/WEPSCLI-shell/index.js.map +1 -0
- package/dist/WEPSCLI-shell/provider-add-flow.js +406 -0
- package/dist/WEPSCLI-shell/provider-add-flow.js.map +1 -0
- package/dist/WEPSCLI-shell/run-wepscli-shell.js +21 -0
- package/dist/WEPSCLI-shell/run-wepscli-shell.js.map +1 -0
- package/dist/WEPSCLI-shell/runtime-recovery.js +37 -0
- package/dist/WEPSCLI-shell/runtime-recovery.js.map +1 -0
- package/dist/WEPSCLI-shell/runtime-status.js +66 -0
- package/dist/WEPSCLI-shell/runtime-status.js.map +1 -0
- package/dist/WEPSCLI-shell/shell-app.js +1047 -0
- package/dist/WEPSCLI-shell/shell-app.js.map +1 -0
- package/dist/WEPSCLI-shell/shell-modes.js +77 -0
- package/dist/WEPSCLI-shell/shell-modes.js.map +1 -0
- package/dist/WEPSCLI-shell/slash-commands.js +135 -0
- package/dist/WEPSCLI-shell/slash-commands.js.map +1 -0
- package/dist/WEPSCLI-shell/theme.js +19 -0
- package/dist/WEPSCLI-shell/theme.js.map +1 -0
- package/dist/WEPSCLI-shell/tool-approval.js +85 -0
- package/dist/WEPSCLI-shell/tool-approval.js.map +1 -0
- package/dist/WEPSCLI-shell/tool-diff.js +76 -0
- package/dist/WEPSCLI-shell/tool-diff.js.map +1 -0
- package/dist/WEPSCLI-shell/tool-file-changes.js +268 -0
- package/dist/WEPSCLI-shell/tool-file-changes.js.map +1 -0
- package/dist/WEPSCLI-shell/tool-message-detail.js +138 -0
- package/dist/WEPSCLI-shell/tool-message-detail.js.map +1 -0
- package/dist/WEPSCLI-shell/tool-messages.js +145 -0
- package/dist/WEPSCLI-shell/tool-messages.js.map +1 -0
- package/dist/WEPSCLI-shell/transcript-panel.js +372 -0
- package/dist/WEPSCLI-shell/transcript-panel.js.map +1 -0
- package/dist/WEPSCLI-shell/transcript-state.js +62 -0
- package/dist/WEPSCLI-shell/transcript-state.js.map +1 -0
- package/dist/WEPSCLI-shell/types.js +1 -0
- package/dist/WEPSCLI-shell/types.js.map +1 -0
- package/dist/cli.js +11 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.js +40 -0
- package/dist/config.js.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/main.js +140 -0
- package/dist/main.js.map +1 -0
- package/dist/onboarding/action-screen.js +90 -0
- package/dist/onboarding/action-screen.js.map +1 -0
- package/dist/onboarding/framed-screen.js +35 -0
- package/dist/onboarding/framed-screen.js.map +1 -0
- package/dist/onboarding/onboarding-app.js +312 -0
- package/dist/onboarding/onboarding-app.js.map +1 -0
- package/dist/onboarding/run-onboarding.js +23 -0
- package/dist/onboarding/run-onboarding.js.map +1 -0
- package/dist/onboarding/select-screen.js +21 -0
- package/dist/onboarding/select-screen.js.map +1 -0
- package/dist/onboarding/summary-screen.js +23 -0
- package/dist/onboarding/summary-screen.js.map +1 -0
- package/dist/onboarding/text-input-screen.js +55 -0
- package/dist/onboarding/text-input-screen.js.map +1 -0
- package/dist/onboarding/theme.js +26 -0
- package/dist/onboarding/theme.js.map +1 -0
- package/dist/provider-profiles/api-key-store.js +51 -0
- package/dist/provider-profiles/api-key-store.js.map +1 -0
- package/dist/provider-profiles/defaults.js +18 -0
- package/dist/provider-profiles/defaults.js.map +1 -0
- package/dist/provider-profiles/fetch-models.js +53 -0
- package/dist/provider-profiles/fetch-models.js.map +1 -0
- package/dist/provider-profiles/index.js +6 -0
- package/dist/provider-profiles/index.js.map +1 -0
- package/dist/provider-profiles/provider-profile-service.js +223 -0
- package/dist/provider-profiles/provider-profile-service.js.map +1 -0
- package/dist/provider-profiles/providers-config-store.js +17 -0
- package/dist/provider-profiles/providers-config-store.js.map +1 -0
- package/dist/provider-profiles/types.js +1 -0
- package/dist/provider-profiles/types.js.map +1 -0
- package/dist/session-history/session-history-service.js +142 -0
- package/dist/session-history/session-history-service.js.map +1 -0
- package/dist/shell/animator.js +30 -0
- package/dist/shell/animator.js.map +1 -0
- package/dist/shell/clickables.js +101 -0
- package/dist/shell/clickables.js.map +1 -0
- package/dist/shell/dashboard-shell.js +292 -0
- package/dist/shell/dashboard-shell.js.map +1 -0
- package/dist/shell/index.js +5 -0
- package/dist/shell/index.js.map +1 -0
- package/dist/shell/keymap.js +14 -0
- package/dist/shell/keymap.js.map +1 -0
- package/dist/shell/mouse.js +39 -0
- package/dist/shell/mouse.js.map +1 -0
- package/dist/shell/render.js +122 -0
- package/dist/shell/render.js.map +1 -0
- package/dist/shell/run-shell.js +36 -0
- package/dist/shell/run-shell.js.map +1 -0
- package/dist/shell/theme.js +56 -0
- package/dist/shell/theme.js.map +1 -0
- package/dist/storage/locked-json-file.js +88 -0
- package/dist/storage/locked-json-file.js.map +1 -0
- package/dist/workbench/animator.js +30 -0
- package/dist/workbench/animator.js.map +1 -0
- package/dist/workbench/index.js +6 -0
- package/dist/workbench/index.js.map +1 -0
- package/dist/workbench/mouse.js +39 -0
- package/dist/workbench/mouse.js.map +1 -0
- package/dist/workbench/render.js +82 -0
- package/dist/workbench/render.js.map +1 -0
- package/dist/workbench/renderer.js +364 -0
- package/dist/workbench/renderer.js.map +1 -0
- package/dist/workbench/run-workbench.js +36 -0
- package/dist/workbench/run-workbench.js.map +1 -0
- package/dist/workbench/theme.js +63 -0
- package/dist/workbench/theme.js.map +1 -0
- package/dist/workbench/types.js +1 -0
- package/dist/workbench/types.js.map +1 -0
- package/dist/workbench/workbench-shell.js +649 -0
- package/dist/workbench/workbench-shell.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { toolDetailText } from "./tool-messages.js";
|
|
2
|
+
function withToolContent(message) {
|
|
3
|
+
if (message.tool) {
|
|
4
|
+
return {
|
|
5
|
+
...message,
|
|
6
|
+
content: toolDetailText(message.tool)
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
return message;
|
|
10
|
+
}
|
|
11
|
+
export function appendSessionMessage(current, sessionId, message) {
|
|
12
|
+
const list = current[sessionId] ?? [];
|
|
13
|
+
return {
|
|
14
|
+
...current,
|
|
15
|
+
[sessionId]: [...list, withToolContent(message)].slice(-200)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function insertSessionMessageBefore(current, sessionId, beforeMessageId, message) {
|
|
19
|
+
const list = current[sessionId] ?? [];
|
|
20
|
+
const index = list.findIndex(item => item.id === beforeMessageId);
|
|
21
|
+
if (index === -1) {
|
|
22
|
+
return appendSessionMessage(current, sessionId, message);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
...current,
|
|
26
|
+
[sessionId]: [...list.slice(0, index), withToolContent(message), ...list.slice(index)].slice(-200)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function patchSessionMessage(current, sessionId, messageId, patch) {
|
|
30
|
+
const list = current[sessionId] ?? [];
|
|
31
|
+
let patchedMessage;
|
|
32
|
+
const next = list.map(message => {
|
|
33
|
+
if (message.id !== messageId) {
|
|
34
|
+
return message;
|
|
35
|
+
}
|
|
36
|
+
const updated = withToolContent({
|
|
37
|
+
...message,
|
|
38
|
+
content: patch.appendContent ? `${message.content}${patch.appendContent}` : patch.content ?? message.content,
|
|
39
|
+
time: patch.time ?? message.time,
|
|
40
|
+
tool: patch.tool ?? message.tool
|
|
41
|
+
});
|
|
42
|
+
patchedMessage = updated;
|
|
43
|
+
return updated;
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
messagesBySession: {
|
|
47
|
+
...current,
|
|
48
|
+
[sessionId]: next
|
|
49
|
+
},
|
|
50
|
+
patchedMessage
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export function toggleSessionMessage(current, sessionId, messageId) {
|
|
54
|
+
const list = current[sessionId] ?? [];
|
|
55
|
+
return {
|
|
56
|
+
...current,
|
|
57
|
+
[sessionId]: list.map(message => message.id === messageId && message.collapsible ? {
|
|
58
|
+
...message,
|
|
59
|
+
expanded: !message.expanded
|
|
60
|
+
} : message)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["toolDetailText","withToolContent","message","tool","content","appendSessionMessage","current","sessionId","list","slice","insertSessionMessageBefore","beforeMessageId","index","findIndex","item","id","patchSessionMessage","messageId","patch","patchedMessage","next","map","updated","appendContent","time","messagesBySession","toggleSessionMessage","collapsible","expanded"],"sources":["transcript-state.ts"],"sourcesContent":["import type { ChatMessage } from \"./chat-components.js\";\r\nimport { toolDetailText, type ToolMessageState } from \"./tool-messages.js\";\r\n\r\nexport interface TranscriptMessagePatch {\r\n\tcontent?: string;\r\n\tappendContent?: string;\r\n\ttime?: string;\r\n\ttool?: ToolMessageState;\r\n}\r\n\r\nfunction withToolContent(message: ChatMessage): ChatMessage {\r\n\tif (message.tool) {\r\n\t\treturn {\r\n\t\t\t...message,\r\n\t\t\tcontent: toolDetailText(message.tool),\r\n\t\t};\r\n\t}\r\n\treturn message;\r\n}\r\n\r\nexport function appendSessionMessage(\r\n\tcurrent: Record<string, ChatMessage[]>,\r\n\tsessionId: string,\r\n\tmessage: ChatMessage,\r\n): Record<string, ChatMessage[]> {\r\n\tconst list = current[sessionId] ?? [];\r\n\treturn {\r\n\t\t...current,\r\n\t\t[sessionId]: [...list, withToolContent(message)].slice(-200),\r\n\t};\r\n}\r\n\r\nexport function insertSessionMessageBefore(\r\n\tcurrent: Record<string, ChatMessage[]>,\r\n\tsessionId: string,\r\n\tbeforeMessageId: string,\r\n\tmessage: ChatMessage,\r\n): Record<string, ChatMessage[]> {\r\n\tconst list = current[sessionId] ?? [];\r\n\tconst index = list.findIndex((item) => item.id === beforeMessageId);\r\n\tif (index === -1) {\r\n\t\treturn appendSessionMessage(current, sessionId, message);\r\n\t}\r\n\treturn {\r\n\t\t...current,\r\n\t\t[sessionId]: [...list.slice(0, index), withToolContent(message), ...list.slice(index)].slice(-200),\r\n\t};\r\n}\r\n\r\nexport function patchSessionMessage(\r\n\tcurrent: Record<string, ChatMessage[]>,\r\n\tsessionId: string,\r\n\tmessageId: string,\r\n\tpatch: TranscriptMessagePatch,\r\n): { messagesBySession: Record<string, ChatMessage[]>; patchedMessage?: ChatMessage } {\r\n\tconst list = current[sessionId] ?? [];\r\n\tlet patchedMessage: ChatMessage | undefined;\r\n\r\n\tconst next = list.map((message) => {\r\n\t\tif (message.id !== messageId) {\r\n\t\t\treturn message;\r\n\t\t}\r\n\t\tconst updated = withToolContent({\r\n\t\t\t...message,\r\n\t\t\tcontent: patch.appendContent ? `${message.content}${patch.appendContent}` : patch.content ?? message.content,\r\n\t\t\ttime: patch.time ?? message.time,\r\n\t\t\ttool: patch.tool ?? message.tool,\r\n\t\t});\r\n\t\tpatchedMessage = updated;\r\n\t\treturn updated;\r\n\t});\r\n\r\n\treturn {\r\n\t\tmessagesBySession: {\r\n\t\t\t...current,\r\n\t\t\t[sessionId]: next,\r\n\t\t},\r\n\t\tpatchedMessage,\r\n\t};\r\n}\r\n\r\nexport function toggleSessionMessage(\r\n\tcurrent: Record<string, ChatMessage[]>,\r\n\tsessionId: string,\r\n\tmessageId: string,\r\n): Record<string, ChatMessage[]> {\r\n\tconst list = current[sessionId] ?? [];\r\n\treturn {\r\n\t\t...current,\r\n\t\t[sessionId]: list.map((message) =>\r\n\t\t\tmessage.id === messageId && message.collapsible\r\n\t\t\t\t? {\r\n\t\t\t\t\t\t...message,\r\n\t\t\t\t\t\texpanded: !message.expanded,\r\n\t\t\t\t\t}\r\n\t\t\t\t: message,\r\n\t\t),\r\n\t};\r\n}\r\n"],"mappings":"AACA,SAASA,cAAc,QAA+B,oBAAoB;AAS1E,SAASC,eAAeA,CAACC,OAAoB,EAAe;EAC3D,IAAIA,OAAO,CAACC,IAAI,EAAE;IACjB,OAAO;MACN,GAAGD,OAAO;MACVE,OAAO,EAAEJ,cAAc,CAACE,OAAO,CAACC,IAAI;IACrC,CAAC;EACF;EACA,OAAOD,OAAO;AACf;AAEA,OAAO,SAASG,oBAAoBA,CACnCC,OAAsC,EACtCC,SAAiB,EACjBL,OAAoB,EACY;EAChC,MAAMM,IAAI,GAAGF,OAAO,CAACC,SAAS,CAAC,IAAI,EAAE;EACrC,OAAO;IACN,GAAGD,OAAO;IACV,CAACC,SAAS,GAAG,CAAC,GAAGC,IAAI,EAAEP,eAAe,CAACC,OAAO,CAAC,CAAC,CAACO,KAAK,CAAC,CAAC,GAAG;EAC5D,CAAC;AACF;AAEA,OAAO,SAASC,0BAA0BA,CACzCJ,OAAsC,EACtCC,SAAiB,EACjBI,eAAuB,EACvBT,OAAoB,EACY;EAChC,MAAMM,IAAI,GAAGF,OAAO,CAACC,SAAS,CAAC,IAAI,EAAE;EACrC,MAAMK,KAAK,GAAGJ,IAAI,CAACK,SAAS,CAAEC,IAAI,IAAKA,IAAI,CAACC,EAAE,KAAKJ,eAAe,CAAC;EACnE,IAAIC,KAAK,KAAK,CAAC,CAAC,EAAE;IACjB,OAAO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EAChC,MAAMT,IAAI,GAAGF,OAAO,CAACC,SAAS,CAAC,IAAI,EAAE;EACrC,OAAO;IACN,GAAGD,OAAO;IACV,CAACC,SAAS,GAAGC,IAAI,CAACa,GAAG,CAAEnB,OAAO,IAC7BA,OAAO,CAACa,EAAE,KAAKE,SAAS,IAAIf,OAAO,CAACyB,WAAW,GAC5C;MACA,GAAGzB,OAAO;MACV0B,QAAQ,EAAE,CAAC1B,OAAO,CAAC0B;IACpB,CAAC,GACA1B,OACJ;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export type ShellView = \"home\" | \"providers\" | \"history\";\r\nexport type ShellFocus = \"rail\" | \"main\" | \"composer\" | \"overlay\";\r\nexport type OverlayKind = \"provider\" | \"model-provider\" | \"model\" | \"session\";\r\nexport type CardTone = \"accent\" | \"success\" | \"muted\";\r\nexport type TagTone = \"accent\" | \"success\" | \"muted\" | \"warning\" | \"danger\";\r\n\r\nexport interface SessionCard {\r\n\tid: string;\r\n\ttitle: string;\r\n\tsummary: string;\r\n\tstate: \"active\" | \"ready\" | \"recent\";\r\n\tupdatedAt?: string;\r\n\tproviderLabel?: string;\r\n\tmodelId?: string;\r\n}\r\n\r\nexport interface OverlayOption {\r\n\tid: string;\r\n\tlabel: string;\r\n\tdescription: string;\r\n\tbadge?: string;\r\n}\r\n\r\nexport interface CardTag {\r\n\tlabel: string;\r\n\ttone: TagTone;\r\n\tcolor?: string;\r\n}\r\n\r\nexport interface MainCard {\r\n\tid: string;\r\n\ttitle: string;\r\n\tlines: string[];\r\n\tactionLabel: string;\r\n\ttone: CardTone;\r\n\ttags?: CardTag[];\r\n}\r\n\r\nexport interface MainHero {\r\n\ttitle: string;\r\n\tsubtitle: string;\r\n\tlines: string[];\r\n\ttags: CardTag[];\r\n}\r\n\r\nexport interface SlashCommandItem {\r\n\tid: string;\r\n\tlabel: string;\r\n\tdescription: string;\r\n\tkeyHint?: string;\r\n}\r\n"],"mappings":"","ignoreList":[]}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
process.title = "wepscli";
|
|
3
|
+
process.emitWarning = () => {};
|
|
4
|
+
import { EnvHttpProxyAgent, setGlobalDispatcher } from "undici";
|
|
5
|
+
import { main } from "./main.js";
|
|
6
|
+
setGlobalDispatcher(new EnvHttpProxyAgent());
|
|
7
|
+
main(process.argv.slice(2)).catch(error => {
|
|
8
|
+
const message = error instanceof Error ? error.stack ?? error.message : String(error);
|
|
9
|
+
console.error(message);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
});
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["process","title","emitWarning","EnvHttpProxyAgent","setGlobalDispatcher","main","argv","slice","catch","error","message","Error","stack","String","console","exit"],"sources":["cli.ts"],"sourcesContent":["#!/usr/bin/env node\r\nprocess.title = \"wepscli\";\r\nprocess.emitWarning = (() => {}) as typeof process.emitWarning;\r\n\r\nimport { EnvHttpProxyAgent, setGlobalDispatcher } from \"undici\";\r\nimport { main } from \"./main.js\";\r\n\r\nsetGlobalDispatcher(new EnvHttpProxyAgent());\r\n\r\nmain(process.argv.slice(2)).catch((error: unknown) => {\r\n\tconst message = error instanceof Error ? error.stack ?? error.message : String(error);\r\n\tconsole.error(message);\r\n\tprocess.exit(1);\r\n});\r\n"],"mappings":"AAAA;AACAA,OAAO,CAACC,KAAK,GAAG,SAAS;AACzBD,OAAO,CAACE,WAAW,GAAI,MAAM,CAAC,CAAgC;AAE9D,SAASC,iBAAiB,EAAEC,mBAAmB,QAAQ,QAAQ;AAC/D,SAASC,IAAI,QAAQ,WAAW;AAEhCD,mBAAmB,CAAC,IAAID,iBAAiB,CAAC,CAAC,CAAC;AAE5CE,IAAI,CAACL,OAAO,CAACM,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAACC,KAAK,CAAEC,KAAc,IAAK;EACrD,MAAMC,OAAO,GAAGD,KAAK,YAAYE,KAAK,GAAGF,KAAK,CAACG,KAAK,IAAIH,KAAK,CAACC,OAAO,GAAGG,MAAM,CAACJ,KAAK,CAAC;EACrFK,OAAO,CAACL,KAAK,CAACC,OAAO,CAAC;EACtBV,OAAO,CAACe,IAAI,CAAC,CAAC,CAAC;AAChB,CAAC,CAAC","ignoreList":[]}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { existsSync, mkdirSync } from "fs";
|
|
2
|
+
import { homedir } from "os";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
export const APP_NAME = "wepscli";
|
|
5
|
+
export const CONFIG_DIR_NAME = ".wepscli";
|
|
6
|
+
export const ENV_AGENT_DIR = "WEPSCLI_AGENT_DIR";
|
|
7
|
+
export const ENV_SHELL_DEBUG_LOG = "WEPSCLI_SHELL_DEBUG_LOG";
|
|
8
|
+
function expandHome(pathValue) {
|
|
9
|
+
if (pathValue === "~") return homedir();
|
|
10
|
+
if (pathValue.startsWith("~/")) return join(homedir(), pathValue.slice(2));
|
|
11
|
+
return pathValue;
|
|
12
|
+
}
|
|
13
|
+
export function getAgentDir() {
|
|
14
|
+
const envDir = process.env[ENV_AGENT_DIR];
|
|
15
|
+
if (envDir) {
|
|
16
|
+
return expandHome(envDir);
|
|
17
|
+
}
|
|
18
|
+
return join(homedir(), CONFIG_DIR_NAME, "agent");
|
|
19
|
+
}
|
|
20
|
+
export function getSettingsPath() {
|
|
21
|
+
return join(getAgentDir(), "settings.json");
|
|
22
|
+
}
|
|
23
|
+
export function getAuthPath() {
|
|
24
|
+
return join(getAgentDir(), "auth.json");
|
|
25
|
+
}
|
|
26
|
+
export function getProvidersPath() {
|
|
27
|
+
return join(getAgentDir(), "providers.json");
|
|
28
|
+
}
|
|
29
|
+
export function getSessionsPath() {
|
|
30
|
+
return join(getAgentDir(), "sessions.json");
|
|
31
|
+
}
|
|
32
|
+
export function ensureAgentDir() {
|
|
33
|
+
const agentDir = getAgentDir();
|
|
34
|
+
if (!existsSync(agentDir)) {
|
|
35
|
+
mkdirSync(agentDir, {
|
|
36
|
+
recursive: true
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return agentDir;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["existsSync","mkdirSync","homedir","join","APP_NAME","CONFIG_DIR_NAME","ENV_AGENT_DIR","ENV_SHELL_DEBUG_LOG","expandHome","pathValue","startsWith","slice","getAgentDir","envDir","process","env","getSettingsPath","getAuthPath","getProvidersPath","getSessionsPath","ensureAgentDir","agentDir","recursive"],"sources":["config.ts"],"sourcesContent":["import { existsSync, mkdirSync } from \"fs\";\r\nimport { homedir } from \"os\";\r\nimport { join } from \"path\";\r\n\r\nexport const APP_NAME = \"wepscli\";\r\nexport const CONFIG_DIR_NAME = \".wepscli\";\r\nexport const ENV_AGENT_DIR = \"WEPSCLI_AGENT_DIR\";\r\nexport const ENV_SHELL_DEBUG_LOG = \"WEPSCLI_SHELL_DEBUG_LOG\";\r\n\r\nfunction expandHome(pathValue: string): string {\r\n\tif (pathValue === \"~\") return homedir();\r\n\tif (pathValue.startsWith(\"~/\")) return join(homedir(), pathValue.slice(2));\r\n\treturn pathValue;\r\n}\r\n\r\nexport function getAgentDir(): string {\r\n\tconst envDir = process.env[ENV_AGENT_DIR];\r\n\tif (envDir) {\r\n\t\treturn expandHome(envDir);\r\n\t}\r\n\treturn join(homedir(), CONFIG_DIR_NAME, \"agent\");\r\n}\r\n\r\nexport function getSettingsPath(): string {\r\n\treturn join(getAgentDir(), \"settings.json\");\r\n}\r\n\r\nexport function getAuthPath(): string {\r\n\treturn join(getAgentDir(), \"auth.json\");\r\n}\r\n\r\nexport function getProvidersPath(): string {\r\n\treturn join(getAgentDir(), \"providers.json\");\r\n}\r\n\r\nexport function getSessionsPath(): string {\r\n\treturn join(getAgentDir(), \"sessions.json\");\r\n}\r\n\r\nexport function ensureAgentDir(): string {\r\n\tconst agentDir = getAgentDir();\r\n\tif (!existsSync(agentDir)) {\r\n\t\tmkdirSync(agentDir, { recursive: true });\r\n\t}\r\n\treturn agentDir;\r\n}\r\n"],"mappings":"AAAA,SAASA,UAAU,EAAEC,SAAS,QAAQ,IAAI;AAC1C,SAASC,OAAO,QAAQ,IAAI;AAC5B,SAASC,IAAI,QAAQ,MAAM;AAE3B,OAAO,MAAMC,QAAQ,GAAG,SAAS;AACjC,OAAO,MAAMC,eAAe,GAAG,UAAU;AACzC,OAAO,MAAMC,aAAa,GAAG,mBAAmB;AAChD,OAAO,MAAMC,mBAAmB,GAAG,yBAAyB;AAE5D,SAASC,UAAUA,CAACC,SAAiB,EAAU;EAC9C,IAAIA,SAAS,KAAK,GAAG,EAAE,OAAOP,OAAO,CAAC,CAAC;EACvC,IAAIO,SAAS,CAACC,UAAU,CAAC,IAAI,CAAC,EAAE,OAAOP,IAAI,CAACD,OAAO,CAAC,CAAC,EAAEO,SAAS,CAACE,KAAK,CAAC,CAAC,CAAC,CAAC;EAC1E,OAAOF,SAAS;AACjB;AAEA,OAAO,SAASG,WAAWA,CAAA,EAAW;EACrC,MAAMC,MAAM,GAAGC,OAAO,CAACC,GAAG,CAACT,aAAa,CAAC;EACzC,IAAIO,MAAM,EAAE;IACX,OAAOL,UAAU,CAACK,MAAM,CAAC;EAC1B;EACA,OAAOV,IAAI,CAACD,OAAO,CAAC,CAAC,EAAEG,eAAe,EAAE,OAAO,CAAC;AACjD;AAEA,OAAO,SAASW,eAAeA,CAAA,EAAW;EACzC,OAAOb,IAAI,CAACS,WAAW,CAAC,CAAC,EAAE,eAAe,CAAC;AAC5C;AAEA,OAAO,SAASK,WAAWA,CAAA,EAAW;EACrC,OAAOd,IAAI,CAACS,WAAW,CAAC,CAAC,EAAE,WAAW,CAAC;AACxC;AAEA,OAAO,SAASM,gBAAgBA,CAAA,EAAW;EAC1C,OAAOf,IAAI,CAACS,WAAW,CAAC,CAAC,EAAE,gBAAgB,CAAC;AAC7C;AAEA,OAAO,SAASO,eAAeA,CAAA,EAAW;EACzC,OAAOhB,IAAI,CAACS,WAAW,CAAC,CAAC,EAAE,eAAe,CAAC;AAC5C;AAEA,OAAO,SAASQ,cAAcA,CAAA,EAAW;EACxC,MAAMC,QAAQ,GAAGT,WAAW,CAAC,CAAC;EAC9B,IAAI,CAACZ,UAAU,CAACqB,QAAQ,CAAC,EAAE;IAC1BpB,SAAS,CAACoB,QAAQ,EAAE;MAAEC,SAAS,EAAE;IAAK,CAAC,CAAC;EACzC;EACA,OAAOD,QAAQ;AAChB","ignoreList":[]}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./config.js\";\r\nexport * from \"./main.js\";\r\nexport * from \"./provider-profiles/index.js\";\r\nexport * from \"./workbench/index.js\";\r\n"],"mappings":"AAAA,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,8BAA8B;AAC5C,cAAc,sBAAsB","ignoreList":[]}
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { appendFileSync } from "node:fs";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { APP_NAME, ensureAgentDir, getAuthPath, getProvidersPath, getSettingsPath } from "./config.js";
|
|
6
|
+
import { ProviderProfileService } from "./provider-profiles/index.js";
|
|
7
|
+
import { runOnboarding } from "./onboarding/run-onboarding.js";
|
|
8
|
+
function writeStartupErrorLog(label, error) {
|
|
9
|
+
try {
|
|
10
|
+
const agentDir = ensureAgentDir();
|
|
11
|
+
const details = error instanceof Error ? error.stack ?? error.message : String(error);
|
|
12
|
+
appendFileSync(`${agentDir}\\startup-error.log`, `[${new Date().toISOString()}] ${label}\n${details}\n\n`, "utf8");
|
|
13
|
+
} catch {}
|
|
14
|
+
}
|
|
15
|
+
function isBunRuntime() {
|
|
16
|
+
return typeof process.versions.bun === "string";
|
|
17
|
+
}
|
|
18
|
+
function hasBunAvailable() {
|
|
19
|
+
const result = spawnSync("bun", ["--version"], {
|
|
20
|
+
stdio: "ignore",
|
|
21
|
+
shell: process.platform === "win32"
|
|
22
|
+
});
|
|
23
|
+
return result.status === 0;
|
|
24
|
+
}
|
|
25
|
+
async function resolveBunPreloadPath() {
|
|
26
|
+
const resolved = await import.meta.resolve("@opentui/solid/preload");
|
|
27
|
+
return resolved.startsWith("file:") ? fileURLToPath(resolved) : resolved;
|
|
28
|
+
}
|
|
29
|
+
async function relaunchInBun() {
|
|
30
|
+
const entry = process.argv[1];
|
|
31
|
+
if (!entry) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const preloadPath = await resolveBunPreloadPath();
|
|
35
|
+
const child = spawnSync("bun", ["--conditions=browser", "--preload", preloadPath, entry, ...process.argv.slice(2)], {
|
|
36
|
+
stdio: "inherit",
|
|
37
|
+
env: process.env,
|
|
38
|
+
shell: process.platform === "win32"
|
|
39
|
+
});
|
|
40
|
+
if (typeof child.status === "number") {
|
|
41
|
+
return child.status;
|
|
42
|
+
}
|
|
43
|
+
if (child.error) {
|
|
44
|
+
throw child.error;
|
|
45
|
+
}
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
function printHelp() {
|
|
49
|
+
console.log(`${APP_NAME} - TUI-first coding agent CLI
|
|
50
|
+
|
|
51
|
+
Usage:
|
|
52
|
+
${APP_NAME}
|
|
53
|
+
${APP_NAME} --help
|
|
54
|
+
${APP_NAME} --version
|
|
55
|
+
|
|
56
|
+
Current status:
|
|
57
|
+
Provider profiles and onboarding are implemented.
|
|
58
|
+
The current shell direction is the OpenTUI-based WEPSCLI-shell rebuild.
|
|
59
|
+
Interactive shell launch now prefers Bun automatically when it is available.
|
|
60
|
+
`);
|
|
61
|
+
}
|
|
62
|
+
function printVersion() {
|
|
63
|
+
console.log("0.1.0");
|
|
64
|
+
}
|
|
65
|
+
function printBootstrapSummary() {
|
|
66
|
+
const agentDir = ensureAgentDir();
|
|
67
|
+
const providerProfiles = new ProviderProfileService();
|
|
68
|
+
providerProfiles.ensureStorage();
|
|
69
|
+
const profiles = providerProfiles.listProfiles();
|
|
70
|
+
const activeSelection = providerProfiles.getActiveSelection();
|
|
71
|
+
console.log(chalk.cyanBright("WEPSCLI bootstrap is ready."));
|
|
72
|
+
console.log();
|
|
73
|
+
console.log(`${chalk.bold("Agent dir:")} ${agentDir}`);
|
|
74
|
+
console.log(`${chalk.bold("Settings:")} ${getSettingsPath()}`);
|
|
75
|
+
console.log(`${chalk.bold("Auth:")} ${getAuthPath()}`);
|
|
76
|
+
console.log(`${chalk.bold("Providers:")} ${getProvidersPath()}`);
|
|
77
|
+
console.log(`${chalk.bold("Profiles:")} ${profiles.length}`);
|
|
78
|
+
console.log(`${chalk.bold("Active:")} ${activeSelection.profileId ?? "none"}`);
|
|
79
|
+
console.log();
|
|
80
|
+
console.log(chalk.dim("Next step: use an interactive terminal to complete onboarding or launch the shell."));
|
|
81
|
+
}
|
|
82
|
+
export async function main(args) {
|
|
83
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
84
|
+
printHelp();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (args.includes("--version") || args.includes("-v")) {
|
|
88
|
+
printVersion();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const profiles = new ProviderProfileService();
|
|
92
|
+
profiles.ensureStorage();
|
|
93
|
+
if (profiles.listProfiles().length === 0) {
|
|
94
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
95
|
+
console.log(chalk.yellow("WEPSCLI needs an interactive terminal to complete first-run onboarding."));
|
|
96
|
+
printBootstrapSummary();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const savedProfile = await runOnboarding(profiles);
|
|
100
|
+
console.log(chalk.greenBright(`Saved provider profile: ${savedProfile.label}`));
|
|
101
|
+
}
|
|
102
|
+
if (process.stdin.isTTY && process.stdout.isTTY) {
|
|
103
|
+
if (!isBunRuntime() && hasBunAvailable()) {
|
|
104
|
+
const exitCode = await relaunchInBun();
|
|
105
|
+
if (typeof exitCode === "number" && exitCode !== 0) {
|
|
106
|
+
process.exitCode = exitCode;
|
|
107
|
+
}
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
const {
|
|
112
|
+
runWepscliShell
|
|
113
|
+
} = await import("./WEPSCLI-shell/index.js");
|
|
114
|
+
await runWepscliShell(profiles);
|
|
115
|
+
return;
|
|
116
|
+
} catch (error) {
|
|
117
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
118
|
+
const details = error instanceof Error ? error.stack ?? error.message : String(error);
|
|
119
|
+
writeStartupErrorLog("WEPSCLI-shell startup error", error);
|
|
120
|
+
console.log(chalk.yellow("WEPSCLI-shell could not start. Falling back to the temporary shell."));
|
|
121
|
+
console.log(chalk.dim(message));
|
|
122
|
+
console.error(chalk.red("WEPSCLI-shell startup error:"));
|
|
123
|
+
console.error(details);
|
|
124
|
+
if (process.env.WEPSCLI_DISABLE_FALLBACK === "1") {
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
const {
|
|
129
|
+
runWorkbench
|
|
130
|
+
} = await import("./workbench/index.js");
|
|
131
|
+
await runWorkbench(profiles);
|
|
132
|
+
} catch (fallbackError) {
|
|
133
|
+
writeStartupErrorLog("Fallback workbench startup error", fallbackError);
|
|
134
|
+
throw fallbackError;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
printBootstrapSummary();
|
|
140
|
+
}
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["chalk","appendFileSync","spawnSync","fileURLToPath","APP_NAME","ensureAgentDir","getAuthPath","getProvidersPath","getSettingsPath","ProviderProfileService","runOnboarding","writeStartupErrorLog","label","error","agentDir","details","Error","stack","message","String","Date","toISOString","isBunRuntime","process","versions","bun","hasBunAvailable","result","stdio","shell","platform","status","resolveBunPreloadPath","resolved","import","meta","resolve","startsWith","relaunchInBun","entry","argv","preloadPath","child","slice","env","printHelp","console","log","printVersion","printBootstrapSummary","providerProfiles","ensureStorage","profiles","listProfiles","activeSelection","getActiveSelection","cyanBright","bold","length","profileId","dim","main","args","includes","stdin","isTTY","stdout","yellow","savedProfile","greenBright","exitCode","runWepscliShell","red","WEPSCLI_DISABLE_FALLBACK","runWorkbench","fallbackError"],"sources":["main.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport { appendFileSync } from \"node:fs\";\nimport { spawnSync } from \"node:child_process\";\nimport { fileURLToPath } from \"node:url\";\nimport { APP_NAME, ensureAgentDir, getAgentDir, getAuthPath, getProvidersPath, getSettingsPath } from \"./config.js\";\nimport { ProviderProfileService } from \"./provider-profiles/index.js\";\nimport { runOnboarding } from \"./onboarding/run-onboarding.js\";\n\r\nfunction writeStartupErrorLog(label: string, error: unknown): void {\r\n\ttry {\r\n\t\tconst agentDir = ensureAgentDir();\r\n\t\tconst details = error instanceof Error ? error.stack ?? error.message : String(error);\r\n\t\tappendFileSync(`${agentDir}\\\\startup-error.log`, `[${new Date().toISOString()}] ${label}\\n${details}\\n\\n`, \"utf8\");\r\n\t} catch {}\r\n}\r\n\r\nfunction isBunRuntime(): boolean {\r\n\treturn typeof process.versions.bun === \"string\";\r\n}\r\n\r\nfunction hasBunAvailable(): boolean {\n\tconst result = spawnSync(\"bun\", [\"--version\"], {\n\t\tstdio: \"ignore\",\n\t\tshell: process.platform === \"win32\",\n\t});\n\treturn result.status === 0;\n}\n\nasync function resolveBunPreloadPath(): Promise<string> {\n\tconst resolved = await import.meta.resolve(\"@opentui/solid/preload\");\n\treturn resolved.startsWith(\"file:\") ? fileURLToPath(resolved) : resolved;\n}\n\nasync function relaunchInBun(): Promise<number | null> {\n\tconst entry = process.argv[1];\n\tif (!entry) {\n\t\treturn null;\n\t}\n\n\tconst preloadPath = await resolveBunPreloadPath();\n\tconst child = spawnSync(\"bun\", [\"--conditions=browser\", \"--preload\", preloadPath, entry, ...process.argv.slice(2)], {\n\t\tstdio: \"inherit\",\n\t\tenv: process.env,\n\t\tshell: process.platform === \"win32\",\n\t});\n\r\n\tif (typeof child.status === \"number\") {\r\n\t\treturn child.status;\r\n\t}\r\n\tif (child.error) {\r\n\t\tthrow child.error;\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\nfunction printHelp(): void {\r\n\tconsole.log(`${APP_NAME} - TUI-first coding agent CLI\r\n\r\nUsage:\r\n ${APP_NAME}\r\n ${APP_NAME} --help\r\n ${APP_NAME} --version\r\n\r\nCurrent status:\r\n Provider profiles and onboarding are implemented.\r\n The current shell direction is the OpenTUI-based WEPSCLI-shell rebuild.\r\n Interactive shell launch now prefers Bun automatically when it is available.\r\n`);\r\n}\r\n\r\nfunction printVersion(): void {\r\n\tconsole.log(\"0.1.0\");\r\n}\r\n\r\nfunction printBootstrapSummary(): void {\r\n\tconst agentDir = ensureAgentDir();\r\n\tconst providerProfiles = new ProviderProfileService();\r\n\tproviderProfiles.ensureStorage();\r\n\tconst profiles = providerProfiles.listProfiles();\r\n\tconst activeSelection = providerProfiles.getActiveSelection();\r\n\r\n\tconsole.log(chalk.cyanBright(\"WEPSCLI bootstrap is ready.\"));\r\n\tconsole.log();\r\n\tconsole.log(`${chalk.bold(\"Agent dir:\")} ${agentDir}`);\r\n\tconsole.log(`${chalk.bold(\"Settings:\")} ${getSettingsPath()}`);\r\n\tconsole.log(`${chalk.bold(\"Auth:\")} ${getAuthPath()}`);\r\n\tconsole.log(`${chalk.bold(\"Providers:\")} ${getProvidersPath()}`);\r\n\tconsole.log(`${chalk.bold(\"Profiles:\")} ${profiles.length}`);\r\n\tconsole.log(`${chalk.bold(\"Active:\")} ${activeSelection.profileId ?? \"none\"}`);\r\n\tconsole.log();\r\n\tconsole.log(chalk.dim(\"Next step: use an interactive terminal to complete onboarding or launch the shell.\"));\r\n}\r\n\r\nexport async function main(args: string[]): Promise<void> {\r\n\tif (args.includes(\"--help\") || args.includes(\"-h\")) {\r\n\t\tprintHelp();\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (args.includes(\"--version\") || args.includes(\"-v\")) {\r\n\t\tprintVersion();\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst profiles = new ProviderProfileService();\r\n\tprofiles.ensureStorage();\r\n\r\n\tif (profiles.listProfiles().length === 0) {\r\n\t\tif (!process.stdin.isTTY || !process.stdout.isTTY) {\r\n\t\t\tconsole.log(chalk.yellow(\"WEPSCLI needs an interactive terminal to complete first-run onboarding.\"));\r\n\t\t\tprintBootstrapSummary();\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tconst savedProfile = await runOnboarding(profiles);\r\n\t\tconsole.log(chalk.greenBright(`Saved provider profile: ${savedProfile.label}`));\r\n\t}\r\n\r\n\tif (process.stdin.isTTY && process.stdout.isTTY) {\n\t\tif (!isBunRuntime() && hasBunAvailable()) {\n\t\t\tconst exitCode = await relaunchInBun();\n\t\t\tif (typeof exitCode === \"number\" && exitCode !== 0) {\n\t\t\t\tprocess.exitCode = exitCode;\n\t\t\t}\n\t\t\treturn;\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tconst { runWepscliShell } = await import(\"./WEPSCLI-shell/index.js\");\r\n\t\t\tawait runWepscliShell(profiles);\r\n\t\t\treturn;\r\n\t\t} catch (error) {\r\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\r\n\t\t\tconst details = error instanceof Error ? error.stack ?? error.message : String(error);\r\n\t\t\twriteStartupErrorLog(\"WEPSCLI-shell startup error\", error);\r\n\t\t\tconsole.log(chalk.yellow(\"WEPSCLI-shell could not start. Falling back to the temporary shell.\"));\r\n\t\t\tconsole.log(chalk.dim(message));\r\n\t\t\tconsole.error(chalk.red(\"WEPSCLI-shell startup error:\"));\r\n\t\t\tconsole.error(details);\r\n\t\t\tif (process.env.WEPSCLI_DISABLE_FALLBACK === \"1\") {\r\n\t\t\t\tthrow error;\r\n\t\t\t}\r\n\t\t\ttry {\r\n\t\t\t\tconst { runWorkbench } = await import(\"./workbench/index.js\");\r\n\t\t\t\tawait runWorkbench(profiles);\r\n\t\t\t} catch (fallbackError) {\r\n\t\t\t\twriteStartupErrorLog(\"Fallback workbench startup error\", fallbackError);\r\n\t\t\t\tthrow fallbackError;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn;\r\n\t}\r\n\r\n\tprintBootstrapSummary();\r\n}\r\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,aAAa,QAAQ,UAAU;AACxC,SAASC,QAAQ,EAAEC,cAAc,EAAeC,WAAW,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,aAAa;AACnH,SAASC,sBAAsB,QAAQ,8BAA8B;AACrE,SAASC,aAAa,QAAQ,gCAAgC;AAE9D,SAASC,oBAAoBA,CAACC,KAAa,EAAEC,KAAc,EAAQ;EAClE,IAAI;IACH,MAAMC,QAAQ,GAAGT,cAAc,CAAC,CAAC;IACjC,MAAMU,OAAO,GAAGF,KAAK,YAAYG,KAAK,GAAGH,KAAK,CAACI,KAAK,IAAIJ,KAAK,CAACK,OAAO,GAAGC,MAAM,CAACN,KAAK,CAAC;IACrFZ,cAAc,CAAC,GAAGa,QAAQ,qBAAqB,EAAE,IAAI,IAAIM,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,KAAKT,KAAK,KAAKG,OAAO,MAAM,EAAE,MAAM,CAAC;EACnH,CAAC,CAAC,MAAM,CAAC;AACV;AAEA,SAASO,YAAYA,CAAA,EAAY;EAChC,OAAO,OAAOC,OAAO,CAACC,QAAQ,CAACC,GAAG,KAAK,QAAQ;AAChD;AAEA,SAASC,eAA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QACvBhE,oBAAoB,CAAC,kCAAkC,EAAEgE,aAAa,CAAC;QACvE,MAAMA,aAAa;MACpB;IACD;IACA;EACD;EAEA1B,qBAAqB,CAAC,CAAC;AACxB","ignoreList":[]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { getKeybindings, Spacer, Text } from "@mariozechner/pi-tui";
|
|
2
|
+
import { FramedScreen } from "./framed-screen.js";
|
|
3
|
+
import { onboardingTheme } from "./theme.js";
|
|
4
|
+
export class ActionScreen extends FramedScreen {
|
|
5
|
+
messageText = new Text("", 0, 0);
|
|
6
|
+
detailText = new Text("", 0, 0);
|
|
7
|
+
state = {
|
|
8
|
+
kind: "idle"
|
|
9
|
+
};
|
|
10
|
+
constructor(options) {
|
|
11
|
+
super(options.stepLabel, options.title, options.description);
|
|
12
|
+
this.content.addChild(this.messageText);
|
|
13
|
+
this.content.addChild(new Spacer(1));
|
|
14
|
+
this.content.addChild(this.detailText);
|
|
15
|
+
this.setIdle(options.idleMessage);
|
|
16
|
+
this.handleInput = async data => {
|
|
17
|
+
const kb = getKeybindings();
|
|
18
|
+
if (kb.matches(data, "tui.select.cancel") && this.state.kind !== "running") {
|
|
19
|
+
this.stopTimer();
|
|
20
|
+
options.onBack();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!kb.matches(data, "tui.select.confirm")) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (this.state.kind === "idle") {
|
|
27
|
+
this.state = {
|
|
28
|
+
kind: "running",
|
|
29
|
+
frame: 0
|
|
30
|
+
};
|
|
31
|
+
this.startTimer(options.requestRender);
|
|
32
|
+
this.messageText.setText(onboardingTheme.accent("Working."));
|
|
33
|
+
this.detailText.setText(onboardingTheme.muted("Please wait while WEPSCLI talks to the provider."));
|
|
34
|
+
options.requestRender();
|
|
35
|
+
try {
|
|
36
|
+
const result = await options.run();
|
|
37
|
+
this.stopTimer();
|
|
38
|
+
this.state = {
|
|
39
|
+
kind: "done",
|
|
40
|
+
result
|
|
41
|
+
};
|
|
42
|
+
const formatted = options.formatResult(result);
|
|
43
|
+
this.messageText.setText(formatted.message);
|
|
44
|
+
this.detailText.setText(formatted.detail ? onboardingTheme.muted(formatted.detail) : "");
|
|
45
|
+
this.setFooter("Enter continue | Esc back");
|
|
46
|
+
options.requestRender();
|
|
47
|
+
} catch (error) {
|
|
48
|
+
this.stopTimer();
|
|
49
|
+
this.state = {
|
|
50
|
+
kind: "idle"
|
|
51
|
+
};
|
|
52
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
53
|
+
this.messageText.setText(onboardingTheme.error(message));
|
|
54
|
+
this.detailText.setText(onboardingTheme.muted("Press Enter to retry or Esc to go back."));
|
|
55
|
+
this.setFooter("Enter retry | Esc back");
|
|
56
|
+
options.requestRender();
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (this.state.kind === "done") {
|
|
61
|
+
options.onContinue(this.state.result);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
setIdle(message) {
|
|
66
|
+
this.messageText.setText(onboardingTheme.text(message));
|
|
67
|
+
this.detailText.setText(onboardingTheme.muted("Press Enter to start."));
|
|
68
|
+
this.setFooter("Enter start | Esc back");
|
|
69
|
+
}
|
|
70
|
+
startTimer(requestRender) {
|
|
71
|
+
const frames = ["Working.", "Working..", "Working..."];
|
|
72
|
+
this.timer = setInterval(() => {
|
|
73
|
+
if (this.state.kind !== "running") {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const nextFrame = (this.state.frame + 1) % frames.length;
|
|
77
|
+
this.state = {
|
|
78
|
+
kind: "running",
|
|
79
|
+
frame: nextFrame
|
|
80
|
+
};
|
|
81
|
+
this.messageText.setText(onboardingTheme.accent(frames[nextFrame]));
|
|
82
|
+
requestRender();
|
|
83
|
+
}, 140);
|
|
84
|
+
}
|
|
85
|
+
stopTimer() {
|
|
86
|
+
if (!this.timer) return;
|
|
87
|
+
clearInterval(this.timer);
|
|
88
|
+
this.timer = undefined;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getKeybindings","Spacer","Text","FramedScreen","onboardingTheme","ActionScreen","messageText","detailText","state","kind","constructor","options","stepLabel","title","description","content","addChild","setIdle","idleMessage","handleInput","data","kb","matches","stopTimer","onBack","frame","startTimer","requestRender","setText","accent","muted","result","run","formatted","formatResult","message","detail","setFooter","error","Error","String","onContinue","text","frames","timer","setInterval","nextFrame","length","clearInterval","undefined"],"sources":["action-screen.ts"],"sourcesContent":["import { getKeybindings, Spacer, Text } from \"@mariozechner/pi-tui\";\r\nimport { FramedScreen } from \"./framed-screen.js\";\r\nimport { onboardingTheme } from \"./theme.js\";\r\n\r\ntype ActionState<TResult> =\r\n\t| { kind: \"idle\" }\r\n\t| { kind: \"running\"; frame: number }\r\n\t| { kind: \"done\"; result: TResult };\r\n\r\nexport class ActionScreen<TResult> extends FramedScreen {\r\n\tprivate readonly messageText = new Text(\"\", 0, 0);\r\n\tprivate readonly detailText = new Text(\"\", 0, 0);\r\n\tprivate state: ActionState<TResult> = { kind: \"idle\" };\r\n\tprivate timer: NodeJS.Timeout | undefined;\r\n\r\n\tconstructor(options: {\r\n\t\tstepLabel: string;\r\n\t\ttitle: string;\r\n\t\tdescription: string;\r\n\t\tidleMessage: string;\r\n\t\trun: () => Promise<TResult>;\r\n\t\tformatResult: (result: TResult) => { message: string; detail?: string };\r\n\t\tonContinue: (result: TResult) => void;\r\n\t\tonBack: () => void;\r\n\t\trequestRender: () => void;\r\n\t}) {\r\n\t\tsuper(options.stepLabel, options.title, options.description);\r\n\r\n\t\tthis.content.addChild(this.messageText);\r\n\t\tthis.content.addChild(new Spacer(1));\r\n\t\tthis.content.addChild(this.detailText);\r\n\t\tthis.setIdle(options.idleMessage);\r\n\r\n\t\tthis.handleInput = async (data: string) => {\r\n\t\t\tconst kb = getKeybindings();\r\n\t\t\tif (kb.matches(data, \"tui.select.cancel\") && this.state.kind !== \"running\") {\r\n\t\t\t\tthis.stopTimer();\r\n\t\t\t\toptions.onBack();\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tif (!kb.matches(data, \"tui.select.confirm\")) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tif (this.state.kind === \"idle\") {\r\n\t\t\t\tthis.state = { kind: \"running\", frame: 0 };\r\n\t\t\t\tthis.startTimer(options.requestRender);\r\n\t\t\t\tthis.messageText.setText(onboardingTheme.accent(\"Working.\"));\r\n\t\t\t\tthis.detailText.setText(onboardingTheme.muted(\"Please wait while WEPSCLI talks to the provider.\"));\r\n\t\t\t\toptions.requestRender();\r\n\r\n\t\t\t\ttry {\r\n\t\t\t\t\tconst result = await options.run();\r\n\t\t\t\t\tthis.stopTimer();\r\n\t\t\t\t\tthis.state = { kind: \"done\", result };\r\n\t\t\t\t\tconst formatted = options.formatResult(result);\r\n\t\t\t\t\tthis.messageText.setText(formatted.message);\r\n\t\t\t\t\tthis.detailText.setText(formatted.detail ? onboardingTheme.muted(formatted.detail) : \"\");\r\n\t\t\t\t\tthis.setFooter(\"Enter continue | Esc back\");\r\n\t\t\t\t\toptions.requestRender();\r\n\t\t\t\t} catch (error) {\r\n\t\t\t\t\tthis.stopTimer();\r\n\t\t\t\t\tthis.state = { kind: \"idle\" };\r\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\r\n\t\t\t\t\tthis.messageText.setText(onboardingTheme.error(message));\r\n\t\t\t\t\tthis.detailText.setText(onboardingTheme.muted(\"Press Enter to retry or Esc to go back.\"));\r\n\t\t\t\t\tthis.setFooter(\"Enter retry | Esc back\");\r\n\t\t\t\t\toptions.requestRender();\r\n\t\t\t\t}\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tif (this.state.kind === \"done\") {\r\n\t\t\t\toptions.onContinue(this.state.result);\r\n\t\t\t}\r\n\t\t};\r\n\t}\r\n\r\n\tprivate setIdle(message: string): void {\r\n\t\tthis.messageText.setText(onboardingTheme.text(message));\r\n\t\tthis.detailText.setText(onboardingTheme.muted(\"Press Enter to start.\"));\r\n\t\tthis.setFooter(\"Enter start | Esc back\");\r\n\t}\r\n\r\n\tprivate startTimer(requestRender: () => void): void {\r\n\t\tconst frames = [\"Working.\", \"Working..\", \"Working...\"];\r\n\t\tthis.timer = setInterval(() => {\r\n\t\t\tif (this.state.kind !== \"running\") {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tconst nextFrame = (this.state.frame + 1) % frames.length;\r\n\t\t\tthis.state = { kind: \"running\", frame: nextFrame };\r\n\t\t\tthis.messageText.setText(onboardingTheme.accent(frames[nextFrame]));\r\n\t\t\trequestRender();\r\n\t\t}, 140);\r\n\t}\r\n\r\n\tprivate stopTimer(): void {\r\n\t\tif (!this.timer) return;\r\n\t\tclearInterval(this.timer);\r\n\t\tthis.timer = undefined;\r\n\t}\r\n}\r\n"],"mappings":"AAAA,SAASA,cAAc,EAAEC,MAAM,EAAEC,IAAI,QAAQ,sBAAsB;AACnE,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,eAAe,QAAQ,YAAY;AAO5C,OAAO,MAAMC,YAAY,SAAkBF,YAAY,CAAC;EACtCG,WAAW,GAAG,IAAIJ,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;EAChCK,UAAU,GAAG,IAAIL,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;EACxCM,KAAK,GAAyB;IAAEC,IAAI,EAAE;EAAO,CAAC;EAGtDC,WAAWA,CAACC,OAUX,EAAE;IACF,KAAK,CAACA,OAAO,CAACC,SAAS,EAAED,OAAO,CAACE,KAAK,EAAEF,OAAO,CAACG,WAAW,CAAC;IAE5D,IAAI,CAACC,OAAO,CAACC,QAAQ,CAAC,IAAI,CAACV,WAAW,CAAC;IACvC,IAAI,CAACS,OAAO,CAACC,QAAQ,CAAC,IAAIf,MAAM,CAA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QX,UAAUA,CAACC,aAAyB,EAAQ;IACnD,MAAMgB,MAAM,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,YAAY,CAAC;IACtD,IAAI,CAACC,KAAK,GAAGC,WAAW,CAAC,MAAM;MAC9B,IAAI,IAAI,CAACrC,KAAK,CAACC,IAAI,KAAK,SAAS,EAAE;QAClC;MACD;MACA,MAAMqC,SAAS,GAAG,CAAC,IAAI,CAACtC,KAAK,CAACiB,KAAK,GAAG,CAAC,IAAIkB,MAAM,CAACI,MAAM;MACxD,IAAI,CAACvC,KAAK,GAAG;QAAEC,IAAI,EAAE,SAAS;QAAEgB,KAAK,EAAEqB;MAAU,CAAC;MAClD,IAAI,CAACxC,WAAW,CAACsB,OAAO,CAACxB,eAAe,CAACyB,MAAM,CAACc,MAAM,CAACG,SAAS,CAAC,CAAC,CAAC;MACnEnB,aAAa,CAAC,CAAC;IAChB,CAAC,EAAE,GAAG,CAAC;EACR;EAEQJ,SAASA,CAAA,EAAS;IACzB,IAAI,CAAC,IAAI,CAACqB,KAAK,EAAE;IACjBI,aAAa,CAAC,IAAI,CAACJ,KAAK,CAAC;IACzB,IAAI,CAACA,KAAK,GAAGK,SAAS;EACvB;AACD","ignoreList":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Container, Spacer, Text } from "@mariozechner/pi-tui";
|
|
2
|
+
import { onboardingTheme } from "./theme.js";
|
|
3
|
+
class BorderLine {
|
|
4
|
+
invalidate() {}
|
|
5
|
+
render(width) {
|
|
6
|
+
return [onboardingTheme.border("=".repeat(Math.max(1, width)))];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class FramedScreen extends Container {
|
|
10
|
+
content = new Container();
|
|
11
|
+
footerText = new Text("", 0, 0);
|
|
12
|
+
constructor(stepLabel, title, description) {
|
|
13
|
+
super();
|
|
14
|
+
this.addChild(new BorderLine());
|
|
15
|
+
this.addChild(new Text(onboardingTheme.brand(`WEPSCLI SETUP ${stepLabel}`), 0, 0));
|
|
16
|
+
this.addChild(new Spacer(1));
|
|
17
|
+
this.addChild(new Text(onboardingTheme.title(title), 0, 0));
|
|
18
|
+
if (description.trim()) {
|
|
19
|
+
this.addChild(new Spacer(1));
|
|
20
|
+
this.addChild(new Text(onboardingTheme.muted(description), 0, 0));
|
|
21
|
+
}
|
|
22
|
+
this.addChild(new Spacer(1));
|
|
23
|
+
this.addChild(this.content);
|
|
24
|
+
this.addChild(new Spacer(1));
|
|
25
|
+
this.addChild(this.footerText);
|
|
26
|
+
this.addChild(new BorderLine());
|
|
27
|
+
}
|
|
28
|
+
setFooter(text) {
|
|
29
|
+
this.footerText.setText(onboardingTheme.muted(text));
|
|
30
|
+
}
|
|
31
|
+
getFocusTarget() {
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
handleInput(_data) {}
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Container","Spacer","Text","onboardingTheme","BorderLine","invalidate","render","width","border","repeat","Math","max","FramedScreen","content","footerText","constructor","stepLabel","title","description","addChild","brand","trim","muted","setFooter","text","setText","getFocusTarget","handleInput","_data"],"sources":["framed-screen.ts"],"sourcesContent":["import { Container, Spacer, Text, type Component } from \"@mariozechner/pi-tui\";\r\nimport { onboardingTheme } from \"./theme.js\";\r\n\r\nexport interface WizardScreen extends Component {\r\n\tgetFocusTarget(): Component;\r\n}\r\n\r\nclass BorderLine implements Component {\r\n\tinvalidate(): void {}\r\n\r\n\trender(width: number): string[] {\r\n\t\treturn [onboardingTheme.border(\"=\".repeat(Math.max(1, width)))];\r\n\t}\r\n}\r\n\r\nexport class FramedScreen extends Container implements WizardScreen {\r\n\tprotected readonly content = new Container();\r\n\tprivate readonly footerText = new Text(\"\", 0, 0);\r\n\r\n\tconstructor(stepLabel: string, title: string, description: string) {\r\n\t\tsuper();\r\n\r\n\t\tthis.addChild(new BorderLine());\r\n\t\tthis.addChild(new Text(onboardingTheme.brand(`WEPSCLI SETUP ${stepLabel}`), 0, 0));\r\n\t\tthis.addChild(new Spacer(1));\r\n\t\tthis.addChild(new Text(onboardingTheme.title(title), 0, 0));\r\n\t\tif (description.trim()) {\r\n\t\t\tthis.addChild(new Spacer(1));\r\n\t\t\tthis.addChild(new Text(onboardingTheme.muted(description), 0, 0));\r\n\t\t}\r\n\t\tthis.addChild(new Spacer(1));\r\n\t\tthis.addChild(this.content);\r\n\t\tthis.addChild(new Spacer(1));\r\n\t\tthis.addChild(this.footerText);\r\n\t\tthis.addChild(new BorderLine());\r\n\t}\r\n\r\n\tprotected setFooter(text: string): void {\r\n\t\tthis.footerText.setText(onboardingTheme.muted(text));\r\n\t}\r\n\r\n\tgetFocusTarget(): Component {\r\n\t\treturn this;\r\n\t}\r\n\r\n\thandleInput(_data: string): void {}\r\n}\r\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,IAAI,QAAwB,sBAAsB;AAC9E,SAASC,eAAe,QAAQ,YAAY;AAM5C,MAAMC,UAAU,CAAsB;EACrCC,UAAUA,CAAA,EAAS,CAAC;EAEpBC,MAAMA,CAACC,KAAa,EAAY;IAC/B,OAAO,CAACJ,eAAe,CAACK,MAAM,CAAC,GAAG,CAACC,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEJ,KAAK,CAAC,CAAC,CAAC,CAAC;EAChE;AACD;AAEA,OAAO,MAAMK,YAAY,SAASZ,SAAS,CAAyB;EAChDa,OAAO,GAAG,IAAIb,SAAS,CAAC,CAAC;EAC3Bc,UAAU,GAAG,IAAIZ,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;EAEhDa,WAAWA,CAACC,SAAiB,EAAEC,KAAa,EAAEC,WAAmB,EAAE;IAClE,KAAK,CAAC,CAAC;IAEP,IAAI,CAACC,QAAQ,CAAC,IAAIf,UAAU,CAAC,CAAC,CAAC;IAC/B,IAAI,CAACe,QAAQ,CAAC,IAAIjB,IAAI,CAACC,eAAe,CAACiB,KAAK,CA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