saeeol 1.2.2 → 1.2.3

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 (50) hide show
  1. package/bin/saeeol.cjs +187 -0
  2. package/npm/bin/saeeol +0 -0
  3. package/package.json +2 -2
  4. package/src/cli/cmd/tui/component/dialog/dialog-mcp.tsx +3 -3
  5. package/src/cli/cmd/tui/component/dialog/dialog-model.tsx +1 -1
  6. package/src/cli/cmd/tui/component/dialog/dialog-provider.tsx +5 -5
  7. package/src/cli/cmd/tui/component/dialog/dialog-session-delete-failed.tsx +4 -4
  8. package/src/cli/cmd/tui/component/dialog/dialog-session-list.tsx +5 -5
  9. package/src/cli/cmd/tui/component/dialog/dialog-session-rename.tsx +3 -3
  10. package/src/cli/cmd/tui/component/dialog/dialog-stash.tsx +2 -2
  11. package/src/cli/cmd/tui/component/dialog/dialog-status.tsx +3 -3
  12. package/src/cli/cmd/tui/component/dialog/dialog-theme-list.tsx +4 -4
  13. package/src/cli/cmd/tui/component/dialog/dialog-workspace-create.tsx +4 -4
  14. package/src/cli/cmd/tui/component/dialog/dialog-workspace-unavailable.tsx +4 -4
  15. package/src/cli/cmd/tui/context/app/args.tsx +15 -0
  16. package/src/cli/cmd/tui/context/app/directory.ts +15 -0
  17. package/src/cli/cmd/tui/context/app/editor-zed.ts +281 -0
  18. package/src/cli/cmd/tui/context/app/editor.ts +425 -0
  19. package/src/cli/cmd/tui/context/app/helper.tsx +25 -0
  20. package/src/cli/cmd/tui/context/app/project.tsx +109 -0
  21. package/src/cli/cmd/tui/context/app/route.tsx +67 -0
  22. package/src/cli/cmd/tui/context/app/sdk.tsx +142 -0
  23. package/src/cli/cmd/tui/context/app/sync.tsx +713 -0
  24. package/src/cli/cmd/tui/context/app/theme.tsx +307 -0
  25. package/src/cli/cmd/tui/context/app/tui-config.tsx +9 -0
  26. package/src/cli/cmd/tui/context/args.tsx +1 -15
  27. package/src/cli/cmd/tui/context/directory.ts +1 -15
  28. package/src/cli/cmd/tui/context/editor-zed.ts +1 -281
  29. package/src/cli/cmd/tui/context/editor.ts +1 -425
  30. package/src/cli/cmd/tui/context/event.ts +1 -45
  31. package/src/cli/cmd/tui/context/exit.tsx +1 -67
  32. package/src/cli/cmd/tui/context/helper.tsx +1 -25
  33. package/src/cli/cmd/tui/context/keybind.tsx +1 -105
  34. package/src/cli/cmd/tui/context/kv.tsx +1 -76
  35. package/src/cli/cmd/tui/context/local.tsx +1 -478
  36. package/src/cli/cmd/tui/context/plugin-keybinds.ts +1 -41
  37. package/src/cli/cmd/tui/context/project.tsx +1 -109
  38. package/src/cli/cmd/tui/context/prompt.tsx +1 -18
  39. package/src/cli/cmd/tui/context/route.tsx +1 -67
  40. package/src/cli/cmd/tui/context/runtime/event.ts +45 -0
  41. package/src/cli/cmd/tui/context/runtime/exit.tsx +67 -0
  42. package/src/cli/cmd/tui/context/runtime/keybind.tsx +105 -0
  43. package/src/cli/cmd/tui/context/runtime/kv.tsx +76 -0
  44. package/src/cli/cmd/tui/context/runtime/local.tsx +478 -0
  45. package/src/cli/cmd/tui/context/runtime/plugin-keybinds.ts +41 -0
  46. package/src/cli/cmd/tui/context/sdk.tsx +1 -142
  47. package/src/cli/cmd/tui/context/session/prompt.tsx +18 -0
  48. package/src/cli/cmd/tui/context/sync.tsx +1 -713
  49. package/src/cli/cmd/tui/context/theme.tsx +1 -307
  50. package/src/cli/cmd/tui/context/tui-config.tsx +1 -9
