@minko-ai/minko 0.1.0 → 0.1.1

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 (189) hide show
  1. package/README.md +577 -2
  2. package/assets/mascot-preview.png +0 -0
  3. package/assets/mascot-preview.txt +46 -0
  4. package/assets/mascot-source.png +0 -0
  5. package/assets/skills/README.md +21 -0
  6. package/assets/skills/brainstorming/LICENSE +21 -0
  7. package/assets/skills/brainstorming/SKILL.md +316 -0
  8. package/assets/skills/buddhist-method/LICENSE +21 -0
  9. package/assets/skills/buddhist-method/SKILL.md +137 -0
  10. package/assets/skills/buddhist-method/references/ariyasacca-debug.md +57 -0
  11. package/assets/skills/buddhist-method/references/extended-principles.md +100 -0
  12. package/assets/skills/code-humanizer/LICENSE +21 -0
  13. package/assets/skills/code-humanizer/SKILL.md +174 -0
  14. package/assets/skills/code-review/LICENSE +21 -0
  15. package/assets/skills/code-review/SKILL.md +232 -0
  16. package/assets/skills/code-review/reference/angular.md +768 -0
  17. package/assets/skills/code-review/reference/architecture-review-guide.md +472 -0
  18. package/assets/skills/code-review/reference/c.md +890 -0
  19. package/assets/skills/code-review/reference/code-quality-universal.md +488 -0
  20. package/assets/skills/code-review/reference/code-review-best-practices.md +136 -0
  21. package/assets/skills/code-review/reference/common-bugs-checklist.md +302 -0
  22. package/assets/skills/code-review/reference/cpp.md +893 -0
  23. package/assets/skills/code-review/reference/cross-cutting/async-concurrency-patterns.md +515 -0
  24. package/assets/skills/code-review/reference/cross-cutting/error-handling-principles.md +492 -0
  25. package/assets/skills/code-review/reference/cross-cutting/n-plus-one-queries.md +309 -0
  26. package/assets/skills/code-review/reference/cross-cutting/sql-injection-prevention.md +308 -0
  27. package/assets/skills/code-review/reference/cross-cutting/xss-prevention.md +264 -0
  28. package/assets/skills/code-review/reference/csharp.md +525 -0
  29. package/assets/skills/code-review/reference/css-less-sass.md +661 -0
  30. package/assets/skills/code-review/reference/dart.md +670 -0
  31. package/assets/skills/code-review/reference/django.md +985 -0
  32. package/assets/skills/code-review/reference/fastapi.md +580 -0
  33. package/assets/skills/code-review/reference/go.md +993 -0
  34. package/assets/skills/code-review/reference/java.md +409 -0
  35. package/assets/skills/code-review/reference/java8.md +586 -0
  36. package/assets/skills/code-review/reference/kotlin.md +1018 -0
  37. package/assets/skills/code-review/reference/nestjs.md +593 -0
  38. package/assets/skills/code-review/reference/performance-review-guide.md +816 -0
  39. package/assets/skills/code-review/reference/php.md +684 -0
  40. package/assets/skills/code-review/reference/python.md +1073 -0
  41. package/assets/skills/code-review/reference/qt.md +757 -0
  42. package/assets/skills/code-review/reference/react.md +871 -0
  43. package/assets/skills/code-review/reference/ruby.md +964 -0
  44. package/assets/skills/code-review/reference/rust.md +846 -0
  45. package/assets/skills/code-review/reference/security-review-guide.md +494 -0
  46. package/assets/skills/code-review/reference/svelte.md +1064 -0
  47. package/assets/skills/code-review/reference/swift.md +936 -0
  48. package/assets/skills/code-review/reference/typescript.md +1016 -0
  49. package/assets/skills/code-review/reference/vue.md +924 -0
  50. package/assets/skills/code-review/reference/zig.md +440 -0
  51. package/assets/skills/cyclomatic-complexity/LICENSE +201 -0
  52. package/assets/skills/cyclomatic-complexity/SKILL.md +69 -0
  53. package/assets/skills/five-whys/LICENSE +21 -0
  54. package/assets/skills/five-whys/SKILL.md +247 -0
  55. package/assets/skills/five-whys/examples/performance-regression.md +161 -0
  56. package/assets/skills/five-whys/examples/production-incident.md +134 -0
  57. package/assets/skills/five-whys/references/software-patterns.md +284 -0
  58. package/assets/skills/five-whys/references/toyota-origins.md +257 -0
  59. package/assets/skills/systematic-debugging/LICENSE +21 -0
  60. package/assets/skills/systematic-debugging/SKILL.md +283 -0
  61. package/assets/skills/test-driven-development/LICENSE +21 -0
  62. package/assets/skills/test-driven-development/SKILL.md +330 -0
  63. package/assets/skills/verification-before-completion/LICENSE +21 -0
  64. package/assets/skills/verification-before-completion/SKILL.md +120 -0
  65. package/assets/skills/vibe-sec/LICENSE +201 -0
  66. package/assets/skills/vibe-sec/SKILL.md +758 -0
  67. package/assets/skills/writing-plans/LICENSE +21 -0
  68. package/assets/skills/writing-plans/SKILL.md +204 -0
  69. package/bin/minko.js +2 -2
  70. package/dist/agent/approvalTokens.js +224 -0
  71. package/dist/agent/branchLock.js +315 -0
  72. package/dist/agent/compact.js +182 -0
  73. package/dist/agent/context.js +183 -0
  74. package/dist/agent/cron.js +326 -0
  75. package/dist/agent/hooks.js +211 -0
  76. package/dist/agent/lanes.js +511 -0
  77. package/dist/agent/loop.js +337 -0
  78. package/dist/agent/memory.js +159 -0
  79. package/dist/agent/permissions.js +71 -0
  80. package/dist/agent/plan.js +118 -0
  81. package/dist/agent/prompt.js +120 -0
  82. package/dist/agent/subagent.js +67 -0
  83. package/dist/agent/tasks.js +449 -0
  84. package/dist/agent/transcript.js +62 -0
  85. package/dist/agent/workerStore.js +172 -0
  86. package/dist/agent/workerTypes.js +1 -0
  87. package/dist/agent/workers.js +503 -0
  88. package/dist/cli/app.js +261 -0
  89. package/dist/cli/argv.js +206 -0
  90. package/dist/cli/commandsCommand.js +12 -0
  91. package/dist/cli/configCommand.js +170 -0
  92. package/dist/cli/doctorCommand.js +112 -0
  93. package/dist/cli/exportCommand.js +85 -0
  94. package/dist/cli/forkCommand.js +24 -0
  95. package/dist/cli/linkCommand.js +272 -0
  96. package/dist/cli/loginCommand.js +69 -0
  97. package/dist/cli/mcpLoginCommand.js +68 -0
  98. package/dist/cli/pluginCommand.js +113 -0
  99. package/dist/cli/powerCommand.js +174 -0
  100. package/dist/cli/promptFooter.js +74 -0
  101. package/dist/cli/relayCommand.js +38 -0
  102. package/dist/cli/sandboxCommand.js +31 -0
  103. package/dist/cli/serveCommand.js +104 -0
  104. package/dist/cli/statusCommand.js +120 -0
  105. package/dist/cli/tui.js +1104 -0
  106. package/dist/commands/registry.js +99 -0
  107. package/dist/config/paths.js +81 -0
  108. package/dist/config/store.js +605 -0
  109. package/dist/index.js +199 -0
  110. package/dist/link/protocol.js +159 -0
  111. package/dist/link/relay.js +184 -0
  112. package/dist/link/server.js +566 -0
  113. package/dist/link/tunnel.js +90 -0
  114. package/dist/lsp/client.js +340 -0
  115. package/dist/lsp/tool.js +177 -0
  116. package/dist/mcp/client.js +469 -0
  117. package/dist/mcp/httpClient.js +191 -0
  118. package/dist/mcp/server.js +206 -0
  119. package/dist/mcp/tools.js +173 -0
  120. package/dist/oauth/device.js +111 -0
  121. package/dist/oauth/store.js +56 -0
  122. package/dist/plugins/loader.js +291 -0
  123. package/dist/plugins/market.js +98 -0
  124. package/dist/providers/anthropic.js +279 -0
  125. package/dist/providers/factory.js +109 -0
  126. package/dist/providers/openai.js +182 -0
  127. package/dist/providers/retry.js +95 -0
  128. package/dist/providers/sse.js +67 -0
  129. package/dist/providers/types.js +10 -0
  130. package/dist/rag/embeddings.js +171 -0
  131. package/dist/rag/index.js +373 -0
  132. package/dist/rag/server.js +167 -0
  133. package/dist/rag/tool.js +148 -0
  134. package/dist/sandbox/index.js +55 -0
  135. package/dist/sdk/server.js +150 -0
  136. package/dist/sdk/session.js +104 -0
  137. package/dist/session/liveness.js +148 -0
  138. package/dist/session/recorder.js +49 -0
  139. package/dist/session/store.js +171 -0
  140. package/dist/skills/index.js +428 -0
  141. package/dist/theme.js +30 -0
  142. package/dist/tools/fs.js +195 -0
  143. package/dist/tools/notebook.js +109 -0
  144. package/dist/tools/registry.js +32 -0
  145. package/dist/tools/search.js +130 -0
  146. package/dist/tools/shell.js +200 -0
  147. package/dist/tools/structured.js +83 -0
  148. package/dist/tools/types.js +1 -0
  149. package/dist/ui/ansi.js +135 -0
  150. package/dist/ui/banner.js +103 -0
  151. package/dist/ui/input.js +49 -0
  152. package/dist/ui/inputModel.js +113 -0
  153. package/dist/ui/keyboard.js +142 -0
  154. package/dist/ui/mascot.js +34 -0
  155. package/dist/ui/mascotData.js +96 -0
  156. package/dist/ui/md.js +183 -0
  157. package/dist/ui/screen.js +49 -0
  158. package/dist/ui/spinner.js +52 -0
  159. package/dist/ui/transcript.js +287 -0
  160. package/dist/util/clipboard.js +53 -0
  161. package/dist/util/errors.js +50 -0
  162. package/dist/util/version.js +12 -0
  163. package/dist/web/fetch.js +168 -0
  164. package/dist/web/search.js +97 -0
  165. package/package.json +45 -36
  166. package/src/agent/loop.ts +0 -159
  167. package/src/agent/prompt.ts +0 -45
  168. package/src/cli/app.ts +0 -396
  169. package/src/cli/argv.ts +0 -139
  170. package/src/cli/configCommand.ts +0 -175
  171. package/src/config/paths.ts +0 -20
  172. package/src/config/store.ts +0 -149
  173. package/src/index.ts +0 -120
  174. package/src/providers/anthropic.ts +0 -215
  175. package/src/providers/openai.ts +0 -158
  176. package/src/providers/sse.ts +0 -57
  177. package/src/providers/types.ts +0 -59
  178. package/src/session/store.ts +0 -125
  179. package/src/theme.ts +0 -41
  180. package/src/tools/fs.ts +0 -143
  181. package/src/tools/registry.ts +0 -19
  182. package/src/tools/shell.ts +0 -120
  183. package/src/tools/types.ts +0 -26
  184. package/src/ui/ansi.ts +0 -110
  185. package/src/ui/banner.ts +0 -39
  186. package/src/ui/input.ts +0 -54
  187. package/src/ui/md.ts +0 -160
  188. package/src/ui/spinner.ts +0 -58
  189. package/src/util/errors.ts +0 -48
