nomoreide 0.1.61 → 0.1.63
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/fix-loop.d.ts +55 -0
- package/dist/core/fix-loop.js +73 -0
- package/dist/core/fix-loop.js.map +1 -0
- package/dist/web/client/assets/{code-editor-DqtEBM4Y.js → code-editor-CfUFgwHT.js} +1 -1
- package/dist/web/client/assets/{index-CuTdDFQe.js → index-D2mAOWKY.js} +69 -69
- package/dist/web/client/index.html +1 -1
- package/dist/web/routes/context.d.ts +2 -0
- package/dist/web/routes/context.js.map +1 -1
- package/dist/web/routes/errors-routes.js +21 -1
- package/dist/web/routes/errors-routes.js.map +1 -1
- package/dist/web/server.js +10 -0
- package/dist/web/server.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AgentSessionStore } from "./agent-sessions.js";
|
|
2
|
+
import type { ReproBundleBuilder } from "./repro-bundle.js";
|
|
3
|
+
import { SnapshotManager } from "./snapshot-manager.js";
|
|
4
|
+
/**
|
|
5
|
+
* The Error → Fix loop. Closes the AI-native circle: turn an Error Inbox
|
|
6
|
+
* incident into one agent task whose result is a reviewable, one-click-revertable
|
|
7
|
+
* change-set.
|
|
8
|
+
*
|
|
9
|
+
* Today the separate features (Error Inbox, repro bundle, snapshot/restore,
|
|
10
|
+
* change-set review) are chained by hand. {@link FixLoop.prepare} stitches them:
|
|
11
|
+
* it builds the repro bundle, snapshots the working tree, and records an agent
|
|
12
|
+
* session pinned to that snapshot — so whatever the in-dock agent then edits
|
|
13
|
+
* surfaces in Agent → Changes with a "restore to before this session" button.
|
|
14
|
+
*
|
|
15
|
+
* Why the snapshot is taken here rather than auto-firing: the in-dock agent
|
|
16
|
+
* runs the Claude/Codex CLI directly (it does not go through NoMoreIDE's MCP),
|
|
17
|
+
* so the MCP recording wrapper's auto-snapshot never triggers for a dock run.
|
|
18
|
+
* The fix endpoint must capture the pre-fix state itself.
|
|
19
|
+
*/
|
|
20
|
+
export interface FixPreparation {
|
|
21
|
+
/** Recorded agent session id; the change-set/restore endpoints key off this. */
|
|
22
|
+
sessionId: string;
|
|
23
|
+
/** The fix prompt (repro bundle wrapped in a fix instruction) for the dock. */
|
|
24
|
+
prompt: string;
|
|
25
|
+
/** Repository the snapshot was taken in (where the agent will edit). */
|
|
26
|
+
repoPath: string;
|
|
27
|
+
/** Snapshot sha, or undefined when the repo isn't a git working tree. */
|
|
28
|
+
snapshotSha?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface FixLoopOptions {
|
|
31
|
+
reproBundle: ReproBundleBuilder;
|
|
32
|
+
agentSessions: AgentSessionStore;
|
|
33
|
+
/** Resolve the repo the agent will edit (the selected git repository). */
|
|
34
|
+
resolveRepoPath: () => Promise<string>;
|
|
35
|
+
/** Injectable for tests. */
|
|
36
|
+
snapshotManagerFor?: (repoPath: string) => Pick<SnapshotManager, "snapshot" | "prune">;
|
|
37
|
+
now?: () => number;
|
|
38
|
+
}
|
|
39
|
+
export declare class FixLoop {
|
|
40
|
+
private readonly reproBundle;
|
|
41
|
+
private readonly agentSessions;
|
|
42
|
+
private readonly resolveRepoPath;
|
|
43
|
+
private readonly snapshotManagerFor;
|
|
44
|
+
private readonly now;
|
|
45
|
+
constructor(options: FixLoopOptions);
|
|
46
|
+
/**
|
|
47
|
+
* Prepare a fix for an incident: build the repro bundle, snapshot the working
|
|
48
|
+
* tree, and record the session. Returns null when the incident is unknown.
|
|
49
|
+
* Never throws on a missing/non-git repo — the session is recorded without a
|
|
50
|
+
* snapshot so the run still proceeds (just no reviewable change-set).
|
|
51
|
+
*/
|
|
52
|
+
prepare(incidentId: number): Promise<FixPreparation | null>;
|
|
53
|
+
}
|
|
54
|
+
/** Wrap the repro-bundle markdown in a concise fix instruction for the agent. */
|
|
55
|
+
export declare function buildFixPrompt(markdown: string): string;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { SnapshotManager } from "./snapshot-manager.js";
|
|
2
|
+
const SNAPSHOT_KEEP = 50;
|
|
3
|
+
export class FixLoop {
|
|
4
|
+
reproBundle;
|
|
5
|
+
agentSessions;
|
|
6
|
+
resolveRepoPath;
|
|
7
|
+
snapshotManagerFor;
|
|
8
|
+
now;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.reproBundle = options.reproBundle;
|
|
11
|
+
this.agentSessions = options.agentSessions;
|
|
12
|
+
this.resolveRepoPath = options.resolveRepoPath;
|
|
13
|
+
this.snapshotManagerFor =
|
|
14
|
+
options.snapshotManagerFor ?? ((repoPath) => new SnapshotManager(repoPath));
|
|
15
|
+
this.now = options.now ?? Date.now;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Prepare a fix for an incident: build the repro bundle, snapshot the working
|
|
19
|
+
* tree, and record the session. Returns null when the incident is unknown.
|
|
20
|
+
* Never throws on a missing/non-git repo — the session is recorded without a
|
|
21
|
+
* snapshot so the run still proceeds (just no reviewable change-set).
|
|
22
|
+
*/
|
|
23
|
+
async prepare(incidentId) {
|
|
24
|
+
const bundle = await this.reproBundle.build(incidentId);
|
|
25
|
+
if (!bundle)
|
|
26
|
+
return null;
|
|
27
|
+
const repoPath = await this.resolveRepoPath();
|
|
28
|
+
const startedAt = new Date(this.now()).toISOString();
|
|
29
|
+
const session = {
|
|
30
|
+
id: `s-${this.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`,
|
|
31
|
+
repoPath,
|
|
32
|
+
startedAt,
|
|
33
|
+
lastToolAt: startedAt,
|
|
34
|
+
toolCount: 0,
|
|
35
|
+
};
|
|
36
|
+
try {
|
|
37
|
+
const manager = this.snapshotManagerFor(repoPath);
|
|
38
|
+
const snapshot = await manager.snapshot(`fix incident ${incidentId}`);
|
|
39
|
+
session.snapshotSha = snapshot.sha;
|
|
40
|
+
session.snapshotRef = snapshot.ref;
|
|
41
|
+
await manager.prune(SNAPSHOT_KEEP);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Not a git repo (or git unavailable) — record the session without a
|
|
45
|
+
// snapshot. The fix still runs; there just isn't a change-set to review.
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
await this.agentSessions.save(session);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// Persistence is best-effort; never block the fix on it.
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
sessionId: session.id,
|
|
55
|
+
prompt: buildFixPrompt(bundle.markdown),
|
|
56
|
+
repoPath,
|
|
57
|
+
snapshotSha: session.snapshotSha,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** Wrap the repro-bundle markdown in a concise fix instruction for the agent. */
|
|
62
|
+
export function buildFixPrompt(markdown) {
|
|
63
|
+
return [
|
|
64
|
+
"A bug was detected in this workspace. Below is an automatically assembled repro bundle: the error, the affected file's diff, recent logs, the service's runtime state, and its environment with secrets masked.",
|
|
65
|
+
"",
|
|
66
|
+
"Investigate the root cause and apply the smallest change that resolves it. When you are done, briefly summarize what you changed and why. Your edits are snapshotted, so they can be reviewed and reverted as a single change-set.",
|
|
67
|
+
"",
|
|
68
|
+
"---",
|
|
69
|
+
"",
|
|
70
|
+
markdown,
|
|
71
|
+
].join("\n");
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=fix-loop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-loop.js","sourceRoot":"","sources":["../../src/core/fix-loop.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAiB,MAAM,uBAAuB,CAAC;AAwCvE,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,MAAM,OAAO,OAAO;IACD,WAAW,CAAqB;IAChC,aAAa,CAAoB;IACjC,eAAe,CAAwB;IACvC,kBAAkB,CAEc;IAChC,GAAG,CAAe;IAEnC,YAAY,OAAuB;QACjC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC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