minicode-ai 0.14.2 → 0.14.4
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 +34 -178
- package/cli/args.ts +10 -18
- package/cli/commands/acp.ts +20 -27
- package/cli/commands/daemon.ts +6 -7
- package/cli/commands/exec.ts +12 -10
- package/cli/commands.ts +6 -9
- package/cli/index.ts +30 -15
- package/cli/provider-manager.ts +1 -3
- package/cli/setup.ts +167 -143
- package/cli/tui.ts +15 -23
- package/docs/CONTROL-PLANE-MAP.md +145 -0
- package/docs/OUTPUT_EVENT_MODEL.md +1 -1
- package/docs/OUTPUT_PROTOCOL_SPEC.md +2 -2
- package/docs/OUTPUT_RENDERING_SPEC.md +7 -2
- package/docs/OUTPUT_UX_RULES.md +1 -1
- package/docs/README.md +14 -102
- package/docs/SUMMARY.md +53 -0
- package/docs/TERMINAL_CONTRACT.md +84 -51
- package/docs/UI_RENDER_PIPELINE.md +204 -0
- package/docs/agents.md +5 -5
- package/docs/architecture.md +23 -12
- package/docs/choosing-mode.md +7 -7
- package/docs/cli.md +22 -29
- package/docs/concepts.md +1 -1
- package/docs/config.md +10 -5
- package/docs/contributing.md +6 -6
- package/docs/environment.md +3 -1
- package/docs/exec.md +5 -5
- package/docs/glossary.md +8 -6
- package/docs/memory-sessions.md +7 -5
- package/docs/policy-sandbox.md +16 -14
- package/docs/quickstart.md +2 -2
- package/docs/repl.md +4 -3
- package/docs/security-model.md +14 -15
- package/docs/security.md +8 -29
- package/docs/skills.md +1 -1
- package/docs/tools.md +2 -2
- package/package.json +5 -3
- package/scripts/vendor-overlays/minicode-context.patch +109 -0
- package/src/app/provider-layer.ts +13 -1
- package/src/app/session.ts +216 -13
- package/src/config.ts +30 -3
- package/src/constants.ts +2 -0
- package/src/daemon/control.ts +1 -1
- package/src/mcp/server.ts +2 -3
- package/src/policy/compaction.ts +272 -16
- package/src/policy/context-window.ts +73 -0
- package/src/policy/context.ts +55 -3
- package/src/policy/ratelimit.ts +47 -18
- package/src/policy/usage.ts +15 -8
- package/src/policy/work-mode.ts +1 -1
- package/src/providers/guards.ts +61 -4
- package/src/providers/provision.ts +12 -3
- package/src/providers/router.ts +56 -23
- package/src/session/context-projection.ts +14 -0
- package/src/session/context-selector.ts +58 -20
- package/src/session/persistence.ts +1 -1
- package/src/task/model.ts +21 -70
- package/src/tools/task.ts +7 -0
- package/src/ui/footer.ts +131 -66
- package/src/ui/i18n/en.ts +0 -11
- package/src/ui/i18n/id.ts +0 -11
- package/src/ui/input/input.ts +2 -3
- package/src/ui/input/prompt-engine.ts +2 -5
- package/src/ui/screens/model-manager.ts +3 -10
- package/src/ui/screens/picker.ts +23 -40
- package/src/ui/screens/provider-manager.ts +12 -33
- package/src/ui/screens/wizard.ts +0 -1
- package/src/ui/tui/app.ts +10 -6
- package/src/ui/tui/transcript.ts +48 -8
- package/vendor/minicore/VENDOR.md +9 -5
- package/vendor/minicore/src/core/loop.ts +47 -12
- package/vendor/minicore/src/core/provider.ts +4 -0
- package/vendor/minicore/src/core/session.ts +14 -1
- package/docs/OUTPUT_ARCHITECTURE_AUDIT.md +0 -489
- package/docs/OUTPUT_IMPLEMENTATION_PLAN.md +0 -391
package/src/tools/task.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { loadConfig } from "../config.ts"
|
|
|
7
7
|
import { LIMITS } from "../constants.ts"
|
|
8
8
|
import { resolveLocalDbPath } from "../lib/db-path.ts"
|
|
9
9
|
import { evaluateConsequence, isAceEnabled } from "../policy/consequence-engine.ts"
|
|
10
|
+
import { resolveContextWindow } from "../policy/context-window.ts"
|
|
10
11
|
import type { NoProgressOptions } from "../policy/no-progress.ts"
|
|
11
12
|
import type { RateLimiter } from "../policy/ratelimit.ts"
|
|
12
13
|
import type { WorkMode } from "../policy/work-mode.ts"
|
|
@@ -151,6 +152,7 @@ export function clearSubAgentSessionFactory(): void {
|
|
|
151
152
|
export interface SubAgentParentRouting {
|
|
152
153
|
rateLimiter?: RateLimiter
|
|
153
154
|
defaultProviderId?: string
|
|
155
|
+
contextWindowTokensForModel?: (model?: string) => number
|
|
154
156
|
}
|
|
155
157
|
|
|
156
158
|
let parentRouting: SubAgentParentRouting = {}
|
|
@@ -201,6 +203,9 @@ export function setSubAgentParentRouting(c: SubAgentParentRouting): void {
|
|
|
201
203
|
parentRouting = {
|
|
202
204
|
...(c.rateLimiter ? { rateLimiter: c.rateLimiter } : {}),
|
|
203
205
|
...(c.defaultProviderId ? { defaultProviderId: c.defaultProviderId } : {}),
|
|
206
|
+
...(c.contextWindowTokensForModel
|
|
207
|
+
? { contextWindowTokensForModel: c.contextWindowTokensForModel }
|
|
208
|
+
: {}),
|
|
204
209
|
}
|
|
205
210
|
}
|
|
206
211
|
|
|
@@ -224,6 +229,8 @@ async function getProvider(overrides: SubAgentParentRouting = parentRouting) {
|
|
|
224
229
|
if (providers.length === 0) throw new Error("no provider for sub-agent")
|
|
225
230
|
return createRouterProvider({
|
|
226
231
|
providers,
|
|
232
|
+
contextWindowTokensForModel:
|
|
233
|
+
overrides.contextWindowTokensForModel ?? ((model) => resolveContextWindow(cfg, model).tokens),
|
|
227
234
|
...(overrides.rateLimiter ? { limiter: overrides.rateLimiter } : {}),
|
|
228
235
|
...(overrides.defaultProviderId ? { defaultProviderId: overrides.defaultProviderId } : {}),
|
|
229
236
|
})
|
package/src/ui/footer.ts
CHANGED
|
@@ -5,26 +5,18 @@
|
|
|
5
5
|
// jadi render tetap deterministik dan bisa diuji tanpa menunggu waktu.
|
|
6
6
|
//
|
|
7
7
|
// Gaya (keputusan produk): footer hampir tak terlihat; field dipisahkan
|
|
8
|
-
// dengan spasi dan warna, tanpa bullet separator. Mode
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// Tata letak: `✦ 00.00.00 mode model cwd ……… 14.2k` — konteks rata kanan.
|
|
12
|
-
// Mode di-pad ke lebar tetap agar teks di kanannya TIDAK bergeser saat mode
|
|
13
|
-
// berganti (Shift+Tab): tanpa padding, `auto`→`allowlist` menggeser seluruh baris.
|
|
8
|
+
// dengan spasi dan warna, tanpa bullet separator. Work Mode ada di kiri;
|
|
9
|
+
// Permission Mode berwarna cyan di sisi kanan, dekat penggunaan konteks.
|
|
14
10
|
import { sanitizeAnsiLine } from "./render/sanitize.ts"
|
|
15
11
|
import { c, glyphs } from "./render/theme.ts"
|
|
16
|
-
import { displayWidth,
|
|
12
|
+
import { displayWidth, truncateToWidth } from "./render/width.ts"
|
|
17
13
|
|
|
18
14
|
export type TimerHighlight = "seconds" | "minutes" | "hours"
|
|
19
15
|
|
|
20
16
|
export interface FooterStatus {
|
|
17
|
+
/** Permission mode efektif sesi ini (umumnya AUTO atau ASK). */
|
|
21
18
|
mode: string
|
|
22
|
-
/**
|
|
23
|
-
* P12 S2.2 Slice 5 — WorkMode aktif sesi (DISCUSS|PLAN|EXECUTE). Hanya
|
|
24
|
-
* ditampilkan bila bukan EXECUTE: label jadi `<WorkMode>·<permission mode>`
|
|
25
|
-
* (mis. `PLAN·auto`, `DISCUSS·auto`) agar dua lapis intent/permission bisa
|
|
26
|
-
* dibedakan. EXECUTE (default) = perilaku lama, label permission mode saja.
|
|
27
|
-
*/
|
|
19
|
+
/** WorkMode aktif sesi; identitas internal EXECUTE ditampilkan sebagai Build. */
|
|
28
20
|
workMode?: string
|
|
29
21
|
model: string
|
|
30
22
|
cwd: string
|
|
@@ -48,8 +40,10 @@ export interface FooterStatus {
|
|
|
48
40
|
timerHighlight?: TimerHighlight
|
|
49
41
|
}
|
|
50
42
|
|
|
51
|
-
/** Lebar tetap kolom
|
|
52
|
-
const
|
|
43
|
+
/** Lebar tetap kolom agar perubahan WorkMode tidak menggeser model/CWD. */
|
|
44
|
+
const WORK_MODE_WIDTH = 18
|
|
45
|
+
const WORK_MODE_COMPACT_WIDTH = 13
|
|
46
|
+
const WORK_MODE_VALUE_WIDTH = 7
|
|
53
47
|
|
|
54
48
|
/** Buang prefix provider (`acme::deepseek-v4` → `deepseek-v4`). */
|
|
55
49
|
export function shortModel(id: string): string {
|
|
@@ -57,30 +51,50 @@ export function shortModel(id: string): string {
|
|
|
57
51
|
return i >= 0 ? id.slice(i + 2) : id
|
|
58
52
|
}
|
|
59
53
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
function titleCaseMode(value: string, fallback: string): string {
|
|
55
|
+
const clean = sanitizeAnsiLine(value).trim()
|
|
56
|
+
if (!clean) return fallback
|
|
57
|
+
return clean
|
|
58
|
+
.toLowerCase()
|
|
59
|
+
.replace(/(^|[\s_-])([a-z])/g, (_match, sep: string, letter: string) => {
|
|
60
|
+
return `${sep}${letter.toUpperCase()}`
|
|
61
|
+
})
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
*/
|
|
76
|
-
export function
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
64
|
+
function workModeValue(workMode?: string): string {
|
|
65
|
+
const normalized = (workMode || "DISCUSS").toUpperCase()
|
|
66
|
+
if (normalized === "EXECUTE" || normalized === "BUILD") return "Build"
|
|
67
|
+
if (normalized === "DISCUSS") return "Discuss"
|
|
68
|
+
if (normalized === "PLAN") return "Plan"
|
|
69
|
+
return titleCaseMode(workMode ?? "", "Build")
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
type ModeLabelStyle = "full" | "compact" | "value"
|
|
73
|
+
|
|
74
|
+
/** Work Mode memakai warna semantik; label/nilai memakai title case. */
|
|
75
|
+
export function paintWorkMode(workMode?: string, style: ModeLabelStyle = "full"): string {
|
|
76
|
+
const value = workModeValue(workMode)
|
|
77
|
+
const normalized = sanitizeAnsiLine(workMode || "DISCUSS").toUpperCase()
|
|
78
|
+
const prefix = style === "full" ? "Work Mode: " : style === "compact" ? "Work: " : ""
|
|
79
|
+
const width =
|
|
80
|
+
style === "full"
|
|
81
|
+
? WORK_MODE_WIDTH
|
|
82
|
+
: style === "compact"
|
|
83
|
+
? WORK_MODE_COMPACT_WIDTH
|
|
84
|
+
: WORK_MODE_VALUE_WIDTH
|
|
85
|
+
const labelWidth = displayWidth(sanitizeAnsiLine(`${prefix}${value}`))
|
|
86
|
+
const colorValue = normalized === "DISCUSS" || normalized === "PLAN" ? c.warning : c.success
|
|
87
|
+
return `${prefix ? c.gray(prefix) : ""}${colorValue(value)}${" ".repeat(
|
|
88
|
+
Math.max(0, width - labelWidth),
|
|
89
|
+
)}`
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Permission Mode selalu cyan agar terpisah secara visual dari Work Mode. */
|
|
93
|
+
export function paintPermissionMode(mode: string, style: ModeLabelStyle = "full"): string {
|
|
94
|
+
const value = titleCaseMode(mode, "Auto")
|
|
95
|
+
if (style === "value") return c.info(value)
|
|
96
|
+
const prefix = style === "full" ? "Permission Mode: " : "Permission: "
|
|
97
|
+
return `${c.gray(prefix)}${c.info(value)}`
|
|
84
98
|
}
|
|
85
99
|
|
|
86
100
|
/** Spark glyph: redup saat idle, pulse putih↔abu saat busy (frame genap/ganjil). */
|
|
@@ -131,7 +145,6 @@ export function renderFooter(s: FooterStatus, columns: number): string[] {
|
|
|
131
145
|
? `${paintTimer(timerText, s.timerActive === true, s.timerHighlight)} `
|
|
132
146
|
: ""
|
|
133
147
|
const lead = `${spark} ${timer}`
|
|
134
|
-
const mode = paintFooterMode(s.mode, s.workMode)
|
|
135
148
|
const fieldGap = " "
|
|
136
149
|
// Satu-baris: cwd/model bisa berisi newline (nama dir) — sanitizeAnsiLine
|
|
137
150
|
// agar \n tak memecah frame lengket ke scrollback (displayWidth menghitung
|
|
@@ -139,38 +152,90 @@ export function renderFooter(s: FooterStatus, columns: number): string[] {
|
|
|
139
152
|
const model = c.gray(sanitizeAnsiLine(shortModel(s.model)))
|
|
140
153
|
const cwdTxt = c.muted(sanitizeAnsiLine(s.cwd))
|
|
141
154
|
const shortCwdTxt = c.muted(sanitizeAnsiLine(shortenPath(s.cwd)))
|
|
142
|
-
|
|
143
|
-
const full = `${lead}${mode}${fieldGap}${model}${fieldGap}${cwdTxt}`
|
|
144
|
-
const shortened = `${lead}${mode}${fieldGap}${model}${fieldGap}${shortCwdTxt}`
|
|
145
|
-
const mid = `${lead}${mode}${fieldGap}${model}`
|
|
146
|
-
const lean = `${lead}${mode}`
|
|
147
|
-
|
|
148
155
|
const target = Math.max(4, cols - 1)
|
|
149
156
|
const ctx = s.context ? sanitizeAnsiLine(s.context) : ""
|
|
150
157
|
const metrics = s.metrics ? sanitizeAnsiLine(s.metrics) : ""
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
158
|
+
const contextParts = [ctx, metrics].filter(Boolean).map((part) => c.gray(part))
|
|
159
|
+
const leftWithCwdFor = (style: ModeLabelStyle): string[] => {
|
|
160
|
+
const work = paintWorkMode(s.workMode, style)
|
|
161
|
+
return [
|
|
162
|
+
`${lead}${work}${fieldGap}${model}${fieldGap}${cwdTxt}`,
|
|
163
|
+
...(shortCwdTxt !== cwdTxt
|
|
164
|
+
? [`${lead}${work}${fieldGap}${model}${fieldGap}${shortCwdTxt}`]
|
|
165
|
+
: []),
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
const leftWithoutCwdFor = (style: ModeLabelStyle): string[] => {
|
|
169
|
+
const work = paintWorkMode(s.workMode, style)
|
|
170
|
+
return [`${lead}${work}${fieldGap}${model}`]
|
|
171
|
+
}
|
|
172
|
+
const leftModeOnlyFor = (style: ModeLabelStyle): string => {
|
|
173
|
+
return `${lead}${paintWorkMode(s.workMode, style)}`
|
|
174
|
+
}
|
|
175
|
+
const rightFor = (style: ModeLabelStyle): string =>
|
|
176
|
+
[...contextParts, paintPermissionMode(s.mode, style)].join(fieldGap)
|
|
177
|
+
const align = (left: string, right: string): string | undefined => {
|
|
178
|
+
const leftWidth = displayWidth(left)
|
|
179
|
+
const rightWidth = displayWidth(right)
|
|
180
|
+
const gapWidth = target - leftWidth - rightWidth
|
|
181
|
+
if (gapWidth < 1) return undefined
|
|
182
|
+
return `${left}${" ".repeat(gapWidth)}${right}`
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Pertahankan label penuh selama muat; jika tidak, padatkan kedua label
|
|
186
|
+
// bersama-sama sebelum menghilangkan konteks atau memotong salah satu mode.
|
|
187
|
+
const labelPairGroups: ReadonlyArray<ReadonlyArray<readonly [ModeLabelStyle, ModeLabelStyle]>> = [
|
|
188
|
+
[
|
|
189
|
+
["full", "full"],
|
|
190
|
+
["compact", "compact"],
|
|
191
|
+
],
|
|
192
|
+
[["value", "value"]],
|
|
193
|
+
[
|
|
194
|
+
["full", "compact"],
|
|
195
|
+
["compact", "full"],
|
|
196
|
+
],
|
|
197
|
+
[
|
|
198
|
+
["compact", "value"],
|
|
199
|
+
["value", "compact"],
|
|
200
|
+
],
|
|
201
|
+
[
|
|
202
|
+
["full", "value"],
|
|
203
|
+
["value", "full"],
|
|
204
|
+
],
|
|
205
|
+
]
|
|
206
|
+
for (const pairGroup of labelPairGroups) {
|
|
207
|
+
for (const leftCandidates of [leftWithCwdFor, leftWithoutCwdFor]) {
|
|
208
|
+
for (const [workStyle, permissionStyle] of pairGroup) {
|
|
209
|
+
for (const left of leftCandidates(workStyle)) {
|
|
210
|
+
const line = align(left, rightFor(permissionStyle))
|
|
211
|
+
if (line && displayWidth(line) <= target) return [line]
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
for (const pairGroup of labelPairGroups) {
|
|
217
|
+
for (const [workStyle, permissionStyle] of pairGroup) {
|
|
218
|
+
const line = align(leftModeOnlyFor(workStyle), rightFor(permissionStyle))
|
|
219
|
+
if (line && displayWidth(line) <= target) return [line]
|
|
220
|
+
}
|
|
165
221
|
}
|
|
166
222
|
|
|
167
|
-
//
|
|
168
|
-
//
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
223
|
+
// Terminal sangat sempit: pertahankan spark dan dua nilai mode, hilangkan
|
|
224
|
+
// timer/model/CWD/label sebelum konteks; potong konteks lebih dahulu.
|
|
225
|
+
const workValue = paintWorkMode(s.workMode, "value")
|
|
226
|
+
const permissionValue = paintPermissionMode(s.mode, "value")
|
|
227
|
+
const shortWorkValue = workValue.trimEnd()
|
|
228
|
+
const modeOnly = `${spark} ${shortWorkValue} ${permissionValue}`
|
|
229
|
+
if (ctx || metrics) {
|
|
230
|
+
const context = [ctx, metrics].filter(Boolean).join(" ")
|
|
231
|
+
const baseWidth = displayWidth(modeOnly)
|
|
232
|
+
const contextBudget = target - baseWidth - 2
|
|
233
|
+
if (contextBudget > 0) {
|
|
234
|
+
const shortenedContext = truncateToWidth(context, contextBudget, "…")
|
|
235
|
+
const withContext = `${spark} ${shortWorkValue} ${c.gray(shortenedContext)} ${permissionValue}`
|
|
236
|
+
if (displayWidth(withContext) <= target) return [withContext]
|
|
237
|
+
}
|
|
173
238
|
}
|
|
174
|
-
|
|
175
|
-
return [truncateToWidth(
|
|
239
|
+
if (displayWidth(modeOnly) <= target) return [modeOnly]
|
|
240
|
+
return [truncateToWidth(modeOnly, target, "…")]
|
|
176
241
|
}
|
package/src/ui/i18n/en.ts
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
// Nilai memakai interpolasi `{nama}` sederhana (lihat t()).
|
|
4
4
|
export const en = {
|
|
5
5
|
"app.placeholder": "ask anything, / for commands… (Ctrl+D exits)",
|
|
6
|
-
"app.menuHeader": "─ commands ─",
|
|
7
|
-
"app.moreLines": " … {n} more",
|
|
8
6
|
"app.newBelow": "↓ {n} new lines below · PgDn to bottom",
|
|
9
7
|
"app.abortHint": "abort sent — press Esc again to quit",
|
|
10
8
|
"app.working": "Working",
|
|
@@ -63,17 +61,11 @@ export const en = {
|
|
|
63
61
|
"verb.delete": "delete",
|
|
64
62
|
"verb.edit": "edit",
|
|
65
63
|
"verb.close": "close",
|
|
66
|
-
"pick.filter": "Filter:",
|
|
67
|
-
"pick.placeholder": "type to filter",
|
|
68
64
|
"pick.noMatch": 'No matches for "{q}"',
|
|
69
|
-
"pick.matches": "{n}/{total} matches",
|
|
70
|
-
"pick.hint": "↑↓:{select} · Enter:{confirm} · Esc:{back}",
|
|
71
65
|
"pick.fail": "picker failed: {msg}",
|
|
72
66
|
"pick.failOpen": "picker failed to open: {msg}",
|
|
73
67
|
"model.empty": "No models configured",
|
|
74
68
|
"model.noMatch": "No models match",
|
|
75
|
-
"model.title": "Models",
|
|
76
|
-
"model.typeFilter": "type to filter",
|
|
77
69
|
"model.deleteTitle": "Delete model",
|
|
78
70
|
"model.deleteFooter": "←/→/y/n select · Enter delete · Esc cancel",
|
|
79
71
|
"model.delActive": 'Delete ACTIVE model "{id}"?',
|
|
@@ -81,9 +73,7 @@ export const en = {
|
|
|
81
73
|
"model.failOpen": "model manager failed to open: {msg}",
|
|
82
74
|
"effort.title": "Thinking effort",
|
|
83
75
|
"effort.saved": "Thinking: {effort} (next session)",
|
|
84
|
-
"prov.title": "Providers",
|
|
85
76
|
"prov.empty": "No providers",
|
|
86
|
-
"prov.hint": "Enter:{select} · a:{add} · d:{delete} · e:{edit} · Esc:{close}",
|
|
87
77
|
"prov.addTitle": "Add provider",
|
|
88
78
|
"prov.customUrl": "Custom URL",
|
|
89
79
|
"prov.editTitle": 'Edit "{id}"',
|
|
@@ -98,7 +88,6 @@ export const en = {
|
|
|
98
88
|
"prov.deleteAsk": " — delete?",
|
|
99
89
|
"prov.deleteFooter": "←/→/y/n select · Enter delete · Esc cancel",
|
|
100
90
|
"prov.failOpen": "provider manager failed to open: {msg}",
|
|
101
|
-
"prov.models": "{n} models",
|
|
102
91
|
"prov.reloadFail": "provider reload failed — restart to apply changes",
|
|
103
92
|
"prov.detectFail": "Model detection failed: {msg}",
|
|
104
93
|
"prov.updateFail": "Update failed: {msg}",
|
package/src/ui/i18n/id.ts
CHANGED
|
@@ -4,8 +4,6 @@ import type { MsgKey } from "./locale.ts"
|
|
|
4
4
|
|
|
5
5
|
export const id: Record<MsgKey, string> = {
|
|
6
6
|
"app.placeholder": "tanya sesuatu, / untuk perintah… (Ctrl+D keluar)",
|
|
7
|
-
"app.menuHeader": "─ perintah ─",
|
|
8
|
-
"app.moreLines": " … {n} lagi",
|
|
9
7
|
"app.newBelow": "↓ {n} baris baru di bawah · PgDn ke ekor",
|
|
10
8
|
"app.abortHint": "abort terkirim — tekan Esc sekali lagi untuk keluar",
|
|
11
9
|
"app.working": "Bekerja",
|
|
@@ -64,17 +62,11 @@ export const id: Record<MsgKey, string> = {
|
|
|
64
62
|
"verb.delete": "hapus",
|
|
65
63
|
"verb.edit": "ubah",
|
|
66
64
|
"verb.close": "tutup",
|
|
67
|
-
"pick.filter": "Filter:",
|
|
68
|
-
"pick.placeholder": "ketik untuk saring",
|
|
69
65
|
"pick.noMatch": 'Tidak cocok untuk "{q}"',
|
|
70
|
-
"pick.matches": "{n}/{total} cocok",
|
|
71
|
-
"pick.hint": "↑↓:{select} · Enter:{confirm} · Esc:{back}",
|
|
72
66
|
"pick.fail": "picker gagal: {msg}",
|
|
73
67
|
"pick.failOpen": "picker gagal dibuka: {msg}",
|
|
74
68
|
"model.empty": "Belum ada model",
|
|
75
69
|
"model.noMatch": "Tidak ada model yang cocok",
|
|
76
|
-
"model.title": "Model",
|
|
77
|
-
"model.typeFilter": "ketik untuk saring",
|
|
78
70
|
"model.deleteTitle": "Hapus model",
|
|
79
71
|
"model.deleteFooter": "←/→/y/n pilih · Enter hapus · Esc batal",
|
|
80
72
|
"model.delActive": 'Hapus model AKTIF "{id}"?',
|
|
@@ -82,9 +74,7 @@ export const id: Record<MsgKey, string> = {
|
|
|
82
74
|
"model.failOpen": "model manager gagal dibuka: {msg}",
|
|
83
75
|
"effort.title": "Upaya berpikir",
|
|
84
76
|
"effort.saved": "Thinking: {effort} (sesi berikut)",
|
|
85
|
-
"prov.title": "Penyedia",
|
|
86
77
|
"prov.empty": "Belum ada penyedia",
|
|
87
|
-
"prov.hint": "Enter:{select} · a:{add} · d:{delete} · e:{edit} · Esc:{close}",
|
|
88
78
|
"prov.addTitle": "Tambah penyedia",
|
|
89
79
|
"prov.customUrl": "URL kustom",
|
|
90
80
|
"prov.editTitle": 'Ubah "{id}"',
|
|
@@ -99,7 +89,6 @@ export const id: Record<MsgKey, string> = {
|
|
|
99
89
|
"prov.deleteAsk": " — hapus?",
|
|
100
90
|
"prov.deleteFooter": "←/→/y/n pilih · Enter hapus · Esc batal",
|
|
101
91
|
"prov.failOpen": "provider manager gagal dibuka: {msg}",
|
|
102
|
-
"prov.models": "{n} model",
|
|
103
92
|
"prov.reloadFail": "reload provider gagal — restart untuk menerapkan",
|
|
104
93
|
"prov.detectFail": "Deteksi model gagal: {msg}",
|
|
105
94
|
"prov.updateFail": "Pembaruan gagal: {msg}",
|
package/src/ui/input/input.ts
CHANGED
|
@@ -112,9 +112,8 @@ export interface AskLineOptions {
|
|
|
112
112
|
/**
|
|
113
113
|
* Dipanggil untuk setiap keypress SEBELUM logika bawaan (history, applyKey).
|
|
114
114
|
* Return truthy = key sudah ditangani pemanggil; askLine melewatkan handling
|
|
115
|
-
* default dan tetap me-render ulang. Dipakai
|
|
116
|
-
*
|
|
117
|
-
* `line` = isi baris saat ini (untuk Tab kosong).
|
|
115
|
+
* default dan tetap me-render ulang. Dipakai pemanggil untuk kontrol yang
|
|
116
|
+
* khusus pada permukaan input, seperti navigasi mode atau tampilan.
|
|
118
117
|
*/
|
|
119
118
|
onKey?: (key: PromptKey, line: string) => boolean
|
|
120
119
|
}
|
|
@@ -261,11 +261,8 @@ export function applyKey(
|
|
|
261
261
|
return { state: { ...state, sel: (state.sel + 1) % n }, action: "render" }
|
|
262
262
|
}
|
|
263
263
|
case "tab": {
|
|
264
|
-
// Tab
|
|
265
|
-
//
|
|
266
|
-
// Completion dropdown tidak lagi pakai Tab — user pilih via ↑/↓ lalu
|
|
267
|
-
// Enter (lengkapi + kirim). Tanpa ini Tab saat mengetik tidak bisa
|
|
268
|
-
// ganti mode (keluhan nyata) dan menabrak completion.
|
|
264
|
+
// TUI menangani Tab sebagai siklus Work Mode sebelum editor generik.
|
|
265
|
+
// Picker command memilih item dengan ↑/↓ lalu Enter.
|
|
269
266
|
return { state, action: "none" }
|
|
270
267
|
}
|
|
271
268
|
case "enter": {
|
|
@@ -85,9 +85,8 @@ export async function runModelManagerView(opts: ModelManagerViewOptions): Promis
|
|
|
85
85
|
return new Promise<void>((resolve) => {
|
|
86
86
|
const visibleRows = () => {
|
|
87
87
|
const rows = process.stdout.rows || 24
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
return Math.max(1, Math.min(rows - 5, 8))
|
|
88
|
+
// Dialog tanpa judul/footer; satu baris dipakai untuk pencarian.
|
|
89
|
+
return Math.max(1, Math.min(rows - 3, 8))
|
|
91
90
|
}
|
|
92
91
|
// Lantai lebar tak boleh melebihi terminal. Lebar konten = lebar kotak
|
|
93
92
|
// tetap dikurangi chrome dialog (border+padding = 4) agar sepakat dengan
|
|
@@ -134,9 +133,8 @@ export async function runModelManagerView(opts: ModelManagerViewOptions): Promis
|
|
|
134
133
|
// App. Lebar TETAP 64 (min=max) — tak pernah melompat mengikuti konten.
|
|
135
134
|
const box = dialogBox(
|
|
136
135
|
{
|
|
137
|
-
title:
|
|
136
|
+
title: "",
|
|
138
137
|
body: bodyLinesModal(),
|
|
139
|
-
footer: modelHint(),
|
|
140
138
|
minWidth: MODAL_BOX_W,
|
|
141
139
|
maxWidth: MODAL_BOX_W,
|
|
142
140
|
maxHeight: 14,
|
|
@@ -164,11 +162,6 @@ export async function runModelManagerView(opts: ModelManagerViewOptions): Promis
|
|
|
164
162
|
} catch {}
|
|
165
163
|
}
|
|
166
164
|
|
|
167
|
-
/** Hint footer /model: Del/type-to-filter jadi discoverable (dulu tanpa
|
|
168
|
-
* footer — user baru tak tahu cara hapus/saring). */
|
|
169
|
-
const modelHint = (): string =>
|
|
170
|
-
`${c.accent(t("model.typeFilter"))} · Del:${c.accent(t("verb.delete"))} · Enter:${c.accent(t("verb.select"))} · Esc:${c.accent(t("verb.close"))}`
|
|
171
|
-
|
|
172
165
|
// Popup butuh layar mampu; selain itu tolak BERSUARA + batal.
|
|
173
166
|
const screen: AltScreen = openAltScreen()
|
|
174
167
|
const useModal = screen.ok && (process.stdout.rows || 24) >= 10
|
package/src/ui/screens/picker.ts
CHANGED
|
@@ -26,12 +26,10 @@ export interface PickerOptions {
|
|
|
26
26
|
items: PickerItem[]
|
|
27
27
|
onPick: (value: string) => void
|
|
28
28
|
onCancel: () => void
|
|
29
|
-
placeholder?: string
|
|
30
29
|
filterable?: boolean
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
const dim = (s: string): string => c.dim(s)
|
|
34
|
-
ACC_DIM = (s: string) => c.accent(s)
|
|
32
|
+
const dim = (s: string): string => c.dim(s)
|
|
35
33
|
|
|
36
34
|
/** Lebar kotak popup picker TETAP (keputusan rasa: geometri stabil). */
|
|
37
35
|
const PICKER_BOX_W = 64
|
|
@@ -53,10 +51,11 @@ export async function runPicker(opts: PickerOptions): Promise<void> {
|
|
|
53
51
|
if (!process.stdin.isTTY) {
|
|
54
52
|
// Pipe/redirect: item dari config (tak-terpercaya) disanitasi agar ANSI
|
|
55
53
|
// mentah tak mencemari output program (kontrak stdout non-TTY).
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
for (const it of opts.items) {
|
|
55
|
+
const provider = sanitizeAnsiLine(it.provider)
|
|
56
|
+
const name = sanitizeAnsiLine(it.name)
|
|
57
|
+
console.log(provider ? `${provider}::${name}` : name)
|
|
58
|
+
}
|
|
60
59
|
// Fail-closed: pemanggil nested (mis. pickEffort di /model) menunggu
|
|
61
60
|
// onPick/onCancel — tanpa ini await-nya gantung selamanya (busy=true)
|
|
62
61
|
// saat isTTY flip di tengah. Non-TTY = tak ada pilihan = batal.
|
|
@@ -88,11 +87,9 @@ export async function runPicker(opts: PickerOptions): Promise<void> {
|
|
|
88
87
|
// dicetak — keduanya membungkus dan merusak tampilan.
|
|
89
88
|
const visibleRows = () => {
|
|
90
89
|
const rows = process.stdout.rows || 24
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
// 1 baris untuk baris counter ("… N more") agar End selalu sampai dasar.
|
|
95
|
-
if (useModal) return Math.max(1, Math.min(rows - 5, 12))
|
|
90
|
+
// Modal tanpa judul/footer; sisakan border dan baris pencarian bila ada.
|
|
91
|
+
if (useModal) return Math.max(1, Math.min(rows - (isFilterable ? 3 : 2), 12))
|
|
92
|
+
const chrome = isFilterable ? 3 : 2
|
|
96
93
|
return Math.max(1, Math.min(rows - chrome, 12))
|
|
97
94
|
}
|
|
98
95
|
// Lebar konten = lebar kotak TETAP (min=max, keputusan rasa: geometri
|
|
@@ -115,11 +112,9 @@ export async function runPicker(opts: PickerOptions): Promise<void> {
|
|
|
115
112
|
const cut = (s: string) => truncateToWidth(s, w)
|
|
116
113
|
const lines: string[] = []
|
|
117
114
|
if (isFilterable) {
|
|
118
|
-
const placeholderText = opts.placeholder ?? t("pick.placeholder")
|
|
119
115
|
// Filter = input user tak terpercaya — sanitasi sebelum tampil.
|
|
120
|
-
const display = filter ? c.brightCyan(sanitizeAnsiLine(filter)) :
|
|
121
|
-
|
|
122
|
-
lines.push(cut(`${label} ${display}`))
|
|
116
|
+
const display = filter ? c.brightCyan(sanitizeAnsiLine(filter)) : ""
|
|
117
|
+
lines.push(cut(`${dim(">")} ${display}${c.accent("█")}`))
|
|
123
118
|
}
|
|
124
119
|
if (items.length === 0) {
|
|
125
120
|
lines.push(cut(dim(` ${t("pick.noMatch", { q: sanitizeAnsiLine(filter) })}`)))
|
|
@@ -128,38 +123,27 @@ export async function runPicker(opts: PickerOptions): Promise<void> {
|
|
|
128
123
|
for (let i = 0; i < rows.length; i++) {
|
|
129
124
|
const it = rows[i]!
|
|
130
125
|
const picked = i === sel - scroll
|
|
131
|
-
//
|
|
132
|
-
// Highlight query
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const rawLabel = `${sanitizeAnsiLine(it.name)}${it.provider ? ` — ${sanitizeAnsiLine(it.provider)}` : ""}`
|
|
126
|
+
// Label provider::model ringkas; teks tetap disanitasi sebelum truncate.
|
|
127
|
+
// Highlight query diterapkan sebelum truncate agar posisi kolom tepat.
|
|
128
|
+
const safeProvider = sanitizeAnsiLine(it.provider)
|
|
129
|
+
const rawLabel = safeProvider
|
|
130
|
+
? `${safeProvider}::${sanitizeAnsiLine(it.name)}`
|
|
131
|
+
: sanitizeAnsiLine(it.name)
|
|
138
132
|
const label = highlightMatch(truncateToWidth(rawLabel, w - 4), filter)
|
|
139
133
|
if (picked) lines.push(` ${c.accent("›")} ${c.accent(c.bold(label))}`)
|
|
140
134
|
else lines.push(` ${dim(label)}`)
|
|
141
135
|
}
|
|
142
|
-
|
|
143
|
-
lines.push(cut(dim(t("dlg.more", { n: items.length - scroll - v }))))
|
|
144
|
-
} else if (isFilterable && filter) {
|
|
145
|
-
lines.push(
|
|
146
|
-
cut(dim(` ${t("pick.matches", { n: items.length, total: opts.items.length })}`)),
|
|
147
|
-
)
|
|
148
|
-
}
|
|
149
|
-
return lines
|
|
136
|
+
return lines.slice(0, v + (isFilterable ? 1 : 0))
|
|
150
137
|
}
|
|
151
138
|
|
|
152
|
-
const hintText = (): string => t("pick.hint")
|
|
153
|
-
|
|
154
139
|
const render = () => {
|
|
155
140
|
// Popup komposit: HANYA region kotak yang dilukis (tanpa clear) di atas
|
|
156
141
|
// konten pemilik layar (transkrip App / alt-buffer wizard). Pemilik
|
|
157
142
|
// me-repaint penuh saat popup tutup. Lebar TETAP 64 (min=max).
|
|
158
143
|
const box = dialogBox(
|
|
159
144
|
{
|
|
160
|
-
title:
|
|
145
|
+
title: "",
|
|
161
146
|
body: bodyLines(),
|
|
162
|
-
footer: hintText(),
|
|
163
147
|
minWidth: PICKER_BOX_W,
|
|
164
148
|
maxWidth: PICKER_BOX_W,
|
|
165
149
|
},
|
|
@@ -167,16 +151,15 @@ export async function runPicker(opts: PickerOptions): Promise<void> {
|
|
|
167
151
|
screen.rows,
|
|
168
152
|
)
|
|
169
153
|
screen.paintRegion(box.lines, box.topRow)
|
|
170
|
-
// Parkir kursor
|
|
171
|
-
//
|
|
172
|
-
// filter kosong, parkir di baris item aktif (navigasi ↑↓).
|
|
154
|
+
// Parkir kursor pada input filter meski kosong agar teks pertama langsung
|
|
155
|
+
// masuk ke pencarian; navigasi item tetap memakai tombol panah.
|
|
173
156
|
// Kolom = padding kiri + border + spasi + lebar label+filter + 1.
|
|
174
157
|
try {
|
|
175
|
-
if (isFilterable
|
|
158
|
+
if (isFilterable) {
|
|
176
159
|
const li = Math.min(box.lines.length - 1, box.bodyTop)
|
|
177
160
|
const row = box.topRow + li
|
|
178
161
|
const leftPad = boxLeftPad(stripAnsi(box.lines[li] ?? ""))
|
|
179
|
-
const col = leftPad + 2 + displayWidth(stripAnsi(
|
|
162
|
+
const col = leftPad + 2 + 2 + displayWidth(stripAnsi(filter)) + 1
|
|
180
163
|
process.stdout.write(`\x1b[${row};${Math.max(1, col)}H\x1b[?25h`)
|
|
181
164
|
} else {
|
|
182
165
|
const itemRow = Math.min(Math.max(0, sel - scroll), Math.max(0, visibleRows() - 1))
|