package/bin/saeeol.cjs ADDED
@@ -0,0 +1,187 @@
1
+ #!/usr/bin/env node
2
+
3
+ const childProcess = require("child_process")
4
+ const fs = require("fs")
5
+ const path = require("path")
6
+ const os = require("os")
7
+
8
+ function run(target) {
9
+ const result = childProcess.spawnSync(target, process.argv.slice(2), {
10
+ stdio: "inherit",
11
+ })
12
+ if (result.error) {
13
+ console.error(result.error.message)
14
+ process.exit(1)
15
+ }
16
+ const code = typeof result.status === "number" ? result.status : 0
17
+ process.exit(code)
18
+ }
19
+
20
+ const envPath = process.env.SAEEOL_BIN_PATH
21
+ if (envPath) {
22
+ run(envPath)
23
+ }
24
+
25
+ const scriptPath = fs.realpathSync(__filename)
26
+ const scriptDir = path.dirname(scriptPath)
27
+
28
+ // fall through to findBinary() if cached binary fails
29
+ const cached = path.join(scriptDir, ".saeeol")
30
+ if (fs.existsSync(cached)) {
31
+ const result = childProcess.spawnSync(cached, process.argv.slice(2), {
32
+ stdio: "inherit",
33
+ })
34
+ if (!result.error) {
35
+ const code = typeof result.status === "number" ? result.status : 0
36
+ process.exit(code)
37
+ }
38
+ // cached binary failed (e.g. wrong platform/arch, missing dynamic linker),
39
+ // fall through to findBinary() which has better variant detection
40
+ }
41
+
42
+ const platformMap = {
43
+ darwin: "darwin",
44
+ linux: "linux",
45
+ win32: "windows",
46
+ }
47
+ const archMap = {
48
+ x64: "x64",
49
+ arm64: "arm64",
50
+ arm: "arm",
51
+ }
52
+
53
+ let platform = platformMap[os.platform()]
54
+ if (!platform) {
55
+ platform = os.platform()
56
+ }
57
+ let arch = archMap[os.arch()]
58
+ if (!arch) {
59
+ arch = os.arch()
60
+ }
61
+ const base = "saeeol-" + platform + "-" + arch
62
+ const binary = platform === "windows" ? "saeeol.exe" : "saeeol"
63
+
64
+ function supportsAvx2() {
65
+ if (arch !== "x64") return false
66
+
67
+ if (platform === "linux") {
68
+ try {
69
+ return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
70
+ } catch {
71
+ return false
72
+ }
73
+ }
74
+
75
+ if (platform === "darwin") {
76
+ try {
77
+ const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
78
+ encoding: "utf8",
79
+ timeout: 1500,
80
+ })
81
+ if (result.status !== 0) return false
82
+ return (result.stdout || "").trim() === "1"
83
+ } catch {
84
+ return false
85
+ }
86
+ }
87
+
88
+ if (platform === "windows") {
89
+ const cmd =
90
+ '(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
91
+
92
+ for (const exe of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
93
+ try {
94
+ const result = childProcess.spawnSync(exe, ["-NoProfile", "-NonInteractive", "-Command", cmd], {
95
+ encoding: "utf8",
96
+ timeout: 3000,
97
+ windowsHide: true,
98
+ })
99
+ if (result.status !== 0) continue
100
+ const out = (result.stdout || "").trim().toLowerCase()
101
+ if (out === "true" || out === "1") return true
102
+ if (out === "false" || out === "0") return false
103
+ } catch {
104
+ continue
105
+ }
106
+ }
107
+
108
+ return false
109
+ }
110
+
111
+ return false
112
+ }
113
+
114
+ const names = (() => {
115
+ const avx2 = supportsAvx2()
116
+ const baseline = arch === "x64" && !avx2
117
+
118
+ if (platform === "linux") {
119
+ const musl = (() => {
120
+ try {
121
+ if (fs.existsSync("/etc/alpine-release")) return true
122
+ } catch {
123
+ // ignore
124
+ }
125
+
126
+ try {
127
+ const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
128
+ const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
129
+ if (text.includes("musl")) return true
130
+ } catch {
131
+ // ignore
132
+ }
133
+
134
+ return false
135
+ })()
136
+
137
+ if (musl) {
138
+ if (arch === "x64") {
139
+ if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
140
+ return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
141
+ }
142
+ return [`${base}-musl`, base]
143
+ }
144
+
145
+ if (arch === "x64") {
146
+ if (baseline) return [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
147
+ return [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
148
+ }
149
+ return [base, `${base}-musl`]
150
+ }
151
+
152
+ if (arch === "x64") {
153
+ if (baseline) return [`${base}-baseline`, base]
154
+ return [base, `${base}-baseline`]
155
+ }
156
+ return [base]
157
+ })()
158
+
159
+ function findBinary(startDir) {
160
+ let current = startDir
161
+ for (;;) {
162
+ const modules = path.join(current, "node_modules")
163
+ if (fs.existsSync(modules)) {
164
+ for (const name of names) {
165
+ const candidate = path.join(modules, name, "bin", binary)
166
+ if (fs.existsSync(candidate)) return candidate
167
+ }
168
+ }
169
+ const parent = path.dirname(current)
170
+ if (parent === current) {
171
+ return
172
+ }
173
+ current = parent
174
+ }
175
+ }
176
+
177
+ const resolved = findBinary(scriptDir)
178
+ if (!resolved) {
179
+ console.error(
180
+ "It seems that your package manager failed to install the right version of the SAEEOL CLI for your platform. You can try manually installing " +
181
+ names.map((n) => `\"${n}\"`).join(" or ") +
182
+ " package",
183
+ )
184
+ process.exit(1)
185
+ }
186
+
187
+ run(resolved)
package/npm/bin/saeeol CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "name": "saeeol",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -24,7 +24,7 @@
24
24
  "db": "bun drizzle-kit"
25
25
  },
26
26
  "bin": {
27
- "saeeol": "./bin/saeeol"
27
+ "saeeol": "./bin/saeeol.cjs"
28
28
  },
29
29
  "exports": {
30
30
  "./*": "./src/*.ts"
@@ -1,9 +1,9 @@
1
- import { createMemo, createSignal } from "solid-js"
1
+ import { createMemo, createSignal } from "solid-js"
2
2
  import { useLocal } from "@tui/context/local"
3
3
  import { useSync } from "@tui/context/sync"
4
4
  import { map, pipe, entries, sortBy } from "remeda"
5
5
  import { DialogSelect, type DialogSelectRef, type DialogSelectOption } from "@tui/ui/dialog-select"
6
- import { useTheme } from "../context/theme"
6
+ import { useTheme } from "../../context/theme"
7
7
  import { Keybind } from "@/util/keybind"
8
8
  import { TextAttributes } from "@opentui/core"
9
9
  import { useSDK } from "@tui/context/sdk"
@@ -83,4 +83,4 @@ export function DialogMcp() {
83
83
  }}
84
84
  />
85
85
  )
