minicode-ai 0.9.26

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.
Files changed (162) hide show
  1. package/CHANGELOG.md +935 -0
  2. package/LICENSE +21 -0
  3. package/README.md +200 -0
  4. package/cli/args.ts +195 -0
  5. package/cli/auto-update.ts +108 -0
  6. package/cli/commands/auth.ts +166 -0
  7. package/cli/commands/config.ts +382 -0
  8. package/cli/commands/doctor.ts +128 -0
  9. package/cli/commands/exec.ts +179 -0
  10. package/cli/commands/mcp.ts +35 -0
  11. package/cli/commands/memory.ts +107 -0
  12. package/cli/commands/pricing.ts +100 -0
  13. package/cli/commands/providers.ts +162 -0
  14. package/cli/commands/sessions.ts +128 -0
  15. package/cli/commands/skills.ts +61 -0
  16. package/cli/commands/stats.ts +82 -0
  17. package/cli/commands.ts +317 -0
  18. package/cli/index.ts +539 -0
  19. package/cli/model-manager.ts +112 -0
  20. package/cli/provider-manager.ts +111 -0
  21. package/cli/repl.ts +734 -0
  22. package/cli/router.ts +124 -0
  23. package/cli/setup.ts +780 -0
  24. package/cli/wizard.ts +21 -0
  25. package/docs/ARCHITECTURE.html +1222 -0
  26. package/docs/README.md +109 -0
  27. package/docs/architecture.md +44 -0
  28. package/docs/changelog.md +3 -0
  29. package/package.json +91 -0
  30. package/src/agents/pool.ts +43 -0
  31. package/src/app/mentions.ts +50 -0
  32. package/src/app/provider-layer.ts +118 -0
  33. package/src/app/rag-layer.ts +105 -0
  34. package/src/app/session.ts +154 -0
  35. package/src/app/tool-layer.ts +56 -0
  36. package/src/config.ts +372 -0
  37. package/src/constants.ts +119 -0
  38. package/src/hooks/run.ts +89 -0
  39. package/src/lib/atomic-write.ts +88 -0
  40. package/src/lib/db-path.ts +36 -0
  41. package/src/lib/git-hardening.ts +91 -0
  42. package/src/lib/ignore.ts +58 -0
  43. package/src/lib/keystore.ts +202 -0
  44. package/src/lib/net.ts +70 -0
  45. package/src/lib/safe-open.ts +138 -0
  46. package/src/lib/session-id.ts +23 -0
  47. package/src/lib/trash.ts +38 -0
  48. package/src/lib/trusted-exec.ts +81 -0
  49. package/src/lsp/client.ts +395 -0
  50. package/src/mcp/client.ts +400 -0
  51. package/src/mcp/http-transport.ts +344 -0
  52. package/src/mcp/server.ts +538 -0
  53. package/src/mcp/transport.ts +150 -0
  54. package/src/memory/files.ts +159 -0
  55. package/src/memory/vector.ts +775 -0
  56. package/src/policy/allowlist.ts +67 -0
  57. package/src/policy/bash-guard.ts +465 -0
  58. package/src/policy/compaction.ts +271 -0
  59. package/src/policy/context.ts +161 -0
  60. package/src/policy/executor.ts +199 -0
  61. package/src/policy/jail.ts +127 -0
  62. package/src/policy/permission.ts +517 -0
  63. package/src/policy/pricing.ts +336 -0
  64. package/src/policy/ratelimit.ts +54 -0
  65. package/src/policy/sandbox-policy.ts +157 -0
  66. package/src/policy/scrub.ts +138 -0
  67. package/src/policy/update-check.ts +200 -0
  68. package/src/policy/usage.ts +292 -0
  69. package/src/policy/verifier.ts +181 -0
  70. package/src/providers/anthropic.ts +401 -0
  71. package/src/providers/auth-store.ts +139 -0
  72. package/src/providers/build.ts +136 -0
  73. package/src/providers/detect.ts +126 -0
  74. package/src/providers/effort.ts +165 -0
  75. package/src/providers/guards.ts +107 -0
  76. package/src/providers/oauth.ts +326 -0
  77. package/src/providers/presets.ts +122 -0
  78. package/src/providers/provision.ts +298 -0
  79. package/src/providers/responses.ts +371 -0
  80. package/src/providers/router.ts +247 -0
  81. package/src/repo/repomap.ts +470 -0
  82. package/src/sandbox/docker.ts +129 -0
  83. package/src/sandbox/os.ts +193 -0
  84. package/src/session/checkpoint.ts +543 -0
  85. package/src/session/journal.ts +1347 -0
  86. package/src/session/persistence.ts +446 -0
  87. package/src/session/shadow-git.ts +351 -0
  88. package/src/session/turn-marker.ts +118 -0
  89. package/src/skills/loader.ts +117 -0
  90. package/src/telemetry/trace.ts +283 -0
  91. package/src/tools/ask_user.ts +54 -0
  92. package/src/tools/bash.ts +400 -0
  93. package/src/tools/code_run.ts +96 -0
  94. package/src/tools/delete_file.ts +31 -0
  95. package/src/tools/edit.ts +204 -0
  96. package/src/tools/git.ts +301 -0
  97. package/src/tools/glob.ts +90 -0
  98. package/src/tools/grep.ts +281 -0
  99. package/src/tools/hashline.ts +66 -0
  100. package/src/tools/index.ts +103 -0
  101. package/src/tools/lsp.ts +346 -0
  102. package/src/tools/mcp_call.ts +163 -0
  103. package/src/tools/memory.ts +144 -0
  104. package/src/tools/move_file.ts +47 -0
  105. package/src/tools/patch.ts +86 -0
  106. package/src/tools/read_file.ts +130 -0
  107. package/src/tools/read_image.ts +80 -0
  108. package/src/tools/submit_result.ts +49 -0
  109. package/src/tools/task.ts +346 -0
  110. package/src/tools/todo.ts +201 -0
  111. package/src/tools/web_fetch.ts +161 -0
  112. package/src/tools/web_search.ts +156 -0
  113. package/src/tools/write_file.ts +42 -0
  114. package/src/ui/approval/prompt.ts +76 -0
  115. package/src/ui/assistant/simple.ts +568 -0
  116. package/src/ui/assistant/turn-status.ts +303 -0
  117. package/src/ui/contract.ts +55 -0
  118. package/src/ui/footer.ts +105 -0
  119. package/src/ui/input/input.ts +805 -0
  120. package/src/ui/input/prompt-engine.ts +606 -0
  121. package/src/ui/render/collapse.ts +84 -0
  122. package/src/ui/render/detail.ts +24 -0
  123. package/src/ui/render/diff.ts +181 -0
  124. package/src/ui/render/errors.ts +239 -0
  125. package/src/ui/render/format.ts +54 -0
  126. package/src/ui/render/highlight.ts +294 -0
  127. package/src/ui/render/markdown.ts +120 -0
  128. package/src/ui/render/money.ts +12 -0
  129. package/src/ui/render/reasoning.ts +20 -0
  130. package/src/ui/render/sanitize.ts +80 -0
  131. package/src/ui/render/table.ts +88 -0
  132. package/src/ui/render/theme.ts +339 -0
  133. package/src/ui/render/width.ts +256 -0
  134. package/src/ui/render/wrap.ts +120 -0
  135. package/src/ui/runtime/bus-debug.ts +83 -0
  136. package/src/ui/runtime/chrome.ts +301 -0
  137. package/src/ui/runtime/spinner.ts +77 -0
  138. package/src/ui/runtime/statusline.ts +227 -0
  139. package/src/ui/screens/model-manager.ts +434 -0
  140. package/src/ui/screens/overlay.ts +61 -0
  141. package/src/ui/screens/picker.ts +307 -0
  142. package/src/ui/screens/provider-manager.ts +450 -0
  143. package/src/ui/screens/wizard.ts +132 -0
  144. package/vendor/minicore/VENDOR.md +29 -0
  145. package/vendor/minicore/package.json +21 -0
  146. package/vendor/minicore/src/core/budget.ts +26 -0
  147. package/vendor/minicore/src/core/compact.ts +76 -0
  148. package/vendor/minicore/src/core/errors.ts +60 -0
  149. package/vendor/minicore/src/core/events.ts +74 -0
  150. package/vendor/minicore/src/core/executor.ts +139 -0
  151. package/vendor/minicore/src/core/history.ts +32 -0
  152. package/vendor/minicore/src/core/index.ts +42 -0
  153. package/vendor/minicore/src/core/loop.ts +344 -0
  154. package/vendor/minicore/src/core/permission.ts +24 -0
  155. package/vendor/minicore/src/core/provider.ts +39 -0
  156. package/vendor/minicore/src/core/recovery.ts +34 -0
  157. package/vendor/minicore/src/core/session.ts +327 -0
  158. package/vendor/minicore/src/core/snapshot.ts +142 -0
  159. package/vendor/minicore/src/core/tokens.ts +111 -0
  160. package/vendor/minicore/src/core/tool.ts +118 -0
  161. package/vendor/minicore/src/core/types.ts +50 -0
  162. package/vendor/minicore/src/providers/openai-compat.ts +366 -0
