@agentprojectcontext/apx 1.15.5 → 1.16.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 (222) hide show
  1. package/package.json +40 -5
  2. package/src/cli/commands/log.js +113 -0
  3. package/src/cli/commands/overlay.js +253 -0
  4. package/src/cli/commands/sys.js +88 -16
  5. package/src/cli/index.js +23 -1
  6. package/src/cli/terminal-chat/renderer.js +71 -56
  7. package/src/cli-ts/commands/agent.ts +173 -0
  8. package/src/cli-ts/commands/chat.ts +119 -0
  9. package/src/cli-ts/commands/daemon.ts +112 -0
  10. package/src/cli-ts/commands/exec.ts +109 -0
  11. package/src/cli-ts/commands/mcp.ts +235 -0
  12. package/src/cli-ts/commands/session.ts +224 -0
  13. package/src/cli-ts/commands/status.ts +61 -0
  14. package/src/cli-ts/http.ts +36 -0
  15. package/src/cli-ts/index.ts +73 -0
  16. package/src/cli-ts/ui.ts +107 -0
  17. package/src/core/logging.js +81 -0
  18. package/src/daemon/api.js +58 -0
  19. package/src/daemon/engines/anthropic.js +60 -1
  20. package/src/daemon/engines/index.js +2 -1
  21. package/src/daemon/engines/ollama.js +70 -3
  22. package/src/daemon/index.js +58 -0
  23. package/src/daemon/overlay-ws.js +40 -0
  24. package/src/daemon/plugins/index.js +2 -1
  25. package/src/daemon/plugins/overlay.js +177 -0
  26. package/src/daemon/plugins/telegram.js +15 -3
  27. package/src/daemon/super-agent.js +102 -19
  28. package/src/daemon/transcription.js +262 -59
  29. package/src/daemon/wakeup.js +14 -19
  30. package/src/daemon/whisper-server.py +57 -6
  31. package/src/overlay/index.html +44 -0
  32. package/src/overlay/main.js +480 -0
  33. package/src/overlay/package.json +3 -0
  34. package/src/overlay/preload.js +34 -0
  35. package/src/overlay/renderer.js +371 -0
  36. package/src/overlay/style.css +250 -0
  37. package/src/tui/_shims/cli-error.ts +6 -0
  38. package/src/tui/_shims/cli-logo.ts +18 -0
  39. package/src/tui/_shims/cli-ui.ts +1 -0
  40. package/src/tui/_shims/config-console-state.ts +7 -0
  41. package/src/tui/_shims/core-any.ts +30 -0
  42. package/src/tui/_shims/core-binary.ts +13 -0
  43. package/src/tui/_shims/core-flag.ts +3 -0
  44. package/src/tui/_shims/core-log.ts +14 -0
  45. package/src/tui/_shims/lsp-language.ts +1 -0
  46. package/src/tui/_shims/opencode-any.ts +135 -0
  47. package/src/tui/_shims/opencode-sdk-v2.ts +48 -0
  48. package/src/tui/_shims/plugin-tui.ts +13 -0
  49. package/src/tui/_shims/provider-provider.ts +10 -0
  50. package/src/tui/_shims/session-retry.ts +1 -0
  51. package/src/tui/_shims/session-schema.ts +15 -0
  52. package/src/tui/_shims/session-session.ts +3 -0
  53. package/src/tui/_shims/snapshot.ts +4 -0
  54. package/src/tui/_shims/tool-any.ts +18 -0
  55. package/src/tui/_shims/util-error.ts +7 -0
  56. package/src/tui/_shims/util-filesystem.ts +79 -0
  57. package/src/tui/_shims/util-format.ts +7 -0
  58. package/src/tui/_shims/util-iife.ts +3 -0
  59. package/src/tui/_shims/util-locale.ts +10 -0
  60. package/src/tui/_shims/util-process.ts +38 -0
  61. package/src/tui/app.tsx +783 -0
  62. package/src/tui/asset/charge.wav +0 -0
  63. package/src/tui/asset/pulse-a.wav +0 -0
  64. package/src/tui/asset/pulse-b.wav +0 -0
  65. package/src/tui/asset/pulse-c.wav +0 -0
  66. package/src/tui/attach.ts +100 -0
  67. package/src/tui/component/bg-pulse-render.ts +436 -0
  68. package/src/tui/component/bg-pulse.tsx +99 -0
  69. package/src/tui/component/border.tsx +21 -0
  70. package/src/tui/component/dialog-agent.tsx +31 -0
  71. package/src/tui/component/dialog-console-org.tsx +103 -0
  72. package/src/tui/component/dialog-mcp.tsx +85 -0
  73. package/src/tui/component/dialog-model.tsx +175 -0
  74. package/src/tui/component/dialog-provider.tsx +456 -0
  75. package/src/tui/component/dialog-retry-action.tsx +160 -0
  76. package/src/tui/component/dialog-session-delete-failed.tsx +99 -0
  77. package/src/tui/component/dialog-session-list.tsx +323 -0
  78. package/src/tui/component/dialog-session-rename.tsx +31 -0
  79. package/src/tui/component/dialog-skill.tsx +36 -0
  80. package/src/tui/component/dialog-stash.tsx +87 -0
  81. package/src/tui/component/dialog-status.tsx +168 -0
  82. package/src/tui/component/dialog-tag.tsx +44 -0
  83. package/src/tui/component/dialog-theme-list.tsx +50 -0
  84. package/src/tui/component/dialog-variant.tsx +39 -0
  85. package/src/tui/component/dialog-workspace-create.tsx +302 -0
  86. package/src/tui/component/dialog-workspace-file-changes.tsx +138 -0
  87. package/src/tui/component/dialog-workspace-unavailable.tsx +69 -0
  88. package/src/tui/component/error-component.tsx +92 -0
  89. package/src/tui/component/logo.tsx +896 -0
  90. package/src/tui/component/plugin-route-missing.tsx +14 -0
  91. package/src/tui/component/prompt/autocomplete.tsx +869 -0
  92. package/src/tui/component/prompt/cwd.ts +0 -0
  93. package/src/tui/component/prompt/frecency.tsx +90 -0
  94. package/src/tui/component/prompt/history.tsx +108 -0
  95. package/src/tui/component/prompt/index.tsx +1809 -0
  96. package/src/tui/component/prompt/part.ts +16 -0
  97. package/src/tui/component/prompt/stash.tsx +101 -0
  98. package/src/tui/component/prompt/traits.ts +35 -0
  99. package/src/tui/component/spinner.tsx +24 -0
  100. package/src/tui/component/startup-loading.tsx +63 -0
  101. package/src/tui/component/todo-item.tsx +32 -0
  102. package/src/tui/component/use-connected.tsx +9 -0
  103. package/src/tui/component/workspace-label.tsx +19 -0
  104. package/src/tui/config/cwd.ts +5 -0
  105. package/src/tui/config/keybind.ts +432 -0
  106. package/src/tui/config/tui-migrate.ts +154 -0
  107. package/src/tui/config/tui-schema.ts +34 -0
  108. package/src/tui/config/tui.ts +46 -0
  109. package/src/tui/context/aggregate-failures.ts +34 -0
  110. package/src/tui/context/args.tsx +15 -0
  111. package/src/tui/context/command-palette.tsx +163 -0
  112. package/src/tui/context/directory.ts +15 -0
  113. package/src/tui/context/editor-zed.ts +283 -0
  114. package/src/tui/context/editor.ts +468 -0
  115. package/src/tui/context/event-apx.ts +22 -0
  116. package/src/tui/context/event.ts +6 -0
  117. package/src/tui/context/exit.tsx +60 -0
  118. package/src/tui/context/helper.tsx +25 -0
  119. package/src/tui/context/kv.tsx +81 -0
  120. package/src/tui/context/local.tsx +608 -0
  121. package/src/tui/context/path-format.tsx +39 -0
  122. package/src/tui/context/project-apx.tsx +48 -0
  123. package/src/tui/context/project.tsx +7 -0
  124. package/src/tui/context/prompt.tsx +18 -0
  125. package/src/tui/context/route.tsx +52 -0
  126. package/src/tui/context/sdk-apx.tsx +185 -0
  127. package/src/tui/context/sdk.tsx +6 -0
  128. package/src/tui/context/sync-apx.tsx +178 -0
  129. package/src/tui/context/sync-v2.tsx +16 -0
  130. package/src/tui/context/sync.tsx +118 -0
  131. package/src/tui/context/theme/aura.json +69 -0
  132. package/src/tui/context/theme/ayu.json +80 -0
  133. package/src/tui/context/theme/carbonfox.json +248 -0
  134. package/src/tui/context/theme/catppuccin-frappe.json +230 -0
  135. package/src/tui/context/theme/catppuccin-macchiato.json +230 -0
  136. package/src/tui/context/theme/catppuccin.json +112 -0
  137. package/src/tui/context/theme/cobalt2.json +225 -0
  138. package/src/tui/context/theme/cursor.json +249 -0
  139. package/src/tui/context/theme/dracula.json +219 -0
  140. package/src/tui/context/theme/everforest.json +241 -0
  141. package/src/tui/context/theme/flexoki.json +237 -0
  142. package/src/tui/context/theme/github.json +233 -0
  143. package/src/tui/context/theme/gruvbox.json +242 -0
  144. package/src/tui/context/theme/kanagawa.json +77 -0
  145. package/src/tui/context/theme/lucent-orng.json +234 -0
  146. package/src/tui/context/theme/material.json +235 -0
  147. package/src/tui/context/theme/matrix.json +77 -0
  148. package/src/tui/context/theme/mercury.json +252 -0
  149. package/src/tui/context/theme/monokai.json +221 -0
  150. package/src/tui/context/theme/nightowl.json +221 -0
  151. package/src/tui/context/theme/nord.json +223 -0
  152. package/src/tui/context/theme/one-dark.json +84 -0
  153. package/src/tui/context/theme/opencode.json +245 -0
  154. package/src/tui/context/theme/orng.json +249 -0
  155. package/src/tui/context/theme/osaka-jade.json +93 -0
  156. package/src/tui/context/theme/palenight.json +222 -0
  157. package/src/tui/context/theme/rosepine.json +234 -0
  158. package/src/tui/context/theme/solarized.json +223 -0
  159. package/src/tui/context/theme/synthwave84.json +226 -0
  160. package/src/tui/context/theme/tokyonight.json +243 -0
  161. package/src/tui/context/theme/vercel.json +245 -0
  162. package/src/tui/context/theme/vesper.json +218 -0
  163. package/src/tui/context/theme/zenburn.json +223 -0
  164. package/src/tui/context/theme.tsx +1247 -0
  165. package/src/tui/context/tui-config.tsx +9 -0
  166. package/src/tui/event.ts +16 -0
  167. package/src/tui/feature-plugins/home/footer.tsx +94 -0
  168. package/src/tui/feature-plugins/home/tips-view.tsx +166 -0
  169. package/src/tui/feature-plugins/home/tips.tsx +59 -0
  170. package/src/tui/feature-plugins/sidebar/context.tsx +65 -0
  171. package/src/tui/feature-plugins/sidebar/files.tsx +63 -0
  172. package/src/tui/feature-plugins/sidebar/footer.tsx +94 -0
  173. package/src/tui/feature-plugins/sidebar/lsp.tsx +65 -0
  174. package/src/tui/feature-plugins/sidebar/mcp.tsx +97 -0
  175. package/src/tui/feature-plugins/sidebar/todo.tsx +49 -0
  176. package/src/tui/feature-plugins/system/plugins.tsx +269 -0
  177. package/src/tui/feature-plugins/system/session-v2.tsx +1143 -0
  178. package/src/tui/feature-plugins/system/which-key.tsx +608 -0
  179. package/src/tui/keymap.tsx +166 -0
  180. package/src/tui/layer.ts +6 -0
  181. package/src/tui/plugin/api.tsx +381 -0
  182. package/src/tui/plugin/command-shim.ts +109 -0
  183. package/src/tui/plugin/internal.ts +33 -0
  184. package/src/tui/plugin/runtime.ts +1069 -0
  185. package/src/tui/plugin/slots.tsx +60 -0
  186. package/src/tui/routes/home.tsx +96 -0
  187. package/src/tui/routes/session/dialog-fork-from-timeline.tsx +76 -0
  188. package/src/tui/routes/session/dialog-message.tsx +108 -0
  189. package/src/tui/routes/session/dialog-subagent.tsx +26 -0
  190. package/src/tui/routes/session/dialog-timeline.tsx +47 -0
  191. package/src/tui/routes/session/footer.tsx +91 -0
  192. package/src/tui/routes/session/index.tsx +188 -0
  193. package/src/tui/routes/session/permission.tsx +722 -0
  194. package/src/tui/routes/session/question.tsx +490 -0
  195. package/src/tui/routes/session/sidebar.tsx +102 -0
  196. package/src/tui/routes/session/subagent-footer.tsx +133 -0
  197. package/src/tui/run.ts +84 -0
  198. package/src/tui/thread.ts +261 -0
  199. package/src/tui/tsconfig.json +40 -0
  200. package/src/tui/ui/dialog-alert.tsx +66 -0
  201. package/src/tui/ui/dialog-confirm.tsx +108 -0
  202. package/src/tui/ui/dialog-export-options.tsx +217 -0
  203. package/src/tui/ui/dialog-help.tsx +40 -0
  204. package/src/tui/ui/dialog-prompt.tsx +101 -0
  205. package/src/tui/ui/dialog-select.tsx +553 -0
  206. package/src/tui/ui/dialog.tsx +211 -0
  207. package/src/tui/ui/link.tsx +34 -0
  208. package/src/tui/ui/spinner.ts +368 -0
  209. package/src/tui/ui/toast.tsx +111 -0
  210. package/src/tui/util/clipboard.ts +217 -0
  211. package/src/tui/util/editor.ts +37 -0
  212. package/src/tui/util/model.ts +23 -0
  213. package/src/tui/util/provider-origin.ts +7 -0
  214. package/src/tui/util/revert-diff.ts +18 -0
  215. package/src/tui/util/scroll.ts +25 -0
  216. package/src/tui/util/selection.ts +65 -0
  217. package/src/tui/util/signal.ts +41 -0
  218. package/src/tui/util/sound.ts +156 -0
  219. package/src/tui/util/transcript.ts +112 -0
  220. package/src/tui/validate-session.ts +29 -0
  221. package/src/tui/win32.ts +130 -0
  222. package/src/tui/worker.ts +104 -0