@@ -0,0 +1,99 @@
1
+ export const SLASH_COMMANDS = [
2
+ { name: 'help', aliases: ['?'], description: '显示命令帮助', category: '会话' },
3
+ { name: 'new', description: '新建会话', category: '会话' },
4
+ { name: 'clear', description: '清空当前上下文', category: '上下文' },
5
+ { name: 'compact', usage: '[保留条数]', description: '把较早对话折叠成摘要', category: '上下文', examples: ['/compact', '/compact 2'] },
6
+ { name: 'plan', description: '切换只读计划模式', category: '上下文', examples: ['/plan'] },
7
+ { name: 'todos', description: '查看待办清单', category: '上下文' },
8
+ { name: 'fork', usage: '[名字]', description: '从当前会话复制一个分支', category: '会话', examples: ['/fork', '/fork 尝试A'] },
9
+ { name: 'model', usage: '<id>', description: '临时切换模型', category: '设置' },
10
+ { name: 'cwd', description: '显示当前工作目录', category: '状态' },
11
+ { name: 'sessions', description: '列出最近会话', category: '会话' },
12
+ { name: 'export', usage: '[路径]', description: '导出当前会话为 Markdown', category: '会话', examples: ['/export', '/export chat.md'] },
13
+ { name: 'status', description: '查看配置、模型、会话和插件状态', category: '状态' },
14
+ { name: 'usage', description: '查看本会话 token 用量', category: '状态' },
15
+ { name: 'workers', description: '列出后台 worker', category: '工具' },
16
+ { name: 'tasks', description: '列出任务板', category: '工具' },
17
+ { name: 'crons', description: '列出定时任务', category: '工具' },
18
+ { name: 'lanes', description: '列出 git worktree lane', category: '工具' },
19
+ { name: 'approvals', description: '列出审批令牌', category: '工具' },
20
+ { name: 'plugins', description: '列出已安装插件', category: '工具' },
21
+ { name: 'skills', description: '列出技能包', category: '工具' },
22
+ { name: 'memory', description: '查看长期记忆索引', category: '上下文' },
23
+ { name: 'sandbox', description: '查看 Docker 沙箱状态', category: '设置' },
24
+ { name: 'exit', aliases: ['quit'], description: '退出 Minko', category: '会话' },
25
+ ];
26
+ export function listCommands() {
27
+ return SLASH_COMMANDS.map((command) => ({
28
+ ...command,
29
+ aliases: command.aliases ? [...command.aliases] : undefined,
30
+ examples: command.examples ? [...command.examples] : undefined,
31
+ }));
32
+ }
33
+ export function parseSlash(input) {
34
+ const trimmed = input.trim();
35
+ if (!trimmed.startsWith('/')) {
36
+ return null;
37
+ }
38
+ const [first, ...rest] = trimmed.slice(1).split(/\s+/);
39
+ if (!first) {
40
+ return null;
41
+ }
42
+ return { name: first.toLowerCase(), argument: rest.join(' ').trim() };
43
+ }
44
+ export function findCommand(name) {
45
+ const wanted = name.toLowerCase();
46
+ return SLASH_COMMANDS.find((command) => command.name === wanted
47
+ || command.aliases?.includes(wanted));
48
+ }
49
+ export function commandHelp() {
50
+ const categories = ['会话', '上下文', '状态', '工具', '设置'];
51
+ const lines = ['命令'];
52
+ for (const category of categories) {
53
+ const commands = SLASH_COMMANDS.filter((command) => command.category === category);
54
+ if (commands.length === 0) {
55
+ continue;
56
+ }
57
+ lines.push('', ' [' + category + ']');
58
+ for (const command of commands) {
59
+ const usage = command.usage ? ' ' + command.usage : '';
60
+ lines.push(' /' + command.name + usage + ' ' + command.description);
61
+ }
62
+ }
63
+ return lines.join('\n');
64
+ }
65
+ /** Levenshtein-based suggestion for a mistyped command. */
66
+ export function suggestCommand(name) {
67
+ const wanted = name.toLowerCase();
68
+ let best = null;
69
+ let bestDistance = 3;
70
+ for (const command of SLASH_COMMANDS) {
71
+ const candidates = [command.name, ...(command.aliases ?? [])];
72
+ for (const candidate of candidates) {
73
+ const distance = levenshtein(wanted, candidate);
74
+ if (distance < bestDistance) {
75
+ bestDistance = distance;
76
+ best = command.name;
77
+ }
78
+ }
79
+ }
80
+ return bestDistance <= 2 ? best : null;
81
+ }
82
+ function levenshtein(a, b) {
83
+ const rows = a.length + 1;
84
+ const cols = b.length + 1;
85
+ const matrix = Array.from({ length: rows }, () => new Array(cols).fill(0));
86
+ for (let row = 0; row < rows; row += 1) {
87
+ matrix[row][0] = row;
88
+ }
89
+ for (let col = 0; col < cols; col += 1) {
90
+ matrix[0][col] = col;
91
+ }
92
+ for (let row = 1; row < rows; row += 1) {
93
+ for (let col = 1; col < cols; col += 1) {
94
+ const cost = a[row - 1] === b[col - 1] ? 0 : 1;
95
+ matrix[row][col] = Math.min(matrix[row - 1][col] + 1, matrix[row][col - 1] + 1, matrix[row - 1][col - 1] + cost);
96
+ }
97
+ }
98
+ return matrix[rows - 1][cols - 1];
99
+ }
@@ -0,0 +1,81 @@
1
+ import fs from 'node:fs';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+ let resolved = null;
5
+ let fallback = null;
6
+ function canWrite(dir) {
7
+ try {
8
+ fs.mkdirSync(dir, { recursive: true });
9
+ const probe = path.join(dir, '.minko-write-' + Date.now() + '-'
10
+ + Math.random().toString(36).slice(2, 6));
11
+ fs.writeFileSync(probe, '');
12
+ fs.unlinkSync(probe);
13
+ return true;
14
+ }
15
+ catch {
16
+ return false;
17
+ }
18
+ }
19
+ function safeUser() {
20
+ try {
21
+ return os.userInfo().username || 'user';
22
+ }
23
+ catch {
24
+ return 'user';
25
+ }
26
+ }
27
+ /**
28
+ * Picks a writable data directory. Some locked-down Windows profiles reject
29
+ * writes to the whole user folder (even AppData), so fall back instead of
30
+ * dying on the first session save.
31
+ */
32
+ export function minkoHome() {
33
+ if (resolved) {
34
+ return resolved;
35
+ }
36
+ const candidates = [];
37
+ const custom = process.env.MINKO_HOME;
38
+ if (custom && custom.trim().length > 0) {
39
+ candidates.push({ dir: path.resolve(custom), note: 'MINKO_HOME 不可写,改用 ' });
40
+ }
41
+ candidates.push({ dir: path.join(os.homedir(), '.minko'), note: '主目录不可写,改用 ' });
42
+ candidates.push({
43
+ dir: path.join(os.tmpdir(), 'minko-' + safeUser()),
44
+ note: '主目录不可写,数据暂存到临时目录 ',
45
+ });
46
+ for (const candidate of candidates) {
47
+ if (canWrite(candidate.dir)) {
48
+ resolved = candidate.dir;
49
+ fallback = candidate.note.length > 0 ? candidate.note + candidate.dir : null;
50
+ return candidate.dir;
51
+ }
52
+ }
53
+ throw new Error('找不到可写的数据目录,请设置环境变量 MINKO_HOME 指向一个可写文件夹');
54
+ }
55
+ /** Non-null when the default home was unusable and a fallback is in effect. */
56
+ export function homeFallbackWarning() {
57
+ minkoHome();
58
+ return fallback;
59
+ }
60
+ export function configPath() {
61
+ // Read an existing config from the default home even when that folder is
62
+ // read-only; only new configs go to the writable fallback.
63
+ const preferred = path.join(preferredHome(), 'config.json');
64
+ if (fs.existsSync(preferred)) {
65
+ return preferred;
66
+ }
67
+ return path.join(minkoHome(), 'config.json');
68
+ }
69
+ function preferredHome() {
70
+ const custom = process.env.MINKO_HOME;
71
+ if (custom && custom.trim().length > 0) {
72
+ return path.resolve(custom);
73
+ }
74
+ return path.join(os.homedir(), '.minko');
75
+ }
76
+ export function sessionsDir() {
77
+ return path.join(minkoHome(), 'sessions');
78
+ }
79
+ export function historyFile() {
80
+ return path.join(minkoHome(), 'history.jsonl');
81
+ }