86
- }
86
+ }
@@ -7,7 +7,7 @@ import { DialogSelect } from "@tui/ui/dialog-select"
7
7
  import { useDialog } from "@tui/ui/dialog"
8
8
  import { createDialogProviderOptions, DialogProvider } from "./dialog-provider"
9
9
  import { DialogVariant } from "./dialog-variant"
10
- import { useKeybind } from "../context/keybind"
10
+ import { useKeybind } from "../../context/keybind"
11
11
  import type { Model } from "@saeeol/sdk/v2"
12
12
  import * as fuzzysort from "fuzzysort"
13
13
  import { useConnected } from "../use-connected"
@@ -3,16 +3,16 @@ import { useSync } from "@tui/context/sync"
3
3
  import { map, pipe, sortBy } from "remeda"
4
4
  import { DialogSelect } from "@tui/ui/dialog-select"
5
5
  import { useDialog } from "@tui/ui/dialog"
6
- import { useSDK } from "../context/sdk"
7
- import { DialogPrompt } from "../ui/dialog-prompt"
8
- import { Link } from "../ui/link"
9
- import { useTheme } from "../context/theme"
6
+ import { useSDK } from "../../context/sdk"
7
+ import { DialogPrompt } from "../../ui/dialog-prompt"
8
+ import { Link } from "../../ui/link"
9
+ import { useTheme } from "../../context/theme"
10
10
  import { TextAttributes } from "@opentui/core"
