nomoreide 0.1.54 → 0.1.55
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/core/agent-sessions.d.ts +45 -0
- package/dist/core/agent-sessions.js +103 -0
- package/dist/core/agent-sessions.js.map +1 -0
- package/dist/core/snapshot-manager.d.ts +52 -0
- package/dist/core/snapshot-manager.js +182 -0
- package/dist/core/snapshot-manager.js.map +1 -0
- package/dist/core/tool-call-store.d.ts +2 -0
- package/dist/core/tool-call-store.js.map +1 -1
- package/dist/mcp/server.js +6 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools/context.d.ts +6 -1
- package/dist/mcp/tools/context.js +8 -1
- package/dist/mcp/tools/context.js.map +1 -1
- package/dist/mcp/tools/index.d.ts +3 -1
- package/dist/mcp/tools/index.js +5 -2
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/snapshots.d.ts +8 -0
- package/dist/mcp/tools/snapshots.js +37 -0
- package/dist/mcp/tools/snapshots.js.map +1 -0
- package/dist/web/client/assets/{code-editor-dsjVJ-4Z.js → code-editor-CLZ4YEu4.js} +1 -1
- package/dist/web/client/assets/index-CD3YkYz8.css +1 -0
- package/dist/web/client/assets/{index-CpAg7ECo.js → index-siG6R1Rg.js} +101 -101
- package/dist/web/client/index.html +2 -2
- package/dist/web/routes/context.d.ts +2 -0
- package/dist/web/routes/context.js.map +1 -1
- package/dist/web/routes/index.js +2 -0
- package/dist/web/routes/index.js.map +1 -1
- package/dist/web/routes/snapshot-routes.d.ts +8 -0
- package/dist/web/routes/snapshot-routes.js +164 -0
- package/dist/web/routes/snapshot-routes.js.map +1 -0
- package/dist/web/server.js +3 -0
- package/dist/web/server.js.map +1 -1
- package/package.json +1 -1
- package/dist/web/client/assets/index-D4fn2UZ8.css +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ConfigStore } from "./config-store.js";
|
|
2
|
+
import { SnapshotManager } from "./snapshot-manager.js";
|
|
3
|
+
export interface AgentSession {
|
|
4
|
+
id: string;
|
|
5
|
+
/** Repository the session snapshot was taken in. */
|
|
6
|
+
repoPath: string;
|
|
7
|
+
/** Snapshot of the working tree before the session's first tool call. */
|
|
8
|
+
snapshotSha?: string;
|
|
9
|
+
snapshotRef?: string;
|
|
10
|
+
startedAt: string;
|
|
11
|
+
lastToolAt: string;
|
|
12
|
+
toolCount: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Sessions are persisted to `.nomoreide/agent-sessions.json` (not kept only
|
|
16
|
+
* in memory) because the MCP server and the web UI may run in different
|
|
17
|
+
* processes — the UI must be able to list change-sets it didn't record.
|
|
18
|
+
*/
|
|
19
|
+
export declare class AgentSessionStore {
|
|
20
|
+
private readonly filePath;
|
|
21
|
+
constructor(filePath: string);
|
|
22
|
+
list(): Promise<AgentSession[]>;
|
|
23
|
+
get(id: string): Promise<AgentSession | undefined>;
|
|
24
|
+
save(session: AgentSession): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export interface AgentSessionTracker {
|
|
27
|
+
/**
|
|
28
|
+
* Called before every recorded tool call. Starts a session (taking a
|
|
29
|
+
* working-tree snapshot) when none is active or the previous one went
|
|
30
|
+
* idle; otherwise bumps the active session. Never throws — a failed
|
|
31
|
+
* snapshot (e.g. not a git repo) must not block the tool call.
|
|
32
|
+
*/
|
|
33
|
+
beforeToolCall(): Promise<string>;
|
|
34
|
+
}
|
|
35
|
+
export interface AgentSessionTrackerOptions {
|
|
36
|
+
store: AgentSessionStore;
|
|
37
|
+
configStore: ConfigStore;
|
|
38
|
+
cwd?: string;
|
|
39
|
+
/** Gap after which the next tool call starts a new session. */
|
|
40
|
+
idleMs?: number;
|
|
41
|
+
/** Injectable for tests. */
|
|
42
|
+
snapshotManagerFor?: (repoPath: string) => Pick<SnapshotManager, "snapshot" | "prune">;
|
|
43
|
+
now?: () => number;
|
|
44
|
+
}
|
|
45
|
+
export declare function createAgentSessionTracker(options: AgentSessionTrackerOptions): AgentSessionTracker;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { SnapshotManager } from "./snapshot-manager.js";
|
|
4
|
+
const MAX_SESSIONS = 50;
|
|
5
|
+
/**
|
|
6
|
+
* Sessions are persisted to `.nomoreide/agent-sessions.json` (not kept only
|
|
7
|
+
* in memory) because the MCP server and the web UI may run in different
|
|
8
|
+
* processes — the UI must be able to list change-sets it didn't record.
|
|
9
|
+
*/
|
|
10
|
+
export class AgentSessionStore {
|
|
11
|
+
filePath;
|
|
12
|
+
constructor(filePath) {
|
|
13
|
+
this.filePath = filePath;
|
|
14
|
+
}
|
|
15
|
+
async list() {
|
|
16
|
+
try {
|
|
17
|
+
const parsed = JSON.parse(await readFile(this.filePath, "utf8"));
|
|
18
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async get(id) {
|
|
25
|
+
return (await this.list()).find((session) => session.id === id);
|
|
26
|
+
}
|
|
27
|
+
async save(session) {
|
|
28
|
+
const sessions = (await this.list()).filter((existing) => existing.id !== session.id);
|
|
29
|
+
sessions.unshift(session);
|
|
30
|
+
sessions.splice(MAX_SESSIONS);
|
|
31
|
+
await mkdir(dirname(this.filePath), { recursive: true });
|
|
32
|
+
await writeFile(this.filePath, `${JSON.stringify(sessions, null, 2)}\n`, "utf8");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const DEFAULT_IDLE_MS = 30 * 60 * 1000;
|
|
36
|
+
const SNAPSHOT_KEEP = 50;
|
|
37
|
+
export function createAgentSessionTracker(options) {
|
|
38
|
+
const cwd = options.cwd ?? process.cwd();
|
|
39
|
+
const idleMs = options.idleMs ?? DEFAULT_IDLE_MS;
|
|
40
|
+
const now = options.now ?? Date.now;
|
|
41
|
+
const snapshotManagerFor = options.snapshotManagerFor ?? ((repoPath) => new SnapshotManager(repoPath));
|
|
42
|
+
let active = null;
|
|
43
|
+
let pending = null;
|
|
44
|
+
async function beginSession() {
|
|
45
|
+
const startedAt = new Date(now()).toISOString();
|
|
46
|
+
const repoPath = await selectedRepoPath(options.configStore, cwd);
|
|
47
|
+
const session = {
|
|
48
|
+
id: `s-${now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`,
|
|
49
|
+
repoPath,
|
|
50
|
+
startedAt,
|
|
51
|
+
lastToolAt: startedAt,
|
|
52
|
+
toolCount: 0,
|
|
53
|
+
};
|
|
54
|
+
try {
|
|
55
|
+
const manager = snapshotManagerFor(repoPath);
|
|
56
|
+
const snapshot = await manager.snapshot(`agent session ${session.id}`);
|
|
57
|
+
session.snapshotSha = snapshot.sha;
|
|
58
|
+
session.snapshotRef = snapshot.ref;
|
|
59
|
+
await manager.prune(SNAPSHOT_KEEP);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// Not a git repo (or git unavailable) — track the session without a snapshot.
|
|
63
|
+
}
|
|
64
|
+
return session;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
async beforeToolCall() {
|
|
68
|
+
// Serialize: parallel tool calls at session start must share one snapshot.
|
|
69
|
+
const previous = pending ?? Promise.resolve("");
|
|
70
|
+
const next = previous
|
|
71
|
+
.catch(() => "")
|
|
72
|
+
.then(async () => {
|
|
73
|
+
const timestamp = now();
|
|
74
|
+
if (!active || timestamp - Date.parse(active.lastToolAt) > idleMs) {
|
|
75
|
+
active = await beginSession();
|
|
76
|
+
}
|
|
77
|
+
active.lastToolAt = new Date(timestamp).toISOString();
|
|
78
|
+
active.toolCount += 1;
|
|
79
|
+
try {
|
|
80
|
+
await options.store.save(active);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
// Persistence is best-effort; never block the tool call.
|
|
84
|
+
}
|
|
85
|
+
return active.id;
|
|
86
|
+
});
|
|
87
|
+
pending = next;
|
|
88
|
+
return next;
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
async function selectedRepoPath(configStore, fallbackCwd) {
|
|
93
|
+
try {
|
|
94
|
+
const config = await configStore.load();
|
|
95
|
+
const repos = config.gitRepositories ?? [];
|
|
96
|
+
const selected = repos.find((repo) => repo.name === config.selectedGitRepository) ?? repos[0];
|
|
97
|
+
return selected?.path ?? fallbackCwd;
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return fallbackCwd;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=agent-sessions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-sessions.js","sourceRoot":"","sources":["../../src/core/agent-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAiB,MAAM,uBAAuB,CAAC;AAcvE,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IACC;IAA7B,YAA6B,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;IAAG,CAAC;IAEjD,KAAK,CAAC,IAAI;QACR,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;YACjE,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,MAAyB,CAAC,CAAC,CAAC,EAAE,CAAC;QACjE,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,OAAO,CAAC,MAAM,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
|
|
7
|
+
export interface SnapshotChange {
|
|
8
|
+
/** A (added since snapshot), M (modified), D (deleted since snapshot). */
|
|
9
|
+
status: string;
|
|
10
|
+
path: string;
|
|
11
|
+
}
|
|
12
|
+
export interface RestoreResult {
|
|
13
|
+
/** Safety snapshot taken automatically before the restore. */
|
|
14
|
+
preRestore: Snapshot;
|
|
15
|
+
/** Files whose content was restored or re-created from the snapshot. */
|
|
16
|
+
restoredFiles: number;
|
|
17
|
+
/** Files created after the snapshot that the restore removed. */
|
|
18
|
+
deletedPaths: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Working-tree checkpoints under `refs/nomoreide/snapshots/*`, kept
|
|
22
|
+
* deliberately separate from the read-safe {@link GitManager} (like
|
|
23
|
+
* {@link GitActions}). Snapshots are commit objects in a private ref
|
|
24
|
+
* namespace: they never move HEAD, branches, or the user's index — the tree
|
|
25
|
+
* is built through a temporary `GIT_INDEX_FILE` so staged state survives.
|
|
26
|
+
*
|
|
27
|
+
* `restore` is the one destructive operation and it is made reversible by
|
|
28
|
+
* always taking a `pre-restore` snapshot first; it also refuses shas that are
|
|
29
|
+
* not in the snapshot namespace, so the API can never check out arbitrary
|
|
30
|
+
* commits.
|
|
31
|
+
*/
|
|
32
|
+
export declare class SnapshotManager {
|
|
33
|
+
private readonly cwd;
|
|
34
|
+
constructor(cwd?: string);
|
|
35
|
+
snapshot(label: string): Promise<Snapshot>;
|
|
36
|
+
/** Newest first (ref names start with the creation epoch-millis). */
|
|
37
|
+
list(): Promise<Snapshot[]>;
|
|
38
|
+
/** Diff a snapshot against the current working tree (incl. untracked files). */
|
|
39
|
+
changedFiles(sha: string): Promise<SnapshotChange[]>;
|
|
40
|
+
diff(sha: string, path?: string): Promise<string>;
|
|
41
|
+
restore(sha: string): Promise<RestoreResult>;
|
|
42
|
+
/** Drop snapshots beyond the newest `keep`; returns how many were removed. */
|
|
43
|
+
prune(keep?: number): Promise<number>;
|
|
44
|
+
/**
|
|
45
|
+
* Write the current working tree (tracked + untracked, `.gitignore`
|
|
46
|
+
* respected) as a tree object via a throwaway index file.
|
|
47
|
+
*/
|
|
48
|
+
private captureTree;
|
|
49
|
+
private headSha;
|
|
50
|
+
private removeWorktreeFile;
|
|
51
|
+
private git;
|
|
52
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { rm } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join, resolve, sep } from "node:path";
|
|
6
|
+
import { promisify } from "node:util";
|
|
7
|
+
const execFileAsync = promisify(execFile);
|
|
8
|
+
const SNAPSHOT_REF_PREFIX = "refs/nomoreide/snapshots/";
|
|
9
|
+
/** Snapshots are anonymous safety commits; never attributed to the user. */
|
|
10
|
+
const SNAPSHOT_IDENTITY = {
|
|
11
|
+
GIT_AUTHOR_NAME: "nomoreide",
|
|
12
|
+
GIT_AUTHOR_EMAIL: "nomoreide@localhost",
|
|
13
|
+
GIT_COMMITTER_NAME: "nomoreide",
|
|
14
|
+
GIT_COMMITTER_EMAIL: "nomoreide@localhost",
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Working-tree checkpoints under `refs/nomoreide/snapshots/*`, kept
|
|
18
|
+
* deliberately separate from the read-safe {@link GitManager} (like
|
|
19
|
+
* {@link GitActions}). Snapshots are commit objects in a private ref
|
|
20
|
+
* namespace: they never move HEAD, branches, or the user's index — the tree
|
|
21
|
+
* is built through a temporary `GIT_INDEX_FILE` so staged state survives.
|
|
22
|
+
*
|
|
23
|
+
* `restore` is the one destructive operation and it is made reversible by
|
|
24
|
+
* always taking a `pre-restore` snapshot first; it also refuses shas that are
|
|
25
|
+
* not in the snapshot namespace, so the API can never check out arbitrary
|
|
26
|
+
* commits.
|
|
27
|
+
*/
|
|
28
|
+
export class SnapshotManager {
|
|
29
|
+
cwd;
|
|
30
|
+
constructor(cwd = process.cwd()) {
|
|
31
|
+
this.cwd = cwd;
|
|
32
|
+
}
|
|
33
|
+
async snapshot(label) {
|
|
34
|
+
const cleaned = label.trim() || "snapshot";
|
|
35
|
+
const tree = await this.captureTree();
|
|
36
|
+
const head = await this.headSha();
|
|
37
|
+
const commitArgs = ["commit-tree", tree, "-m", cleaned];
|
|
38
|
+
if (head)
|
|
39
|
+
commitArgs.push("-p", head);
|
|
40
|
+
const sha = (await this.git(commitArgs, SNAPSHOT_IDENTITY)).trim();
|
|
41
|
+
const ref = `${SNAPSHOT_REF_PREFIX}${Date.now()}-${slugify(cleaned)}`;
|
|
42
|
+
await this.git(["update-ref", ref, sha]);
|
|
43
|
+
return { sha, ref, label: cleaned, createdAt: new Date().toISOString() };
|
|
44
|
+
}
|
|
45
|
+
/** Newest first (ref names start with the creation epoch-millis). */
|
|
46
|
+
async list() {
|
|
47
|
+
const output = await this.git([
|
|
48
|
+
"for-each-ref",
|
|
49
|
+
"--sort=-refname",
|
|
50
|
+
"--format=%(refname)%09%(objectname)%09%(creatordate:iso-strict)%09%(subject)",
|
|
51
|
+
SNAPSHOT_REF_PREFIX.replace(/\/$/, ""),
|
|
52
|
+
]);
|
|
53
|
+
return output
|
|
54
|
+
.split("\n")
|
|
55
|
+
.filter((line) => line.trim() !== "")
|
|
56
|
+
.map((line) => {
|
|
57
|
+
const [ref, sha, createdAt, ...subject] = line.split("\t");
|
|
58
|
+
return { ref, sha, createdAt, label: subject.join("\t") };
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/** Diff a snapshot against the current working tree (incl. untracked files). */
|
|
62
|
+
async changedFiles(sha) {
|
|
63
|
+
const tree = await this.captureTree();
|
|
64
|
+
const output = await this.git([
|
|
65
|
+
"diff",
|
|
66
|
+
"--no-renames",
|
|
67
|
+
"--name-status",
|
|
68
|
+
sha,
|
|
69
|
+
tree,
|
|
70
|
+
]);
|
|
71
|
+
return output
|
|
72
|
+
.split("\n")
|
|
73
|
+
.filter((line) => line.trim() !== "")
|
|
74
|
+
.map((line) => {
|
|
75
|
+
const [status, ...path] = line.split("\t");
|
|
76
|
+
return { status, path: path.join("\t") };
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async diff(sha, path) {
|
|
80
|
+
const tree = await this.captureTree();
|
|
81
|
+
const args = ["diff", "--no-renames", sha, tree];
|
|
82
|
+
if (path)
|
|
83
|
+
args.push("--", path);
|
|
84
|
+
return this.git(args);
|
|
85
|
+
}
|
|
86
|
+
async restore(sha) {
|
|
87
|
+
const snapshots = await this.list();
|
|
88
|
+
const target = snapshots.find((snapshot) => snapshot.sha === sha);
|
|
89
|
+
if (!target) {
|
|
90
|
+
throw new Error(`Not a nomoreide snapshot: ${sha}`);
|
|
91
|
+
}
|
|
92
|
+
const preRestore = await this.snapshot(`pre-restore (${target.label})`);
|
|
93
|
+
// Everything that differs between the snapshot and the just-captured
|
|
94
|
+
// current state. Additions must be deleted by hand: `git restore` only
|
|
95
|
+
// writes files that exist in the source tree, it never removes extras.
|
|
96
|
+
const changes = await this.git([
|
|
97
|
+
"diff",
|
|
98
|
+
"--no-renames",
|
|
99
|
+
"--name-status",
|
|
100
|
+
sha,
|
|
101
|
+
preRestore.sha,
|
|
102
|
+
]);
|
|
103
|
+
const deletedPaths = [];
|
|
104
|
+
let restoredFiles = 0;
|
|
105
|
+
for (const line of changes.split("\n")) {
|
|
106
|
+
if (line.trim() === "")
|
|
107
|
+
continue;
|
|
108
|
+
const [status, ...rest] = line.split("\t");
|
|
109
|
+
const path = rest.join("\t");
|
|
110
|
+
if (status === "A") {
|
|
111
|
+
await this.removeWorktreeFile(path);
|
|
112
|
+
deletedPaths.push(path);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
restoredFiles += 1;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (restoredFiles > 0) {
|
|
119
|
+
// --worktree only: the user's index stays untouched, mirroring snapshot().
|
|
120
|
+
await this.git(["restore", "--source", sha, "--worktree", "--", ":/"]);
|
|
121
|
+
}
|
|
122
|
+
return { preRestore, restoredFiles, deletedPaths };
|
|
123
|
+
}
|
|
124
|
+
/** Drop snapshots beyond the newest `keep`; returns how many were removed. */
|
|
125
|
+
async prune(keep = 50) {
|
|
126
|
+
const snapshots = await this.list();
|
|
127
|
+
const stale = snapshots.slice(Math.max(0, keep));
|
|
128
|
+
for (const snapshot of stale) {
|
|
129
|
+
await this.git(["update-ref", "-d", snapshot.ref]);
|
|
130
|
+
}
|
|
131
|
+
return stale.length;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Write the current working tree (tracked + untracked, `.gitignore`
|
|
135
|
+
* respected) as a tree object via a throwaway index file.
|
|
136
|
+
*/
|
|
137
|
+
async captureTree() {
|
|
138
|
+
const indexFile = join(tmpdir(), `nomoreide-index-${randomUUID()}`);
|
|
139
|
+
const env = { GIT_INDEX_FILE: indexFile };
|
|
140
|
+
try {
|
|
141
|
+
const head = await this.headSha();
|
|
142
|
+
await this.git(["read-tree", ...(head ? [head] : ["--empty"])], env);
|
|
143
|
+
await this.git(["add", "-A"], env);
|
|
144
|
+
return (await this.git(["write-tree"], env)).trim();
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
await rm(indexFile, { force: true });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async headSha() {
|
|
151
|
+
try {
|
|
152
|
+
return (await this.git(["rev-parse", "--verify", "HEAD"])).trim();
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return null; // repository without commits yet
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
async removeWorktreeFile(path) {
|
|
159
|
+
const absolute = resolve(this.cwd, path);
|
|
160
|
+
if (!absolute.startsWith(resolve(this.cwd) + sep)) {
|
|
161
|
+
throw new Error(`Refusing to delete outside the repository: ${path}`);
|
|
162
|
+
}
|
|
163
|
+
await rm(absolute, { force: true });
|
|
164
|
+
}
|
|
165
|
+
async git(args, env) {
|
|
166
|
+
const { stdout } = await execFileAsync("git", args, {
|
|
167
|
+
cwd: this.cwd,
|
|
168
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
169
|
+
env: env ? { ...process.env, ...env } : process.env,
|
|
170
|
+
});
|
|
171
|
+
return stdout;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function slugify(label) {
|
|
175
|
+
const slug = label
|
|
176
|
+
.toLowerCase()
|
|
177
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
178
|
+
.replace(/^-+|-+$/g, "")
|
|
179
|
+
.slice(0, 40);
|
|
180
|
+
return slug || "snapshot";
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=snapshot-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-manager.js","sourceRoot":"","sources":["../../src/core/snapshot-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,mBAAmB,GAAG,2BAA2B,CAAC;AAExD,4EAA4E;AAC5E,MAAM,iBAAiB,GAAG;IACxB,eAAe,EAAE,WAAW;IAC5B,gBAAgB,EAAE,qBAAqB;IACvC,kBAAkB,EAAE,WAAW;IAC/B,mBAAmB,EAAE,qBAAqB;CAC3C,CAAC;AAwBF;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,eAAe;IACG;IAA7B,YAA6B,MAAM,OAAO,CAAC,GAAG,EAAE;QAAnB,QAAG,GAAH,G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CAAC,CAAC,CAAC,OAAO,CAAC,GAAG;SACpD,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,SAAS,OAAO,CAAC,KAAa;IAC5B,MAAM,IAAI,GAAG,KAAK;SACf,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChB,OAAO,IAAI,IAAI,UAAU,CAAC;AAC5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-call-store.js","sourceRoot":"","sources":["../../src/core/tool-call-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool-call-store.js","sourceRoot":"","sources":["../../src/core/tool-call-store.ts"],"names":[],"mappings":"AAcA,MAAM,OAAO,aAAa;IAKK;IAJZ,OAAO,GAAqB,EAAE,CAAC;IAC/B,SAAS,GAAG,IAAI,GAAG,EAAY,CAAC;IACzC,MAAM,GAAG,CAAC,CAAC;IAEnB,YAA6B,WAAW,GAAG;QAAd,aAAQ,GAAR,QAAQ,CAAM;IAAG,CAAC;IAE/C,MAAM,CAAC,KAAiC;QACtC,MAAM,MAAM,GAAmB,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC;QAC/D,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1B,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YACxC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9D,CAAC;QACD,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,IAAI,CAAC;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@
|
|
|
1
1
|
import { dirname, resolve } from "node:path";
|
|
2
2
|
import { FastMCP } from "fastmcp";
|
|
3
|
+
import { AgentSessionStore, createAgentSessionTracker, } from "../core/agent-sessions.js";
|
|
3
4
|
import { ConfigStore, defaultGlobalConfigPath } from "../core/config-store.js";
|
|
4
5
|
import { DbPeek } from "../core/db-peek.js";
|
|
5
6
|
import { ErrorInbox } from "../core/error-inbox.js";
|
|
@@ -32,6 +33,10 @@ export function createNoMoreIdeMcpServer(options = {}) {
|
|
|
32
33
|
const errorInbox = new ErrorInbox({ logStore, configStore });
|
|
33
34
|
const dbPeek = new DbPeek({ configStore });
|
|
34
35
|
const toolCallStore = new ToolCallStore();
|
|
36
|
+
const agentSessions = createAgentSessionTracker({
|
|
37
|
+
store: new AgentSessionStore(resolve(dirname(resolve(logDir)), "agent-sessions.json")),
|
|
38
|
+
configStore,
|
|
39
|
+
});
|
|
35
40
|
const uiLifecycle = options.uiLifecycle ??
|
|
36
41
|
createUiLifecycleManager({
|
|
37
42
|
configPath,
|
|
@@ -53,6 +58,7 @@ export function createNoMoreIdeMcpServer(options = {}) {
|
|
|
53
58
|
timelineStore,
|
|
54
59
|
uiLifecycle,
|
|
55
60
|
toolCallStore,
|
|
61
|
+
agentSessions,
|
|
56
62
|
});
|
|
57
63
|
return {
|
|
58
64
|
server,
|
package/dist/mcp/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OA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AAM;QACN,UAAU;QACV,QAAQ;QACR,OAAO;QACP,aAAa;QACb,WAAW;QACX,aAAa;QACb,aAAa;KACd,CAAC,CAAC;IAEH,OAAO;QACL,MAAM;QACN,WAAW;QACX,UAAU;QACV,QAAQ;QACR,OAAO;QACP,WAAW;QACX,aAAa;QACb,SAAS,EAAE,oBAAoB;KAChC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,UAA0C,EAAE;IAE5C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACvC,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,EAAE,IAAI,wBAAwB,EAAE,CAAC;IACvE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IACxC,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC;QACxB,OAA8B,CAAC,OAAO,CAAC,uBAAuB,EAAE,CAAC;IACpE,CAAC;IACD,IAAI,GAAG,CAAC,iBAAiB,KAAK,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC;YACH,MAAM,WAAW,CAAC,aAAa,EAAE,CAAC;QACpC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,oCACE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,IAAI,CACL,CAAC;QACJ,CAAC;IACH,CAAC;IACD,MAAM,MAAM,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FastMCP } from "fastmcp";
|
|
2
|
+
import type { AgentSessionTracker } from "../../core/agent-sessions.js";
|
|
2
3
|
import type { ConfigStore } from "../../core/config-store.js";
|
|
3
4
|
import type { DbPeek } from "../../core/db-peek.js";
|
|
4
5
|
import type { ErrorInbox } from "../../core/error-inbox.js";
|
|
@@ -29,5 +30,9 @@ export declare function stringify(value: unknown): string;
|
|
|
29
30
|
* Wrap a FastMCP server so every `addTool` execute is timed and recorded in
|
|
30
31
|
* the tool-call store. The aggregator wraps once, then hands the same wrapped
|
|
31
32
|
* server to each domain's `registerXTools`.
|
|
33
|
+
*
|
|
34
|
+
* When a session tracker is supplied, every execute first runs
|
|
35
|
+
* `beforeToolCall()` — which auto-snapshots the working tree at the start of
|
|
36
|
+
* a new agent session — and the resulting sessionId tags each record.
|
|
32
37
|
*/
|
|
33
|
-
export declare function wrapServerForRecording(server: FastMCP, store: ToolCallStore): FastMCP;
|
|
38
|
+
export declare function wrapServerForRecording(server: FastMCP, store: ToolCallStore, sessions?: AgentSessionTracker): FastMCP;
|
|
@@ -15,14 +15,19 @@ export function stringify(value) {
|
|
|
15
15
|
* Wrap a FastMCP server so every `addTool` execute is timed and recorded in
|
|
16
16
|
* the tool-call store. The aggregator wraps once, then hands the same wrapped
|
|
17
17
|
* server to each domain's `registerXTools`.
|
|
18
|
+
*
|
|
19
|
+
* When a session tracker is supplied, every execute first runs
|
|
20
|
+
* `beforeToolCall()` — which auto-snapshots the working tree at the start of
|
|
21
|
+
* a new agent session — and the resulting sessionId tags each record.
|
|
18
22
|
*/
|
|
19
|
-
export function wrapServerForRecording(server, store) {
|
|
23
|
+
export function wrapServerForRecording(server, store, sessions) {
|
|
20
24
|
const originalAdd = server.addTool.bind(server);
|
|
21
25
|
const wrapped = (definition) => {
|
|
22
26
|
const originalExecute = definition.execute;
|
|
23
27
|
const recordingDefinition = {
|
|
24
28
|
...definition,
|
|
25
29
|
execute: async (args, context) => {
|
|
30
|
+
const sessionId = sessions ? await sessions.beforeToolCall() : undefined;
|
|
26
31
|
const start = Date.now();
|
|
27
32
|
const startedAt = new Date(start).toISOString();
|
|
28
33
|
try {
|
|
@@ -32,6 +37,7 @@ export function wrapServerForRecording(server, store) {
|
|
|
32
37
|
startedAt,
|
|
33
38
|
durationMs: Date.now() - start,
|
|
34
39
|
status: "ok",
|
|
40
|
+
sessionId,
|
|
35
41
|
args: previewArgs(args),
|
|
36
42
|
});
|
|
37
43
|
return result;
|
|
@@ -42,6 +48,7 @@ export function wrapServerForRecording(server, store) {
|
|
|
42
48
|
startedAt,
|
|
43
49
|
durationMs: Date.now() - start,
|
|
44
50
|
status: "error",
|
|
51
|
+
sessionId,
|
|
45
52
|
args: previewArgs(args),
|
|
46
53
|
error: error instanceof Error ? error.message : String(error),
|
|
47
54
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/mcp/tools/context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/mcp/tools/context.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAIvD,OAAO,EAAE,WAAW,EAAsB,MAAM,+BAA+B,CAAC;AAiBhF,MAAM,UAAU,GAAG,CAAC,GAAY;IAC9B,OAAO,IAAI,UAAU,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,UAAU,CAAC,GAAY;IACrC,OAAO,IAAI,UAAU,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAe,EACf,KAAoB,EACpB,QAA8B;IAE9B,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAA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AAC;YACH,CAAC;SACmC,CAAC;QACvC,OAAO,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAC1C,CAAC,CAAC;IACF,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE;QACvB,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ;YACxB,IAAI,IAAI,KAAK,SAAS;gBAAE,OAAO,OAAO,CAAC;YACvC,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FastMCP } from "fastmcp";
|
|
2
|
+
import type { AgentSessionTracker } from "../../core/agent-sessions.js";
|
|
2
3
|
import type { ToolCallStore } from "../../core/tool-call-store.js";
|
|
3
4
|
import { type ToolContext } from "./context.js";
|
|
4
5
|
/**
|
|
@@ -9,10 +10,11 @@ import { type ToolContext } from "./context.js";
|
|
|
9
10
|
* a new domain module and register it below. This aggregator never grows a
|
|
10
11
|
* per-tool branch.
|
|
11
12
|
*/
|
|
12
|
-
export declare const NOMOREIDE_TOOL_NAMES: readonly ["nomoreide_list_services", "nomoreide_register_service", "nomoreide_start_service", "nomoreide_stop_service", "nomoreide_restart_service", "nomoreide_read_logs", "nomoreide_register_bundle", "nomoreide_start_bundle", "nomoreide_stop_bundle", "nomoreide_status", "nomoreide_service_context", "nomoreide_service_health", "nomoreide_timeline", "nomoreide_onboard_repo", "nomoreide_git_status", "nomoreide_git_branches", "nomoreide_git_switch_branch", "nomoreide_git_create_branch", "nomoreide_git_fetch", "nomoreide_git_diff", "nomoreide_git_staged_diff", "nomoreide_git_log", "nomoreide_git_stage", "nomoreide_git_unstage", "nomoreide_git_commit", "nomoreide_git_push", "nomoreide_git_register_repository", "nomoreide_git_select_repository", "nomoreide_github_set_token", "nomoreide_github_list_prs", "nomoreide_github_get_pr", "nomoreide_github_get_pr_diff", "nomoreide_github_create_pr", "nomoreide_github_merge_pr", "nomoreide_github_list_issues", "nomoreide_github_get_issue", "nomoreide_github_list_issue_comments", "nomoreide_github_add_issue_comment", "nomoreide_github_create_issue", "nomoreide_github_get_commit_ci", "nomoreide_github_list_workflow_runs", "nomoreide_list_errors", "nomoreide_error_prompt", "nomoreide_list_databases", "nomoreide_db_tables", "nomoreide_db_sample", "nomoreide_db_query", "nomoreide_docs", "nomoreide_open_ui", "nomoreide_close_ui"];
|
|
13
|
+
export declare const NOMOREIDE_TOOL_NAMES: readonly ["nomoreide_list_services", "nomoreide_register_service", "nomoreide_start_service", "nomoreide_stop_service", "nomoreide_restart_service", "nomoreide_read_logs", "nomoreide_register_bundle", "nomoreide_start_bundle", "nomoreide_stop_bundle", "nomoreide_status", "nomoreide_service_context", "nomoreide_service_health", "nomoreide_timeline", "nomoreide_onboard_repo", "nomoreide_git_status", "nomoreide_git_branches", "nomoreide_git_switch_branch", "nomoreide_git_create_branch", "nomoreide_git_fetch", "nomoreide_git_diff", "nomoreide_git_staged_diff", "nomoreide_git_log", "nomoreide_git_stage", "nomoreide_git_unstage", "nomoreide_git_commit", "nomoreide_git_push", "nomoreide_git_register_repository", "nomoreide_git_select_repository", "nomoreide_snapshots_list", "nomoreide_snapshot_create", "nomoreide_github_set_token", "nomoreide_github_list_prs", "nomoreide_github_get_pr", "nomoreide_github_get_pr_diff", "nomoreide_github_create_pr", "nomoreide_github_merge_pr", "nomoreide_github_list_issues", "nomoreide_github_get_issue", "nomoreide_github_list_issue_comments", "nomoreide_github_add_issue_comment", "nomoreide_github_create_issue", "nomoreide_github_get_commit_ci", "nomoreide_github_list_workflow_runs", "nomoreide_list_errors", "nomoreide_error_prompt", "nomoreide_list_databases", "nomoreide_db_tables", "nomoreide_db_sample", "nomoreide_db_query", "nomoreide_docs", "nomoreide_open_ui", "nomoreide_close_ui"];
|
|
13
14
|
interface RegisterNoMoreIdeToolsOptions extends ToolContext {
|
|
14
15
|
server: FastMCP;
|
|
15
16
|
toolCallStore?: ToolCallStore;
|
|
17
|
+
agentSessions?: AgentSessionTracker;
|
|
16
18
|
}
|
|
17
19
|
export declare function registerNoMoreIdeTools(options: RegisterNoMoreIdeToolsOptions): void;
|
|
18
20
|
export type { ToolContext } from "./context.js";
|
package/dist/mcp/tools/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { GIT_TOOL_NAMES, registerGitTools } from "./git.js";
|
|
|
7
7
|
import { GITHUB_TOOL_NAMES, registerGithubTools } from "./github.js";
|
|
8
8
|
import { ONBOARD_TOOL_NAMES, registerOnboardTools } from "./onboard.js";
|
|
9
9
|
import { registerServiceTools, SERVICE_TOOL_NAMES } from "./services.js";
|
|
10
|
+
import { registerSnapshotTools, SNAPSHOT_TOOL_NAMES } from "./snapshots.js";
|
|
10
11
|
/**
|
|
11
12
|
* Every tool name NoMoreIDE exposes, in registration order. Each domain owns
|
|
12
13
|
* its own slice; this aggregates them — mirroring the web route registry.
|
|
@@ -19,6 +20,7 @@ export const NOMOREIDE_TOOL_NAMES = [
|
|
|
19
20
|
...SERVICE_TOOL_NAMES,
|
|
20
21
|
...ONBOARD_TOOL_NAMES,
|
|
21
22
|
...GIT_TOOL_NAMES,
|
|
23
|
+
...SNAPSHOT_TOOL_NAMES,
|
|
22
24
|
...GITHUB_TOOL_NAMES,
|
|
23
25
|
...ERROR_TOOL_NAMES,
|
|
24
26
|
...DATABASE_TOOL_NAMES,
|
|
@@ -26,13 +28,14 @@ export const NOMOREIDE_TOOL_NAMES = [
|
|
|
26
28
|
...AGENT_TOOL_NAMES,
|
|
27
29
|
];
|
|
28
30
|
export function registerNoMoreIdeTools(options) {
|
|
29
|
-
const { server: rawServer, toolCallStore, ...ctx } = options;
|
|
31
|
+
const { server: rawServer, toolCallStore, agentSessions, ...ctx } = options;
|
|
30
32
|
const server = toolCallStore
|
|
31
|
-
? wrapServerForRecording(rawServer, toolCallStore)
|
|
33
|
+
? wrapServerForRecording(rawServer, toolCallStore, agentSessions)
|
|
32
34
|
: rawServer;
|
|
33
35
|
registerServiceTools(server, ctx);
|
|
34
36
|
registerOnboardTools(server, ctx);
|
|
35
37
|
registerGitTools(server, ctx);
|
|
38
|
+
registerSnapshotTools(server, ctx);
|
|
36
39
|
registerGithubTools(server, ctx);
|
|
37
40
|
registerErrorTools(server, ctx);
|
|
38
41
|
registerDatabaseTools(server, ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp/tools/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp/tools/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAoB,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE5E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,GAAG,kBAAkB;IACrB,GAAG,kBAAkB;IACrB,GAAG,cAAc;IACjB,GAAG,mBAAmB;IACtB,GAAG,iBAAiB;IACpB,GAAG,gBAAgB;IACnB,GAAG,mBAAmB;IACtB,GAAG,cAAc;IACjB,GAAG,gBAAgB;CACX,CAAC;AAQX,MAAM,UAAU,sBAAsB,CACpC,OAAsC;IAEtC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC;IAC5E,MAAM,MAAM,GAAG,aAAa;QAC1B,CAAC,CAAC,sBAAsB,CAAC,SAAS,EAAE,aAAa,EAAE,aAAa,CAAC;QACjE,CAAC,CAAC,SAAS,CAAC;IAEd,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAClC,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAClC,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,qBAAqB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,kBAAkB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,qBAAqB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,kBAAkB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FastMCP } from "fastmcp";
|
|
2
|
+
import { type ToolContext } from "./context.js";
|
|
3
|
+
export declare const SNAPSHOT_TOOL_NAMES: readonly ["nomoreide_snapshots_list", "nomoreide_snapshot_create"];
|
|
4
|
+
/**
|
|
5
|
+
* Read/create only — restore is destructive and stays human-only (web UI
|
|
6
|
+
* with confirmation), mirroring the DbWrite boundary.
|
|
7
|
+
*/
|
|
8
|
+
export declare function registerSnapshotTools(server: FastMCP, _ctx: ToolContext): void;
|