@agentprojectcontext/apx 1.15.6 → 1.17.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/package.json +46 -5
- package/src/cli/commands/log.js +113 -0
- package/src/cli/commands/overlay.js +253 -0
- package/src/cli/commands/sys.js +88 -16
- package/src/cli/index.js +23 -1
- package/src/cli/terminal-chat/renderer.js +71 -56
- package/src/cli-ts/commands/agent.ts +173 -0
- package/src/cli-ts/commands/chat.ts +119 -0
- package/src/cli-ts/commands/daemon.ts +112 -0
- package/src/cli-ts/commands/exec.ts +109 -0
- package/src/cli-ts/commands/mcp.ts +235 -0
- package/src/cli-ts/commands/session.ts +224 -0
- package/src/cli-ts/commands/status.ts +61 -0
- package/src/cli-ts/http.ts +36 -0
- package/src/cli-ts/index.ts +73 -0
- package/src/cli-ts/ui.ts +107 -0
- package/src/core/logging.js +81 -0
- package/src/daemon/api.js +58 -0
- package/src/daemon/engines/anthropic.js +60 -1
- package/src/daemon/engines/index.js +2 -1
- package/src/daemon/engines/ollama.js +70 -3
- package/src/daemon/index.js +58 -0
- package/src/daemon/overlay-ws.js +40 -0
- package/src/daemon/plugins/index.js +2 -1
- package/src/daemon/plugins/overlay.js +177 -0
- package/src/daemon/plugins/telegram.js +15 -3
- package/src/daemon/super-agent-langchain.js +296 -0
- package/src/daemon/super-agent.js +115 -19
- package/src/daemon/transcription.js +262 -59
- package/src/daemon/whisper-server.py +57 -6
- package/src/overlay/index.html +44 -0
- package/src/overlay/main.js +480 -0
- package/src/overlay/package.json +3 -0
- package/src/overlay/preload.js +34 -0
- package/src/overlay/renderer.js +371 -0
- package/src/overlay/style.css +250 -0
- package/src/tui/_shims/cli-error.ts +6 -0
- package/src/tui/_shims/cli-logo.ts +18 -0
- package/src/tui/_shims/cli-ui.ts +1 -0
- package/src/tui/_shims/config-console-state.ts +7 -0
- package/src/tui/_shims/core-any.ts +30 -0
- package/src/tui/_shims/core-binary.ts +13 -0
- package/src/tui/_shims/core-flag.ts +3 -0
- package/src/tui/_shims/core-log.ts +14 -0
- package/src/tui/_shims/lsp-language.ts +1 -0
- package/src/tui/_shims/opencode-any.ts +135 -0
- package/src/tui/_shims/opencode-sdk-v2.ts +48 -0
- package/src/tui/_shims/plugin-tui.ts +13 -0
- package/src/tui/_shims/provider-provider.ts +10 -0
- package/src/tui/_shims/session-retry.ts +1 -0
- package/src/tui/_shims/session-schema.ts +15 -0
- package/src/tui/_shims/session-session.ts +3 -0
- package/src/tui/_shims/snapshot.ts +4 -0
- package/src/tui/_shims/tool-any.ts +18 -0
- package/src/tui/_shims/util-error.ts +7 -0
- package/src/tui/_shims/util-filesystem.ts +79 -0
- package/src/tui/_shims/util-format.ts +7 -0
- package/src/tui/_shims/util-iife.ts +3 -0
- package/src/tui/_shims/util-locale.ts +10 -0
- package/src/tui/_shims/util-process.ts +38 -0
- package/src/tui/app.tsx +783 -0
- package/src/tui/asset/charge.wav +0 -0
- package/src/tui/asset/pulse-a.wav +0 -0
- package/src/tui/asset/pulse-b.wav +0 -0
- package/src/tui/asset/pulse-c.wav +0 -0
- package/src/tui/attach.ts +100 -0
- package/src/tui/component/bg-pulse-render.ts +436 -0
- package/src/tui/component/bg-pulse.tsx +99 -0
- package/src/tui/component/border.tsx +21 -0
- package/src/tui/component/dialog-agent.tsx +31 -0
- package/src/tui/component/dialog-console-org.tsx +103 -0
- package/src/tui/component/dialog-mcp.tsx +85 -0
- package/src/tui/component/dialog-model.tsx +175 -0
- package/src/tui/component/dialog-provider.tsx +456 -0
- package/src/tui/component/dialog-retry-action.tsx +160 -0
- package/src/tui/component/dialog-session-delete-failed.tsx +99 -0
- package/src/tui/component/dialog-session-list.tsx +323 -0
- package/src/tui/component/dialog-session-rename.tsx +31 -0
- package/src/tui/component/dialog-skill.tsx +36 -0
- package/src/tui/component/dialog-stash.tsx +87 -0
- package/src/tui/component/dialog-status.tsx +168 -0
- package/src/tui/component/dialog-tag.tsx +44 -0
- package/src/tui/component/dialog-theme-list.tsx +50 -0
- package/src/tui/component/dialog-variant.tsx +39 -0
- package/src/tui/component/dialog-workspace-create.tsx +302 -0
- package/src/tui/component/dialog-workspace-file-changes.tsx +138 -0
- package/src/tui/component/dialog-workspace-unavailable.tsx +69 -0
- package/src/tui/component/error-component.tsx +92 -0
- package/src/tui/component/logo.tsx +896 -0
- package/src/tui/component/plugin-route-missing.tsx +14 -0
- package/src/tui/component/prompt/autocomplete.tsx +869 -0
- package/src/tui/component/prompt/cwd.ts +0 -0
- package/src/tui/component/prompt/frecency.tsx +90 -0
- package/src/tui/component/prompt/history.tsx +108 -0
- package/src/tui/component/prompt/index.tsx +1809 -0
- package/src/tui/component/prompt/part.ts +16 -0
- package/src/tui/component/prompt/stash.tsx +101 -0
- package/src/tui/component/prompt/traits.ts +35 -0
- package/src/tui/component/spinner.tsx +24 -0
- package/src/tui/component/startup-loading.tsx +63 -0
- package/src/tui/component/todo-item.tsx +32 -0
- package/src/tui/component/use-connected.tsx +9 -0
- package/src/tui/component/workspace-label.tsx +19 -0
- package/src/tui/config/cwd.ts +5 -0
- package/src/tui/config/keybind.ts +432 -0
- package/src/tui/config/tui-migrate.ts +154 -0
- package/src/tui/config/tui-schema.ts +34 -0
- package/src/tui/config/tui.ts +46 -0
- package/src/tui/context/aggregate-failures.ts +34 -0
- package/src/tui/context/args.tsx +15 -0
- package/src/tui/context/command-palette.tsx +163 -0
- package/src/tui/context/directory.ts +15 -0
- package/src/tui/context/editor-zed.ts +283 -0
- package/src/tui/context/editor.ts +468 -0
- package/src/tui/context/event-apx.ts +22 -0
- package/src/tui/context/event.ts +6 -0
- package/src/tui/context/exit.tsx +60 -0
- package/src/tui/context/helper.tsx +25 -0
- package/src/tui/context/kv.tsx +81 -0
- package/src/tui/context/local.tsx +608 -0
- package/src/tui/context/path-format.tsx +39 -0
- package/src/tui/context/project-apx.tsx +48 -0
- package/src/tui/context/project.tsx +7 -0
- package/src/tui/context/prompt.tsx +18 -0
- package/src/tui/context/route.tsx +52 -0
- package/src/tui/context/sdk-apx.tsx +185 -0
- package/src/tui/context/sdk.tsx +6 -0
- package/src/tui/context/sync-apx.tsx +178 -0
- package/src/tui/context/sync-v2.tsx +16 -0
- package/src/tui/context/sync.tsx +118 -0
- package/src/tui/context/theme/aura.json +69 -0
- package/src/tui/context/theme/ayu.json +80 -0
- package/src/tui/context/theme/carbonfox.json +248 -0
- package/src/tui/context/theme/catppuccin-frappe.json +230 -0
- package/src/tui/context/theme/catppuccin-macchiato.json +230 -0
- package/src/tui/context/theme/catppuccin.json +112 -0
- package/src/tui/context/theme/cobalt2.json +225 -0
- package/src/tui/context/theme/cursor.json +249 -0
- package/src/tui/context/theme/dracula.json +219 -0
- package/src/tui/context/theme/everforest.json +241 -0
- package/src/tui/context/theme/flexoki.json +237 -0
- package/src/tui/context/theme/github.json +233 -0
- package/src/tui/context/theme/gruvbox.json +242 -0
- package/src/tui/context/theme/kanagawa.json +77 -0
- package/src/tui/context/theme/lucent-orng.json +234 -0
- package/src/tui/context/theme/material.json +235 -0
- package/src/tui/context/theme/matrix.json +77 -0
- package/src/tui/context/theme/mercury.json +252 -0
- package/src/tui/context/theme/monokai.json +221 -0
- package/src/tui/context/theme/nightowl.json +221 -0
- package/src/tui/context/theme/nord.json +223 -0
- package/src/tui/context/theme/one-dark.json +84 -0
- package/src/tui/context/theme/opencode.json +245 -0
- package/src/tui/context/theme/orng.json +249 -0
- package/src/tui/context/theme/osaka-jade.json +93 -0
- package/src/tui/context/theme/palenight.json +222 -0
- package/src/tui/context/theme/rosepine.json +234 -0
- package/src/tui/context/theme/solarized.json +223 -0
- package/src/tui/context/theme/synthwave84.json +226 -0
- package/src/tui/context/theme/tokyonight.json +243 -0
- package/src/tui/context/theme/vercel.json +245 -0
- package/src/tui/context/theme/vesper.json +218 -0
- package/src/tui/context/theme/zenburn.json +223 -0
- package/src/tui/context/theme.tsx +1247 -0
- package/src/tui/context/tui-config.tsx +9 -0
- package/src/tui/event.ts +16 -0
- package/src/tui/feature-plugins/home/footer.tsx +94 -0
- package/src/tui/feature-plugins/home/tips-view.tsx +166 -0
- package/src/tui/feature-plugins/home/tips.tsx +59 -0
- package/src/tui/feature-plugins/sidebar/context.tsx +65 -0
- package/src/tui/feature-plugins/sidebar/files.tsx +63 -0
- package/src/tui/feature-plugins/sidebar/footer.tsx +94 -0
- package/src/tui/feature-plugins/sidebar/lsp.tsx +65 -0
- package/src/tui/feature-plugins/sidebar/mcp.tsx +97 -0
- package/src/tui/feature-plugins/sidebar/todo.tsx +49 -0
- package/src/tui/feature-plugins/system/plugins.tsx +269 -0
- package/src/tui/feature-plugins/system/session-v2.tsx +1143 -0
- package/src/tui/feature-plugins/system/which-key.tsx +608 -0
- package/src/tui/keymap.tsx +166 -0
- package/src/tui/layer.ts +6 -0
- package/src/tui/plugin/api.tsx +381 -0
- package/src/tui/plugin/command-shim.ts +109 -0
- package/src/tui/plugin/internal.ts +33 -0
- package/src/tui/plugin/runtime.ts +1069 -0
- package/src/tui/plugin/slots.tsx +60 -0
- package/src/tui/routes/home.tsx +96 -0
- package/src/tui/routes/session/dialog-fork-from-timeline.tsx +76 -0
- package/src/tui/routes/session/dialog-message.tsx +108 -0
- package/src/tui/routes/session/dialog-subagent.tsx +26 -0
- package/src/tui/routes/session/dialog-timeline.tsx +47 -0
- package/src/tui/routes/session/footer.tsx +91 -0
- package/src/tui/routes/session/index.tsx +188 -0
- package/src/tui/routes/session/permission.tsx +722 -0
- package/src/tui/routes/session/question.tsx +490 -0
- package/src/tui/routes/session/sidebar.tsx +102 -0
- package/src/tui/routes/session/subagent-footer.tsx +133 -0
- package/src/tui/run.ts +84 -0
- package/src/tui/thread.ts +261 -0
- package/src/tui/tsconfig.json +40 -0
- package/src/tui/ui/dialog-alert.tsx +66 -0
- package/src/tui/ui/dialog-confirm.tsx +108 -0
- package/src/tui/ui/dialog-export-options.tsx +217 -0
- package/src/tui/ui/dialog-help.tsx +40 -0
- package/src/tui/ui/dialog-prompt.tsx +101 -0
- package/src/tui/ui/dialog-select.tsx +553 -0
- package/src/tui/ui/dialog.tsx +211 -0
- package/src/tui/ui/link.tsx +34 -0
- package/src/tui/ui/spinner.ts +368 -0
- package/src/tui/ui/toast.tsx +111 -0
- package/src/tui/util/clipboard.ts +217 -0
- package/src/tui/util/editor.ts +37 -0
- package/src/tui/util/model.ts +23 -0
- package/src/tui/util/provider-origin.ts +7 -0
- package/src/tui/util/revert-diff.ts +18 -0
- package/src/tui/util/scroll.ts +25 -0
- package/src/tui/util/selection.ts +65 -0
- package/src/tui/util/signal.ts +41 -0
- package/src/tui/util/sound.ts +156 -0
- package/src/tui/util/transcript.ts +112 -0
- package/src/tui/validate-session.ts +29 -0
- package/src/tui/win32.ts +130 -0
- 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
|
+
})
|