11
11
  import type { ProviderAuthAuthorization, ProviderAuthMethod } from "@saeeol/sdk/v2"
12
12
  import { DialogModel } from "./dialog-model"
13
13
  import { useKeyboard } from "@opentui/solid"
14
14
  import * as Clipboard from "@tui/util/clipboard"
15
- import { useToast } from "../ui/toast"
15
+ import { useToast } from "../../ui/toast"
16
16
  import { isConsoleManagedProvider } from "@tui/util/provider-origin"
17
17
  import * as Provider from "@/saeeol/cli/cmd/tui/component/dialog-provider"
18
18
  import { useConnected } from "../use-connected"
@@ -1,6 +1,6 @@
1
- import { TextAttributes } from "@opentui/core"
2
- import { useTheme } from "../context/theme"
3
- import { useDialog } from "../ui/dialog"
1
+ import { TextAttributes } from "@opentui/core"
2
+ import { useTheme } from "../../context/theme"
3
+ import { useDialog } from "../../ui/dialog"
4
4
  import { createStore } from "solid-js/store"
5
5
  import { For } from "solid-js"
6
6
  import { useKeyboard } from "@opentui/solid"
@@ -100,4 +100,4 @@ export function DialogSessionDeleteFailed(props: {
100
100
  </box>
101
101
  </box>
102
102
  )
103
- }
103
+ }
@@ -5,14 +5,14 @@ import { useSync } from "@tui/context/sync"
5
5
  import { createMemo, createResource, createSignal, onMount } from "solid-js"
6
6
  import { Locale } from "@/util/locale"
7
7
  import { useProject } from "@tui/context/project"
8
- import { useKeybind } from "../context/keybind"
9
- import { useTheme } from "../context/theme"
10
- import { useSDK } from "../context/sdk"
8
+ import { useKeybind } from "../../context/keybind"
9
+ import { useTheme } from "../../context/theme"
10
+ import { useSDK } from "../../context/sdk"
11
11
  import { Flag } from "@saeeol/core/flag/flag"
12
12
  import { DialogSessionRename } from "./dialog-session-rename"
13
13
  import { Keybind } from "@/util/keybind"
14
- import { createDebouncedSignal } from "../util/signal"
15
- import { useToast } from "../ui/toast"
14
+ import { createDebouncedSignal } from "../../util/signal"
15
+ import { useToast } from "../../ui/toast"
16
16
  import { DialogWorkspaceCreate, openWorkspaceSession, restoreWorkspaceSession } from "./dialog-workspace-create"
17
17
  import { Spinner } from "../spinner"
18
18
  import path from "path"
@@ -1,8 +1,8 @@
1
- import { DialogPrompt } from "@tui/ui/dialog-prompt"
1
+ import { DialogPrompt } from "@tui/ui/dialog-prompt"
2
2
  import { useDialog } from "@tui/ui/dialog"
3
3
  import { useSync } from "@tui/context/sync"
4
4
  import { createMemo } from "solid-js"
5
- import { useSDK } from "../context/sdk"
5
+ import { useSDK } from "../../context/sdk"
6
6
 
7
7
  interface DialogSessionRenameProps {
8
8
  session: string
@@ -32,4 +32,4 @@ export function DialogSessionRename(props: DialogSessionRenameProps) {
32
32
  onCancel={() => dialog.clear()}
33
33
  />
34
34
  )
35
- }
35
+ }
@@ -2,8 +2,8 @@
2
2
  import { DialogSelect } from "@tui/ui/dialog-select"
3
3
  import { createMemo, createSignal } from "solid-js"
4
4
  import { Locale } from "@/util/locale"
5
- import { useTheme } from "../context/theme"
6
- import { useKeybind } from "../context/keybind"
5
+ import { useTheme } from "../../context/theme"
6
+ import { useKeybind } from "../../context/keybind"
7
7
  import { usePromptStash, type StashEntry } from "../prompt/stash"
8
8
 
