minicode-ai 0.27.0 → 0.30.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/README.md +1 -1
- package/cli/args.ts +184 -57
- package/cli/bootstrap/presentation-bridge.ts +383 -0
- package/cli/commands/acp.ts +45 -29
- package/cli/commands/auth.ts +17 -17
- package/cli/commands/config.ts +65 -66
- package/cli/commands/daemon.ts +44 -16
- package/cli/commands/doctor.ts +18 -15
- package/cli/commands/exec.ts +41 -89
- package/cli/commands/mcp.ts +25 -8
- package/cli/commands/memory.ts +16 -24
- package/cli/commands/openwork.ts +6 -2
- package/cli/commands/pricing.ts +14 -12
- package/cli/commands/providers.ts +36 -57
- package/cli/commands/sessions.ts +24 -18
- package/cli/commands/skills.ts +33 -18
- package/cli/commands/stats.ts +15 -30
- package/cli/commands.ts +73 -44
- package/cli/context-command-run.ts +30 -18
- package/cli/index.ts +51 -100
- package/cli/model-manager.ts +7 -2
- package/cli/provider-manager.ts +33 -18
- package/cli/router.ts +41 -12
- package/cli/setup.ts +241 -485
- package/cli/tui.ts +303 -100
- package/docs/TERMINAL_CONTRACT.md +258 -73
- package/docs/UI_RENDER_PIPELINE.md +9 -1
- package/docs/agents.md +2 -2
- package/docs/architecture.md +17 -32
- package/docs/choosing-mode.md +7 -9
- package/docs/cli.md +3 -5
- package/docs/environment.md +1 -2
- package/docs/policy-sandbox.md +3 -3
- package/docs/repl.md +2 -2
- package/docs/tools.md +1 -1
- package/package.json +1 -1
- package/src/app/mentions.ts +60 -13
- package/src/app/rag-layer.ts +17 -20
- package/src/app/session.ts +144 -68
- package/src/app/tool-layer.ts +38 -16
- package/src/config.ts +64 -104
- package/src/constants.ts +4 -6
- package/src/daemon/capability.ts +8 -1
- package/src/daemon/control.ts +3 -2
- package/src/daemon/server.ts +57 -0
- package/src/hooks/run.ts +73 -41
- package/src/lib/atomic-write.ts +31 -59
- package/src/lib/db-path.ts +47 -0
- package/src/lib/process-tree.ts +62 -0
- package/src/lib/public-http.ts +88 -23
- package/src/lib/trusted-exec.ts +48 -1
- package/src/lsp/client.ts +62 -17
- package/src/mcp/client.ts +85 -38
- package/src/mcp/http-transport.ts +28 -16
- package/src/mcp/transport.ts +42 -6
- package/src/memory/files.ts +164 -134
- package/src/memory/vector.ts +371 -420
- package/src/policy/approval-binding.ts +122 -45
- package/src/policy/bash-guard.ts +18 -7
- package/src/policy/compaction.ts +51 -18
- package/src/policy/context-window.ts +31 -8
- package/src/policy/context.ts +62 -36
- package/src/policy/executor.ts +17 -7
- package/src/policy/jail.ts +6 -8
- package/src/policy/microcompact.ts +4 -3
- package/src/policy/no-progress.ts +103 -22
- package/src/policy/permission.ts +36 -12
- package/src/policy/tool-contract.ts +74 -416
- package/src/policy/usage.ts +24 -2
- package/src/policy/verifier.ts +50 -2
- package/src/policy/work-mode.ts +28 -54
- package/src/presentation/adapter.ts +24 -16
- package/src/providers/anthropic.ts +16 -5
- package/src/providers/provision.ts +6 -56
- package/src/providers/responses.ts +38 -7
- package/src/providers/sse-bounds.ts +6 -4
- package/src/runtime/execution-journal.ts +4 -29
- package/src/sandbox/docker.ts +58 -34
- package/src/sandbox/mask.ts +157 -0
- package/src/sandbox/os.ts +107 -73
- package/src/session/authority.ts +29 -10
- package/src/session/context-projection.ts +6 -5
- package/src/session/db/runs.ts +397 -0
- package/src/session/db/schema.ts +358 -0
- package/src/session/open-work.ts +26 -3
- package/src/session/persistence.ts +74 -998
- package/src/session/verification.ts +170 -20
- package/src/skills/loader.ts +31 -16
- package/src/task/db/schema.ts +325 -0
- package/src/task/db/types.ts +269 -0
- package/src/task/production-scheduler.ts +13 -1
- package/src/task/store.ts +92 -1021
- package/src/telemetry/trace.ts +27 -0
- package/src/tools/ask_user.ts +1 -13
- package/src/tools/bash.ts +27 -92
- package/src/tools/code_run.ts +1 -1
- package/src/tools/context.ts +133 -0
- package/src/tools/delete_file.ts +3 -2
- package/src/tools/edit.ts +37 -72
- package/src/tools/git.ts +86 -9
- package/src/tools/glob.ts +26 -51
- package/src/tools/grep.ts +67 -57
- package/src/tools/hashline.ts +4 -0
- package/src/tools/lsp.ts +11 -8
- package/src/tools/mcp_call.ts +9 -6
- package/src/tools/memory.ts +56 -33
- package/src/tools/move_file.ts +36 -10
- package/src/tools/patch.ts +13 -21
- package/src/tools/read_file.ts +18 -25
- package/src/tools/read_image.ts +35 -33
- package/src/tools/submit_result.ts +29 -8
- package/src/tools/task.ts +74 -17
- package/src/tools/todo.ts +181 -74
- package/src/tools/web_fetch.ts +42 -2
- package/src/tools/web_search.ts +47 -8
- package/src/ui/approval/prompt.ts +206 -47
- package/src/ui/assistant/turn-status.ts +14 -5
- package/src/ui/footer.ts +4 -4
- package/src/ui/i18n/en.ts +47 -23
- package/src/ui/i18n/id.ts +76 -51
- package/src/ui/input/input.ts +4 -3
- package/src/ui/input/prompt-engine.ts +35 -5
- package/src/ui/render/activity-panel.ts +4 -2
- package/src/ui/render/hint.ts +7 -4
- package/src/ui/render/list.ts +32 -0
- package/src/ui/render/markdown.ts +6 -3
- package/src/ui/render/notice.ts +19 -0
- package/src/ui/render/table-grid.ts +7 -8
- package/src/ui/render/theme.ts +113 -39
- package/src/ui/runtime/screen.ts +74 -10
- package/src/ui/runtime/spinner.ts +19 -6
- package/src/ui/screens/dialog.ts +19 -1
- package/src/ui/screens/form.ts +80 -35
- package/src/ui/screens/model-manager.ts +82 -61
- package/src/ui/screens/output-window.ts +263 -0
- package/src/ui/screens/picker.ts +94 -81
- package/src/ui/screens/provider-manager.ts +100 -69
- package/src/ui/screens/wizard.ts +117 -28
- package/src/ui/tui/app.ts +196 -33
- package/src/ui/tui/transcript.ts +158 -25
- package/vendor/minicore/src/core/executor.ts +2 -0
- package/vendor/minicore/src/core/loop.ts +17 -6
- package/vendor/minicore/src/core/session.ts +3 -0
- package/vendor/minicore/src/core/tool.ts +1 -0
- package/vendor/minicore/src/providers/openai-compat.ts +35 -19
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs"
|
|
2
|
-
import { resolve } from "node:path"
|
|
3
1
|
import { loadConfig, type MinicodeConfig } from "../../src/config.ts"
|
|
4
2
|
import { refreshProviderModels } from "../../src/providers/provision.ts"
|
|
3
|
+
import { readTraceRows } from "../../src/telemetry/trace.ts"
|
|
5
4
|
import { sanitizeAnsiLine } from "../../src/ui/render/sanitize.ts"
|
|
6
5
|
import { renderTable } from "../../src/ui/render/table.ts"
|
|
7
|
-
import { c
|
|
6
|
+
import { c } from "../../src/ui/render/theme.ts"
|
|
7
|
+
import { allowLocalSubcommand, guardSubcommand, positionalSubArg } from "../args.ts"
|
|
8
|
+
|
|
9
|
+
const PROVIDERS_HELP = `minicode providers | models | sync — inspect & refresh configured LLM providers
|
|
10
|
+
|
|
11
|
+
minicode providers [--allow-local-config] [--cwd <dir>]
|
|
12
|
+
minicode models [provider] [--match <q>] [--allow-local-config] [--cwd <dir>]
|
|
13
|
+
minicode sync [--allow-local-config] [--cwd <dir>]`
|
|
8
14
|
|
|
9
15
|
interface TraceRow {
|
|
10
16
|
model?: string
|
|
@@ -13,23 +19,8 @@ interface TraceRow {
|
|
|
13
19
|
timestamp?: string
|
|
14
20
|
}
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
return readFileSync(resolve(cwd ?? ".", ".minicode", "traces.jsonl"), "utf8")
|
|
20
|
-
.split("\n")
|
|
21
|
-
.filter(Boolean)
|
|
22
|
-
.flatMap((l) => {
|
|
23
|
-
try {
|
|
24
|
-
return [JSON.parse(l) as TraceRow]
|
|
25
|
-
} catch {
|
|
26
|
-
return []
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
} catch {
|
|
30
|
-
return []
|
|
31
|
-
}
|
|
32
|
-
}
|
|
22
|
+
const out = (msg: string): void => console.log(msg)
|
|
23
|
+
const err = (msg: string): void => console.error(msg)
|
|
33
24
|
|
|
34
25
|
export function providerOfTrace(cfg: MinicodeConfig, t: TraceRow): string | undefined {
|
|
35
26
|
const m = t.model ?? ""
|
|
@@ -64,23 +55,20 @@ export async function handleProviders(
|
|
|
64
55
|
if (firstArg !== "providers" && firstArg !== "models" && firstArg !== "sync") {
|
|
65
56
|
process.exit(0)
|
|
66
57
|
}
|
|
58
|
+
guardSubcommand(args, firstArg, PROVIDERS_HELP, out, err, firstArg === "models" ? -1 : 1)
|
|
67
59
|
const cwdArg = getArg("--cwd")
|
|
68
60
|
// Audit #07: local hanya bila operator opt-in (aturan universal — sync
|
|
69
|
-
// tanpa flag tak boleh menghubungi endpoint repo tak dikenal).
|
|
70
|
-
|
|
71
|
-
const allowLocal =
|
|
72
|
-
args.includes("--allow-local-config") || process.env.MINICODE_ALLOW_LOCAL_CONFIG === "1"
|
|
61
|
+
// tanpa flag tak boleh menghubungi endpoint repo tak dikenal).
|
|
62
|
+
const allowLocal = allowLocalSubcommand(args)
|
|
73
63
|
const cfg = await loadConfig(cwdArg, { allowLocal })
|
|
74
64
|
if (firstArg === "providers") {
|
|
75
65
|
if (cfg.providers.length === 0) {
|
|
76
|
-
|
|
66
|
+
out(
|
|
77
67
|
"(no providers yet - run `minicode` for the wizard, `minicode auth login` (free, no API key),\nor `minicode config add --baseUrl <url> --apiKey <key>`)",
|
|
78
68
|
)
|
|
79
69
|
process.exit(0)
|
|
80
70
|
}
|
|
81
|
-
|
|
82
|
-
// padEnd(16) manual sebelumnya rusak begitu id lebih dari 16 karakter.
|
|
83
|
-
const health = healthMap(cfg, readTraces(cwdArg))
|
|
71
|
+
const health = healthMap(cfg, readTraceRows<TraceRow>(cwdArg, "traces.jsonl"))
|
|
84
72
|
const rows = cfg.providers.map((p) => {
|
|
85
73
|
const h = health.get(p.id)
|
|
86
74
|
const status = !h
|
|
@@ -89,13 +77,13 @@ export async function handleProviders(
|
|
|
89
77
|
h.ts ? new Date(h.ts).toISOString().slice(0, 10) : "-",
|
|
90
78
|
)}`
|
|
91
79
|
return {
|
|
92
|
-
id: c.cyan(p.id),
|
|
80
|
+
id: c.cyan(sanitizeAnsiLine(p.id)),
|
|
93
81
|
models: String(p.models.length),
|
|
94
|
-
url: p.baseUrl,
|
|
82
|
+
url: sanitizeAnsiLine(p.baseUrl),
|
|
95
83
|
status,
|
|
96
84
|
}
|
|
97
85
|
})
|
|
98
|
-
|
|
86
|
+
out(
|
|
99
87
|
`\n${c.bold("LLM Providers")}\n` +
|
|
100
88
|
renderTable(
|
|
101
89
|
[
|
|
@@ -108,63 +96,54 @@ export async function handleProviders(
|
|
|
108
96
|
) +
|
|
109
97
|
"\n",
|
|
110
98
|
)
|
|
111
|
-
|
|
99
|
+
out(
|
|
112
100
|
` ${c.dim("next: minicode models | minicode sync | minicode config add --baseUrl <url> --apiKey <key>")}\n`,
|
|
113
101
|
)
|
|
114
102
|
process.exit(0)
|
|
115
103
|
}
|
|
116
104
|
if (firstArg === "models") {
|
|
117
|
-
const pid = args
|
|
118
|
-
const
|
|
119
|
-
const filter = (matchIdx >= 0 && args[matchIdx + 1] ? args[matchIdx + 1]! : "").toLowerCase()
|
|
105
|
+
const pid = positionalSubArg(args, 1)
|
|
106
|
+
const filter = (getArg("--match") ?? "").toLowerCase()
|
|
120
107
|
const match = (s: string) => (filter ? s.toLowerCase().includes(filter) : true)
|
|
121
108
|
if (pid) {
|
|
122
109
|
const p = cfg.providers.find((x) => x.id === pid)
|
|
123
110
|
if (!p) {
|
|
124
|
-
|
|
111
|
+
err(`provider "${sanitizeAnsiLine(pid)}" not found - see: minicode providers`)
|
|
125
112
|
process.exit(1)
|
|
126
113
|
}
|
|
127
114
|
const list = p.models.filter(match)
|
|
128
|
-
if (!list.length)
|
|
129
|
-
for (const [i, m] of list.entries())
|
|
115
|
+
if (!list.length) out(` (no matches for "${sanitizeAnsiLine(filter)}")`)
|
|
116
|
+
for (const [i, m] of list.entries()) out(` [${i}] ${sanitizeAnsiLine(m)}`)
|
|
130
117
|
} else {
|
|
131
|
-
if (cfg.providers.length === 0)
|
|
118
|
+
if (cfg.providers.length === 0) out("(no providers yet)")
|
|
132
119
|
let shown = 0
|
|
133
120
|
for (const p of cfg.providers) {
|
|
134
121
|
const list = p.models.filter(match)
|
|
135
122
|
if (!list.length) continue
|
|
136
|
-
|
|
137
|
-
// hasil probe jaringan — sanitasi sebelum masuk scrollback.
|
|
138
|
-
console.log(
|
|
123
|
+
out(
|
|
139
124
|
`${sanitizeAnsiLine(p.id)} (${sanitizeAnsiLine(p.baseUrl)})${filter ? ` - matches "${sanitizeAnsiLine(filter)}"` : ""}`,
|
|
140
125
|
)
|
|
141
126
|
shown += list.length
|
|
142
|
-
for (const m of list.slice(0, 10))
|
|
143
|
-
if (filter && list.length > 10)
|
|
144
|
-
if (!filter && p.models.length > 10)
|
|
127
|
+
for (const m of list.slice(0, 10)) out(` ${sanitizeAnsiLine(m)}`)
|
|
128
|
+
if (filter && list.length > 10) out(` … +${list.length - 10} more`)
|
|
129
|
+
if (!filter && p.models.length > 10) out(` … +${p.models.length - 10} more`)
|
|
145
130
|
}
|
|
146
|
-
|
|
147
|
-
// mencetak judul lalu "(no matches)", dua baris untuk nol informasi.
|
|
148
|
-
if (filter && shown === 0) console.log(` (no matches for "${sanitizeAnsiLine(filter)}")`)
|
|
131
|
+
if (filter && shown === 0) out(` (no matches for "${sanitizeAnsiLine(filter)}")`)
|
|
149
132
|
}
|
|
150
133
|
process.exit(0)
|
|
151
134
|
}
|
|
152
135
|
if (firstArg === "sync") {
|
|
153
|
-
|
|
136
|
+
out("Syncing model list from providers…")
|
|
154
137
|
const { updated, failed } = await refreshProviderModels({ cwd: cwdArg, allowLocal })
|
|
155
138
|
for (const r of updated)
|
|
156
|
-
|
|
157
|
-
` ${c.green(glyphs.check)} ${sanitizeAnsiLine(r.id)}: ${r.from} -> ${r.to} model`,
|
|
158
|
-
)
|
|
139
|
+
out(` ${c.green("ok")} ${sanitizeAnsiLine(r.id)}: ${r.from} -> ${r.to} model`)
|
|
159
140
|
for (const f of failed)
|
|
160
|
-
|
|
161
|
-
` ${c.red(glyphs.cross)} ${sanitizeAnsiLine(f.id)}: ${sanitizeAnsiLine(f.reason)}`,
|
|
162
|
-
)
|
|
141
|
+
out(` ${c.red("failed")} ${sanitizeAnsiLine(f.id)}: ${sanitizeAnsiLine(f.reason)}`)
|
|
163
142
|
if (!updated.length && !failed.length) {
|
|
164
143
|
const cfgHere = await loadConfig(cwdArg, { allowLocal })
|
|
165
144
|
if (cfgHere.providers.length === 0)
|
|
166
|
-
|
|
167
|
-
else
|
|
145
|
+
out(" (no providers yet - run `minicode config add` first)")
|
|
146
|
+
else out(" (no changes — check API key and network, then retry)")
|
|
168
147
|
}
|
|
169
148
|
process.exit(0)
|
|
170
149
|
}
|
package/cli/commands/sessions.ts
CHANGED
|
@@ -10,8 +10,10 @@ import {
|
|
|
10
10
|
loadSession,
|
|
11
11
|
purgeExpired,
|
|
12
12
|
} from "../../src/session/persistence.ts"
|
|
13
|
+
import { sanitizeAnsiLine } from "../../src/ui/render/sanitize.ts"
|
|
13
14
|
import { renderTable } from "../../src/ui/render/table.ts"
|
|
14
15
|
import { c } from "../../src/ui/render/theme.ts"
|
|
16
|
+
import { hasHelpFlag, positionalSubArg } from "../args.ts"
|
|
15
17
|
|
|
16
18
|
const SESSIONS_HELP = `minicode sessions — session history
|
|
17
19
|
|
|
@@ -19,11 +21,18 @@ const SESSIONS_HELP = `minicode sessions — session history
|
|
|
19
21
|
minicode sessions export <id> [--jsonl] export message history
|
|
20
22
|
minicode sessions purge remove expired sessions (TTL)`
|
|
21
23
|
|
|
24
|
+
const out = (msg: string): void => console.log(msg)
|
|
25
|
+
const err = (msg: string): void => console.error(msg)
|
|
26
|
+
|
|
22
27
|
export async function handleSessions(
|
|
23
28
|
args: string[],
|
|
24
29
|
getArg: (name: string) => string | undefined,
|
|
25
30
|
): Promise<never> {
|
|
26
31
|
const sub = args[1]
|
|
32
|
+
if (hasHelpFlag(args)) {
|
|
33
|
+
out(SESSIONS_HELP)
|
|
34
|
+
process.exit(0)
|
|
35
|
+
}
|
|
27
36
|
if (sub === "list" || !sub) {
|
|
28
37
|
const cwdArg = getArg("--cwd")
|
|
29
38
|
const rows = listSessions(cwdArg)
|
|
@@ -34,15 +43,15 @@ export async function handleSessions(
|
|
|
34
43
|
const usesLocal =
|
|
35
44
|
existsSync(resolve(base, ".minicode", "sessions.db")) ||
|
|
36
45
|
existsSync(resolve(base, ".minicode"))
|
|
37
|
-
if (!usesLocal)
|
|
38
|
-
if (rows.length === 0)
|
|
46
|
+
if (!usesLocal) out(c.dim(`(global scope — no local .minicode/sessions.db in ${base})`))
|
|
47
|
+
if (rows.length === 0) out(c.dim("(no recorded sessions yet)"))
|
|
39
48
|
else {
|
|
40
49
|
const tableData = rows.map((r) => ({
|
|
41
|
-
id: c.cyan(r.id),
|
|
50
|
+
id: c.cyan(sanitizeAnsiLine(r.id)),
|
|
42
51
|
date: new Date(r.created_at).toLocaleString(),
|
|
43
|
-
cwd: c.dim(r.cwd),
|
|
52
|
+
cwd: c.dim(sanitizeAnsiLine(r.cwd)),
|
|
44
53
|
}))
|
|
45
|
-
|
|
54
|
+
out(
|
|
46
55
|
`\n${c.bold("Recent Sessions")}\n` +
|
|
47
56
|
renderTable(
|
|
48
57
|
[
|
|
@@ -57,23 +66,21 @@ export async function handleSessions(
|
|
|
57
66
|
}
|
|
58
67
|
process.exit(0)
|
|
59
68
|
} else if (sub === "export") {
|
|
60
|
-
|
|
61
|
-
// memperlakukannya sebagai id menghasilkan pesan "sesi --cwd tidak ditemukan".
|
|
62
|
-
const id = args[2] && !args[2]!.startsWith("-") ? args[2] : undefined
|
|
69
|
+
const id = positionalSubArg(args, 2)
|
|
63
70
|
const asJsonl = args.includes("--jsonl")
|
|
64
71
|
if (!id) {
|
|
65
|
-
|
|
72
|
+
err("usage: minicode sessions export <id> [--jsonl]")
|
|
66
73
|
process.exit(2)
|
|
67
74
|
}
|
|
68
75
|
// P2.1 read-compat: alias eksak resolve ke kanonik; selain itu input
|
|
69
76
|
// apa adanya (lenien untuk baca; tulis tetap jalur kanonik tunggal).
|
|
70
77
|
const sess = loadSession(resolveSessionDisplayTarget(id, getArg("--cwd")), getArg("--cwd"))
|
|
71
78
|
if (!sess) {
|
|
72
|
-
|
|
79
|
+
err(`session "${sanitizeAnsiLine(id)}" not found - see: minicode sessions list`)
|
|
73
80
|
process.exit(1)
|
|
74
81
|
}
|
|
75
|
-
if (asJsonl) for (const m of sess.messages)
|
|
76
|
-
else
|
|
82
|
+
if (asJsonl) for (const m of sess.messages) out(JSON.stringify(m))
|
|
83
|
+
else out(JSON.stringify(sess, null, 2))
|
|
77
84
|
process.exit(0)
|
|
78
85
|
} else if (sub === "purge") {
|
|
79
86
|
const cwdArg = getArg("--cwd")
|
|
@@ -123,16 +130,15 @@ export async function handleSessions(
|
|
|
123
130
|
}
|
|
124
131
|
} catch {}
|
|
125
132
|
const ttl = getSessionTtlDays()
|
|
126
|
-
|
|
127
|
-
if (orphans > 0)
|
|
133
|
+
out(`[purge] removed ${removed} sessions (older than ${ttl} days)`)
|
|
134
|
+
if (orphans > 0) out(`[purge] removed ${orphans} orphan journals`)
|
|
128
135
|
} finally {
|
|
129
136
|
db.close()
|
|
130
137
|
}
|
|
131
138
|
process.exit(0)
|
|
132
139
|
} else {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
process.exit(asked ? 0 : 2)
|
|
140
|
+
err(`unknown sessions subcommand: ${sanitizeAnsiLine(sub)}\n`)
|
|
141
|
+
out(SESSIONS_HELP)
|
|
142
|
+
process.exit(2)
|
|
137
143
|
}
|
|
138
144
|
}
|
package/cli/commands/skills.ts
CHANGED
|
@@ -1,31 +1,47 @@
|
|
|
1
1
|
import { findSkill, loadSkills } from "../../src/skills/loader.ts"
|
|
2
|
+
import { sanitizeAnsi, sanitizeAnsiLine } from "../../src/ui/render/sanitize.ts"
|
|
2
3
|
import { renderTable } from "../../src/ui/render/table.ts"
|
|
3
4
|
import { c } from "../../src/ui/render/theme.ts"
|
|
5
|
+
import { allowLocalSubcommand, hasHelpFlag, positionalSubArg } from "../args.ts"
|
|
4
6
|
|
|
5
7
|
const SKILLS_HELP = `minicode skills — markdown skills in .minicode/skills/*.md
|
|
6
8
|
|
|
7
|
-
minicode skills list list installed skills
|
|
8
|
-
minicode skills show <name> show one skill
|
|
9
|
+
minicode skills list [--allow-local-config] list installed skills
|
|
10
|
+
minicode skills show <name> [--allow-local-config] show one skill
|
|
9
11
|
|
|
10
12
|
In interactive mode, run a skill with /name [arguments].`
|
|
11
13
|
|
|
14
|
+
const out = (msg: string): void => console.log(msg)
|
|
15
|
+
const err = (msg: string): void => console.error(msg)
|
|
16
|
+
|
|
12
17
|
export async function handleSkills(
|
|
13
18
|
args: string[],
|
|
14
19
|
getArg: (name: string) => string | undefined,
|
|
15
20
|
): Promise<never> {
|
|
16
21
|
const cwdArg = getArg("--cwd")
|
|
22
|
+
const allowLocal = allowLocalSubcommand(args)
|
|
17
23
|
const sub = args[1]
|
|
24
|
+
if (hasHelpFlag(args)) {
|
|
25
|
+
out(SKILLS_HELP)
|
|
26
|
+
process.exit(0)
|
|
27
|
+
}
|
|
18
28
|
if (sub === "list" || sub === undefined) {
|
|
19
|
-
const all = await loadSkills(cwdArg)
|
|
29
|
+
const all = await loadSkills(cwdArg, { allowLocal })
|
|
20
30
|
if (all.length === 0) {
|
|
21
|
-
|
|
31
|
+
out(
|
|
32
|
+
c.dim(
|
|
33
|
+
allowLocal
|
|
34
|
+
? "(no skills yet - add markdown files in .minicode/skills/*.md)"
|
|
35
|
+
: "(no global skills - pass --allow-local-config to include project .minicode/skills)",
|
|
36
|
+
),
|
|
37
|
+
)
|
|
22
38
|
process.exit(0)
|
|
23
39
|
}
|
|
24
40
|
const tableData = all.map((s) => ({
|
|
25
|
-
skill: c.yellow(`/${s.name}`),
|
|
26
|
-
desc: s.description || "(no description)",
|
|
41
|
+
skill: c.yellow(`/${sanitizeAnsiLine(s.name)}`),
|
|
42
|
+
desc: sanitizeAnsiLine(s.description || "(no description)"),
|
|
27
43
|
}))
|
|
28
|
-
|
|
44
|
+
out(
|
|
29
45
|
`\n${c.bold("Installed Skills")}\n` +
|
|
30
46
|
renderTable(
|
|
31
47
|
[
|
|
@@ -39,23 +55,22 @@ export async function handleSkills(
|
|
|
39
55
|
process.exit(0)
|
|
40
56
|
}
|
|
41
57
|
if (sub === "show") {
|
|
42
|
-
|
|
43
|
-
// bukan permintaan skill bernama "--cwd".
|
|
44
|
-
const name = args[2] && !args[2]!.startsWith("-") ? args[2] : undefined
|
|
58
|
+
const name = positionalSubArg(args, 2)
|
|
45
59
|
if (!name) {
|
|
46
|
-
|
|
60
|
+
err("usage: minicode skills show <name>")
|
|
47
61
|
process.exit(2)
|
|
48
62
|
}
|
|
49
|
-
const s = await findSkill(name, cwdArg)
|
|
63
|
+
const s = await findSkill(name, cwdArg, { allowLocal })
|
|
50
64
|
if (!s) {
|
|
51
|
-
|
|
65
|
+
err(`skill "${sanitizeAnsiLine(name)}" not found - see: minicode skills list`)
|
|
52
66
|
process.exit(1)
|
|
53
67
|
}
|
|
54
|
-
|
|
68
|
+
out(
|
|
69
|
+
`${c.bold(c.cyan(`/${sanitizeAnsiLine(s.name)}`))} ${c.dim(`- ${sanitizeAnsiLine(s.description)}`)}\n\n${sanitizeAnsi(s.body)}`,
|
|
70
|
+
)
|
|
55
71
|
process.exit(0)
|
|
56
72
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
process.exit(asked ? 0 : 2)
|
|
73
|
+
err(`unknown skills subcommand: ${sanitizeAnsiLine(sub)}\n`)
|
|
74
|
+
out(SKILLS_HELP)
|
|
75
|
+
process.exit(2)
|
|
61
76
|
}
|
package/cli/commands/stats.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs"
|
|
2
1
|
import { resolve } from "node:path"
|
|
3
2
|
import type { RuntimeView } from "../../src/runtime/runtime-status.ts"
|
|
4
3
|
import { currentRuntimeView } from "../../src/runtime/runtime-status-provider.ts"
|
|
5
|
-
import { type StepTrace, summarizeStepTraces } from "../../src/telemetry/trace.ts"
|
|
4
|
+
import { readTraceRows, type StepTrace, summarizeStepTraces } from "../../src/telemetry/trace.ts"
|
|
6
5
|
import { c } from "../../src/ui/render/theme.ts"
|
|
6
|
+
import { guardSubcommand } from "../args.ts"
|
|
7
|
+
|
|
8
|
+
const STATS_HELP = `minicode stats — run & tool telemetry summary
|
|
9
|
+
|
|
10
|
+
minicode stats [--json] [--cwd <dir>]`
|
|
7
11
|
|
|
8
12
|
interface TraceRow {
|
|
9
13
|
ok?: boolean
|
|
@@ -30,23 +34,16 @@ function runtimeStatusSummary(view: RuntimeView): string {
|
|
|
30
34
|
return `phase=${view.phase} · admission=${view.admission} · health=${view.health} · termination=${view.termination} · bukti=${view.evidenceState} · kapabilitas=${caps} · anak-ter-supervisi=${view.supervisedChildren}${missing}${note}`
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
export async function handleStats(
|
|
37
|
+
export async function handleStats(
|
|
38
|
+
getArg: (name: string) => string | undefined,
|
|
39
|
+
args: readonly string[] = [],
|
|
40
|
+
): Promise<never> {
|
|
41
|
+
guardSubcommand(args, "stats", STATS_HELP, console.log, console.error)
|
|
34
42
|
const cwdArg = getArg("--cwd")
|
|
35
|
-
const asJson =
|
|
43
|
+
const asJson =
|
|
44
|
+
getArg("--json") !== undefined || args.includes("--json") || process.argv.includes("--json")
|
|
36
45
|
const file = resolve(cwdArg ?? ".", ".minicode", "traces.jsonl")
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
traces = readFileSync(file, "utf8")
|
|
40
|
-
.split("\n")
|
|
41
|
-
.filter(Boolean)
|
|
42
|
-
.flatMap((l) => {
|
|
43
|
-
try {
|
|
44
|
-
return [JSON.parse(l) as TraceRow]
|
|
45
|
-
} catch {
|
|
46
|
-
return []
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
} catch {}
|
|
46
|
+
const traces = readTraceRows<TraceRow>(cwdArg, "traces.jsonl")
|
|
50
47
|
const total = traces.length
|
|
51
48
|
const ok = traces.filter((t) => t.ok).length
|
|
52
49
|
const inputTokens = traces.reduce((s, t) => s + (t.inputTokens ?? 0), 0)
|
|
@@ -56,19 +53,7 @@ export async function handleStats(getArg: (name: string) => string | undefined):
|
|
|
56
53
|
|
|
57
54
|
// Harness-P3: agregat step-trace (P1.2) — deny-rate, tool bermasalah,
|
|
58
55
|
// mode sandbox. Berkas tak ada/rusak = nol, bukan crash.
|
|
59
|
-
|
|
60
|
-
try {
|
|
61
|
-
stepRows = readFileSync(resolve(cwdArg ?? ".", ".minicode", "step-traces.jsonl"), "utf8")
|
|
62
|
-
.split("\n")
|
|
63
|
-
.filter(Boolean)
|
|
64
|
-
.flatMap((l) => {
|
|
65
|
-
try {
|
|
66
|
-
return [JSON.parse(l) as StepTrace]
|
|
67
|
-
} catch {
|
|
68
|
-
return []
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
} catch {}
|
|
56
|
+
const stepRows = readTraceRows<StepTrace>(cwdArg, "step-traces.jsonl")
|
|
72
57
|
const steps = summarizeStepTraces(stepRows)
|
|
73
58
|
|
|
74
59
|
// [P13.1] Status runtime: dari model kanonik, bukan sumber status kedua.
|