minicode-ai 0.9.29 → 0.11.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/AGENTS.md +45 -0
- package/CHANGELOG.md +79 -1
- package/PLAN.md +491 -0
- package/README.md +2 -2
- package/cli/args.ts +1 -0
- package/cli/commands/acp.ts +485 -0
- package/cli/commands/auth.ts +7 -4
- package/cli/commands/config.ts +41 -27
- package/cli/commands/exec.ts +33 -12
- package/cli/commands/mcp.ts +3 -2
- package/cli/commands/memory.ts +1 -1
- package/cli/commands/pricing.ts +6 -4
- package/cli/commands/providers.ts +18 -8
- package/cli/commands/sessions.ts +11 -4
- package/cli/commands/skills.ts +3 -3
- package/cli/commands/stats.ts +3 -1
- package/cli/commands.ts +225 -103
- package/cli/index.ts +89 -62
- package/cli/model-manager.ts +8 -8
- package/cli/provider-manager.ts +13 -13
- package/cli/router.ts +7 -0
- package/cli/setup.ts +349 -4
- package/cli/tui.ts +542 -0
- package/cli/wizard.ts +2 -1
- package/docs/ARCHITECTURE.html +62 -36
- package/docs/CONTROL-PLANE-MAP.md +139 -0
- package/docs/HARNESS.md +150 -0
- package/docs/PLAN_UIUX_V6.md +209 -0
- package/docs/README.md +1 -1
- package/docs/SUMMARY.md +52 -0
- package/docs/TERMINAL_CONTRACT.md +367 -0
- package/docs/UI_RENDER_PIPELINE.md +165 -0
- package/docs/USAGE.md +11 -0
- package/docs/agents.md +31 -0
- package/docs/architecture.md +3 -3
- package/docs/choosing-mode.md +34 -0
- package/docs/cli.md +130 -0
- package/docs/concepts.md +53 -0
- package/docs/config-providers.md +87 -0
- package/docs/config.md +63 -0
- package/docs/contributing.md +79 -0
- package/docs/environment.md +95 -0
- package/docs/exec.md +73 -0
- package/docs/getting-started.md +102 -0
- package/docs/glossary.md +37 -0
- package/docs/mcp-lsp.md +54 -0
- package/docs/memory-sessions.md +63 -0
- package/docs/policy-sandbox.md +72 -0
- package/docs/pricing-budget.md +49 -0
- package/docs/quickstart.md +60 -0
- package/docs/repl.md +67 -0
- package/docs/security-model.md +95 -0
- package/docs/security.md +91 -0
- package/docs/skills.md +48 -0
- package/docs/terminal.md +79 -0
- package/docs/tools.md +123 -0
- package/docs/troubleshooting.md +40 -0
- package/docs/verify-benchmark.md +58 -0
- package/package.json +8 -5
- package/src/app/provider-layer.ts +12 -4
- package/src/app/rag-layer.ts +7 -2
- package/src/app/session.ts +6 -0
- package/src/app/tool-layer.ts +2 -1
- package/src/config.ts +30 -1
- package/src/constants.ts +35 -0
- package/src/lib/net.ts +6 -1
- package/src/lsp/client.ts +41 -8
- package/src/mcp/http-transport.ts +52 -15
- package/src/mcp/transport.ts +32 -1
- package/src/memory/files.ts +6 -5
- package/src/policy/allowlist.ts +1 -1
- package/src/policy/bash-guard.ts +213 -17
- package/src/policy/compaction.ts +57 -3
- package/src/policy/context.ts +4 -0
- package/src/policy/jail.ts +49 -4
- package/src/policy/permission.ts +152 -12
- package/src/policy/pricing.ts +12 -9
- package/src/policy/update-check.ts +4 -1
- package/src/presentation/adapter.ts +721 -0
- package/src/presentation/events.ts +324 -0
- package/src/presentation/label.ts +140 -0
- package/src/presentation/model.ts +172 -0
- package/src/presentation/reducer.ts +486 -0
- package/src/presentation/store.ts +256 -0
- package/src/providers/anthropic.ts +22 -4
- package/src/providers/detect.ts +2 -1
- package/src/providers/router.ts +13 -0
- package/src/repo/repomap.ts +2 -29
- package/src/session/checkpoint.ts +27 -9
- package/src/session/journal.ts +27 -5
- package/src/skills/loader.ts +88 -5
- package/src/telemetry/trace.ts +36 -15
- package/src/tools/ask_user.ts +73 -4
- package/src/tools/bash.ts +23 -17
- package/src/tools/glob.ts +10 -11
- package/src/tools/lsp.ts +3 -56
- package/src/tools/memory.ts +13 -12
- package/src/tools/task.ts +7 -1
- package/src/tools/web_fetch.ts +11 -2
- package/src/tools/web_search.ts +4 -1
- package/src/ui/approval/prompt.ts +96 -22
- package/src/ui/assistant/simple.ts +188 -44
- package/src/ui/assistant/turn-status.ts +32 -10
- package/src/ui/contract.ts +119 -0
- package/src/ui/footer.ts +35 -14
- package/src/ui/i18n/en.ts +253 -0
- package/src/ui/i18n/id.ts +255 -0
- package/src/ui/i18n/locale.ts +68 -0
- package/src/ui/input/input.ts +189 -81
- package/src/ui/input/prompt-engine.ts +139 -4
- package/src/ui/render/collapse.ts +20 -13
- package/src/ui/render/diff.ts +7 -2
- package/src/ui/render/errors.ts +75 -50
- package/src/ui/render/format.ts +26 -8
- package/src/ui/render/highlight.ts +12 -5
- package/src/ui/render/markdown.ts +5 -1
- package/src/ui/render/sanitize.ts +29 -2
- package/src/ui/render/table.ts +12 -6
- package/src/ui/render/theme.ts +23 -4
- package/src/ui/render/width.ts +104 -17
- package/src/ui/runtime/motion.ts +16 -0
- package/src/ui/runtime/screen.ts +242 -0
- package/src/ui/runtime/spinner.ts +50 -4
- package/src/ui/runtime/statusline.ts +50 -1
- package/src/ui/screens/dialog.ts +174 -0
- package/src/ui/screens/form.ts +486 -0
- package/src/ui/screens/model-manager.ts +289 -134
- package/src/ui/screens/picker.ts +264 -109
- package/src/ui/screens/provider-manager.ts +385 -172
- package/src/ui/screens/wizard.ts +165 -102
- package/src/ui/tui/app.ts +951 -0
- package/src/ui/tui/transcript.ts +475 -0
- package/vendor/minicore/LICENSE +21 -0
- package/vendor/minicore/VENDOR.md +6 -3
- package/vendor/minicore/package.json +6 -3
- package/vendor/minicore/src/core/loop.ts +12 -2
- package/vendor/minicore/src/core/snapshot.ts +4 -0
- package/vendor/minicore/src/providers/openai-compat.ts +76 -25
- package/cli/repl.ts +0 -740
- package/src/ui/runtime/chrome.ts +0 -369
- package/src/ui/screens/overlay.ts +0 -61
package/src/ui/screens/wizard.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
// View wizard setup pertama — murni presentasi: picker gateway
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// View wizard setup pertama — murni presentasi: picker gateway + form
|
|
2
|
+
// URL/key dalam popup. Penyimpanan provider lewat callback `onSubmit` yang
|
|
3
|
+
// di-inject controller (cli/wizard.ts). SEMUA langkah dalam kotak: tak ada
|
|
4
|
+
// ketikan di luar popup.
|
|
4
5
|
import { formatError } from "../assistant/simple.ts"
|
|
5
|
-
import {
|
|
6
|
+
import { t } from "../i18n/locale.ts"
|
|
6
7
|
import { sanitizeAnsiLine } from "../render/sanitize.ts"
|
|
7
8
|
import { c, glyphs } from "../render/theme.ts"
|
|
8
|
-
import {
|
|
9
|
+
import { openAltScreen } from "../runtime/screen.ts"
|
|
10
|
+
import { dialogBox } from "./dialog.ts"
|
|
11
|
+
import { runForm, validateUrl } from "./form.ts"
|
|
9
12
|
import { runPicker } from "./picker.ts"
|
|
10
13
|
|
|
11
14
|
export interface WizardPreset {
|
|
@@ -19,114 +22,174 @@ export interface SetupWizardViewOptions {
|
|
|
19
22
|
onSubmit(baseUrl: string, apiKey: string): Promise<string>
|
|
20
23
|
}
|
|
21
24
|
|
|
25
|
+
/** Lebar kotak wizard TETAP (paritas picker/form/manager — tak bernapas antar langkah). */
|
|
26
|
+
const WIZARD_BOX_W = 64
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Tunggu tanpa menahan process hidup (unref): jeda sukses/gagal wizard tak
|
|
30
|
+
* boleh menahan exit bila stdin sudah ditutup. Gagal-di-kode-lama: timer
|
|
31
|
+
* polos menahan event-loop 1.2/2.5 dtk.
|
|
32
|
+
*/
|
|
33
|
+
function sleepUnref(ms: number): Promise<void> {
|
|
34
|
+
return new Promise((r) => {
|
|
35
|
+
const timer = setTimeout(r, ms)
|
|
36
|
+
try {
|
|
37
|
+
;(timer as unknown as { unref?: () => void }).unref?.()
|
|
38
|
+
} catch {}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
22
42
|
/**
|
|
23
43
|
* Wizard setup pertama — hal PERTAMA yang dilihat pengguna baru.
|
|
24
44
|
*
|
|
25
|
-
* Memakai `runPicker` (panah + filter),
|
|
26
|
-
*
|
|
27
|
-
* daftar — jadi dua UX berbeda untuk satu konsep membingungkan; (2) nomor manual
|
|
28
|
-
* membuat pilihan di luar rentang diam-diam jatuh ke item pertama, sehingga user
|
|
29
|
-
* mengira memilih sesuatu yang lain.
|
|
30
|
-
*
|
|
31
|
-
* Fallback readline tetap ada untuk terminal tanpa raw mode.
|
|
45
|
+
* Memakai `runPicker` (panah + filter) untuk gateway, lalu form dalam popup
|
|
46
|
+
* untuk URL + API key. Esc di langkah mana pun = batal total.
|
|
32
47
|
*/
|
|
33
48
|
export async function runSetupWizardView(opts: SetupWizardViewOptions): Promise<boolean> {
|
|
34
49
|
if (!process.stdin.isTTY) return false
|
|
50
|
+
const screen = openAltScreen()
|
|
51
|
+
if (!screen.ok) return false
|
|
52
|
+
let exitMsg: string | null = null
|
|
53
|
+
try {
|
|
54
|
+
const CUSTOM = "\u0000custom"
|
|
55
|
+
const items = [
|
|
56
|
+
...opts.presets.map((p) => ({ name: p.label, provider: "", value: p.baseUrl })),
|
|
57
|
+
{ name: t("prov.customUrl"), provider: "", value: CUSTOM },
|
|
58
|
+
]
|
|
35
59
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
{ name: "Custom URL", provider: "", value: CUSTOM },
|
|
52
|
-
]
|
|
53
|
-
|
|
54
|
-
let picked: string | null = null
|
|
55
|
-
await runPicker({
|
|
56
|
-
title: "Select gateway",
|
|
57
|
-
items,
|
|
58
|
-
filterable: true,
|
|
59
|
-
placeholder: "Filter",
|
|
60
|
-
onPick: (v) => {
|
|
61
|
-
picked = v
|
|
62
|
-
},
|
|
63
|
-
onCancel: () => {
|
|
64
|
-
picked = null
|
|
65
|
-
},
|
|
66
|
-
})
|
|
67
|
-
if (picked === null) {
|
|
68
|
-
process.stdout.write("Setup canceled.\n")
|
|
69
|
-
return false
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Isian URL memakai askLine (bukan readline) — satu stack input: sanitasi
|
|
73
|
-
// paste, editing UTF-16/grapheme, history, dan ukuran lebar kolom semuanya
|
|
74
|
-
// sama dengan prompt REPL. Readline lama tidak lewat decodeKeys sehingga
|
|
75
|
-
// paste/mouse bisa bocor sebagai teks.
|
|
76
|
-
let targetUrl: string
|
|
77
|
-
if (picked === CUSTOM) {
|
|
78
|
-
targetUrl = (await askLine({ prompt: "Base URL: " })) ?? ""
|
|
79
|
-
} else {
|
|
80
|
-
const custom = await askLine({ prompt: `Base URL [${picked}]: ` })
|
|
81
|
-
// Esc/Ctrl+C = batal total — dulu jatuh ke "pakai default" dan wizard
|
|
82
|
-
// lanjut ke API key padahal sapaan bilang "(Ctrl+C to cancel)".
|
|
83
|
-
if (custom == null) {
|
|
84
|
-
process.stdout.write("Setup canceled.\n")
|
|
60
|
+
let picked: string | null = null
|
|
61
|
+
await runPicker({
|
|
62
|
+
title: t("wiz.gateway"),
|
|
63
|
+
items,
|
|
64
|
+
filterable: true,
|
|
65
|
+
placeholder: t("pick.placeholder"),
|
|
66
|
+
onPick: (v) => {
|
|
67
|
+
picked = v
|
|
68
|
+
},
|
|
69
|
+
onCancel: () => {
|
|
70
|
+
picked = null
|
|
71
|
+
},
|
|
72
|
+
})
|
|
73
|
+
if (picked === null) {
|
|
74
|
+
exitMsg = `${t("wiz.canceled")}\n`
|
|
85
75
|
return false
|
|
86
76
|
}
|
|
87
|
-
targetUrl = custom.trim() || (picked as string)
|
|
88
|
-
}
|
|
89
77
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
78
|
+
// URL via form dalam popup (validasi inline, bukan gagal saat detect).
|
|
79
|
+
const urlForm = await runForm(
|
|
80
|
+
{
|
|
81
|
+
title: t("wiz.stepUrl"),
|
|
82
|
+
fields: [
|
|
83
|
+
{
|
|
84
|
+
id: "url",
|
|
85
|
+
label: picked === CUSTOM ? t("wiz.urlLabel") : `${t("wiz.urlLabel")} [${picked}]`,
|
|
86
|
+
kind: "text",
|
|
87
|
+
initial: picked === CUSTOM ? "" : (picked as string),
|
|
88
|
+
validate: (v) => {
|
|
89
|
+
const val = v.trim() || (picked === CUSTOM ? "" : (picked as string))
|
|
90
|
+
if (!val) return t("form.required")
|
|
91
|
+
return validateUrl(val)
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
screen,
|
|
97
|
+
)
|
|
98
|
+
if (urlForm.cancelled || !urlForm.values) {
|
|
99
|
+
exitMsg = `${t("wiz.canceled")}\n`
|
|
100
|
+
return false
|
|
101
|
+
}
|
|
102
|
+
const rawUrl = (urlForm.values.url ?? "").trim()
|
|
103
|
+
const targetUrl = rawUrl || (picked === CUSTOM ? "" : (picked as string))
|
|
104
|
+
if (!targetUrl) {
|
|
105
|
+
exitMsg = `${t("wiz.canceled")}\n`
|
|
106
|
+
return false
|
|
107
|
+
}
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
109
|
+
// Endpoint lokal (Ollama/LM Studio) tidak butuh API key; kirim placeholder
|
|
110
|
+
// agar header Authorization tetap terbentuk.
|
|
111
|
+
const lokal = /^(https?:\/\/)(localhost|127\.0\.0\.1|\[::1\])(:|\/|$)/.test(targetUrl)
|
|
112
|
+
let apiKey = "ollama"
|
|
113
|
+
if (!lokal) {
|
|
114
|
+
const keyForm = await runForm(
|
|
115
|
+
{
|
|
116
|
+
title: t("wiz.stepKey"),
|
|
117
|
+
fields: [
|
|
118
|
+
{
|
|
119
|
+
id: "key",
|
|
120
|
+
label: t("wiz.keyLabel", { url: targetUrl }),
|
|
121
|
+
kind: "secret",
|
|
122
|
+
validate: (v) => (v.trim() ? null : t("form.required")),
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
screen,
|
|
127
|
+
)
|
|
128
|
+
if (keyForm.cancelled || !keyForm.values) {
|
|
129
|
+
exitMsg = `${t("wiz.canceled")}\n`
|
|
130
|
+
return false
|
|
131
|
+
}
|
|
132
|
+
apiKey = (keyForm.values.key ?? "").trim()
|
|
133
|
+
if (!apiKey) {
|
|
134
|
+
exitMsg = `${t("wiz.keyLater")}\n`
|
|
135
|
+
return false
|
|
136
|
+
}
|
|
137
|
+
}
|
|
119
138
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
139
|
+
// Progres sebagai baris dalam kotak (bukan spinner liar di bawah popup).
|
|
140
|
+
const box = dialogBox(
|
|
141
|
+
{
|
|
142
|
+
title: t("wiz.title"),
|
|
143
|
+
body: [c.muted(t("wiz.detecting"))],
|
|
144
|
+
minWidth: WIZARD_BOX_W,
|
|
145
|
+
maxWidth: WIZARD_BOX_W,
|
|
146
|
+
},
|
|
147
|
+
screen.cols,
|
|
148
|
+
screen.rows,
|
|
149
|
+
)
|
|
150
|
+
screen.paintRegion(box.lines, box.topRow)
|
|
151
|
+
try {
|
|
152
|
+
const message = await opts.onSubmit(targetUrl, apiKey)
|
|
153
|
+
// Pesan dari jaringan (nama model/gateway) — sanitasi sebelum tampil.
|
|
154
|
+
screen.clearRegion()
|
|
155
|
+
const doneBox = dialogBox(
|
|
156
|
+
{
|
|
157
|
+
title: t("wiz.title"),
|
|
158
|
+
body: [`${glyphs.check} ${sanitizeAnsiLine(message)}`, "", t("wiz.done")],
|
|
159
|
+
minWidth: WIZARD_BOX_W,
|
|
160
|
+
maxWidth: WIZARD_BOX_W,
|
|
161
|
+
},
|
|
162
|
+
screen.cols,
|
|
163
|
+
screen.rows,
|
|
164
|
+
)
|
|
165
|
+
screen.paintRegion(doneBox.lines, doneBox.topRow)
|
|
166
|
+
await sleepUnref(1200)
|
|
167
|
+
return true
|
|
168
|
+
} catch (e) {
|
|
169
|
+
screen.clearRegion()
|
|
170
|
+
const errBox = dialogBox(
|
|
171
|
+
{
|
|
172
|
+
title: t("wiz.title"),
|
|
173
|
+
body: [c.error(`${glyphs.cross} ${t("wiz.detectFail", { msg: formatError(e) })}`)],
|
|
174
|
+
minWidth: WIZARD_BOX_W,
|
|
175
|
+
maxWidth: WIZARD_BOX_W,
|
|
176
|
+
},
|
|
177
|
+
screen.cols,
|
|
178
|
+
screen.rows,
|
|
179
|
+
)
|
|
180
|
+
screen.paintRegion(errBox.lines, errBox.topRow)
|
|
181
|
+
await sleepUnref(2500)
|
|
182
|
+
return false
|
|
183
|
+
}
|
|
184
|
+
} finally {
|
|
185
|
+
try {
|
|
186
|
+
screen.clearRegion()
|
|
187
|
+
} catch {}
|
|
188
|
+
try {
|
|
189
|
+
screen.close()
|
|
190
|
+
} catch {}
|
|
191
|
+
if (exitMsg) {
|
|
192
|
+
process.stdout.write(exitMsg)
|
|
193
|
+
}
|
|
131
194
|
}
|
|
132
195
|
}
|