om-memory-system 4.4.0-next.69 → 4.4.0-next.70

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.
@@ -1,6 +1,7 @@
1
1
  import { type ClaudeHookOptions } from "./hook-client.js";
2
+ import { type ClaudeStatusOptions } from "./status.js";
2
3
  /**
3
4
  * `om-memory-system claude-hook <event>`. Always returns 0: a hook must never
4
5
  * block or break a Claude Code session, whatever goes wrong.
5
6
  */
6
- export declare function runClaudeHookCommand(argv: string[], io?: ClaudeHookOptions): Promise<number>;
7
+ export declare function runClaudeHookCommand(argv: string[], io?: ClaudeHookOptions & ClaudeStatusOptions): Promise<number>;
@@ -1,7 +1,14 @@
1
1
  import { CLAUDE_HOOK_EVENTS, runClaudeHook, } from "./hook-client.js";
2
+ import { buildClaudeStatus, loadClaudeStatusInputs } from "./status.js";
2
3
  function isHookEvent(value) {
3
4
  return CLAUDE_HOOK_EVENTS.includes(value ?? "");
4
5
  }
6
+ /** `claude-hook status`: one JSON line for the status line mod. Prints nothing on failure. */
7
+ async function printStatus(io) {
8
+ const inputs = await (io.statusInputs ?? loadClaudeStatusInputs)();
9
+ const status = await buildClaudeStatus({ ...inputs, fetch: io.fetch ?? globalThis.fetch });
10
+ (io.writeStdout ?? ((text) => process.stdout.write(text)))(`${JSON.stringify(status)}\n`);
11
+ }
5
12
  /**
6
13
  * `om-memory-system claude-hook <event>`. Always returns 0: a hook must never
7
14
  * block or break a Claude Code session, whatever goes wrong.
@@ -9,6 +16,10 @@ function isHookEvent(value) {
9
16
  export async function runClaudeHookCommand(argv, io = {}) {
10
17
  try {
11
18
  const [event] = argv;
19
+ if (event === "status") {
20
+ await printStatus(io);
21
+ return 0;
22
+ }
12
23
  if (isHookEvent(event)) {
13
24
  await runClaudeHook(event, io);
14
25
  return 0;
@@ -0,0 +1,25 @@
1
+ export interface ClaudeStatus {
2
+ healthUrl: string;
3
+ /** The version of the OMMS copy that ran this command. */
4
+ version: string;
5
+ /** The `latest` version on npm, or null when the check is off or fails. */
6
+ latest: string | null;
7
+ }
8
+ export interface ClaudeStatusInputs {
9
+ config: {
10
+ webServerHost: string;
11
+ webServerPort: number;
12
+ };
13
+ version: string;
14
+ checkUpdates: boolean;
15
+ }
16
+ /** Options for tests; production reads the global config and the package version. */
17
+ export interface ClaudeStatusOptions {
18
+ statusInputs?: () => Promise<ClaudeStatusInputs>;
19
+ }
20
+ /** Pure: `CONFIG` is passed in, because tests stub `src/config.js`. */
21
+ export declare function buildClaudeStatus(inputs: ClaudeStatusInputs & {
22
+ fetch: typeof fetch;
23
+ }): Promise<ClaudeStatus>;
24
+ /** The global config and this copy's version, as `om-memory-system web` reads them. */
25
+ export declare function loadClaudeStatusInputs(): Promise<ClaudeStatusInputs>;
@@ -0,0 +1,33 @@
1
+ import { homedir } from "node:os";
2
+ import { latestNpmVersion } from "../../services/update-check.js";
3
+ /** Pure: `CONFIG` is passed in, because tests stub `src/config.js`. */
4
+ export async function buildClaudeStatus(inputs) {
5
+ const { webServerHost, webServerPort } = inputs.config;
6
+ const host = webServerHost === "0.0.0.0" ? "127.0.0.1" : webServerHost;
7
+ const urlHost = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
8
+ return {
9
+ healthUrl: `http://${urlHost}:${webServerPort}/api/health`,
10
+ version: inputs.version,
11
+ latest: inputs.checkUpdates ? await latestNpmVersion(inputs.fetch) : null,
12
+ };
13
+ }
14
+ /** The global config and this copy's version, as `om-memory-system web` reads them. */
15
+ export async function loadClaudeStatusInputs() {
16
+ // Importing the config on a first run prints "Created config template" with
17
+ // console.log. Stdout must hold only the JSON line, so that goes to stderr.
18
+ const log = console.log;
19
+ console.log = console.error;
20
+ try {
21
+ const config = await import("../../config.js");
22
+ config.initConfig(homedir());
23
+ const { packageVersion } = await import("../../services/package-version.js");
24
+ return {
25
+ config: config.CONFIG,
26
+ version: packageVersion(),
27
+ checkUpdates: process.env.OMMS_DISABLE_UPDATE_CHECK !== "1",
28
+ };
29
+ }
30
+ finally {
31
+ console.log = log;
32
+ }
33
+ }
@@ -4,10 +4,6 @@ export interface TuiStatusState {
4
4
  update: string | null;
5
5
  }