package/cli/router.ts ADDED
@@ -0,0 +1,124 @@
1
+ import { flagNameOf, valueFlags } from "./args.ts"
2
+
3
+ export async function dispatch(
4
+ args: string[],
5
+ _getArg: (name: string) => string | undefined,
6
+ HELP: string,
7
+ ): Promise<boolean> {
8
+ let cmdIndex = -1
9
+ for (let i = 0; i < args.length; i++) {
10
+ const token = args[i]
11
+ if (!token) continue
12
+ if (token === "--") break
13
+ const flag = flagNameOf(token)
14
+ if (flag) {
15
+ if (valueFlags.has(flag) && !token.includes("=")) i++
16
+ continue
17
+ }
18
+ if (!token.startsWith("-")) {
19
+ cmdIndex = i
20
+ break
21
+ }
22
+ }
23
+ const cmd = cmdIndex >= 0 ? args[cmdIndex] : undefined
24
+ if (!cmd) return false
25
+
26
+ // P10 P0.1 — scoped argv agar --cwd/--json setelah subcommand tetap terbaca.
27
+ // getArg global berhenti di token subcommand (boundary anti-injeksi P8),
28
+ // sehingga `minicode sessions list --cwd /tmp` mengembalikan undefined.
29
+ // Bangun subArgv = [flag global sebelum cmd + args dari cmd] dan getArg
30
+ // yang beroperasi di atasnya; teruskan sebagai getArg kedua ke handler.
31
+ const subArgv: string[] = []
32
+ for (let i = 0; i < cmdIndex; i++) {
33
+ const t = args[i]
34
+ if (!t) continue
35
+ const flag = flagNameOf(t)
36
+ if (flag) {
37
+ subArgv.push(t)
38
+ if (valueFlags.has(flag) && !t.includes("=") && i + 1 < cmdIndex) {
39
+ const v = args[i + 1]
40
+ if (v !== undefined) {
41
+ subArgv.push(v)
42
+ i++
43
+ }
44
+ }
45
+ }
46
+ }
47
+ subArgv.push(...args.slice(cmdIndex))
48
+ // subGetArg untuk handler: cari flag di subArgv TANPA boundary prompt,
49
+ // karena token subcommand ("sessions") sendiri akan memicu early-return di
50
+ // getArg global. Scan sederhana last-wins.
51
+ const subGetArg = (name: string): string | undefined => {
52
+ let found: string | undefined
53
+ for (let i = 0; i < subArgv.length; i++) {
54
+ const a = subArgv[i]
55
+ if (a === undefined) continue
56
+ if (a === name) {
57
+ const v = subArgv[i + 1]
58
+ if (v !== undefined && (v === "-" || !v.startsWith("-") || /^-?\d+(\.\d+)?$/.test(v)))
59
+ found = v
60
+ } else if (a.startsWith(`${name}=`)) {
61
+ const v = a.slice(name.length + 1)
62
+ if (v !== "") found = v
63
+ }
64
+ }
65
+ return found
66
+ }
67
+
68
+ if (cmd === "stats") {
69
+ const { handleStats } = await import("./commands/stats.ts")
70
+ await handleStats(subGetArg)
71
+ return true
72
+ }
73
+ if (cmd === "sessions") {
74
+ const { handleSessions } = await import("./commands/sessions.ts")
75
+ await handleSessions(args, subGetArg)
76
+ return true
77
+ }
78
+ if (cmd === "mcp") {
79
+ const { handleMcp } = await import("./commands/mcp.ts")
80
+ await handleMcp(args, subGetArg, HELP)
81
+ return true
82
+ }
83
+ if (cmd === "config") {
84
+ const { handleConfig } = await import("./commands/config.ts")
85
+ await handleConfig(args, subGetArg, HELP)
86
+ return true
87
+ }
88
+ if (cmd === "skills") {
89
+ const { handleSkills } = await import("./commands/skills.ts")
90
+ await handleSkills(args, subGetArg)
91
+ return true
92
+ }
93
+ if (cmd === "providers" || cmd === "models" || cmd === "sync") {
94
+ const { handleProviders } = await import("./commands/providers.ts")
95
+ await handleProviders(args, subGetArg)
96
+ return true
97
+ }
98
+ if (cmd === "auth") {
99
+ const { handleAuth } = await import("./commands/auth.ts")
100
+ await handleAuth(args)
101
+ return true
102
+ }
103
+ if (cmd === "pricing") {
104
+ const { handlePricing } = await import("./commands/pricing.ts")
105
+ await handlePricing(args)
106
+ return true
107
+ }
108
+ if (cmd === "exec") {
109
+ const { handleExec } = await import("./commands/exec.ts")
110
+ await handleExec(args, subGetArg)
111
+ return true
112
+ }
113
+ if (cmd === "memory") {
114
+ const { handleMemory } = await import("./commands/memory.ts")
115
+ await handleMemory(args, subGetArg)
116
+ return true
117
+ }
118
+ if (cmd === "doctor") {
119
+ const { handleDoctor } = await import("./commands/doctor.ts")
120
+ await handleDoctor(args, subGetArg)
121
+ return true
122
+ }
123
+ return false
124
+ }