wisp-agents 0.18.0 → 0.21.0
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/CHANGELOG.md +62 -1
- package/README.md +23 -7
- package/bin/wisp.js +4 -3
- package/package.json +2 -2
- package/server/adapters/antigravity.js +2 -1
- package/server/adapters/claude.js +7 -5
- package/server/adapters/codex.js +7 -3
- package/server/adapters/commands.js +808 -0
- package/server/adapters/cursor.js +2 -1
- package/server/adapters/grok.js +2 -1
- package/server/adapters/opencode.js +2 -1
- package/server/check.js +205 -0
- package/server/client.js +3 -2
- package/server/index.js +2 -1
- package/server/judge.js +78 -0
- package/server/mcp-wisp.js +2 -1
- package/server/openapi.js +4 -3
- package/server/pipeline.js +217 -0
- package/server/quick.js +76 -0
- package/server/router.js +201 -28
- package/server/routes/auto.js +8 -1
- package/server/routes/sessions.js +15 -8
- package/server/routes/settings.js +2 -0
- package/server/routes/ship.js +27 -27
- package/server/runner.js +83 -17
- package/server/scout.js +71 -0
- package/server/services/auto.js +111 -14
- package/server/services/launch.js +45 -8
- package/server/services/ship.js +132 -23
- package/skills/wisp/SKILL.md +2 -1
- package/web/css/auto.css +22 -0
- package/web/css/feed.css +3 -0
- package/web/css/launcher.css +12 -0
- package/web/css/palette.css +6 -0
- package/web/css/ship.css +17 -1
- package/web/index.html +1 -0
- package/web/js/blocks.js +1 -1
- package/web/js/core/state.js +4 -2
- package/web/js/features/actions.js +3 -5
- package/web/js/features/auto.js +38 -7
- package/web/js/features/composer.js +2 -4
- package/web/js/features/feed.js +40 -10
- package/web/js/features/launcher.js +62 -18
- package/web/js/features/live.js +2 -7
- package/web/js/features/places.js +10 -0
- package/web/js/features/project-list.js +20 -5
- package/web/js/features/projects.js +6 -8
- package/web/js/features/runners.js +7 -6
- package/web/js/features/settings.js +34 -8
- package/web/js/features/ship.js +95 -31
- package/web/js/features/turns.js +6 -4
- package/web/js/ui/popover.js +10 -0
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// ask_user tool isn't available here; the protocol tells the agent to end with a question block.
|
|
5
5
|
|
|
6
6
|
import { attachmentNote, clip, detectVersion, exitText, fileTracker, quietOutput, rel, spawnJsonl, withProtocol } from './common.js';
|
|
7
|
+
import { describeCommand } from './commands.js';
|
|
7
8
|
|
|
8
9
|
const BIN = process.env.WISP_CURSOR_BIN || 'cursor-agent';
|
|
9
10
|
|
|
@@ -130,7 +131,7 @@ function describeTool(name, a, cwd) {
|
|
|
130
131
|
case 'deleteToolCall':
|
|
131
132
|
return { kind: 'edit', label: `Deleting ${f}`, file: f };
|
|
132
133
|
case 'shellToolCall':
|
|
133
|
-
return { kind: 'run', label: a.description ? clip(a.description) :
|
|
134
|
+
return { kind: 'run', label: a.description ? clip(a.description) : describeCommand(a.command, cwd), detail: a.command };
|
|
134
135
|
case 'grepToolCall':
|
|
135
136
|
return { kind: 'search', label: `Searching for “${clip(a.pattern, 40)}”` };
|
|
136
137
|
case 'globToolCall':
|
package/server/adapters/grok.js
CHANGED
|
@@ -10,6 +10,7 @@ import fs from 'node:fs';
|
|
|
10
10
|
import os from 'node:os';
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import { ASK_TIMEOUT_MS, attachmentNote, clip, detectVersion, exitText, fileTracker, flatten, quietOutput, rel, spawnJsonl } from './common.js';
|
|
13
|
+
import { describeCommand } from './commands.js';
|
|
13
14
|
|
|
14
15
|
const BIN = process.env.WISP_GROK_BIN || 'grok';
|
|
15
16
|
|
|
@@ -195,7 +196,7 @@ function describeTool(name, input, cwd) {
|
|
|
195
196
|
return { kind: 'edit', label: `Writing ${f}`, file: f };
|
|
196
197
|
case 'run_terminal_command':
|
|
197
198
|
case 'run_terminal_cmd':
|
|
198
|
-
return { kind: 'run', label: input.description ? clip(input.description) :
|
|
199
|
+
return { kind: 'run', label: input.description ? clip(input.description) : describeCommand(input.command, cwd), detail: input.command };
|
|
199
200
|
case 'grep':
|
|
200
201
|
return { kind: 'search', label: `Searching for “${clip(input.pattern, 40)}”` };
|
|
201
202
|
case 'list_dir':
|
|
@@ -5,6 +5,7 @@ import os from 'node:os';
|
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { toolsDir } from '../util.js';
|
|
7
7
|
import { ASK_TIMEOUT_MS, attachmentNote, clip, detectVersion, exitText, fileTracker, quietOutput, rel, spawnJsonl, withProtocol } from './common.js';
|
|
8
|
+
import { describeCommand } from './commands.js';
|
|
8
9
|
|
|
9
10
|
const exe = process.platform === 'win32' ? 'opencode.cmd' : 'opencode';
|
|
10
11
|
// Where opencode lives when it isn't on PATH: the copy wisp installs (POST /agents/install),
|
|
@@ -213,7 +214,7 @@ function describeTool(name, input, cwd) {
|
|
|
213
214
|
return { kind: 'edit', label: `Writing ${f}`, file: f };
|
|
214
215
|
case 'bash':
|
|
215
216
|
case 'shell':
|
|
216
|
-
return { kind: 'run', label: input.description ? clip(input.description) :
|
|
217
|
+
return { kind: 'run', label: input.description ? clip(input.description) : describeCommand(input.command, cwd), detail: input.command };
|
|
217
218
|
case 'grep':
|
|
218
219
|
return { kind: 'search', label: `Searching for “${clip(input.pattern, 40)}”` };
|
|
219
220
|
case 'glob':
|
package/server/check.js
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// wisp's own test check: after an Auto turn, wisp runs the project's tests itself instead of taking
|
|
2
|
+
// the agent's word for it (in the wisp-bench pilot, 19 of 20 failed runs still said "done").
|
|
3
|
+
//
|
|
4
|
+
// detectTests(dir, project) finds the command; runCheck(dir, command) runs it and reads which tests
|
|
5
|
+
// failed from the usual reporters (node --test, jest/vitest, pytest, go, cargo, rspec). A failure
|
|
6
|
+
// only counts against the agent when it's new: check() compares with the same command on the
|
|
7
|
+
// task's base commit (a throwaway worktree, cached per base and command), and runs a failing
|
|
8
|
+
// command twice so a flaky test doesn't send the agent off to fix nothing.
|
|
9
|
+
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
import os from 'node:os';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import { spawn } from 'node:child_process';
|
|
14
|
+
import { git } from './git.js';
|
|
15
|
+
import { killTree } from './proc.js';
|
|
16
|
+
|
|
17
|
+
const MAX_OUTPUT = 400 * 1024;
|
|
18
|
+
export const CHECK_TIMEOUT_MS = Number(process.env.WISP_CHECK_TIMEOUT_MS || 10 * 60_000);
|
|
19
|
+
|
|
20
|
+
const read = (f) => {
|
|
21
|
+
try {
|
|
22
|
+
return fs.readFileSync(f, 'utf8');
|
|
23
|
+
} catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const has = (dir, f) => fs.existsSync(path.join(dir, f));
|
|
28
|
+
|
|
29
|
+
// { command, kind, why } | { skip: reason } | null (nothing that looks like tests).
|
|
30
|
+
// project.testCommand overrides it; 'off' turns the check off for that project.
|
|
31
|
+
export function detectTests(dir, project = null) {
|
|
32
|
+
const custom = String(project?.testCommand || '').trim();
|
|
33
|
+
if (custom === 'off') return { skip: 'Turned off for this project' };
|
|
34
|
+
if (custom) return { command: custom, kind: 'custom', why: 'Set for this project' };
|
|
35
|
+
|
|
36
|
+
const pkg = JSON.parse(read(path.join(dir, 'package.json')) || 'null');
|
|
37
|
+
const script = pkg?.scripts?.test;
|
|
38
|
+
if (script && !/no test specified/.test(script)) {
|
|
39
|
+
const deps = Object.keys({ ...pkg.dependencies, ...pkg.devDependencies });
|
|
40
|
+
if (deps.length && !has(dir, 'node_modules')) return { skip: 'Dependencies are not installed in this worktree (no node_modules)' };
|
|
41
|
+
const pm = has(dir, 'pnpm-lock.yaml') ? 'pnpm' : has(dir, 'yarn.lock') ? 'yarn' : has(dir, 'bun.lockb') || has(dir, 'bun.lock') ? 'bun' : 'npm';
|
|
42
|
+
return { command: `${pm} test`, kind: 'node', why: 'package.json "test" script' };
|
|
43
|
+
}
|
|
44
|
+
const py = ['pytest.ini', 'tox.ini', 'conftest.py'].some((f) => has(dir, f)) || /\[tool\.pytest/.test(read(path.join(dir, 'pyproject.toml')) || '') || /\[tool:pytest\]/.test(read(path.join(dir, 'setup.cfg')) || '') || (has(dir, 'tests') && fs.readdirSync(path.join(dir, 'tests')).some((f) => /^test_.*\.py$|_test\.py$/.test(f)));
|
|
45
|
+
if (py) {
|
|
46
|
+
const python = ['.venv/bin/python', 'venv/bin/python', '.venv/Scripts/python.exe'].find((p) => has(dir, p)) || 'python3';
|
|
47
|
+
return { command: `${python} -m pytest -q -rA`, kind: 'pytest', why: 'pytest configuration' };
|
|
48
|
+
}
|
|
49
|
+
if (has(dir, 'go.mod')) return { command: 'go test ./...', kind: 'go', why: 'go.mod' };
|
|
50
|
+
if (has(dir, 'Cargo.toml')) return { command: 'cargo test', kind: 'cargo', why: 'Cargo.toml' };
|
|
51
|
+
if (has(dir, 'Gemfile') && has(dir, 'spec')) return { command: 'bundle exec rspec', kind: 'rspec', why: 'Gemfile and spec/' };
|
|
52
|
+
if (/^test:/m.test(read(path.join(dir, 'Makefile')) || '')) return { command: 'make test', kind: 'make', why: 'Makefile test target' };
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Failing test names and pass/fail counts from whatever reporter printed `out`.
|
|
57
|
+
export function parseResults(out) {
|
|
58
|
+
const failed = new Set();
|
|
59
|
+
let passed = null;
|
|
60
|
+
let failedN = null;
|
|
61
|
+
let skipped = null;
|
|
62
|
+
const add = (x) => x && failed.add(x.trim().replace(/\s+\(\d+(\.\d+)?m?s\)$/, ''));
|
|
63
|
+
for (const line of out.split('\n')) {
|
|
64
|
+
let m;
|
|
65
|
+
if ((m = line.match(/^\s*✖ (.+?)(?: \([\d.]+m?s\))?$/)) && !/^failing tests:$/.test(m[1])) add(m[1]); // node --test spec
|
|
66
|
+
else if ((m = line.match(/^not ok \d+ - (.+?)(?: # .*)?$/))) add(m[1]); // TAP, top level
|
|
67
|
+
else if ((m = line.match(/^(?:FAILED|ERROR) (\S+)/))) add(m[1]); // pytest -rA
|
|
68
|
+
else if ((m = line.match(/^\s+[✕×] (.+?)(?: \(\d+ ?ms\))?$/))) add(m[1]); // jest / vitest
|
|
69
|
+
else if ((m = line.match(/^--- FAIL: (\S+)/))) add(m[1]); // go
|
|
70
|
+
else if ((m = line.match(/^test (\S+) \.\.\. FAILED/))) add(m[1]); // cargo
|
|
71
|
+
else if ((m = line.match(/^rspec (\.\/\S+)/))) add(m[1]); // rspec
|
|
72
|
+
if ((m = line.match(/^ℹ pass (\d+)/))) passed = +m[1];
|
|
73
|
+
if ((m = line.match(/^ℹ fail (\d+)/))) failedN = +m[1];
|
|
74
|
+
if ((m = line.match(/^ℹ skipped (\d+)/))) skipped = +m[1];
|
|
75
|
+
if ((m = line.match(/^# pass (\d+)/))) passed = +m[1];
|
|
76
|
+
if ((m = line.match(/^# fail (\d+)/))) failedN = +m[1];
|
|
77
|
+
if ((m = line.match(/^=+ (.*) in [\d.]+s/))) {
|
|
78
|
+
// pytest summary: "== 3 failed, 41 passed, 2 skipped in 1.2s =="
|
|
79
|
+
passed = +(m[1].match(/(\d+) passed/)?.[1] || 0);
|
|
80
|
+
failedN = +(m[1].match(/(\d+) failed/)?.[1] || 0) + +(m[1].match(/(\d+) errors?/)?.[1] || 0);
|
|
81
|
+
skipped = +(m[1].match(/(\d+) skipped/)?.[1] || 0) || null;
|
|
82
|
+
}
|
|
83
|
+
if ((m = line.match(/^Tests:\s+(.*)$/))) {
|
|
84
|
+
// jest / vitest: "Tests: 1 failed, 12 passed, 13 total"
|
|
85
|
+
passed = +(m[1].match(/(\d+) passed/)?.[1] || 0);
|
|
86
|
+
failedN = +(m[1].match(/(\d+) failed/)?.[1] || 0);
|
|
87
|
+
skipped = +(m[1].match(/(\d+) skipped/)?.[1] || 0) || null;
|
|
88
|
+
}
|
|
89
|
+
if ((m = line.match(/^test result: \w+\. (\d+) passed; (\d+) failed/))) {
|
|
90
|
+
passed = (passed || 0) + +m[1];
|
|
91
|
+
failedN = (failedN || 0) + +m[2];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return { failed: [...failed].slice(0, 200), passed, failedCount: failedN ?? failed.size, skipped };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Run `command` in dir: { exitCode, output, durationMs, timedOut, ...parseResults }.
|
|
98
|
+
export function runCheck(dir, command, { timeout = CHECK_TIMEOUT_MS, env = {} } = {}) {
|
|
99
|
+
return new Promise((resolve) => {
|
|
100
|
+
const started = Date.now();
|
|
101
|
+
let output = '';
|
|
102
|
+
let timedOut = false;
|
|
103
|
+
// Not inherited: a test runner's own markers (wisp under `node --test` would make the project's
|
|
104
|
+
// `node --test` report to it and exit 0) and wisp's.
|
|
105
|
+
const base = Object.fromEntries(Object.entries(process.env).filter(([k]) => !/^(NODE_TEST_CONTEXT|NODE_UNIQUE_ID|WISP_|FAKE_)/.test(k)));
|
|
106
|
+
const child = spawn(process.platform === 'win32' ? 'cmd.exe' : 'sh', process.platform === 'win32' ? ['/d', '/s', '/c', command] : ['-c', command], {
|
|
107
|
+
cwd: dir,
|
|
108
|
+
env: { ...base, CI: '1', FORCE_COLOR: '0', NO_COLOR: '1', ...env },
|
|
109
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
110
|
+
detached: process.platform !== 'win32',
|
|
111
|
+
});
|
|
112
|
+
const take = (d) => {
|
|
113
|
+
output += d;
|
|
114
|
+
if (output.length > MAX_OUTPUT * 2) output = output.slice(-MAX_OUTPUT);
|
|
115
|
+
};
|
|
116
|
+
child.stdout.on('data', take);
|
|
117
|
+
child.stderr.on('data', take);
|
|
118
|
+
const timer = setTimeout(() => {
|
|
119
|
+
timedOut = true;
|
|
120
|
+
killTree(child);
|
|
121
|
+
}, timeout);
|
|
122
|
+
const done = (exitCode) => {
|
|
123
|
+
clearTimeout(timer);
|
|
124
|
+
output = output.replace(/\x1b\[[0-9;]*m/g, '').slice(-MAX_OUTPUT);
|
|
125
|
+
resolve({ exitCode, output, durationMs: Date.now() - started, timedOut, ...parseResults(output) });
|
|
126
|
+
};
|
|
127
|
+
child.on('error', (err) => ((output += `\n${err.message}`), done(127)));
|
|
128
|
+
child.on('close', (code) => done(timedOut ? 124 : code ?? 1));
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// The same command at the base commit, once per (repo, base, command).
|
|
133
|
+
const baselines = new Map();
|
|
134
|
+
export async function baseline(wt, command) {
|
|
135
|
+
if (!wt?.root || !wt.head) return null;
|
|
136
|
+
const key = `${wt.root}\0${wt.head}\0${command}`;
|
|
137
|
+
if (!baselines.has(key)) {
|
|
138
|
+
baselines.set(
|
|
139
|
+
key,
|
|
140
|
+
(async () => {
|
|
141
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'wisp-base-'));
|
|
142
|
+
try {
|
|
143
|
+
await git(wt.root, ['worktree', 'add', '--quiet', '--detach', dir, wt.head]);
|
|
144
|
+
// node_modules and virtualenvs aren't in git: borrow the task's, so the base can run too.
|
|
145
|
+
for (const d of ['node_modules', '.venv', 'venv']) {
|
|
146
|
+
const from = path.join(wt.path, d);
|
|
147
|
+
if (fs.existsSync(from) && !fs.existsSync(path.join(dir, d))) fs.symlinkSync(from, path.join(dir, d), 'dir');
|
|
148
|
+
}
|
|
149
|
+
const sub = path.relative(wt.path, wt.cwd || wt.path);
|
|
150
|
+
return await runCheck(path.join(dir, sub), command);
|
|
151
|
+
} catch {
|
|
152
|
+
return null;
|
|
153
|
+
} finally {
|
|
154
|
+
await git(wt.root, ['worktree', 'remove', '--force', dir]).catch(() => {});
|
|
155
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
156
|
+
}
|
|
157
|
+
})(),
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
return baselines.get(key);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// The verdict wisp acts on. pass: exit 0, or every failure was failing on the base already.
|
|
164
|
+
// fail: tests that passed on the base fail now (twice). unknown: it failed and we can't tell why
|
|
165
|
+
// (no base to compare with, or a reporter we can't read). skip: nothing to run.
|
|
166
|
+
export async function check({ dir, project, worktree, timeout } = {}) {
|
|
167
|
+
const found = detectTests(dir, project);
|
|
168
|
+
if (!found) return { verdict: 'skip', reason: 'No test command found', command: null };
|
|
169
|
+
if (found.skip) return { verdict: 'skip', reason: found.skip, command: null };
|
|
170
|
+
const { command } = found;
|
|
171
|
+
let run = await runCheck(dir, command, { timeout });
|
|
172
|
+
if (run.exitCode === 0 && !run.timedOut) return summary('pass', command, run, [], []);
|
|
173
|
+
// Flaky? Only failures that happen twice count.
|
|
174
|
+
const again = await runCheck(dir, command, { timeout });
|
|
175
|
+
if (again.exitCode === 0 && !again.timedOut) return summary('pass', command, again, [], [], 'Passed on a second run (a flaky test)');
|
|
176
|
+
const twice = run.failed.filter((t) => again.failed.includes(t));
|
|
177
|
+
run = { ...again, failed: twice.length || !again.failed.length ? twice : again.failed };
|
|
178
|
+
const base = await baseline(worktree, command);
|
|
179
|
+
if (!base) return summary(run.failed.length || run.timedOut ? 'fail' : 'unknown', command, run, run.failed, [], 'No base to compare with');
|
|
180
|
+
if (base.exitCode === 0) return summary('fail', command, run, run.failed, []);
|
|
181
|
+
const before = new Set(base.failed);
|
|
182
|
+
const fresh = run.failed.filter((t) => !before.has(t));
|
|
183
|
+
const old = run.failed.filter((t) => before.has(t));
|
|
184
|
+
if (!run.failed.length || !base.failed.length) return summary('unknown', command, run, [], [], 'Fails on the base commit too, and the failures could not be read');
|
|
185
|
+
return summary(fresh.length ? 'fail' : 'pass', command, run, fresh, old, fresh.length ? '' : `${old.length} failing on the base commit too`);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function summary(verdict, command, run, fresh, old, note = '') {
|
|
189
|
+
const tail = run.output.split('\n').filter((l) => l.trim()).slice(-60).join('\n');
|
|
190
|
+
return {
|
|
191
|
+
verdict,
|
|
192
|
+
command,
|
|
193
|
+
exitCode: run.exitCode,
|
|
194
|
+
passed: run.passed,
|
|
195
|
+
failed: run.failedCount || run.failed.length || (run.exitCode ? 1 : 0),
|
|
196
|
+
skipped: run.skipped,
|
|
197
|
+
newFailures: fresh.slice(0, 50),
|
|
198
|
+
preexisting: old.slice(0, 50),
|
|
199
|
+
timedOut: run.timedOut,
|
|
200
|
+
durationMs: run.durationMs,
|
|
201
|
+
note,
|
|
202
|
+
output: verdict === 'pass' ? '' : tail.slice(-6000),
|
|
203
|
+
at: Date.now(),
|
|
204
|
+
};
|
|
205
|
+
}
|
package/server/client.js
CHANGED
|
@@ -132,14 +132,15 @@ export class WispClient {
|
|
|
132
132
|
// worktree: true/false overrides the default (on in git repos). compare: [{ agent, model, effort }]
|
|
133
133
|
// runs the same task on more harnesses at once, each in its own worktree. subagents:
|
|
134
134
|
// [{ name, agent, model, effort, use }] (or preset: a saved team's id) the lead can delegate to.
|
|
135
|
-
|
|
135
|
+
// also: more folders the same task works in (each git repo gets its own worktree and PR).
|
|
136
|
+
async launch({ prompt, cwd = process.cwd(), also, agent, mode, model, effort, attachments, worktree, compare, subagents, preset } = {}) {
|
|
136
137
|
if (!agent || !mode || model === undefined) {
|
|
137
138
|
const { defaults = {} } = await this.config();
|
|
138
139
|
agent ||= defaults.agent || 'auto';
|
|
139
140
|
mode ||= defaults.mode || 'auto';
|
|
140
141
|
model ??= defaults.models?.[agent] ?? (agent === defaults.agent ? defaults.model || '' : '');
|
|
141
142
|
}
|
|
142
|
-
return this.request('POST', '/sessions', { prompt, cwd: path.resolve(cwd), agent, mode, model, effort, attachments, worktree, compare, subagents, preset });
|
|
143
|
+
return this.request('POST', '/sessions', { prompt, cwd: path.resolve(cwd), also: also?.length ? also.map((d) => path.resolve(d)) : undefined, agent, mode, model, effort, attachments, worktree, compare, subagents, preset });
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
// Ship it: commit the session's worktree, push its branch, open (or update) the PR.
|
package/server/index.js
CHANGED
|
@@ -25,6 +25,7 @@ import { Routes } from './http/router.js';
|
|
|
25
25
|
import { send, eventStream } from './http/respond.js';
|
|
26
26
|
import { serveStatic } from './http/static.js';
|
|
27
27
|
import { createAuto } from './services/auto.js';
|
|
28
|
+
import { scoutNote } from './scout.js';
|
|
28
29
|
import { createFeedback } from './services/feedback.js';
|
|
29
30
|
import { createInstaller } from './services/install.js';
|
|
30
31
|
import { createLaunch } from './services/launch.js';
|
|
@@ -119,7 +120,7 @@ export async function startServer({ port = DEFAULT_PORT, host = '127.0.0.1', han
|
|
|
119
120
|
app.prefs = new Preferences(store.home);
|
|
120
121
|
app.learning = () => store.config.defaults.learn !== 'off';
|
|
121
122
|
const projectOf = (cwd) => store.projectFor(cwd)?.path || cwd;
|
|
122
|
-
runner.promptExtra = (s) => (app.learning() && s.agent !== 'wisp' ? app.prefs.prompt(projectOf(s.cwd)) : '');
|
|
123
|
+
runner.promptExtra = (s) => (app.learning() && s.agent !== 'wisp' ? app.prefs.prompt(projectOf(s.cwd)) : '') + scoutNote(s.scout);
|
|
123
124
|
app.retro = new Retro({
|
|
124
125
|
store,
|
|
125
126
|
runner,
|
package/server/judge.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Picking between two runs of the same task (best-of-2). Tests decide when they can: a run whose
|
|
2
|
+
// check passed beats one whose check failed. Otherwise a cheap model reads both diffs, and if
|
|
3
|
+
// that isn't available either, fewer new failures and then the smaller diff win.
|
|
4
|
+
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import os from 'node:os';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { execFileSync } from 'node:child_process';
|
|
9
|
+
import { askJson } from './quick.js';
|
|
10
|
+
|
|
11
|
+
const MAX_DIFF = 24_000;
|
|
12
|
+
|
|
13
|
+
// The run's changes against its base: tracked diff plus new files.
|
|
14
|
+
export function diffOf(dir, base = 'HEAD') {
|
|
15
|
+
const run = (args) => {
|
|
16
|
+
try {
|
|
17
|
+
return execFileSync('git', args, { cwd: dir, stdio: ['ignore', 'pipe', 'ignore'], maxBuffer: 64 << 20, timeout: 15_000 }).toString();
|
|
18
|
+
} catch {
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
let out = run(['diff', base, '--', '.', ':(exclude)node_modules']);
|
|
23
|
+
for (const f of run(['ls-files', '--others', '--exclude-standard']).split('\n').filter(Boolean).slice(0, 30)) {
|
|
24
|
+
try {
|
|
25
|
+
out += `\n--- /dev/null\n+++ b/${f}\n${fs.readFileSync(path.join(dir, f), 'utf8').slice(0, 4000).split('\n').map((l) => `+${l}`).join('\n')}`;
|
|
26
|
+
} catch {}
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const changed = (d) => d.split('\n').filter((l) => /^[+-](?![+-])/.test(l)).length;
|
|
32
|
+
const SCORE = { pass: 3, unknown: 2, skip: 2, fail: 0 };
|
|
33
|
+
|
|
34
|
+
// candidates: [{ id, label, check, diff }]. Resolves with { winner, why, by }.
|
|
35
|
+
export async function judge({ prompt, candidates, agents }) {
|
|
36
|
+
const [a, b] = candidates;
|
|
37
|
+
const sa = SCORE[a.check?.verdict] ?? 1;
|
|
38
|
+
const sb = SCORE[b.check?.verdict] ?? 1;
|
|
39
|
+
if (sa !== sb) {
|
|
40
|
+
const w = sa > sb ? a : b;
|
|
41
|
+
return { winner: w.id, by: 'tests', why: `${w.label}'s changes pass the tests; the other run's don't.` };
|
|
42
|
+
}
|
|
43
|
+
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'wisp-judge-'));
|
|
44
|
+
try {
|
|
45
|
+
const ask = `Two coding agents did the same task. Judge which change is better: correct, complete, minimal, and in the style of the code around it. Tests: run A ${a.check?.verdict || 'not checked'}, run B ${b.check?.verdict || 'not checked'}.
|
|
46
|
+
|
|
47
|
+
<task>
|
|
48
|
+
${String(prompt).slice(0, 4000)}
|
|
49
|
+
</task>
|
|
50
|
+
|
|
51
|
+
<run id="A" label="${a.label}">
|
|
52
|
+
${a.diff.slice(0, MAX_DIFF) || '(no changes)'}
|
|
53
|
+
</run>
|
|
54
|
+
|
|
55
|
+
<run id="B" label="${b.label}">
|
|
56
|
+
${b.diff.slice(0, MAX_DIFF) || '(no changes)'}
|
|
57
|
+
</run>
|
|
58
|
+
|
|
59
|
+
Reply with one JSON object: {"winner": "A" | "B", "why": "one sentence"}`;
|
|
60
|
+
const j = await askJson({ agents, prompt: ask, cwd, timeoutMs: 120_000 });
|
|
61
|
+
if (j && (j.winner === 'A' || j.winner === 'B')) return { winner: (j.winner === 'A' ? a : b).id, by: 'model', why: String(j.why || '').slice(0, 300) };
|
|
62
|
+
} finally {
|
|
63
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
64
|
+
}
|
|
65
|
+
const fa = a.check?.newFailures?.length ?? 0;
|
|
66
|
+
const fb = b.check?.newFailures?.length ?? 0;
|
|
67
|
+
if (fa !== fb) {
|
|
68
|
+
const w = fa < fb ? a : b;
|
|
69
|
+
return { winner: w.id, by: 'rule', why: `${w.label} leaves fewer new failing tests.` };
|
|
70
|
+
}
|
|
71
|
+
const empty = (c) => !c.diff.trim();
|
|
72
|
+
if (empty(a) !== empty(b)) {
|
|
73
|
+
const w = empty(a) ? b : a;
|
|
74
|
+
return { winner: w.id, by: 'rule', why: `${w.label} changed something; the other run didn't.` };
|
|
75
|
+
}
|
|
76
|
+
const w = changed(a.diff) <= changed(b.diff) ? a : b;
|
|
77
|
+
return { winner: w.id, by: 'rule', why: `${w.label} made the smaller change.` };
|
|
78
|
+
}
|
package/server/mcp-wisp.js
CHANGED
|
@@ -23,6 +23,7 @@ const TOOLS = [
|
|
|
23
23
|
properties: {
|
|
24
24
|
prompt: { type: 'string', description: 'The task, written as you would brief a colleague: goal, constraints, how to verify.' },
|
|
25
25
|
cwd: { type: 'string', description: 'Absolute path of the project folder. Default: this MCP server’s working directory.' },
|
|
26
|
+
also: { type: 'array', items: { type: 'string' }, description: 'Absolute paths of more folders the same agent works in (e.g. the API next to its web app). Git repos each get a worktree, and Ship it opens a PR in each.' },
|
|
26
27
|
agent: { type: 'string', enum: AGENTS, description: 'Harness to run; auto lets wisp pick harness and model from what worked before. Default: the user’s last pick in wisp.' },
|
|
27
28
|
mode: { type: 'string', enum: ['plan', 'edits', 'auto'], description: 'plan = read-only, edits = auto-accept file edits, auto = no permission prompts. Default: the user’s pick.' },
|
|
28
29
|
model: { type: 'string', description: 'Model id for that harness. Default: the user’s pick.' },
|
|
@@ -116,7 +117,7 @@ async function callTool(name, a = {}) {
|
|
|
116
117
|
switch (name) {
|
|
117
118
|
case 'wisp_launch': {
|
|
118
119
|
if (!a.prompt?.trim()) throw new Error('prompt is required');
|
|
119
|
-
const s = await c.launch({ prompt: a.prompt, cwd: a.cwd || process.cwd(), agent: a.agent, mode: a.mode, model: a.model, effort: a.effort, subagents: a.subagents, preset: a.preset });
|
|
120
|
+
const s = await c.launch({ prompt: a.prompt, cwd: a.cwd || process.cwd(), also: Array.isArray(a.also) ? a.also : undefined, agent: a.agent, mode: a.mode, model: a.model, effort: a.effort, subagents: a.subagents, preset: a.preset });
|
|
120
121
|
if (a.wait) return waitFor(s.id);
|
|
121
122
|
return `Launched session \`${s.id}\` (“${s.title}”) on ${s.agent} in ${s.cwd}, mode ${s.mode}. Call wisp_wait or wisp_get with this id for the result.`;
|
|
122
123
|
}
|
package/server/openapi.js
CHANGED
|
@@ -47,7 +47,7 @@ export function openapi({ version, port }) {
|
|
|
47
47
|
'/agents': { get: { summary: 'Installed harnesses with their models and thinking levels (?fresh=1 detects again)', responses: { 200: json({ type: 'array', items: ref('Agent') }) } } },
|
|
48
48
|
'/router': {
|
|
49
49
|
get: { summary: 'Auto: the goal, settings, every harness · model with its learned chance of success and cost, and recent routes', responses: { 200: json({ type: 'object' }) } },
|
|
50
|
-
patch: { summary: 'Auto settings', requestBody: body({ type: 'object', properties: { goal: { enum: ['cheap', 'balanced', 'best'] }, explore: { type: 'boolean', description: 'Let Auto try new models on a few tasks' }, allowed: { type: 'array', items: { type: 'string' }, description: 'Harness ids Auto may pick; empty or null = all' } } }), responses: { 200: json({ type: 'object' }) } },
|
|
50
|
+
patch: { summary: 'Auto settings', requestBody: body({ type: 'object', properties: { goal: { enum: ['cheap', 'balanced', 'best'] }, explore: { type: 'boolean', description: 'Let Auto try new models on a few tasks' }, allowed: { type: 'array', items: { type: 'string' }, description: 'Harness ids Auto may pick; empty or null = all' }, check: { type: 'boolean', description: 'Run the project tests after an Auto run; only new failures count' }, repairs: { type: 'integer', minimum: 0, maximum: 2, description: 'Times failing tests go back to the same agent' }, escalate: { type: 'boolean', description: 'Still failing: run the task again on a stronger pick, in its own worktree' }, best2: { type: 'boolean', description: 'Goal Best: two picks side by side, the better one marked' }, scout: { enum: ['off', 'big', 'all'], description: 'A cheap model looks at the repo first' } } }), responses: { 200: json({ type: 'object' }) } },
|
|
51
51
|
},
|
|
52
52
|
'/router/reset': { post: { summary: 'Forget what Auto learned here (the shipped starting point stays)', responses: { 200: json({ type: 'object' }) } } },
|
|
53
53
|
'/agents/install': {
|
|
@@ -144,7 +144,7 @@ export function openapi({ version, port }) {
|
|
|
144
144
|
},
|
|
145
145
|
},
|
|
146
146
|
'/sessions/{id}/pr': { parameters: [id], post: { summary: 'Refresh the PR status (checks, review, state) now; it is also polled every minute', responses: { 200: json(ref('PullRequest')), 404: err[404] } } },
|
|
147
|
-
'/sessions/{id}/fix-conflicts': { parameters: [id], post: { summary: '
|
|
147
|
+
'/sessions/{id}/fix-conflicts': { parameters: [id], post: { summary: 'Fix the PR\'s merge conflicts now (the PR row\'s Fix conflicts button): a follow-up merges the base in, then wisp pushes to the PR', responses: { 200: json({ type: 'object' }), 400: err[400] } } },
|
|
148
148
|
'/sessions/{id}/merge': {
|
|
149
149
|
parameters: [id],
|
|
150
150
|
post: { summary: 'Mark the PR ready if draft, squash-merge it with --match-head-commit, fast-forward the local base branch, remove the worktree', responses: { 200: json({ type: 'object', properties: { pr: ref('PullRequest'), sync: { type: 'object', properties: { ok: { type: 'boolean' }, text: { type: 'string' } } } } }), 400: err[400] } },
|
|
@@ -304,6 +304,7 @@ export function openapi({ version, port }) {
|
|
|
304
304
|
properties: {
|
|
305
305
|
prompt: { type: 'string' },
|
|
306
306
|
cwd: { type: 'string', description: 'Project folder (absolute; ~ allowed). Default: the server’s cwd' },
|
|
307
|
+
also: { type: 'array', maxItems: 8, items: { type: 'string' }, description: 'More folders the same task works in (absolute; ~ allowed). The agent gets each; git repos get their own worktree, and Ship it opens a PR in each' },
|
|
307
308
|
scratch: { type: 'boolean', description: 'No project folder: run in an empty scratch directory (no worktree). Overrides cwd' },
|
|
308
309
|
agent: { enum: ['auto', 'claude', 'codex', 'opencode', 'cursor', 'antigravity', 'grok'], default: 'auto', description: 'auto: wisp picks the harness and model from what worked before; model is then the goal (cheap, balanced, best)' },
|
|
309
310
|
important: { type: 'boolean', description: 'With agent auto: no exploring, take the pick with the best record' },
|
|
@@ -409,7 +410,7 @@ export function openapi({ version, port }) {
|
|
|
409
410
|
branch: { type: 'string', description: 'Worktree branch, if it has one' },
|
|
410
411
|
pr: { type: ['object', 'null'], description: 'Its pull request, once shipped' },
|
|
411
412
|
shipping: { type: ['object', 'null'], description: "{ step: start | commit | push | pr, update } while Ship it runs" },
|
|
412
|
-
conflictFix: { type: ['object', 'null'], description: "{ step: fixing | pushing | done | failed, why } while wisp fixes the PR's merge conflicts on its own
|
|
413
|
+
conflictFix: { type: ['object', 'null'], description: "{ step: fixing | pushing | done | failed, why } while wisp fixes the PR's merge conflicts: after Fix conflicts, or on its own with defaults.fixConflicts: 'on'" },
|
|
413
414
|
groupId: { type: ['string', 'null'], description: 'Shared by sessions launched together with compare' },
|
|
414
415
|
origin: { type: ['object', 'null'], description: '{ kind: recipe | trigger, id, name } when not launched by hand' },
|
|
415
416
|
},
|