minicode-ai 0.13.0 → 0.14.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/CHANGELOG.md +23 -0
- package/LICENSE +21 -21
- package/README.md +4 -0
- package/cli/args.ts +50 -2
- package/cli/commands/acp.ts +18 -3
- package/cli/commands/daemon.ts +114 -19
- package/cli/commands/exec.ts +95 -7
- package/cli/commands/mcp.ts +66 -5
- package/cli/commands/memory.ts +46 -14
- package/cli/commands.ts +5 -0
- package/cli/index.ts +30 -5
- package/cli/minicode.js +6 -0
- package/cli/setup.ts +365 -24
- package/cli/tui.ts +72 -27
- package/docs/TERMINAL_CONTRACT.md +91 -24
- package/docs/agents.md +2 -2
- package/docs/cli.md +1 -0
- package/docs/environment.md +1 -0
- package/docs/memory-sessions.md +5 -0
- package/package.json +3 -2
- package/src/app/session.ts +153 -35
- package/src/app/tool-layer.ts +67 -61
- package/src/daemon/approvals.ts +25 -1
- package/src/daemon/client.ts +51 -1
- package/src/daemon/control.ts +8 -0
- package/src/daemon/protocol.ts +47 -1
- package/src/daemon/server.ts +45 -9
- package/src/daemon/subscription.ts +25 -1
- package/src/daemon/telemetry.ts +4 -0
- package/src/hooks/run.ts +5 -1
- package/src/mcp/client.ts +349 -90
- package/src/mcp/http-transport.ts +7 -0
- package/src/mcp/transport.ts +5 -0
- package/src/memory/files.ts +69 -3
- package/src/memory/vector.ts +556 -160
- package/src/policy/approval-binding.ts +199 -0
- package/src/policy/context.ts +20 -1
- package/src/policy/executor.ts +44 -5
- package/src/policy/permission.ts +243 -26
- package/src/policy/tool-contract.ts +77 -0
- package/src/policy/usage.ts +3 -1
- package/src/policy/work-mode.ts +49 -1
- package/src/presentation/adapter.ts +157 -7
- package/src/presentation/events.ts +173 -1
- package/src/presentation/model.ts +37 -0
- package/src/presentation/projection.ts +107 -18
- package/src/presentation/reducer.ts +134 -10
- package/src/sandbox/os.ts +18 -1
- package/src/session/persistence.ts +153 -11
- package/src/task/store.ts +43 -3
- package/src/tools/memory.ts +70 -10
- package/src/tools/task.ts +7 -1
- package/src/tools/todo.ts +14 -4
- package/src/ui/approval/prompt.ts +52 -7
- package/src/ui/assistant/simple.ts +160 -57
- package/src/ui/contract.ts +46 -0
- package/src/ui/footer.ts +14 -5
- package/src/ui/i18n/en.ts +9 -0
- package/src/ui/i18n/id.ts +9 -0
- package/src/ui/render/collapse.ts +24 -52
- package/src/ui/render/detail.ts +14 -9
- package/src/ui/render/errors.ts +8 -0
- package/src/ui/render/reasoning.ts +13 -8
- package/src/ui/session-state.ts +243 -0
- package/src/ui/tui/app.ts +7 -3
- package/src/ui/tui/transcript.ts +271 -30
- package/vendor/minicore/src/core/budget.ts +25 -25
- package/vendor/minicore/src/core/compact.ts +75 -75
- package/vendor/minicore/src/core/errors.ts +59 -59
- package/vendor/minicore/src/core/events.ts +73 -73
- package/vendor/minicore/src/core/executor.ts +139 -139
- package/vendor/minicore/src/core/history.ts +31 -31
- package/vendor/minicore/src/core/index.ts +41 -41
- package/vendor/minicore/src/core/loop.ts +355 -355
- package/vendor/minicore/src/core/permission.ts +22 -22
- package/vendor/minicore/src/core/provider.ts +39 -39
- package/vendor/minicore/src/core/recovery.ts +35 -35
- package/vendor/minicore/src/core/session.ts +327 -327
- package/vendor/minicore/src/core/snapshot.ts +146 -146
- package/vendor/minicore/src/core/tokens.ts +107 -107
- package/vendor/minicore/src/core/tool.ts +115 -115
- package/vendor/minicore/src/core/types.ts +50 -50
- package/vendor/minicore/src/providers/openai-compat.ts +417 -417
package/src/memory/files.ts
CHANGED
|
@@ -91,12 +91,24 @@ async function withMemLock<T>(path: string, fn: () => Promise<T>): Promise<T> {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
export async function appendMemory(
|
|
94
|
+
export async function appendMemory(
|
|
95
|
+
text: string,
|
|
96
|
+
cwd = process.cwd(),
|
|
97
|
+
tags?: readonly string[],
|
|
98
|
+
): Promise<string> {
|
|
95
99
|
const path = resolve(cwd, LOCAL_MEM)
|
|
96
100
|
return withMemLock(path, async () => {
|
|
97
101
|
await mkdir(dirname(path), { recursive: true, mode: 0o700 }).catch(() => {})
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
// [Area E / D5] JANGAN potong per-entri di sini. Batas 1000 karakter lama
|
|
103
|
+
// membuat MEMORY.md lebih pendek daripada chunk vektor (2000) sehingga
|
|
104
|
+
// reconcile menganggap chunk ekor "vector-only" dan menghapusnya. Batas
|
|
105
|
+
// ukuran total berkas tetap dijaga MAX_MEMORY_FILE_BYTES di bawah.
|
|
106
|
+
const clean = scrubSecrets(text.trim())
|
|
107
|
+
// [Area E / D2] Provenance (MEM-01) benar-benar ditulis ke berkas — tanpa
|
|
108
|
+
// tag ini jalur revoke-by-provenance tidak punya bukti di sisi file dan
|
|
109
|
+
// gagal-closed (atau, pada versi lama, menghapus SEMUA baris tanpa tag).
|
|
110
|
+
const meta = tags && tags.length > 0 ? ` [tags: ${JSON.stringify(tags)}]` : ""
|
|
111
|
+
const entry = `- ${new Date().toISOString().slice(0, 10)} ${clean}${meta}\n`
|
|
100
112
|
// atomic append — no read+write race
|
|
101
113
|
await appendFile(path, entry, "utf8").catch(async () => {
|
|
102
114
|
// fallback if file not exists
|
|
@@ -124,6 +136,60 @@ export async function readMemoryFile(cwd = process.cwd()): Promise<string> {
|
|
|
124
136
|
return await loadMemoryFiles(cwd)
|
|
125
137
|
}
|
|
126
138
|
|
|
139
|
+
/**
|
|
140
|
+
* [Area E / D6] Ambil teks entri dari satu baris MEMORY.md — buang prefix
|
|
141
|
+
* tanggal dan metadata `[tags: ...]`. Dipakai supersession untuk mencocokkan
|
|
142
|
+
* baris lama tanpa bergantung pada posisi/urutan.
|
|
143
|
+
*/
|
|
144
|
+
export function memoryLineText(line: string): string {
|
|
145
|
+
const match = line.match(/^-\s+\d{4}-\d{2}-\d{2}(?:T\S+)?\s+(.+)$/)
|
|
146
|
+
const body = match
|
|
147
|
+
? match[1]!
|
|
148
|
+
: line
|
|
149
|
+
.trim()
|
|
150
|
+
.replace(/^-\s+\S+\s+/, "")
|
|
151
|
+
.trim()
|
|
152
|
+
const tagMatch = body.match(/\[tags:\s*[^\]]+\]/)
|
|
153
|
+
return (tagMatch ? body.slice(0, tagMatch.index!) : body).trim()
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* [Area E / D6] Hapus SATU entri MEMORY.md lokal berdasarkan teksnya.
|
|
158
|
+
*
|
|
159
|
+
* `target` boleh berupa teks utuh (entri pendek) atau prefix chunk pertama
|
|
160
|
+
* (entri multi-chunk yang tersimpan utuh di berkas). `startsWith` diperlukan
|
|
161
|
+
* karena baris lama yang panjang tidak lagi dipotong saat append.
|
|
162
|
+
*
|
|
163
|
+
* Fail-closed: berkas tak ada / tak ada baris yang cocok → `false`, bukan
|
|
164
|
+
* menulis ulang berkas tanpa perubahan.
|
|
165
|
+
*/
|
|
166
|
+
export async function deleteMemoryEntry(target: string, cwd = process.cwd()): Promise<boolean> {
|
|
167
|
+
const needle = target.trim()
|
|
168
|
+
if (!needle) return false
|
|
169
|
+
const path = resolve(cwd, LOCAL_MEM)
|
|
170
|
+
return withMemLock(path, async () => {
|
|
171
|
+
let txt: string
|
|
172
|
+
try {
|
|
173
|
+
txt = await readFile(path, "utf8")
|
|
174
|
+
} catch {
|
|
175
|
+
return false
|
|
176
|
+
}
|
|
177
|
+
const lines = txt.split("\n")
|
|
178
|
+
let removed = 0
|
|
179
|
+
const kept = lines.filter((line) => {
|
|
180
|
+
if (!line.startsWith("- ")) return true
|
|
181
|
+
const text = memoryLineText(line)
|
|
182
|
+
const hit = text === needle || text.startsWith(needle)
|
|
183
|
+
if (hit) removed++
|
|
184
|
+
return !hit
|
|
185
|
+
})
|
|
186
|
+
if (removed === 0) return false
|
|
187
|
+
const { atomicWriteText } = await import("../lib/atomic-write.ts")
|
|
188
|
+
await atomicWriteText(path, kept.join("\n"))
|
|
189
|
+
return true
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
|
|
127
193
|
/**
|
|
128
194
|
* Hapus baris MEMORY.md lokal + global yang cocok query (temuan audit #06,
|
|
129
195
|
* diperluas audit 2026-09-16 M4).
|