sessiongraph 1.0.14 → 1.0.16
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/PRIVACY.md +15 -61
- package/README.md +35 -55
- package/bin/sessiongraph.mjs +14 -8
- package/dist/assets/index-C0jATzD9.css +1 -0
- package/dist/assets/{index-D4P4hbvc.js → index-CFlNwG9H.js} +1 -1
- package/dist/assets/index-D24Hz9MJ.js +180 -0
- package/dist/assets/{index-Kotmn42s.js → index-D7udGrT1.js} +1 -1
- package/dist/assets/{index-BLM-0yG6.js → index-U9QGDl1t.js} +1 -1
- package/dist/assets/katagami-sans-DMv8PCo8.woff2 +0 -0
- package/dist/assets/licenses/hugeicons.txt +21 -0
- package/dist/assets/licenses/katagami.txt +93 -0
- package/dist/assets/public-viewer-CyDoUT6s.css +1 -0
- package/dist/assets/public-viewer-iQBchlbq.js +24 -0
- package/dist/assets/scene-DmT4K5Nj.js +248 -0
- package/dist/assets/share-DrezE0sG.js +7 -0
- package/dist/assets/{three-D_1Qt16u.js → three-DDiuFd7k.js} +21 -21
- package/dist/assets/{worker-C10U_apJ.js → worker-B9mWJfQ6.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-server/cli.mjs +50326 -17640
- package/dist-server/install-cli.mjs +204 -0
- package/dist-server/server.mjs +1089 -379
- package/docs/cli.md +293 -190
- package/docs/guide.md +16 -9
- package/docs/import-coverage.md +73 -5
- package/docs/performance.md +164 -0
- package/docs/releases.md +6 -0
- package/package.json +18 -10
- package/dist/assets/external-links-BmBkCsrt.js +0 -1
- package/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dist/assets/index-B1kyvo41.js +0 -175
- package/dist/assets/index-Du0_nVjH.css +0 -1
- package/dist/assets/publishing-CEvQPkO1.css +0 -1
- package/dist/assets/publishing-D9CqkbeB.js +0 -23
- package/dist/assets/scene-CTHyYtma.js +0 -139
- package/dist/assets/share-Cw1E-ED9.js +0 -7
- package/docs/importer-comparison.md +0 -48
- package/docs/session-artifacts-audit.md +0 -176
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// server/cli-install-main.ts
|
|
4
|
+
import { dirname as dirname2 } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
// server/cli-install.ts
|
|
8
|
+
import { constants } from "node:fs";
|
|
9
|
+
import { chmod, copyFile, cp, lstat, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
10
|
+
import { execFile } from "node:child_process";
|
|
11
|
+
import { homedir } from "node:os";
|
|
12
|
+
import { basename, dirname, isAbsolute, join } from "node:path";
|
|
13
|
+
import { promisify } from "node:util";
|
|
14
|
+
import { randomUUID } from "node:crypto";
|
|
15
|
+
var names = ["sessiongraph", "ssg"];
|
|
16
|
+
var start = "# >>> SessionGraph CLI >>>";
|
|
17
|
+
var end = "# <<< SessionGraph CLI <<<";
|
|
18
|
+
var wrapperMarker = "SessionGraph CLI launcher";
|
|
19
|
+
var quote = (value) => `'${value.replace(/'/g, `'\\''`)}'`;
|
|
20
|
+
function cliInstallDirectory(home, env, platform) {
|
|
21
|
+
if (platform === "darwin") return join(home, "Library", "Application Support", "SessionGraph", "cli");
|
|
22
|
+
if (platform === "win32") return join(env.LOCALAPPDATA && isAbsolute(env.LOCALAPPDATA) ? env.LOCALAPPDATA : join(home, "AppData", "Local"), "SessionGraph", "cli");
|
|
23
|
+
const data = env.XDG_DATA_HOME && isAbsolute(env.XDG_DATA_HOME) ? env.XDG_DATA_HOME : join(home, ".local", "share");
|
|
24
|
+
return join(data, "sessiongraph", "cli");
|
|
25
|
+
}
|
|
26
|
+
async function exists(path) {
|
|
27
|
+
try {
|
|
28
|
+
return await lstat(path);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (error.code === "ENOENT") return void 0;
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function writeOwned(path, content, marker, mode = 384) {
|
|
35
|
+
const info = await exists(path);
|
|
36
|
+
if (info) {
|
|
37
|
+
if (!info.isFile() || !(await readFile(path, "utf8")).includes(marker)) throw new Error(`CLI setup found an existing file: ${path}`);
|
|
38
|
+
if (await readFile(path, "utf8") === content) return;
|
|
39
|
+
}
|
|
40
|
+
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
41
|
+
try {
|
|
42
|
+
await writeFile(temporary, content, { mode, flag: "wx" });
|
|
43
|
+
await rename(temporary, path);
|
|
44
|
+
} finally {
|
|
45
|
+
await rm(temporary, { force: true });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function shellPathBlock(directory, fish = false) {
|
|
49
|
+
const path = quote(directory);
|
|
50
|
+
const content = fish ? `fish_add_path --prepend --move --path ${path}` : `case ":\${PATH-}:" in
|
|
51
|
+
*:${path}:*) ;;
|
|
52
|
+
*) export PATH=${path}"\${PATH:+:$PATH}" ;;
|
|
53
|
+
esac`;
|
|
54
|
+
return `${start}
|
|
55
|
+
${content}
|
|
56
|
+
${end}`;
|
|
57
|
+
}
|
|
58
|
+
function updateShellProfile(content, block) {
|
|
59
|
+
const first = content.indexOf(start), last = content.indexOf(end);
|
|
60
|
+
if (first >= 0 || last >= 0) {
|
|
61
|
+
if (first < 0 || last < first || content.indexOf(start, first + start.length) >= 0 || content.indexOf(end, last + end.length) >= 0) {
|
|
62
|
+
throw new Error("CLI setup found an incomplete or repeated PATH block. Check the SessionGraph CLI section in your shell profile.");
|
|
63
|
+
}
|
|
64
|
+
return content.slice(0, first) + block + content.slice(last + end.length);
|
|
65
|
+
}
|
|
66
|
+
return `${content}${content && !content.endsWith("\n") ? "\n" : ""}
|
|
67
|
+
${block}
|
|
68
|
+
`;
|
|
69
|
+
}
|
|
70
|
+
async function registerShellPath(directory, home, env, platform) {
|
|
71
|
+
const shell = basename(env.SHELL || (platform === "darwin" ? "/bin/zsh" : "/bin/sh"));
|
|
72
|
+
let profiles;
|
|
73
|
+
if (shell === "fish") {
|
|
74
|
+
const config = env.XDG_CONFIG_HOME && isAbsolute(env.XDG_CONFIG_HOME) ? env.XDG_CONFIG_HOME : join(home, ".config");
|
|
75
|
+
profiles = [join(config, "fish", "conf.d", "sessiongraph-cli.fish")];
|
|
76
|
+
} else if (shell === "zsh") {
|
|
77
|
+
const directory2 = env.ZDOTDIR && isAbsolute(env.ZDOTDIR) ? env.ZDOTDIR : home;
|
|
78
|
+
profiles = [join(directory2, ".zprofile"), join(directory2, ".zshrc")];
|
|
79
|
+
} else if (shell === "bash") {
|
|
80
|
+
const login = [".bash_profile", ".bash_login", ".profile"].map((name) => join(home, name));
|
|
81
|
+
const existing = await Promise.all(login.map(exists));
|
|
82
|
+
profiles = [login[existing.findIndex(Boolean) >= 0 ? existing.findIndex(Boolean) : 2], join(home, ".bashrc")];
|
|
83
|
+
} else if (["sh", "dash", "ksh"].includes(shell)) {
|
|
84
|
+
profiles = [join(home, ".profile")];
|
|
85
|
+
} else {
|
|
86
|
+
throw new Error(`Add ${directory} to PATH in your ${shell} configuration.`);
|
|
87
|
+
}
|
|
88
|
+
const block = shellPathBlock(directory, shell === "fish");
|
|
89
|
+
for (const profile of profiles) {
|
|
90
|
+
await mkdir(dirname(profile), { recursive: true });
|
|
91
|
+
const before = await exists(profile) ? await readFile(profile, "utf8") : "";
|
|
92
|
+
const after = updateShellProfile(before, block);
|
|
93
|
+
if (after !== before) await writeFile(profile, after, { mode: 384 });
|
|
94
|
+
}
|
|
95
|
+
return profiles;
|
|
96
|
+
}
|
|
97
|
+
var windowsPathScript = `
|
|
98
|
+
$ErrorActionPreference = 'Stop'
|
|
99
|
+
$bin = $env:SESSIONGRAPH_CLI_BIN
|
|
100
|
+
$key = [Microsoft.Win32.Registry]::CurrentUser.CreateSubKey('Environment')
|
|
101
|
+
try {
|
|
102
|
+
$path = [string]$key.GetValue('Path', '', [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames)
|
|
103
|
+
$found = @($path -split ';' | Where-Object { [Environment]::ExpandEnvironmentVariables($_).TrimEnd('\\') -ieq $bin.TrimEnd('\\') })
|
|
104
|
+
if ($found.Count -gt 0) { exit 0 }
|
|
105
|
+
$kind = [Microsoft.Win32.RegistryValueKind]::ExpandString
|
|
106
|
+
if ($null -ne $key.GetValue('Path')) { $kind = $key.GetValueKind('Path') }
|
|
107
|
+
if ($kind -ne [Microsoft.Win32.RegistryValueKind]::String -and $kind -ne [Microsoft.Win32.RegistryValueKind]::ExpandString) { throw 'Unsupported user PATH value type' }
|
|
108
|
+
$value = if (!$path) { $bin } elseif ($path.EndsWith(';')) { $path + $bin } else { $path + ';' + $bin }
|
|
109
|
+
$key.SetValue('Path', $value, $kind)
|
|
110
|
+
} finally { $key.Close() }
|
|
111
|
+
Add-Type @'
|
|
112
|
+
using System;
|
|
113
|
+
using System.Runtime.InteropServices;
|
|
114
|
+
public static class SessionGraphPath {
|
|
115
|
+
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
|
116
|
+
public static extern IntPtr SendMessageTimeout(IntPtr hwnd, uint msg, UIntPtr wparam, string lparam, uint flags, uint timeout, out UIntPtr result);
|
|
117
|
+
}
|
|
118
|
+
'@
|
|
119
|
+
$result = [UIntPtr]::Zero
|
|
120
|
+
[void][SessionGraphPath]::SendMessageTimeout([IntPtr]0xffff, 0x1a, [UIntPtr]::Zero, 'Environment', 2, 5000, [ref]$result)
|
|
121
|
+
`;
|
|
122
|
+
async function registerWindowsPath(directory, env) {
|
|
123
|
+
const powershell = join(env.SystemRoot || "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
124
|
+
await promisify(execFile)(powershell, ["-NoProfile", "-NonInteractive", "-EncodedCommand", Buffer.from(windowsPathScript, "utf16le").toString("base64")], {
|
|
125
|
+
env: { ...env, SESSIONGRAPH_CLI_BIN: directory },
|
|
126
|
+
windowsHide: true,
|
|
127
|
+
timeout: 15e3
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
async function installDesktopCli(options) {
|
|
131
|
+
const { resources, executable } = options, home = options.home || homedir(), env = options.env || process.env, platform = options.platform || process.platform;
|
|
132
|
+
if (!isAbsolute(resources) || !isAbsolute(executable) || !isAbsolute(home)) throw new Error("CLI setup requires absolute resource, application, and home paths.");
|
|
133
|
+
const metadata = JSON.parse(await readFile(join(resources, "cli-package.json"), "utf8"));
|
|
134
|
+
if (!/^\d+\.\d+\.\d+$/.test(metadata.version) || !/^[a-f0-9]{64}$/.test(metadata.buildID)) throw new Error("Invalid bundled CLI metadata.");
|
|
135
|
+
const root = cliInstallDirectory(home, env, platform), bin = join(root, "bin");
|
|
136
|
+
if (bin.includes(platform === "win32" ? ";" : ":")) throw new Error(`CLI directory contains a PATH separator: ${bin}`);
|
|
137
|
+
await mkdir(bin, { recursive: true, mode: 448 });
|
|
138
|
+
const nodeName = platform === "win32" ? "node.exe" : "node";
|
|
139
|
+
const runtimeKey = `${process.version}-${platform}-${process.arch}`;
|
|
140
|
+
const runtime = join(root, "runtimes", runtimeKey);
|
|
141
|
+
await mkdir(runtime, { recursive: true, mode: 448 });
|
|
142
|
+
const node = join(runtime, nodeName);
|
|
143
|
+
const runtimeInfo = await exists(node);
|
|
144
|
+
if (runtimeInfo && !runtimeInfo.isFile()) throw new Error(`CLI setup found an existing file: ${node}`);
|
|
145
|
+
if (!runtimeInfo) {
|
|
146
|
+
const temporary = `${node}.${randomUUID()}.tmp`;
|
|
147
|
+
try {
|
|
148
|
+
await copyFile(join(resources, nodeName), temporary, constants.COPYFILE_FICLONE);
|
|
149
|
+
if (platform !== "win32") await chmod(temporary, 493);
|
|
150
|
+
await rename(temporary, node);
|
|
151
|
+
} finally {
|
|
152
|
+
await rm(temporary, { force: true });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const packageKey = `${metadata.version}-${metadata.buildID.slice(0, 16)}`, packages = join(root, "packages"), target = join(packages, packageKey);
|
|
156
|
+
await mkdir(packages, { recursive: true, mode: 448 });
|
|
157
|
+
if (!await exists(target)) {
|
|
158
|
+
const stage = join(packages, `.${packageKey}-${randomUUID()}`);
|
|
159
|
+
try {
|
|
160
|
+
await mkdir(join(stage, "bin"), { recursive: true, mode: 448 });
|
|
161
|
+
await mkdir(join(stage, "dist-server"));
|
|
162
|
+
await copyFile(join(resources, "cli-launcher.mjs"), join(stage, "bin", "sessiongraph.mjs"));
|
|
163
|
+
await copyFile(join(resources, "cli.mjs"), join(stage, "dist-server", "cli.mjs"));
|
|
164
|
+
await copyFile(join(resources, "server.mjs"), join(stage, "dist-server", "server.mjs"));
|
|
165
|
+
await copyFile(join(resources, "LICENSE"), join(stage, "LICENSE"));
|
|
166
|
+
await cp(join(resources, "web"), join(stage, "dist"), { recursive: true });
|
|
167
|
+
await writeFile(join(stage, "package.json"), JSON.stringify({ name: "sessiongraph", version: metadata.version, type: "module", sessionGraphDesktopExecutable: executable }), { mode: 384 });
|
|
168
|
+
await rename(stage, target);
|
|
169
|
+
} finally {
|
|
170
|
+
await rm(stage, { recursive: true, force: true });
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
const path = join(target, "package.json"), pkg = JSON.parse(await readFile(path, "utf8"));
|
|
174
|
+
if (pkg.name !== "sessiongraph" || pkg.version !== metadata.version || typeof pkg.sessionGraphDesktopExecutable !== "string") {
|
|
175
|
+
throw new Error(`CLI setup found an existing package: ${target}`);
|
|
176
|
+
}
|
|
177
|
+
if (pkg.sessionGraphDesktopExecutable !== executable) {
|
|
178
|
+
pkg.sessionGraphDesktopExecutable = executable;
|
|
179
|
+
await writeOwned(path, JSON.stringify(pkg), '"sessionGraphDesktopExecutable"');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
for (const name of names) {
|
|
183
|
+
const script = platform === "win32" ? `@echo off\r
|
|
184
|
+
rem ${wrapperMarker}\r
|
|
185
|
+
"%~dp0..\\runtimes\\${runtimeKey}\\node.exe" "%~dp0..\\packages\\${packageKey}\\bin\\sessiongraph.mjs" %*\r
|
|
186
|
+
` : `#!/bin/sh
|
|
187
|
+
# ${wrapperMarker}
|
|
188
|
+
exec ${quote(node)} ${quote(join(target, "bin", "sessiongraph.mjs"))} "$@"
|
|
189
|
+
`;
|
|
190
|
+
await writeOwned(join(bin, platform === "win32" ? `${name}.cmd` : name), script, wrapperMarker, 493);
|
|
191
|
+
}
|
|
192
|
+
const profiles = platform === "win32" ? (await (options.registerWindowsPath || ((directory) => registerWindowsPath(directory, env)))(bin), []) : await registerShellPath(bin, home, env, platform);
|
|
193
|
+
return { directory: root, bin, profiles };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// server/cli-install-main.ts
|
|
197
|
+
try {
|
|
198
|
+
const executable = process.argv[2];
|
|
199
|
+
if (!executable) throw new Error("Missing desktop application path.");
|
|
200
|
+
await installDesktopCli({ resources: dirname2(fileURLToPath(import.meta.url)), executable });
|
|
201
|
+
} catch (error) {
|
|
202
|
+
console.error(`SessionGraph CLI setup failed: ${error instanceof Error ? error.message : error}`);
|
|
203
|
+
process.exitCode = 1;
|
|
204
|
+
}
|