nomoreide 0.1.53 → 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/core/workflows.d.ts +22 -0
- package/dist/core/workflows.js +19 -1
- package/dist/core/workflows.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-CFwgiwCM.js → code-editor-CLZ4YEu4.js} +1 -1
- package/dist/web/client/assets/index-CD3YkYz8.css +1 -0
- package/dist/web/client/assets/{index-DixOCrTR.js → index-siG6R1Rg.js} +140 -140
- 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-D2WEod6o.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;I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
3
|
+
ref: string;
|
|
4
|
+
label: string;
|
|
5
|
+
createdAt: string;
|
|
6
|
+
}
|
|
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;I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C,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,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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ACnB,CAAC;AACH,CAAC"}
|
package/dist/core/workflows.d.ts
CHANGED
|
@@ -62,6 +62,14 @@ export declare const workflowStepSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodO
|
|
|
62
62
|
plugins?: string[] | undefined;
|
|
63
63
|
hooks?: string[] | undefined;
|
|
64
64
|
}>>;
|
|
65
|
+
/**
|
|
66
|
+
* Run this step in a fresh, one-shot agent session instead of resuming the
|
|
67
|
+
* dock conversation. Much cheaper — the model isn't re-fed every earlier
|
|
68
|
+
* step's transcript and tool output — but the step gets no shared memory, so
|
|
69
|
+
* only set it on self-contained steps (e.g. drafting a commit message, not
|
|
70
|
+
* "merge the PR you just opened").
|
|
71
|
+
*/
|
|
72
|
+
isolated: z.ZodOptional<z.ZodBoolean>;
|
|
65
73
|
/**
|
|
66
74
|
* Real-state check run after the agent's turn before advancing:
|
|
67
75
|
* - `committed` — the working tree is clean (changes were committed).
|
|
@@ -79,6 +87,7 @@ export declare const workflowStepSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodO
|
|
|
79
87
|
plugins?: string[] | undefined;
|
|
80
88
|
hooks?: string[] | undefined;
|
|
81
89
|
} | undefined;
|
|
90
|
+
isolated?: boolean | undefined;
|
|
82
91
|
verify?: "committed" | "pushed" | undefined;
|
|
83
92
|
}, {
|
|
84
93
|
kind: "agent";
|
|
@@ -91,6 +100,7 @@ export declare const workflowStepSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodO
|
|
|
91
100
|
plugins?: string[] | undefined;
|
|
92
101
|
hooks?: string[] | undefined;
|
|
93
102
|
} | undefined;
|
|
103
|
+
isolated?: boolean | undefined;
|
|
94
104
|
verify?: "committed" | "pushed" | undefined;
|
|
95
105
|
}>, z.ZodObject<{
|
|
96
106
|
kind: z.ZodLiteral<"gate">;
|
|
@@ -161,6 +171,14 @@ export declare const workflowSchema: z.ZodObject<{
|
|
|
161
171
|
plugins?: string[] | undefined;
|
|
162
172
|
hooks?: string[] | undefined;
|
|
163
173
|
}>>;
|
|
174
|
+
/**
|
|
175
|
+
* Run this step in a fresh, one-shot agent session instead of resuming the
|
|
176
|
+
* dock conversation. Much cheaper — the model isn't re-fed every earlier
|
|
177
|
+
* step's transcript and tool output — but the step gets no shared memory, so
|
|
178
|
+
* only set it on self-contained steps (e.g. drafting a commit message, not
|
|
179
|
+
* "merge the PR you just opened").
|
|
180
|
+
*/
|
|
181
|
+
isolated: z.ZodOptional<z.ZodBoolean>;
|
|
164
182
|
/**
|
|
165
183
|
* Real-state check run after the agent's turn before advancing:
|
|
166
184
|
* - `committed` — the working tree is clean (changes were committed).
|
|
@@ -178,6 +196,7 @@ export declare const workflowSchema: z.ZodObject<{
|
|
|
178
196
|
plugins?: string[] | undefined;
|
|
179
197
|
hooks?: string[] | undefined;
|
|
180
198
|
} | undefined;
|
|
199
|
+
isolated?: boolean | undefined;
|
|
181
200
|
verify?: "committed" | "pushed" | undefined;
|
|
182
201
|
}, {
|
|
183
202
|
kind: "agent";
|
|
@@ -190,6 +209,7 @@ export declare const workflowSchema: z.ZodObject<{
|
|
|
190
209
|
plugins?: string[] | undefined;
|
|
191
210
|
hooks?: string[] | undefined;
|
|
192
211
|
} | undefined;
|
|
212
|
+
isolated?: boolean | undefined;
|
|
193
213
|
verify?: "committed" | "pushed" | undefined;
|
|
194
214
|
}>, z.ZodObject<{
|
|
195
215
|
kind: z.ZodLiteral<"gate">;
|
|
@@ -227,6 +247,7 @@ export declare const workflowSchema: z.ZodObject<{
|
|
|
227
247
|
plugins?: string[] | undefined;
|
|
228
248
|
hooks?: string[] | undefined;
|
|
229
249
|
} | undefined;
|
|
250
|
+
isolated?: boolean | undefined;
|
|
230
251
|
verify?: "committed" | "pushed" | undefined;
|
|
231
252
|
} | {
|
|
232
253
|
message: string;
|
|
@@ -255,6 +276,7 @@ export declare const workflowSchema: z.ZodObject<{
|
|
|
255
276
|
plugins?: string[] | undefined;
|
|
256
277
|
hooks?: string[] | undefined;
|
|
257
278
|
} | undefined;
|
|
279
|
+
isolated?: boolean | undefined;
|
|
258
280
|
verify?: "committed" | "pushed" | undefined;
|
|
259
281
|
} | {
|
|
260
282
|
message: string;
|
package/dist/core/workflows.js
CHANGED
|
@@ -45,6 +45,14 @@ export const workflowStepSchema = z.discriminatedUnion("kind", [
|
|
|
45
45
|
prompt: z.string().min(1),
|
|
46
46
|
/** Optional user-selected capabilities the runner adds as prompt guidance. */
|
|
47
47
|
capabilities: workflowCapabilitiesSchema.optional(),
|
|
48
|
+
/**
|
|
49
|
+
* Run this step in a fresh, one-shot agent session instead of resuming the
|
|
50
|
+
* dock conversation. Much cheaper — the model isn't re-fed every earlier
|
|
51
|
+
* step's transcript and tool output — but the step gets no shared memory, so
|
|
52
|
+
* only set it on self-contained steps (e.g. drafting a commit message, not
|
|
53
|
+
* "merge the PR you just opened").
|
|
54
|
+
*/
|
|
55
|
+
isolated: z.boolean().optional(),
|
|
48
56
|
/**
|
|
49
57
|
* Real-state check run after the agent's turn before advancing:
|
|
50
58
|
* - `committed` — the working tree is clean (changes were committed).
|
|
@@ -82,6 +90,10 @@ const COMMIT_MESSAGE_STEP = {
|
|
|
82
90
|
kind: "agent",
|
|
83
91
|
id: "commit-message",
|
|
84
92
|
title: "Generate commit message",
|
|
93
|
+
// Self-contained: it stages, reads its own staged diff, and replies with just
|
|
94
|
+
// the message (which the commit action consumes). No later step needs its
|
|
95
|
+
// session, so run it isolated to avoid re-feeding the dock transcript.
|
|
96
|
+
isolated: true,
|
|
85
97
|
prompt: "Stage my changes with `nomoreide_git_stage` (skip anything that looks like a secret, e.g. `.env`), inspect the staged diff once with `nomoreide_git_staged_diff`, then write one conventional-commit message — a `<type>: concise title` line (feat/fix/refactor/chore/docs/test) plus a few short bullets of what changed. Do NOT commit. Reply with ONLY the commit message you recommend.",
|
|
86
98
|
};
|
|
87
99
|
const COMMIT_ACTION_STEP = {
|
|
@@ -136,6 +148,9 @@ export const BUILTIN_WORKFLOWS = [
|
|
|
136
148
|
kind: "agent",
|
|
137
149
|
id: "open-pr",
|
|
138
150
|
title: "Open a PR",
|
|
151
|
+
// Self-contained: gathers its own commit list, so it needs no prior
|
|
152
|
+
// session — run it isolated. The merge step below finds the PR itself.
|
|
153
|
+
isolated: true,
|
|
139
154
|
prompt: "Open a PR for the current branch into `main` using the `nomoreide_github_create_pr` tool. Title = the latest commit subject; for the body, list the commits via `nomoreide_git_log`. Do NOT read file diffs. Reply with just the PR number and URL.",
|
|
140
155
|
},
|
|
141
156
|
{ kind: "gate", id: "gate-merge", title: "Approve merge", message: "Squash-merge the pull request?" },
|
|
@@ -143,7 +158,10 @@ export const BUILTIN_WORKFLOWS = [
|
|
|
143
158
|
kind: "agent",
|
|
144
159
|
id: "merge",
|
|
145
160
|
title: "Squash-merge",
|
|
146
|
-
|
|
161
|
+
// Finds the PR by branch rather than relying on the open-pr step's
|
|
162
|
+
// session, so it can run isolated too.
|
|
163
|
+
isolated: true,
|
|
164
|
+
prompt: "Squash-merge the open pull request for the current branch. First call `nomoreide_git_status` for the branch name, then `nomoreide_github_list_prs` to find its open PR, then merge it with `nomoreide_github_merge_pr`. Don't analyze anything else — just find it and merge. Reply with one line.",
|
|
147
165
|
},
|
|
148
166
|
CHECKOUT_DEFAULT_AND_PULL_STEP,
|
|
149
167
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.js","sourceRoot":"","sources":["../../src/core/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC7C,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACjD,OAAO,EAAE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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,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,4B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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;
|