reslop 0.2.7 → 0.3.1
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 +30 -1
- package/README.md +16 -14
- package/bin/reslop.js +8 -5
- package/lib/agents/agents.js +573 -0
- package/lib/agents/allow.js +71 -0
- package/lib/agents/allow.json +17 -0
- package/lib/agents/models.js +467 -0
- package/lib/api.js +15 -12
- package/lib/cli.js +43 -68
- package/lib/{files.js → common/files.js} +48 -55
- package/lib/{find.js → common/find.js} +1 -1
- package/lib/common/format.js +101 -0
- package/lib/{utilities.js → common/process.js} +7 -95
- package/lib/common/tasks.json +27 -0
- package/lib/common/utilities.js +112 -0
- package/lib/dashboard/git.js +9 -16
- package/lib/dashboard/model.js +90 -49
- package/lib/dashboard/npm.js +17 -13
- package/lib/dashboard/tree.js +27 -30
- package/lib/{session → dashboard}/watch.js +36 -31
- package/lib/{workspace.js → dashboard/workspace.js} +23 -38
- package/lib/{deps.js → deps/deps.js} +31 -45
- package/lib/{deps-diff.js → deps/diff.js} +35 -25
- package/lib/{manifest.js → deps/manifest.js} +47 -30
- package/lib/diff/align.js +1 -2
- package/lib/diff/diff.js +2 -2
- package/lib/diff/display.js +29 -5
- package/lib/diff/inline.js +10 -14
- package/lib/diff/items.js +6 -4
- package/lib/diff/patch.js +39 -3
- package/lib/diff/unit.js +45 -16
- package/lib/{git-branches.js → git/branches.js} +53 -48
- package/lib/{git-deps.js → git/deps.js} +151 -95
- package/lib/git/git.js +71 -0
- package/lib/git/worktree.js +504 -0
- package/lib/highlight/bash.js +1 -2
- package/lib/highlight/csv.js +1 -2
- package/lib/highlight/dot.js +1 -2
- package/lib/{highlight.js → highlight/highlight.js} +42 -11
- package/lib/highlight/html.js +20 -18
- package/lib/highlight/json.js +1 -2
- package/lib/highlight/log.js +1 -2
- package/lib/highlight/txt.js +1 -2
- package/lib/{session → input}/actions.js +114 -48
- package/lib/{editor.js → input/editor.js} +16 -8
- package/lib/{keys.js → input/keys.js} +24 -45
- package/lib/input/line-edit.js +78 -0
- package/lib/input/menu-pick.js +70 -0
- package/lib/render/agents.js +642 -0
- package/lib/render/branches.js +4 -5
- package/lib/render/commits.js +54 -64
- package/lib/render/{dash-activity.js → dashboard/activity.js} +25 -40
- package/lib/render/{dash-blocks.js → dashboard/blocks.js} +131 -137
- package/lib/render/{dashboard.js → dashboard/dashboard.js} +25 -22
- package/lib/render/diff.js +166 -45
- package/lib/render/field.js +131 -0
- package/lib/render/files.js +9 -14
- package/lib/render/footer.js +385 -0
- package/lib/render/frame.js +123 -25
- package/lib/render/header.js +176 -0
- package/lib/render/log.js +320 -0
- package/lib/render/menu.js +60 -0
- package/lib/render/notes.js +16 -11
- package/lib/render/npm.js +322 -196
- package/lib/render/packages.js +9 -13
- package/lib/render/primitives.js +101 -15
- package/lib/render/render.js +7 -11
- package/lib/render/repos.js +13 -25
- package/lib/render/status.js +370 -0
- package/lib/render/status.json +85 -0
- package/lib/render/{dash-table.js → table.js} +13 -60
- package/lib/render/tiles.js +109 -48
- package/lib/render/unit.js +32 -13
- package/lib/{report-model.js → report/model.js} +4 -6
- package/lib/{report-parse.js → report/parse.js} +9 -14
- package/lib/{report-render.js → report/render.js} +48 -19
- package/lib/{report-run.js → report/run.js} +42 -30
- package/lib/{report-test.js → report/test.js} +56 -55
- package/lib/{report-tools.js → report/tools.js} +24 -33
- package/lib/review/agent-instructions.md +14 -0
- package/lib/review/format.js +420 -0
- package/lib/{review-merge.js → review/merge.js} +9 -8
- package/lib/review/review.js +190 -0
- package/lib/review/store.js +281 -0
- package/lib/review/templates.js +83 -0
- package/lib/runs/commands.js +14 -0
- package/lib/runs/logs.js +299 -0
- package/lib/runs/output.js +174 -0
- package/lib/runs/process.js +113 -0
- package/lib/{runs.js → runs/runs.js} +84 -36
- package/lib/runs/scripts.js +150 -0
- package/lib/session/agents/agents.js +976 -0
- package/lib/session/agents/job.js +320 -0
- package/lib/session/agents/jobs.js +355 -0
- package/lib/session/agents/options.js +153 -0
- package/lib/session/agents/plans.js +83 -0
- package/lib/session/branches.js +33 -40
- package/lib/session/change-actions.js +34 -100
- package/lib/session/commit.js +91 -52
- package/lib/session/compose.js +189 -147
- package/lib/session/dashboard.js +23 -22
- package/lib/session/dispatch.js +86 -21
- package/lib/session/files-pane.js +47 -26
- package/lib/session/find.js +16 -29
- package/lib/session/import.js +93 -0
- package/lib/session/items.js +8 -17
- package/lib/session/lifecycle.js +78 -72
- package/lib/session/load.js +2 -4
- package/lib/session/navigation.js +6 -3
- package/lib/session/npm/history.js +250 -0
- package/lib/session/npm/npm.js +836 -0
- package/lib/session/{packages.js → npm/packages.js} +21 -14
- package/lib/session/ops.js +125 -34
- package/lib/session/pointer.js +202 -10
- package/lib/session/prefs.js +112 -0
- package/lib/session/reads.js +109 -0
- package/lib/session/review.js +28 -10
- package/lib/session/run-panel.js +40 -0
- package/lib/{session.js → session/session.js} +158 -63
- package/lib/session/tasks.js +321 -66
- package/lib/session/templates.js +1 -1
- package/lib/session/terminal.js +94 -12
- package/lib/session/unit.js +35 -30
- package/lib/session/update.js +194 -6
- package/lib/session/view.js +65 -65
- package/lib/session/workspace.js +39 -78
- package/lib/{capabilities.js → source/capabilities.js} +3 -12
- package/lib/{github.js → source/github.js} +102 -32
- package/lib/{gitlab.js → source/gitlab.js} +87 -10
- package/lib/{remote.js → source/remote.js} +144 -40
- package/lib/source/review-threads.graphql +20 -0
- package/lib/source/source.js +74 -0
- package/lib/term/ansi.js +396 -0
- package/lib/{clipboard.js → term/clipboard.js} +3 -6
- package/lib/{select.js → term/select.js} +4 -3
- package/lib/term/themes/dark.json +122 -0
- package/lib/term/themes/light.json +122 -0
- package/lib/term/wide.txt +21 -0
- package/lib/{wrap.js → term/wrap.js} +4 -4
- package/package.json +2 -2
- package/lib/ansi.js +0 -545
- package/lib/detect.js +0 -34
- package/lib/diff/edit.js +0 -33
- package/lib/git-worktree.js +0 -455
- package/lib/git.js +0 -79
- package/lib/npm-commands.js +0 -522
- package/lib/render/chrome.js +0 -806
- package/lib/render/present.js +0 -19
- package/lib/render/report.js +0 -43
- package/lib/render/search.js +0 -25
- package/lib/review.js +0 -745
- package/lib/session/accessors.js +0 -26
- package/lib/session/edit-click.js +0 -57
- package/lib/session/npm.js +0 -452
- package/lib/session/progress.js +0 -41
- package/lib/source.js +0 -36
- package/lib/update.js +0 -192
- /package/lib/{git-reword-todo.js → git/reword-todo.js} +0 -0
package/lib/update.js
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const fs = require('node:fs');
|
|
4
|
-
const os = require('node:os');
|
|
5
|
-
const path = require('node:path');
|
|
6
|
-
|
|
7
|
-
const metautil = require('metautil');
|
|
8
|
-
const { jsonParse, isHashObject } = metautil;
|
|
9
|
-
const utilities = require('./utilities.js');
|
|
10
|
-
const { parseVersion, cmpVersion, npmBin } = utilities;
|
|
11
|
-
const { npmOpts, runProc, oneLine, asText } = utilities;
|
|
12
|
-
|
|
13
|
-
const PKG = require('../package.json');
|
|
14
|
-
|
|
15
|
-
const PKG_NAME = PKG.name;
|
|
16
|
-
const PKG_VERSION = PKG.version;
|
|
17
|
-
const PKG_DIR = path.resolve(__dirname, '..');
|
|
18
|
-
const CHECK_INTERVAL_MS = 12 * 60 * 60 * 1000;
|
|
19
|
-
const FETCH_MS = 8000;
|
|
20
|
-
const INSTALL_MS = 120000;
|
|
21
|
-
const REGISTRY = 'https://registry.npmjs.org';
|
|
22
|
-
|
|
23
|
-
const RELEASE = /^\d+\.\d+\.\d+$/;
|
|
24
|
-
const NO_TARGETS = { compatible: '', major: '' };
|
|
25
|
-
|
|
26
|
-
const isNpmInstall = (pkgDir) =>
|
|
27
|
-
path.basename(path.dirname(pkgDir)) === 'node_modules';
|
|
28
|
-
|
|
29
|
-
const cacheFile = (env = process.env) => {
|
|
30
|
-
if (env.XDG_CACHE_HOME) {
|
|
31
|
-
return path.join(env.XDG_CACHE_HOME, 'reslop', 'update.json');
|
|
32
|
-
}
|
|
33
|
-
if (process.platform === 'win32') {
|
|
34
|
-
const local =
|
|
35
|
-
env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local');
|
|
36
|
-
return path.join(local, 'reslop', 'update.json');
|
|
37
|
-
}
|
|
38
|
-
return path.join(os.homedir(), '.cache', 'reslop', 'update.json');
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const readCache = (file) => {
|
|
42
|
-
try {
|
|
43
|
-
const data = jsonParse(fs.readFileSync(file, 'utf8'));
|
|
44
|
-
if (isHashObject(data)) {
|
|
45
|
-
return {
|
|
46
|
-
checkedAt: parseInt(data.checkedAt, 10) || 0,
|
|
47
|
-
compatible: asText(data.compatible),
|
|
48
|
-
major: asText(data.major) || asText(data.latest),
|
|
49
|
-
skipped: asText(data.skipped) || asText(data.handled),
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
} catch {
|
|
53
|
-
// missing or unreadable cache
|
|
54
|
-
}
|
|
55
|
-
return { checkedAt: 0, compatible: '', major: '', skipped: '' };
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const writeCache = (file, data) => {
|
|
59
|
-
const { checkedAt, compatible, major, skipped } = data;
|
|
60
|
-
const body = JSON.stringify({ checkedAt, compatible, major, skipped });
|
|
61
|
-
try {
|
|
62
|
-
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
63
|
-
fs.writeFileSync(file, `${body}\n`);
|
|
64
|
-
} catch {
|
|
65
|
-
// ignore cache write errors
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const isFresh = (cache, now, interval = CHECK_INTERVAL_MS) => {
|
|
70
|
-
if (!cache.checkedAt || now < cache.checkedAt) return false;
|
|
71
|
-
return now - cache.checkedAt < interval;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const listVersions = (data) => {
|
|
75
|
-
if (!data || typeof data !== 'object') return [];
|
|
76
|
-
const names = [];
|
|
77
|
-
if (isHashObject(data.versions)) names.push(...Object.keys(data.versions));
|
|
78
|
-
const tags = data['dist-tags'];
|
|
79
|
-
if (tags && typeof tags.latest === 'string') names.push(tags.latest);
|
|
80
|
-
if (typeof data.version === 'string') names.push(data.version);
|
|
81
|
-
return [...new Set(names)].filter((name) => RELEASE.test(name));
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const newer = (best, name) => {
|
|
85
|
-
if (!best) return name;
|
|
86
|
-
return cmpVersion(parseVersion(name), parseVersion(best)) > 0 ? name : best;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const pickTargets = (current, names) => {
|
|
90
|
-
const from = parseVersion(current);
|
|
91
|
-
if (!from) return NO_TARGETS;
|
|
92
|
-
let compatible = '';
|
|
93
|
-
let major = '';
|
|
94
|
-
for (const name of names) {
|
|
95
|
-
const ver = parseVersion(name);
|
|
96
|
-
if (cmpVersion(ver, from) <= 0) continue;
|
|
97
|
-
if (ver.major === from.major) compatible = newer(compatible, name);
|
|
98
|
-
else if (ver.major > from.major) major = newer(major, name);
|
|
99
|
-
}
|
|
100
|
-
return { compatible, major };
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const planUpdate = (current, targets) => {
|
|
104
|
-
const from = parseVersion(current);
|
|
105
|
-
if (!from) return { action: 'none' };
|
|
106
|
-
const { compatible, major, skipped } = targets;
|
|
107
|
-
const compatVer = parseVersion(compatible);
|
|
108
|
-
if (compatVer && compatVer.major === from.major) {
|
|
109
|
-
if (cmpVersion(compatVer, from) > 0) {
|
|
110
|
-
return { action: 'install', current, latest: compatible };
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
const majorVer = parseVersion(major);
|
|
114
|
-
if (!majorVer || majorVer.major <= from.major) return { action: 'none' };
|
|
115
|
-
const skipVer = parseVersion(skipped);
|
|
116
|
-
if (skipVer && cmpVersion(majorVer, skipVer) <= 0) return { action: 'none' };
|
|
117
|
-
return { action: 'confirm', current, latest: major };
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const isEnabled = (options) => {
|
|
121
|
-
if (typeof options.enabled === 'boolean') return options.enabled;
|
|
122
|
-
return isNpmInstall(options.pkgDir ?? PKG_DIR);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const fetchTargets = async (current, options) => {
|
|
126
|
-
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
127
|
-
if (typeof fetchImpl !== 'function') return NO_TARGETS;
|
|
128
|
-
const url = `${REGISTRY}/${encodeURIComponent(PKG_NAME)}`;
|
|
129
|
-
const headers = { accept: 'application/json' };
|
|
130
|
-
const signal = options.signal ?? AbortSignal.timeout(FETCH_MS);
|
|
131
|
-
const response = await fetchImpl(url, { headers, signal });
|
|
132
|
-
if (!response || !response.ok) return NO_TARGETS;
|
|
133
|
-
const data = await response.json();
|
|
134
|
-
return pickTargets(current, listVersions(data));
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const installUpdate = async (version, options = {}) => {
|
|
138
|
-
if (typeof options.install === 'function') {
|
|
139
|
-
await options.install(version);
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const timeout = options.timeout ?? INSTALL_MS;
|
|
143
|
-
const args = ['install', '-g', `${PKG_NAME}@${version}`];
|
|
144
|
-
const result = await runProc(npmBin(), args, npmOpts({ timeout }));
|
|
145
|
-
if (result.error) throw result.error;
|
|
146
|
-
if (result.status !== 0) {
|
|
147
|
-
throw new Error(oneLine(result.stderr, 'npm install failed'));
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const markSkipped = (version, options = {}) => {
|
|
152
|
-
const file = options.cacheFile ?? cacheFile(options.env);
|
|
153
|
-
writeCache(file, { ...readCache(file), skipped: version });
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const checkUpdate = async (options = {}) => {
|
|
157
|
-
if (!isEnabled(options)) return { action: 'skip' };
|
|
158
|
-
const now = Date.now();
|
|
159
|
-
const current = options.current ?? PKG_VERSION;
|
|
160
|
-
const file = options.cacheFile ?? cacheFile(options.env);
|
|
161
|
-
const cache = readCache(file);
|
|
162
|
-
if (isFresh(cache, now, options.interval)) {
|
|
163
|
-
const plan = planUpdate(current, cache);
|
|
164
|
-
return plan.action === 'install' ? { action: 'none' } : plan;
|
|
165
|
-
}
|
|
166
|
-
let targets = NO_TARGETS;
|
|
167
|
-
try {
|
|
168
|
-
targets = await fetchTargets(current, options);
|
|
169
|
-
} catch {
|
|
170
|
-
// ignore registry errors
|
|
171
|
-
}
|
|
172
|
-
if (!targets.compatible && !targets.major) {
|
|
173
|
-
writeCache(file, { ...cache, checkedAt: now });
|
|
174
|
-
return { action: 'none' };
|
|
175
|
-
}
|
|
176
|
-
const next = { ...cache, checkedAt: now, ...targets };
|
|
177
|
-
writeCache(file, next);
|
|
178
|
-
return planUpdate(current, next);
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
module.exports = {
|
|
182
|
-
CHECK_INTERVAL_MS,
|
|
183
|
-
isNpmInstall,
|
|
184
|
-
cacheFile,
|
|
185
|
-
readCache,
|
|
186
|
-
writeCache,
|
|
187
|
-
isFresh,
|
|
188
|
-
planUpdate,
|
|
189
|
-
checkUpdate,
|
|
190
|
-
installUpdate,
|
|
191
|
-
markSkipped,
|
|
192
|
-
};
|
|
File without changes
|