sumo-agents 0.7.2 → 0.8.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 +88 -0
- package/README.md +43 -20
- package/package.json +2 -1
- package/prompts/scribe.md +1 -1
- package/src/apply.mjs +16 -12
- package/src/auth.mjs +2 -2
- package/src/card.mjs +3 -2
- package/src/catalog.mjs +100 -13
- package/src/chat.mjs +71 -16
- package/src/check.mjs +17 -15
- package/src/cli.mjs +21 -11
- package/src/cost.mjs +2 -4
- package/src/cursor.mjs +405 -0
- package/src/db.mjs +24 -13
- package/src/dream.mjs +2 -2
- package/src/jobs.mjs +32 -14
- package/src/ledger.mjs +4 -3
- package/src/loop.mjs +124 -73
- package/src/mcp.mjs +7 -9
- package/src/memeval.mjs +2 -3
- package/src/memory.mjs +5 -4
- package/src/model.mjs +5 -0
- package/src/page.mjs +1 -0
- package/src/prime.mjs +11 -7
- package/src/rebuild.mjs +8 -3
- package/src/redact.mjs +13 -1
- package/src/route.mjs +263 -56
- package/src/sandbox.mjs +86 -20
- package/src/scan.mjs +4 -2
- package/src/scorecard.mjs +419 -0
- package/src/scribe.mjs +82 -38
- package/src/sessions.mjs +9 -7
- package/src/settings.mjs +114 -37
- package/src/setup.mjs +33 -14
- package/src/spool.mjs +68 -43
- package/src/tools.mjs +170 -77
- package/src/ui.mjs +14 -5
- package/src/verify.mjs +68 -12
- package/src/worktree.mjs +23 -16
package/src/worktree.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { execFileSync, spawnSync } from 'node:child_process';
|
|
|
2
2
|
import { copyFileSync, cpSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, rmSync, statSync, symlinkSync } from 'node:fs';
|
|
3
3
|
import { dirname, isAbsolute, join, relative, sep } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { ownGit } from './sandbox.mjs';
|
|
5
6
|
import { DIFF } from './verify.mjs';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -10,13 +11,13 @@ import { DIFF } from './verify.mjs';
|
|
|
10
11
|
* branches, and what the work changed is brought back to the project at the end. Nothing here knows about jobs.
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
|
-
/** Sumo's own git calls:
|
|
14
|
-
const OWN = ['-c', '
|
|
14
|
+
/** Sumo's own git calls: nothing the project's git files name runs (`ownGit`), nothing is signed, and a commit has an author where git has no identity. */
|
|
15
|
+
const OWN = ['-c', 'commit.gpgsign=false', '-c', 'user.name=sumo', '-c', 'user.email=sumo@localhost'];
|
|
15
16
|
|
|
16
|
-
const git = (root, args) => execFileSync('git', ['-C', root, ...OWN, ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: 256 * 1024 * 1024 }).trim();
|
|
17
|
+
const git = (root, args) => execFileSync('git', ['-C', root, ...OWN, ...ownGit(args)], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: 256 * 1024 * 1024 }).trim();
|
|
17
18
|
/** How a git command that reads a patch on stdin went: whether it succeeded, and the first lines of what it said, on one line. */
|
|
18
19
|
const fed = (root, args, patch, env = {}) => {
|
|
19
|
-
const run = spawnSync('git', ['-C', root, ...OWN, ...args], { input: patch, env: { ...process.env, ...env }, stdio: ['pipe', 'ignore', 'pipe'], encoding: 'utf8' });
|
|
20
|
+
const run = spawnSync('git', ['-C', root, ...OWN, ...ownGit(args)], { input: patch, env: { ...process.env, ...env }, stdio: ['pipe', 'ignore', 'pipe'], encoding: 'utf8' });
|
|
20
21
|
return { ok: run.status === 0, said: (run.stderr ?? '').split('\n').map((l) => l.trim()).filter(Boolean).slice(0, 3).join('; ') };
|
|
21
22
|
};
|
|
22
23
|
/** The paths a NUL-separated git listing names. */
|
|
@@ -79,6 +80,15 @@ const within = (root, path) => {
|
|
|
79
80
|
const rel = relative(root, path);
|
|
80
81
|
return rel !== '..' && !rel.startsWith('..' + sep) && !isAbsolute(rel);
|
|
81
82
|
};
|
|
83
|
+
/** Where a path leads, or null for a link to nothing: that loads nothing, so it is no one's source. */
|
|
84
|
+
const realOrNull = (path) => {
|
|
85
|
+
try {
|
|
86
|
+
return realpathSync(path);
|
|
87
|
+
} catch (cause) {
|
|
88
|
+
if (cause.code === 'ENOENT') return null;
|
|
89
|
+
throw cause;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
82
92
|
|
|
83
93
|
/** Inspect package-manager links, including scoped packages and pnpm's virtual store. */
|
|
84
94
|
function nodeLoadsOriginal(modules, repository, candidate) {
|
|
@@ -96,19 +106,19 @@ function nodeLoadsOriginal(modules, repository, candidate) {
|
|
|
96
106
|
for (const name of readdirSync(path)) if (isDir(join(path, name, 'node_modules'))) queue.push(join(path, name, 'node_modules'));
|
|
97
107
|
} else if (entry.name.startsWith('@') && entry.isDirectory()) queue.push(path);
|
|
98
108
|
else if (entry.isSymbolicLink()) {
|
|
99
|
-
const target =
|
|
100
|
-
if (within(repository, target) && !within(installed, target) && !within(candidate, target)) return true;
|
|
109
|
+
const target = realOrNull(path);
|
|
110
|
+
if (target && within(repository, target) && !within(installed, target) && !within(candidate, target)) return true;
|
|
101
111
|
} else if (entry.isDirectory() && isDir(join(path, 'node_modules'))) queue.push(join(path, 'node_modules'));
|
|
102
112
|
}
|
|
103
113
|
}
|
|
104
114
|
return false;
|
|
105
115
|
}
|
|
106
116
|
|
|
107
|
-
/** Common editable-install formats: PEP 610/660 metadata, path-based .pth files and legacy egg links. */
|
|
108
|
-
function pythonLoadsOriginal(env, repository, candidate
|
|
117
|
+
/** Common editable-install formats: PEP 610/660 metadata, path-based .pth files and legacy egg links — each judged by where it points. */
|
|
118
|
+
function pythonLoadsOriginal(env, repository, candidate) {
|
|
109
119
|
function loadsOriginal(path) {
|
|
110
|
-
const target =
|
|
111
|
-
return within(repository, target) && !within(candidate, target);
|
|
120
|
+
const target = realOrNull(path);
|
|
121
|
+
return target !== null && within(repository, target) && !within(candidate, target);
|
|
112
122
|
}
|
|
113
123
|
const lib = join(env, 'lib');
|
|
114
124
|
const sites = [join(env, 'Lib', 'site-packages')];
|
|
@@ -116,7 +126,6 @@ function pythonLoadsOriginal(env, repository, candidate, shared) {
|
|
|
116
126
|
for (const site of sites.filter(isDir)) {
|
|
117
127
|
for (const name of readdirSync(site)) {
|
|
118
128
|
const file = join(site, name);
|
|
119
|
-
if (shared && (name.endsWith('.egg-link') || name.startsWith('__editable__'))) return true;
|
|
120
129
|
if (name.endsWith('.egg-link') || name.endsWith('.pth')) {
|
|
121
130
|
for (const line of readFileSync(file, 'utf8').split(/\r?\n/)) {
|
|
122
131
|
const path = line.trim();
|
|
@@ -125,7 +134,7 @@ function pythonLoadsOriginal(env, repository, candidate, shared) {
|
|
|
125
134
|
}
|
|
126
135
|
if (name.endsWith('.dist-info') && taken(join(file, 'direct_url.json'))) {
|
|
127
136
|
const metadata = JSON.parse(readFileSync(join(file, 'direct_url.json'), 'utf8'));
|
|
128
|
-
if (metadata.dir_info?.editable &&
|
|
137
|
+
if (metadata.dir_info?.editable && metadata.url?.startsWith('file:') && loadsOriginal(fileURLToPath(metadata.url))) return true;
|
|
129
138
|
}
|
|
130
139
|
}
|
|
131
140
|
}
|
|
@@ -140,11 +149,9 @@ export function sharedSourceDependencies(tree, project) {
|
|
|
140
149
|
const dependency = join(tree.path, name);
|
|
141
150
|
if (!taken(dependency)) continue;
|
|
142
151
|
try {
|
|
143
|
-
const original = join(project, name);
|
|
144
|
-
const sharedInstall = taken(original) && realpathSync(dependency) === realpathSync(original);
|
|
145
152
|
const candidate = realpathSync(tree.top);
|
|
146
153
|
const repository = realpathSync(git(project, ['rev-parse', '--show-toplevel']));
|
|
147
|
-
if (name === 'node_modules' ? nodeLoadsOriginal(dependency, repository, candidate) : pythonLoadsOriginal(dependency, repository, candidate
|
|
154
|
+
if (name === 'node_modules' ? nodeLoadsOriginal(dependency, repository, candidate) : pythonLoadsOriginal(dependency, repository, candidate)) shared.push(name);
|
|
148
155
|
} catch {
|
|
149
156
|
shared.push(name); // Unreadable installation or link: its source cannot be verified.
|
|
150
157
|
}
|
|
@@ -155,7 +162,7 @@ export function sharedSourceDependencies(tree, project) {
|
|
|
155
162
|
/** Everything changed in the tree since it was made, new files included, as git itself writes a diff: with `binary`, whole enough to apply. */
|
|
156
163
|
export function treeDiff({ top, prefix, base }, { binary = false } = {}) {
|
|
157
164
|
git(top, ['add', '-A']);
|
|
158
|
-
return execFileSync('git', ['-C', top, ...DIFF, '--cached', ...(binary ? ['--binary'] : []), base, '--', prefix || '.'], {
|
|
165
|
+
return execFileSync('git', ['-C', top, ...ownGit([...DIFF, '--cached', ...(binary ? ['--binary'] : []), base, '--', prefix || '.'])], {
|
|
159
166
|
encoding: binary ? 'buffer' : 'utf8',
|
|
160
167
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
161
168
|
maxBuffer: 256 * 1024 * 1024,
|