miii-agent 0.1.5 → 0.1.7

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 (2) hide show
  1. package/dist/cli.js +25 -6
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -7,15 +7,26 @@ import { createElement } from "react";
7
7
  // src/ui/App.tsx
8
8
  import { useState as useState4, useEffect as useEffect3 } from "react";
9
9
  import { Box as Box10, Text as Text10, useApp } from "ink";
10
- import { homedir as homedir2 } from "os";
10
+ import { homedir as homedir3 } from "os";
11
11
  import { sep } from "path";
12
12
 
13
13
  // src/ollama/client.ts
14
14
  import { Ollama } from "ollama";
15
+ import { execFileSync } from "child_process";
15
16
  var ollama = new Ollama({
16
17
  host: process.env.OLLAMA_HOST ?? "http://localhost:11434"
17
18
  });
19
+ var OLLAMA_NOT_INSTALLED = "Ollama is not installed. Install it with: npm i -g ollama\nOr download from https://ollama.com/download";
18
20
  var OLLAMA_NOT_RUNNING = "Ollama is not running. Start it with: ollama serve";
21
+ function ollamaInstalled() {
22
+ try {
23
+ const cmd = process.platform === "win32" ? "where" : "which";
24
+ execFileSync(cmd, ["ollama"], { stdio: "ignore" });
25
+ return true;
26
+ } catch {
27
+ return false;
28
+ }
29
+ }
19
30
  var HARMONY_RE = /<\|?\/?(?:channel|message|start|end|return|constrain|assistant|user|system|developer|tool|tool_call|tool_response|final|analysis|commentary)\|?>/gi;
20
31
  var CHANNEL_LABEL_RE = /^(?:analysis|commentary|final)\s*(?=\w)/i;
21
32
  function stripHarmony(s) {
@@ -343,8 +354,12 @@ function filteredCommands(filter) {
343
354
  // src/session/store.ts
344
355
  import { writeFileSync as writeFileSync2, mkdirSync as mkdirSync2, existsSync as existsSync2, readdirSync, readFileSync as readFileSync2, rmSync } from "fs";
345
356
  import { join as join2 } from "path";
357
+ import { homedir as homedir2 } from "os";
346
358
  import { randomUUID } from "crypto";
347
- var SESSION_DIR = join2(process.cwd(), ".miii", "session");
359
+ function encodeProjectDir(cwd) {
360
+ return cwd.replace(/[/\\]/g, "-").replace(/^-+/, "");
361
+ }
362
+ var SESSION_DIR = join2(homedir2(), ".miii", "projects", encodeProjectDir(process.cwd()), "session");
348
363
  function newSessionId() {
349
364
  return randomUUID();
350
365
  }
@@ -2031,7 +2046,7 @@ async function checkForUpdate() {
2031
2046
  import { Fragment as Fragment2, jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
2032
2047
  function App() {
2033
2048
  const { exit } = useApp();
2034
- const cwd = process.cwd().replace(homedir2(), "~").split(sep).join("/");
2049
+ const cwd = process.cwd().replace(homedir3(), "~").split(sep).join("/");
2035
2050
  const [cfg, setCfg] = useState4(loadConfig());
2036
2051
  const [models, setModels] = useState4([]);
2037
2052
  const [contexts, setContexts] = useState4({});
@@ -2039,6 +2054,7 @@ function App() {
2039
2054
  const [state, setState] = useState4("loading");
2040
2055
  const [cursor, setCursor] = useState4(0);
2041
2056
  const [updateAvailable, setUpdateAvailable] = useState4(null);
2057
+ const [ollamaDown, setOllamaDown] = useState4(false);
2042
2058
  const [sessionId, setSessionId] = useState4(() => newSessionId());
2043
2059
  const [sessions, setSessions] = useState4([]);
2044
2060
  const [notice, setNotice] = useState4(null);
@@ -2067,7 +2083,8 @@ function App() {
2067
2083
  });
2068
2084
  }).catch((err) => {
2069
2085
  const msg = err instanceof Error ? err.message : String(err);
2070
- agent.setError(msg);
2086
+ agent.setError(ollamaInstalled() ? msg : OLLAMA_NOT_INSTALLED);
2087
+ setOllamaDown(true);
2071
2088
  setModels([]);
2072
2089
  setState(cfg.model ? "ready" : "select-model");
2073
2090
  });
@@ -2158,8 +2175,10 @@ function App() {
2158
2175
  if (!m) return null;
2159
2176
  return /* @__PURE__ */ jsx10(FilePicker, { matches: searchFiles(process.cwd(), m.query), cursor: filePickerCursor });
2160
2177
  })(),
2161
- /* @__PURE__ */ jsx10(InputBar, { input, disabled: agent.busy, processingLabel: agent.processingLabel }),
2162
- !agent.busy && /* @__PURE__ */ jsx10(Box10, { marginLeft: 2, marginBottom: 1, children: /* @__PURE__ */ jsx10(Text10, { dimColor: true, children: "type / to see commands" }) })
2178
+ !ollamaDown && /* @__PURE__ */ jsxs10(Fragment2, { children: [
2179
+ /* @__PURE__ */ jsx10(InputBar, { input, disabled: agent.busy, processingLabel: agent.processingLabel }),
2180
+ !agent.busy && /* @__PURE__ */ jsx10(Box10, { marginLeft: 2, marginBottom: 1, children: /* @__PURE__ */ jsx10(Text10, { dimColor: true, children: "type / to see commands" }) })
2181
+ ] })
2163
2182
  ] })
2164
2183
  ] });
2165
2184
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miii-agent",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Terminal AI coding agent powered by Ollama",
5
5
  "type": "module",
6
6
  "bin": {