6
6
  export declare function tuiStatusText(state: TuiStatusState): string;
7
- /** The `latest` version on npm, or null when the registry cannot be reached. */
8
- export declare function latestNpmVersion(fetchFn: typeof fetch, timeoutMs?: number): Promise<string | null>;
9
- /** A newer release than `current`, ignoring prereleases; null otherwise. */
10
- export declare function availableUpdate(current: string, latest: string | null): string | null;
11
7
  export interface TuiStatusDeps {
12
8
  currentVersion: string;
13
9
  healthUrl: string;
@@ -1,30 +1,8 @@
1
- import { isOlderVersion } from "../../services/version-compare.js";
1
+ import { availableUpdate, latestNpmVersion } from "../../services/update-check.js";
2
2
  export function tuiStatusText(state) {
3
3
  const web = state.web === "offline" ? "omms:web app off" : `omms:${state.web}`;
4
4
  return state.update ? `${web} · ${state.update} available` : web;
5
5
  }
6
- /** The `latest` version on npm, or null when the registry cannot be reached. */
7
- export async function latestNpmVersion(fetchFn, timeoutMs = 5_000) {
8
- try {
9
- const response = await fetchFn("https://registry.npmjs.org/om-memory-system/latest", {
10
- signal: AbortSignal.timeout(timeoutMs),
11
- headers: { accept: "application/json" },
12
- });
13
- if (!response.ok)
14
- return null;
15
- const body = (await response.json());
16
- return typeof body.version === "string" ? body.version : null;
17
- }
18
- catch {
19
- return null;
20
- }
21
- }
22
- /** A newer release than `current`, ignoring prereleases; null otherwise. */
23
- export function availableUpdate(current, latest) {
24
- if (!latest || latest.includes("-"))
25
- return null;
26
- return isOlderVersion(current, latest) ? latest : null;
27
- }
28
6
  /**
29
7
  * Keep the footer text current: the web app is polled, and npm is asked for a
30
8
  * newer release at start and then every few hours. Returns a stop function.
@@ -0,0 +1,4 @@
1
+ /** The `latest` version on npm, or null when the registry cannot be reached. */
2
+ export declare function latestNpmVersion(fetchFn: typeof fetch, timeoutMs?: number): Promise<string | null>;
3
+ /** A newer release than `current`, ignoring prereleases; null otherwise. */
4
+ export declare function availableUpdate(current: string, latest: string | null): string | null;
@@ -0,0 +1,23 @@
1
+ import { isOlderVersion } from "./version-compare.js";
2
+ /** The `latest` version on npm, or null when the registry cannot be reached. */
3
+ export async function latestNpmVersion(fetchFn, timeoutMs = 5_000) {
4
+ try {
5
+ const response = await fetchFn("https://registry.npmjs.org/om-memory-system/latest", {
6
+ signal: AbortSignal.timeout(timeoutMs),
7
+ headers: { accept: "application/json" },
8
+ });
9
+ if (!response.ok)
10
+ return null;
11
+ const body = (await response.json());
12
+ return typeof body.version === "string" ? body.version : null;
13
+ }
14
+ catch {
15
+ return null;
16
+ }
17
+ }
18
+ /** A newer release than `current`, ignoring prereleases; null otherwise. */
19
+ export function availableUpdate(current, latest) {
20
+ if (!latest || latest.includes("-"))
21
+ return null;
22
+ return isOlderVersion(current, latest) ? latest : null;
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "om-memory-system",
3
- "version": "4.4.0-next.69",
3
+ "version": "4.4.0-next.70",
4
4
  "description": "Opinionated modular memory system for coding agents (OpenCode + Pi)",
5
5
  "type": "module",
6
6
  "main": "dist/plugin.js",