gnosys 5.8.1 → 5.8.3
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.
- package/dist/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/lib/idFormat.d.ts +21 -0
- package/dist/lib/idFormat.d.ts.map +1 -1
- package/dist/lib/idFormat.js +48 -0
- package/dist/lib/idFormat.js.map +1 -1
- package/package.json +1 -1
package/dist/lib/idFormat.d.ts
CHANGED
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import type { GnosysDB } from "./db.js";
|
|
21
21
|
export type IdFormat = "short" | "long" | "raw";
|
|
22
|
+
export declare function isTtyStdout(): boolean;
|
|
23
|
+
/** Build the gnosys:// URI for a memory id. Encodes the id defensively. */
|
|
24
|
+
export declare function memoryUri(id: string): string;
|
|
25
|
+
/** Wrap `display` in OSC8 escapes pointing at `uri`. Caller decides when to use. */
|
|
26
|
+
export declare function osc8Wrap(uri: string, display: string): string;
|
|
22
27
|
/**
|
|
23
28
|
* Format a single memory ID for display.
|
|
24
29
|
*
|
|
@@ -26,6 +31,22 @@ export type IdFormat = "short" | "long" | "raw";
|
|
|
26
31
|
* scoped, or when lookup failed. In that case the project segment is omitted.
|
|
27
32
|
*/
|
|
28
33
|
export declare function formatMemoryId(id: string, projectName: string | null | undefined, format?: IdFormat): string;
|
|
34
|
+
/**
|
|
35
|
+
* Same as `formatMemoryId`, but wraps the result in an OSC8 hyperlink
|
|
36
|
+
* pointing at `gnosys://memory/<id>` when stdout is a TTY.
|
|
37
|
+
*
|
|
38
|
+
* In OSC8-aware terminals (iTerm2, Ghostty, Kitty, WezTerm) the citation
|
|
39
|
+
* renders underlined and the user can click / cmd-click / right-click-copy
|
|
40
|
+
* the URI. In every other context (pipes, CI logs, `--json` consumers,
|
|
41
|
+
* `less`) the function returns plain text exactly like `formatMemoryId`.
|
|
42
|
+
*
|
|
43
|
+
* Always emits the FULL id in the underlying URI (so right-click-copy
|
|
44
|
+
* gives back something useful) even when the visible text is the
|
|
45
|
+
* truncated `short` form.
|
|
46
|
+
*/
|
|
47
|
+
export declare function formatMemoryIdHyperlink(id: string, projectName: string | null | undefined, format?: IdFormat, options?: {
|
|
48
|
+
tty?: boolean;
|
|
49
|
+
}): string;
|
|
29
50
|
/**
|
|
30
51
|
* Build a single-shot {project_id → project_name} lookup map.
|
|
31
52
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idFormat.d.ts","sourceRoot":"","sources":["../../src/lib/idFormat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,SAAS,CAAC;AAEnD,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"idFormat.d.ts","sourceRoot":"","sources":["../../src/lib/idFormat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,SAAS,CAAC;AAEnD,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AAuBhD,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,oFAAoF;AACpF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,MAAM,EACV,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,MAAM,GAAE,QAAkB,GACzB,MAAM,CAcR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,MAAM,EACV,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,MAAM,GAAE,QAAkB,EAC1B,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1B,MAAM,CAKR;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAOxE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,CAGjE"}
|
package/dist/lib/idFormat.js
CHANGED
|
@@ -18,6 +18,34 @@
|
|
|
18
18
|
* across one project. Users who script against IDs should pass `--id-format raw`.
|
|
19
19
|
*/
|
|
20
20
|
const SHORT_ULID_PREFIX = 8;
|
|
21
|
+
// ─── OSC8 hyperlink helpers ─────────────────────────────────────────────
|
|
22
|
+
//
|
|
23
|
+
// v5.8.3 (#91): emit clickable links for memory IDs in OSC8-supporting
|
|
24
|
+
// terminals (iTerm2, Ghostty, Kitty, WezTerm, modern gnome-terminal).
|
|
25
|
+
// The escape sequence is `\x1b]8;;<URI>\x1b\\<text>\x1b]8;;\x1b\\`. A
|
|
26
|
+
// terminal that doesn't understand it ignores the escapes and prints
|
|
27
|
+
// only `<text>`, so this is safe everywhere — but we only emit when
|
|
28
|
+
// stdout is a TTY to keep pipes/CI logs clean.
|
|
29
|
+
//
|
|
30
|
+
// URI scheme: `gnosys://memory/<id>`. No OS-level handler is required
|
|
31
|
+
// for visual underline/click affordance to render; users who want
|
|
32
|
+
// "click → open in gnosys" can register a URL handler later, but the
|
|
33
|
+
// out-of-the-box value is the visual hint + copy-URL menu in the
|
|
34
|
+
// terminal.
|
|
35
|
+
const OSC8_START = "\x1b]8;;";
|
|
36
|
+
const OSC8_BREAK = "\x1b\\";
|
|
37
|
+
const OSC8_END = "\x1b]8;;\x1b\\";
|
|
38
|
+
export function isTtyStdout() {
|
|
39
|
+
return Boolean(process.stdout.isTTY);
|
|
40
|
+
}
|
|
41
|
+
/** Build the gnosys:// URI for a memory id. Encodes the id defensively. */
|
|
42
|
+
export function memoryUri(id) {
|
|
43
|
+
return `gnosys://memory/${encodeURIComponent(id)}`;
|
|
44
|
+
}
|
|
45
|
+
/** Wrap `display` in OSC8 escapes pointing at `uri`. Caller decides when to use. */
|
|
46
|
+
export function osc8Wrap(uri, display) {
|
|
47
|
+
return `${OSC8_START}${uri}${OSC8_BREAK}${display}${OSC8_END}`;
|
|
48
|
+
}
|
|
21
49
|
/**
|
|
22
50
|
* Format a single memory ID for display.
|
|
23
51
|
*
|
|
@@ -39,6 +67,26 @@ export function formatMemoryId(id, projectName, format = "short") {
|
|
|
39
67
|
return renderedId;
|
|
40
68
|
return `${projectName} · ${renderedId}`;
|
|
41
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Same as `formatMemoryId`, but wraps the result in an OSC8 hyperlink
|
|
72
|
+
* pointing at `gnosys://memory/<id>` when stdout is a TTY.
|
|
73
|
+
*
|
|
74
|
+
* In OSC8-aware terminals (iTerm2, Ghostty, Kitty, WezTerm) the citation
|
|
75
|
+
* renders underlined and the user can click / cmd-click / right-click-copy
|
|
76
|
+
* the URI. In every other context (pipes, CI logs, `--json` consumers,
|
|
77
|
+
* `less`) the function returns plain text exactly like `formatMemoryId`.
|
|
78
|
+
*
|
|
79
|
+
* Always emits the FULL id in the underlying URI (so right-click-copy
|
|
80
|
+
* gives back something useful) even when the visible text is the
|
|
81
|
+
* truncated `short` form.
|
|
82
|
+
*/
|
|
83
|
+
export function formatMemoryIdHyperlink(id, projectName, format = "short", options) {
|
|
84
|
+
const display = formatMemoryId(id, projectName, format);
|
|
85
|
+
const tty = options?.tty ?? isTtyStdout();
|
|
86
|
+
if (!tty)
|
|
87
|
+
return display;
|
|
88
|
+
return osc8Wrap(memoryUri(id), display);
|
|
89
|
+
}
|
|
42
90
|
/**
|
|
43
91
|
* Build a single-shot {project_id → project_name} lookup map.
|
|
44
92
|
*
|
package/dist/lib/idFormat.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;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3E,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gnosys",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.3",
|
|
4
4
|
"description": "Gnosys — Persistent Memory for AI Agents. Sandbox-first runtime, central SQLite brain, federated search, Dream Mode, Web Knowledge Base, Obsidian export.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|