reslop 0.2.6 → 0.3.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.
Files changed (158) hide show
  1. package/CHANGELOG.md +27 -1
  2. package/README.md +16 -14
  3. package/bin/reslop.js +8 -5
  4. package/lib/agents/agents.js +504 -0
  5. package/lib/agents/allow.js +71 -0
  6. package/lib/agents/allow.json +16 -0
  7. package/lib/agents/models.js +460 -0
  8. package/lib/api.js +15 -12
  9. package/lib/cli.js +61 -66
  10. package/lib/{files.js → common/files.js} +51 -52
  11. package/lib/common/find.js +61 -0
  12. package/lib/common/format.js +101 -0
  13. package/lib/{utilities.js → common/process.js} +7 -95
  14. package/lib/common/tasks.json +27 -0
  15. package/lib/common/utilities.js +112 -0
  16. package/lib/dashboard/git.js +9 -16
  17. package/lib/dashboard/model.js +117 -51
  18. package/lib/dashboard/npm.js +133 -32
  19. package/lib/dashboard/tree.js +27 -30
  20. package/lib/{session → dashboard}/watch.js +41 -31
  21. package/lib/dashboard/workspace.js +151 -0
  22. package/lib/{deps.js → deps/deps.js} +31 -45
  23. package/lib/{deps-diff.js → deps/diff.js} +35 -25
  24. package/lib/{manifest.js → deps/manifest.js} +47 -30
  25. package/lib/diff/align.js +1 -2
  26. package/lib/diff/diff.js +2 -2
  27. package/lib/diff/display.js +29 -5
  28. package/lib/diff/inline.js +10 -14
  29. package/lib/diff/items.js +6 -4
  30. package/lib/diff/patch.js +39 -3
  31. package/lib/diff/unit.js +45 -16
  32. package/lib/{git-branches.js → git/branches.js} +53 -48
  33. package/lib/{git-deps.js → git/deps.js} +123 -95
  34. package/lib/git/git.js +71 -0
  35. package/lib/git/worktree.js +475 -0
  36. package/lib/highlight/bash.js +1 -2
  37. package/lib/highlight/csv.js +1 -2
  38. package/lib/highlight/dot.js +1 -2
  39. package/lib/{highlight.js → highlight/highlight.js} +42 -11
  40. package/lib/highlight/html.js +20 -18
  41. package/lib/highlight/json.js +1 -2
  42. package/lib/highlight/log.js +1 -2
  43. package/lib/highlight/txt.js +1 -2
  44. package/lib/{session → input}/actions.js +240 -71
  45. package/lib/{editor.js → input/editor.js} +7 -8
  46. package/lib/{keys.js → input/keys.js} +36 -39
  47. package/lib/input/line-edit.js +77 -0
  48. package/lib/input/menu-pick.js +70 -0
  49. package/lib/render/agents.js +640 -0
  50. package/lib/render/branches.js +4 -5
  51. package/lib/render/commits.js +54 -64
  52. package/lib/render/{dash-activity.js → dashboard/activity.js} +25 -40
  53. package/lib/render/dashboard/blocks.js +490 -0
  54. package/lib/render/{dashboard.js → dashboard/dashboard.js} +25 -22
  55. package/lib/render/diff.js +166 -45
  56. package/lib/render/field.js +131 -0
  57. package/lib/render/files.js +22 -8
  58. package/lib/render/footer.js +383 -0
  59. package/lib/render/frame.js +127 -25
  60. package/lib/render/header.js +176 -0
  61. package/lib/render/log.js +319 -0
  62. package/lib/render/menu.js +60 -0
  63. package/lib/render/notes.js +29 -13
  64. package/lib/render/npm.js +322 -196
  65. package/lib/render/packages.js +89 -0
  66. package/lib/render/primitives.js +109 -16
  67. package/lib/render/render.js +7 -11
  68. package/lib/render/repos.js +214 -0
  69. package/lib/render/status.js +370 -0
  70. package/lib/render/status.json +85 -0
  71. package/lib/render/{dash-table.js → table.js} +19 -61
  72. package/lib/render/tiles.js +203 -47
  73. package/lib/render/unit.js +32 -13
  74. package/lib/{report-model.js → report/model.js} +4 -6
  75. package/lib/{report-parse.js → report/parse.js} +9 -14
  76. package/lib/{report-render.js → report/render.js} +46 -14
  77. package/lib/{report-run.js → report/run.js} +42 -30
  78. package/lib/{report-test.js → report/test.js} +56 -55
  79. package/lib/{report-tools.js → report/tools.js} +24 -33
  80. package/lib/review/agent-instructions.md +9 -0
  81. package/lib/review/format.js +426 -0
  82. package/lib/{review-merge.js → review/merge.js} +9 -8
  83. package/lib/review/review.js +190 -0
  84. package/lib/review/store.js +281 -0
  85. package/lib/review/templates.js +83 -0
  86. package/lib/runs/commands.js +14 -0
  87. package/lib/runs/logs.js +299 -0
  88. package/lib/runs/output.js +174 -0
  89. package/lib/runs/process.js +113 -0
  90. package/lib/{runs.js → runs/runs.js} +84 -36
  91. package/lib/runs/scripts.js +150 -0
  92. package/lib/session/agents/agents.js +958 -0
  93. package/lib/session/agents/job.js +320 -0
  94. package/lib/session/agents/jobs.js +355 -0
  95. package/lib/session/agents/options.js +153 -0
  96. package/lib/session/agents/plans.js +83 -0
  97. package/lib/session/branches.js +36 -44
  98. package/lib/session/change-actions.js +34 -100
  99. package/lib/session/commit.js +122 -56
  100. package/lib/session/compose.js +197 -146
  101. package/lib/session/dashboard.js +183 -37
  102. package/lib/session/dispatch.js +120 -22
  103. package/lib/session/files-pane.js +60 -24
  104. package/lib/session/find.js +81 -0
  105. package/lib/session/import.js +82 -0
  106. package/lib/session/items.js +8 -17
  107. package/lib/session/lifecycle.js +96 -66
  108. package/lib/session/load.js +2 -4
  109. package/lib/session/navigation.js +8 -3
  110. package/lib/session/npm/history.js +249 -0
  111. package/lib/session/npm/npm.js +815 -0
  112. package/lib/session/npm/packages.js +150 -0
  113. package/lib/session/ops.js +125 -34
  114. package/lib/session/pointer.js +216 -10
  115. package/lib/session/prefs.js +112 -0
  116. package/lib/session/reads.js +109 -0
  117. package/lib/session/review.js +28 -10
  118. package/lib/session/run-panel.js +40 -0
  119. package/lib/{session.js → session/session.js} +166 -59
  120. package/lib/session/tasks.js +321 -66
  121. package/lib/session/templates.js +1 -1
  122. package/lib/session/terminal.js +94 -12
  123. package/lib/session/unit.js +35 -30
  124. package/lib/session/update.js +194 -6
  125. package/lib/session/view.js +72 -59
  126. package/lib/session/workspace.js +416 -0
  127. package/lib/{capabilities.js → source/capabilities.js} +3 -12
  128. package/lib/{github.js → source/github.js} +102 -32
  129. package/lib/{gitlab.js → source/gitlab.js} +87 -10
  130. package/lib/{remote.js → source/remote.js} +144 -40
  131. package/lib/source/review-threads.graphql +20 -0
  132. package/lib/source/source.js +74 -0
  133. package/lib/term/ansi.js +396 -0
  134. package/lib/{clipboard.js → term/clipboard.js} +3 -6
  135. package/lib/{select.js → term/select.js} +2 -2
  136. package/lib/term/themes/dark.json +122 -0
  137. package/lib/term/themes/light.json +122 -0
  138. package/lib/term/wide.txt +21 -0
  139. package/lib/{wrap.js → term/wrap.js} +4 -4
  140. package/package.json +2 -2
  141. package/lib/ansi.js +0 -505
  142. package/lib/detect.js +0 -34
  143. package/lib/diff/edit.js +0 -33
  144. package/lib/git-worktree.js +0 -437
  145. package/lib/git.js +0 -79
  146. package/lib/npm-commands.js +0 -522
  147. package/lib/render/chrome.js +0 -628
  148. package/lib/render/dash-blocks.js +0 -245
  149. package/lib/render/present.js +0 -19
  150. package/lib/render/report.js +0 -43
  151. package/lib/review.js +0 -744
  152. package/lib/session/accessors.js +0 -26
  153. package/lib/session/edit-click.js +0 -57
  154. package/lib/session/npm.js +0 -452
  155. package/lib/session/progress.js +0 -41
  156. package/lib/source.js +0 -36
  157. package/lib/update.js +0 -192
  158. /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