File without changes
@@ -0,0 +1,90 @@
1
+ import path from "path"
2
+ import { Global } from "@opencode-ai/core/global"
3
+ import { Filesystem } from "@/util/filesystem"
4
+ import { onMount } from "solid-js"
5
+ import { createStore } from "solid-js/store"
6
+ import { createSimpleContext } from "../../context/helper"
7
+ import { appendFile, writeFile } from "fs/promises"
8
+
9
+ function calculateFrecency(entry?: { frequency: number; lastOpen: number }): number {
10
+ if (!entry) return 0
11
+ const daysSince = (Date.now() - entry.lastOpen) / 86400000 // ms per day
12
+ const weight = 1 / (1 + daysSince)
13
+ return entry.frequency * weight
14
+ }
15
+
16
+ const MAX_FRECENCY_ENTRIES = 1000
17
+
18
+ export const { use: useFrecency, provider: FrecencyProvider } = createSimpleContext({
19
+ name: "Frecency",
20
+ init: () => {
21
+ const frecencyPath = path.join(Global.Path.state, "frecency.jsonl")
22
+ onMount(async () => {
23
+ const text = await Filesystem.readText(frecencyPath).catch(() => "")
24
+ const lines = text
25
+ .split("\n")
26
+ .filter(Boolean)
27
+ .map((line) => {
28
+ try {
29
+ return JSON.parse(line) as { path: string; frequency: number; lastOpen: number }
30
+ } catch {
31
+ return null
32
+ }
33
+ })
34
+ .filter((line): line is { path: string; frequency: number; lastOpen: number } => line !== null)
35
+
36
+ const latest = lines.reduce(
37
+ (acc, entry) => {
38
+ acc[entry.path] = entry
39
+ return acc
40
+ },
41
+ {} as Record<string, { path: string; frequency: number; lastOpen: number }>,
42
+ )
43
+
44
+ const sorted = Object.values(latest)
45
+ .sort((a, b) => b.lastOpen - a.lastOpen)
46
+ .slice(0, MAX_FRECENCY_ENTRIES)
47
+
48
+ setStore(
49
+ "data",
50
+ Object.fromEntries(
51
+ sorted.map((entry) => [entry.path, { frequency: entry.frequency, lastOpen: entry.lastOpen }]),
52
+ ),
53
+ )
54
+
55
+ if (sorted.length > 0) {
56
+ const content = sorted.map((entry) => JSON.stringify(entry)).join("\n") + "\n"
57
+ writeFile(frecencyPath, content).catch(() => {})
58
+ }
59
+ })
60
+
61
+ const [store, setStore] = createStore({
62
+ data: {} as Record<string, { frequency: number; lastOpen: number }>,
63
+ })
64
+
65
+ function updateFrecency(filePath: string) {
66
+ const absolutePath = path.resolve(process.cwd(), filePath)
67
+ const newEntry = {
68
+ frequency: (store.data[absolutePath]?.frequency || 0) + 1,
69
+ lastOpen: Date.now(),
70
+ }
71
+ setStore("data", absolutePath, newEntry)
72
+ appendFile(frecencyPath, JSON.stringify({ path: absolutePath, ...newEntry }) + "\n").catch(() => {})
73
+
74
+ if (Object.keys(store.data).length > MAX_FRECENCY_ENTRIES) {
75
+ const sorted = Object.entries(store.data)
76
+ .sort(([, a], [, b]) => b.lastOpen - a.lastOpen)
77
+ .slice(0, MAX_FRECENCY_ENTRIES)
78
+ setStore("data", Object.fromEntries(sorted))
79
+ const content = sorted.map(([path, entry]) => JSON.stringify({ path, ...entry })).join("\n") + "\n"
80
+ writeFile(frecencyPath, content).catch(() => {})
81
+ }
82
+ }
83
+
84
+ return {
85
+ getFrecency: (filePath: string) => calculateFrecency(store.data[path.resolve(process.cwd(), filePath)]),
86
+ updateFrecency,
87
+ data: () => store.data,
88
+ }
89
+ },
90
+ })
@@ -0,0 +1,108 @@
1
+ import path from "path"
2
+ import { Global } from "@opencode-ai/core/global"
3
+ import { Filesystem } from "@/util/filesystem"
4
+ import { onMount } from "solid-js"
5
+ import { createStore, produce, unwrap } from "solid-js/store"
6
+ import { createSimpleContext } from "../../context/helper"
7
+ import { appendFile, writeFile } from "fs/promises"
8
+ import type { AgentPart, FilePart, TextPart } from "@opencode-ai/sdk/v2"
9
+
10
+ export type PromptInfo = {
11
+ input: string
12
+ mode?: "normal" | "shell"
13
+ parts: (
14
+ | Omit<FilePart, "id" | "messageID" | "sessionID">
15
+ | Omit<AgentPart, "id" | "messageID" | "sessionID">
16
+ | (Omit<TextPart, "id" | "messageID" | "sessionID"> & {
17
+ source?: {
18
+ text: {
19
+ start: number
20
+ end: number
21
+ value: string
22
+ }
23
+ }
24
+ })
25
+ )[]
26
+ }
27
+
28
+ const MAX_HISTORY_ENTRIES = 50
29
+
30
+ export const { use: usePromptHistory, provider: PromptHistoryProvider } = createSimpleContext({
31
+ name: "PromptHistory",
32
+ init: () => {
33
+ const historyPath = path.join(Global.Path.state, "prompt-history.jsonl")
34
+ onMount(async () => {
35
+ const text = await Filesystem.readText(historyPath).catch(() => "")
36
+ const lines = text
37
+ .split("\n")
38
+ .filter(Boolean)
39
+ .map((line) => {
40
+ try {
41
+ return JSON.parse(line)
42
+ } catch {
43
+ return null
44
+ }
45
+ })
46
+ .filter((line): line is PromptInfo => line !== null)
47
+ .slice(-MAX_HISTORY_ENTRIES)
48
+
49
+ setStore("history", lines)
50
+
51
+ // Rewrite file with only valid entries to self-heal corruption
52
+ if (lines.length > 0) {
53
+ const content = lines.map((line) => JSON.stringify(line)).join("\n") + "\n"
54
+ writeFile(historyPath, content).catch(() => {})
55
+ }
56
+ })
57
+
58
+ const [store, setStore] = createStore({
59
+ index: 0,
60
+ history: [] as PromptInfo[],
61
+ })
62
+
63
+ return {
64
+ move(direction: 1 | -1, input: string) {
65
+ if (!store.history.length) return undefined
66
+ const current = store.history.at(store.index)
67
+ if (!current) return undefined
68
+ if (current.input !== input && input.length) return
69
+ setStore(
70
+ produce((draft) => {
71
+ const next = store.index + direction
72
+ if (Math.abs(next) > store.history.length) return
73
+ if (next > 0) return
74
+ draft.index = next
75
+ }),
76
+ )
77
+ if (store.index === 0)
78
+ return {
79
+ input: "",
80
+ parts: [],
81
+ }
82
+ return store.history.at(store.index)
83
+ },
84
+ append(item: PromptInfo) {
85
+ const entry = structuredClone(unwrap(item))
86
+ let trimmed = false
87
+ setStore(
88
+ produce((draft) => {
89
+ draft.history.push(entry)
90
+ if (draft.history.length > MAX_HISTORY_ENTRIES) {
91
+ draft.history = draft.history.slice(-MAX_HISTORY_ENTRIES)
92
+ trimmed = true
93
+ }
94
+ draft.index = 0
95
+ }),
96
+ )
97
+
98
+ if (trimmed) {
99
+ const content = store.history.map((line) => JSON.stringify(line)).join("\n") + "\n"
100
+ writeFile(historyPath, content).catch(() => {})
101
+ return
102
+ }
103
+
104
+ appendFile(historyPath, JSON.stringify(entry) + "\n").catch(() => {})
105
+ },
106
+ }
107
+ },
108
+ })