mu-coding 0.1.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.
Files changed (40) hide show
  1. package/README.md +81 -0
  2. package/bin/mu.js +2 -0
  3. package/package.json +19 -0
  4. package/src/cli.ts +90 -0
  5. package/src/clipboard.ts +62 -0
  6. package/src/config.ts +116 -0
  7. package/src/diff.ts +81 -0
  8. package/src/main.tsx +80 -0
  9. package/src/project.ts +32 -0
  10. package/src/session.ts +95 -0
  11. package/src/singleShot.ts +42 -0
  12. package/src/tui/commands.ts +19 -0
  13. package/src/tui/components/chat/ChatPanel.tsx +55 -0
  14. package/src/tui/components/chat/ChatPanelBody.tsx +67 -0
  15. package/src/tui/components/chat/Pickers.tsx +44 -0
  16. package/src/tui/components/chatLayout.tsx +192 -0
  17. package/src/tui/components/inputBox.tsx +152 -0
  18. package/src/tui/components/messages/EditOutput.tsx +89 -0
  19. package/src/tui/components/messages/ReadOutput.tsx +43 -0
  20. package/src/tui/components/messages/WriteOutput.tsx +68 -0
  21. package/src/tui/components/messages/assistantMessage.tsx +24 -0
  22. package/src/tui/components/messages/messageItem.tsx +36 -0
  23. package/src/tui/components/messages/reasoningBlock.tsx +14 -0
  24. package/src/tui/components/messages/streamingOutput.tsx +14 -0
  25. package/src/tui/components/messages/toolCallBlock.tsx +99 -0
  26. package/src/tui/components/messages/userMessage.tsx +29 -0
  27. package/src/tui/components/ui/dropdown.tsx +96 -0
  28. package/src/tui/components/ui/modal.tsx +45 -0
  29. package/src/tui/components/ui/toast.tsx +45 -0
  30. package/src/tui/context/chat.ts +10 -0
  31. package/src/tui/hooks/useInputHandler.ts +257 -0
  32. package/src/tui/hooks/useScroll.ts +56 -0
  33. package/src/tui/hooks/useTerminal.ts +40 -0
  34. package/src/tui/hooks/useUI.ts +15 -0
  35. package/src/tui/useAbort.ts +68 -0
  36. package/src/tui/useChat.ts +52 -0
  37. package/src/tui/useChatSession.ts +155 -0
  38. package/src/tui/useChatUI.ts +51 -0
  39. package/src/tui/useModelList.ts +49 -0
  40. package/tsconfig.json +10 -0
@@ -0,0 +1,49 @@
1
+ import { type ApiModel, listModels } from 'mu-provider';
2
+ import { useCallback, useEffect, useState } from 'react';
3
+ import { saveConfig } from '../config';
4
+
5
+ export interface ModelListState {
6
+ models: ApiModel[];
7
+ currentModel: string;
8
+ modelError: string | null;
9
+ cycleModel: () => void;
10
+ selectModel: (id: string) => void;
11
+ }
12
+
13
+ export function useModelList(baseUrl: string, preferredModel?: string): ModelListState {
14
+ const [models, setModels] = useState<ApiModel[]>([]);
15
+ const [currentModel, setCurrentModel] = useState(preferredModel ?? '');
16
+ const [error, setError] = useState<string | null>(null);
17
+
18
+ useEffect(() => {
19
+ listModels(baseUrl)
20
+ .then((list) => {
21
+ if (list.length === 0) {
22
+ setError(`No models found at ${baseUrl}`);
23
+ return;
24
+ }
25
+ setError(null);
26
+ setModels(list);
27
+ const target = preferredModel && list.some((m) => m.id === preferredModel) ? preferredModel : list[0].id;
28
+ setCurrentModel(target);
29
+ })
30
+ .catch((err) => {
31
+ setError(err instanceof Error ? err.message : 'Failed to fetch models');
32
+ });
33
+ }, [baseUrl, preferredModel]);
34
+
35
+ const cycleModel = useCallback(() => {
36
+ if (models.length === 0) {
37
+ return;
38
+ }
39
+ const idx = models.findIndex((m) => m.id === currentModel);
40
+ setCurrentModel(models[(idx + 1) % models.length].id);
41
+ }, [models, currentModel]);
42
+
43
+ const selectModel = useCallback((id: string) => {
44
+ setCurrentModel(id);
45
+ saveConfig({ model: id });
46
+ }, []);
47
+
48
+ return { models, currentModel, cycleModel, selectModel, modelError: error };
49
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "rootDir": "src"
6
+ },
7
+ "include": ["src/**/*"],
8
+ "exclude": ["node_modules", "dist"],
9
+ "references": [{ "path": "../mu-provider" }, { "path": "../mu-agents" }, { "path": "../mu-repomap" }]
10
+ }