9
9
  function getRelativeTime(timestamp: number): string {
@@ -1,6 +1,6 @@
1
- import { TextAttributes } from "@opentui/core"
1
+ import { TextAttributes } from "@opentui/core"
2
2
  import { fileURLToPath } from "bun"
3
- import { useTheme } from "../context/theme"
3
+ import { useTheme } from "../../context/theme"
4
4
  import { useDialog } from "@tui/ui/dialog"
5
5
  import { useSync } from "@tui/context/sync"
6
6
  import { useProject } from "@tui/context/project"
@@ -187,4 +187,4 @@ export function DialogStatus() {
187
187
  </Show>
188
188
  </box>
189
189
  )
190
- }
190
+ }
@@ -1,6 +1,6 @@
1
- import { DialogSelect, type DialogSelectRef } from "../ui/dialog-select"
2
- import { useTheme } from "../context/theme"
3
- import { useDialog } from "../ui/dialog"
1
+ import { DialogSelect, type DialogSelectRef } from "../../ui/dialog-select"
2
+ import { useTheme } from "../../context/theme"
3
+ import { useDialog } from "../../ui/dialog"
4
4
  import { onCleanup } from "solid-js"
5
5
 
6
6
  export function DialogThemeList() {
@@ -47,4 +47,4 @@ export function DialogThemeList() {
47
47
  }}
48
48
  />
49
49
  )
50
- }
50
+ }
@@ -1,4 +1,4 @@
1
- import { createSaeeolClient } from "@saeeol/sdk/v2"
1
+ import { createSaeeolClient } from "@saeeol/sdk/v2"
2
2
  import { useDialog } from "@tui/ui/dialog"
3
3
  import { DialogSelect } from "@tui/ui/dialog-select"
4
4
  import { useRoute } from "@tui/context/route"
@@ -7,8 +7,8 @@ import { useProject } from "@tui/context/project"
7
7
  import { createMemo, createSignal, onMount } from "solid-js"
8
8
  import { setTimeout as sleep } from "node:timers/promises"
9
9
  import { errorMessage } from "@/util/error"
10
- import { useSDK } from "../context/sdk"
11
- import { useToast } from "../ui/toast"
10
+ import { useSDK } from "../../context/sdk"
11
+ import { useToast } from "../../ui/toast"
12
12
 
13
13
  type Adapter = {
14
14
  type: string
@@ -197,4 +197,4 @@ export function DialogWorkspaceCreate(props: { onSelect: (workspaceID: string) =
197
197
  }}
198
198
  />
199
199
  )
200
- }
200
+ }
@@ -1,9 +1,9 @@
1
- import { TextAttributes } from "@opentui/core"
1
+ import { TextAttributes } from "@opentui/core"
2
2
  import { useKeyboard } from "@opentui/solid"
3
3
  import { createStore } from "solid-js/store"
4
4
  import { For } from "solid-js"
5
- import { useTheme } from "../context/theme"
6
- import { useDialog } from "../ui/dialog"
5
+ import { useTheme } from "../../context/theme"
6
+ import { useDialog } from "../../ui/dialog"
7
7
 
8
8
  export function DialogWorkspaceUnavailable(props: { onRestore?: () => boolean | void | Promise<boolean | void> }) {
9
9
  const dialog = useDialog()
@@ -78,4 +78,4 @@ export function DialogWorkspaceUnavailable(props: { onRestore?: () => boolean |
78
78
  </box>
79
79
  </box>
80
80
  )
81
- }
81
+ }
@@ -0,0 +1,15 @@
1
+ import { createSimpleContext } from "./helper"
2
+
3
+ export interface Args {
4
+ model?: string
5
+ agent?: string
6
+ prompt?: string
7
+ continue?: boolean
8
+ sessionID?: string
9
+ fork?: boolean
10
+ }
11
+
12
+ export const { use: useArgs, provider: ArgsProvider } = createSimpleContext({
13
+ name: "Args",
14
+ init: (props: Args) => props,
15
+ })
@@ -0,0 +1,15 @@
1
+ import { createMemo } from "solid-js"
2
+ import { useProject } from "../app/project"
3
+ import { useSync } from "../app/sync"
4
+ import { Global } from "@saeeol/core/global"
5
+
6
+ export function useDirectory() {
7
+ const project = useProject()
8
+ const sync = useSync()
9
+ return createMemo(() => {
10
+ const directory = project.instance.path().directory || process.cwd()
11
+ const result = directory.replace(Global.Path.home, "~")
12
+ if (sync.data.vcs?.branch) return result + ":" + sync.data.vcs.branch
13
+ return result
14
+ })
15
+ }