neuro-cli 4.1.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/LICENSE +21 -0
- package/README.md +510 -0
- package/dist/advisor/advisor.d.ts +50 -0
- package/dist/advisor/advisor.js +178 -0
- package/dist/agents/base.d.ts +62 -0
- package/dist/agents/base.js +215 -0
- package/dist/agents/orchestrator.d.ts +46 -0
- package/dist/agents/orchestrator.js +192 -0
- package/dist/agents/team.d.ts +51 -0
- package/dist/agents/team.js +210 -0
- package/dist/api/models.d.ts +23 -0
- package/dist/api/models.js +514 -0
- package/dist/api/ollama.d.ts +153 -0
- package/dist/api/ollama.js +751 -0
- package/dist/api/openrouter.d.ts +55 -0
- package/dist/api/openrouter.js +223 -0
- package/dist/commands/commands.d.ts +43 -0
- package/dist/commands/commands.js +308 -0
- package/dist/config/config.d.ts +8 -0
- package/dist/config/config.js +311 -0
- package/dist/context/compaction.d.ts +54 -0
- package/dist/context/compaction.js +251 -0
- package/dist/context/custom-agents.d.ts +107 -0
- package/dist/context/custom-agents.js +397 -0
- package/dist/context/custom-tools.d.ts +120 -0
- package/dist/context/custom-tools.js +564 -0
- package/dist/context/git-checkpoint.d.ts +52 -0
- package/dist/context/git-checkpoint.js +240 -0
- package/dist/context/neuro-md.d.ts +48 -0
- package/dist/context/neuro-md.js +202 -0
- package/dist/context/neuroignore.d.ts +102 -0
- package/dist/context/neuroignore.js +441 -0
- package/dist/context/repo-map.d.ts +38 -0
- package/dist/context/repo-map.js +220 -0
- package/dist/context/skill-standard.d.ts +262 -0
- package/dist/context/skill-standard.js +1156 -0
- package/dist/context/skill-system.d.ts +75 -0
- package/dist/context/skill-system.js +578 -0
- package/dist/context/tree-sitter.d.ts +99 -0
- package/dist/context/tree-sitter.js +1956 -0
- package/dist/core/acp.d.ts +325 -0
- package/dist/core/acp.js +1498 -0
- package/dist/core/api-server.d.ts +143 -0
- package/dist/core/api-server.js +550 -0
- package/dist/core/approval.d.ts +81 -0
- package/dist/core/approval.js +432 -0
- package/dist/core/auto-compact.d.ts +127 -0
- package/dist/core/auto-compact.js +436 -0
- package/dist/core/auto-mode.d.ts +232 -0
- package/dist/core/auto-mode.js +831 -0
- package/dist/core/background-session.d.ts +166 -0
- package/dist/core/background-session.js +696 -0
- package/dist/core/cicd.d.ts +257 -0
- package/dist/core/cicd.js +1443 -0
- package/dist/core/cloud-sync.d.ts +156 -0
- package/dist/core/cloud-sync.js +582 -0
- package/dist/core/code-review.d.ts +132 -0
- package/dist/core/code-review.js +1191 -0
- package/dist/core/completion.d.ts +49 -0
- package/dist/core/completion.js +384 -0
- package/dist/core/context.d.ts +38 -0
- package/dist/core/context.js +144 -0
- package/dist/core/diff-preview.d.ts +35 -0
- package/dist/core/diff-preview.js +173 -0
- package/dist/core/doom-loop.d.ts +51 -0
- package/dist/core/doom-loop.js +179 -0
- package/dist/core/engine.d.ts +183 -0
- package/dist/core/engine.js +942 -0
- package/dist/core/extended-thinking.d.ts +103 -0
- package/dist/core/extended-thinking.js +269 -0
- package/dist/core/fallback.d.ts +54 -0
- package/dist/core/fallback.js +104 -0
- package/dist/core/git-worktree.d.ts +139 -0
- package/dist/core/git-worktree.js +614 -0
- package/dist/core/headless.d.ts +30 -0
- package/dist/core/headless.js +101 -0
- package/dist/core/i18n.d.ts +83 -0
- package/dist/core/i18n.js +739 -0
- package/dist/core/linting.d.ts +129 -0
- package/dist/core/linting.js +699 -0
- package/dist/core/model-router.d.ts +109 -0
- package/dist/core/model-router.js +581 -0
- package/dist/core/multi-model.d.ts +243 -0
- package/dist/core/multi-model.js +1099 -0
- package/dist/core/multi-session.d.ts +144 -0
- package/dist/core/multi-session.js +442 -0
- package/dist/core/multimodal.d.ts +125 -0
- package/dist/core/multimodal.js +286 -0
- package/dist/core/observability.d.ts +93 -0
- package/dist/core/observability.js +737 -0
- package/dist/core/os-sandbox.d.ts +122 -0
- package/dist/core/os-sandbox.js +1193 -0
- package/dist/core/outcome-grading.d.ts +228 -0
- package/dist/core/outcome-grading.js +1123 -0
- package/dist/core/output-styles.d.ts +57 -0
- package/dist/core/output-styles.js +382 -0
- package/dist/core/parallel-agents.d.ts +183 -0
- package/dist/core/parallel-agents.js +563 -0
- package/dist/core/plugin-bundle.d.ts +236 -0
- package/dist/core/plugin-bundle.js +887 -0
- package/dist/core/plugin-sdk.d.ts +139 -0
- package/dist/core/plugin-sdk.js +273 -0
- package/dist/core/prompt-cache.d.ts +163 -0
- package/dist/core/prompt-cache.js +599 -0
- package/dist/core/sandbox.d.ts +127 -0
- package/dist/core/sandbox.js +369 -0
- package/dist/core/scheduled-tasks.d.ts +151 -0
- package/dist/core/scheduled-tasks.js +502 -0
- package/dist/core/security-scanner.d.ts +160 -0
- package/dist/core/security-scanner.js +1494 -0
- package/dist/core/session.d.ts +83 -0
- package/dist/core/session.js +269 -0
- package/dist/core/shell-completion.d.ts +51 -0
- package/dist/core/shell-completion.js +674 -0
- package/dist/core/smart-monitor.d.ts +146 -0
- package/dist/core/smart-monitor.js +1199 -0
- package/dist/core/spec-driven.d.ts +233 -0
- package/dist/core/spec-driven.js +1485 -0
- package/dist/core/spending-warnings.d.ts +123 -0
- package/dist/core/spending-warnings.js +456 -0
- package/dist/core/sub-agent.d.ts +298 -0
- package/dist/core/sub-agent.js +1023 -0
- package/dist/core/telemetry.d.ts +157 -0
- package/dist/core/telemetry.js +412 -0
- package/dist/core/terminal-ux.d.ts +134 -0
- package/dist/core/terminal-ux.js +649 -0
- package/dist/core/testing.d.ts +146 -0
- package/dist/core/testing.js +1200 -0
- package/dist/core/types.d.ts +439 -0
- package/dist/core/types.js +6 -0
- package/dist/core/undo-redo.d.ts +112 -0
- package/dist/core/undo-redo.js +290 -0
- package/dist/core/updater.d.ts +159 -0
- package/dist/core/updater.js +608 -0
- package/dist/core/vim-mode.d.ts +151 -0
- package/dist/core/vim-mode.js +771 -0
- package/dist/core/voice.d.ts +137 -0
- package/dist/core/voice.js +538 -0
- package/dist/core/web-dashboard.d.ts +109 -0
- package/dist/core/web-dashboard.js +484 -0
- package/dist/hooks/hooks.d.ts +74 -0
- package/dist/hooks/hooks.js +160 -0
- package/dist/hooks/llm-evaluator.d.ts +165 -0
- package/dist/hooks/llm-evaluator.js +560 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1186 -0
- package/dist/lsp/lsp-manager.d.ts +63 -0
- package/dist/lsp/lsp-manager.js +351 -0
- package/dist/mcp/client.d.ts +133 -0
- package/dist/mcp/client.js +684 -0
- package/dist/mcp/mcp-apps.d.ts +70 -0
- package/dist/mcp/mcp-apps.js +1007 -0
- package/dist/tools/bash.d.ts +5 -0
- package/dist/tools/bash.js +195 -0
- package/dist/tools/browser.d.ts +92 -0
- package/dist/tools/browser.js +1570 -0
- package/dist/tools/extended.d.ts +6 -0
- package/dist/tools/extended.js +191 -0
- package/dist/tools/file.d.ts +10 -0
- package/dist/tools/file.js +382 -0
- package/dist/tools/github.d.ts +389 -0
- package/dist/tools/github.js +759 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.js +40 -0
- package/dist/tools/memory.d.ts +6 -0
- package/dist/tools/memory.js +197 -0
- package/dist/tools/registry.d.ts +29 -0
- package/dist/tools/registry.js +64 -0
- package/dist/tools/web.d.ts +6 -0
- package/dist/tools/web.js +150 -0
- package/dist/ui/renderer.d.ts +97 -0
- package/dist/ui/renderer.js +279 -0
- package/dist/ui/theme.d.ts +27 -0
- package/dist/ui/theme.js +106 -0
- package/package.json +83 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { writeFileSync, unlinkSync, existsSync, mkdirSync } from 'fs';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Helpers
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
let _nextSeq = 0;
|
|
7
|
+
function generateId() {
|
|
8
|
+
_nextSeq += 1;
|
|
9
|
+
return `act_${Date.now().toString(36)}_${_nextSeq}`;
|
|
10
|
+
}
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// UndoRedoSystem
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
/**
|
|
15
|
+
* Production-quality undo/redo system for NeuroCLI.
|
|
16
|
+
*
|
|
17
|
+
* Tracks file-level create, modify and delete operations so that any change
|
|
18
|
+
* can be rolled back (undo) or re-applied (redo). The redo stack is cleared
|
|
19
|
+
* automatically whenever a new action is pushed -- this mirrors the behaviour
|
|
20
|
+
* of most professional editors and prevents ambiguous redo states.
|
|
21
|
+
*/
|
|
22
|
+
export class UndoRedoSystem {
|
|
23
|
+
undoStack = [];
|
|
24
|
+
redoStack = [];
|
|
25
|
+
// Cumulative counters -- survive clear() so that stats remain meaningful.
|
|
26
|
+
totalUndos = 0;
|
|
27
|
+
totalRedos = 0;
|
|
28
|
+
totalActionsPushed = 0;
|
|
29
|
+
// -----------------------------------------------------------------------
|
|
30
|
+
// Core mutators
|
|
31
|
+
// -----------------------------------------------------------------------
|
|
32
|
+
/**
|
|
33
|
+
* Record a new action. The action is pushed onto the undo stack and the
|
|
34
|
+
* redo stack is cleared (standard expectation: a new edit invalidates
|
|
35
|
+
* previously undone changes).
|
|
36
|
+
*/
|
|
37
|
+
push(action) {
|
|
38
|
+
const full = {
|
|
39
|
+
...action,
|
|
40
|
+
id: generateId(),
|
|
41
|
+
timestamp: Date.now(),
|
|
42
|
+
};
|
|
43
|
+
this.undoStack.push(full);
|
|
44
|
+
this.redoStack = [];
|
|
45
|
+
this.totalActionsPushed += 1;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Undo the most recent action. Returns the undone action or `null` when
|
|
49
|
+
* there is nothing to undo. The action is moved from the undo stack to
|
|
50
|
+
* the redo stack and the file system change is reversed.
|
|
51
|
+
*/
|
|
52
|
+
undo() {
|
|
53
|
+
if (this.undoStack.length === 0) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const action = this.undoStack.pop();
|
|
57
|
+
this.redoStack.push(action);
|
|
58
|
+
this.totalUndos += 1;
|
|
59
|
+
try {
|
|
60
|
+
this.applyUndo(action);
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
// Re-throw with context so callers can decide how to handle a partial
|
|
64
|
+
// failure -- the action has already been moved to the redo stack which
|
|
65
|
+
// keeps the internal state consistent.
|
|
66
|
+
throw new UndoRedoError(`Failed to apply undo for action "${action.id}" (${action.type}) on "${action.path}": ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
67
|
+
}
|
|
68
|
+
return action;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Redo the most recently undone action. Returns the re-applied action or
|
|
72
|
+
* `null` when there is nothing to redo. The action is moved from the redo
|
|
73
|
+
* stack back to the undo stack and the file system change is re-applied.
|
|
74
|
+
*/
|
|
75
|
+
redo() {
|
|
76
|
+
if (this.redoStack.length === 0) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const action = this.redoStack.pop();
|
|
80
|
+
this.undoStack.push(action);
|
|
81
|
+
this.totalRedos += 1;
|
|
82
|
+
try {
|
|
83
|
+
this.applyRedo(action);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
throw new UndoRedoError(`Failed to apply redo for action "${action.id}" (${action.type}) on "${action.path}": ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
87
|
+
}
|
|
88
|
+
return action;
|
|
89
|
+
}
|
|
90
|
+
// -----------------------------------------------------------------------
|
|
91
|
+
// Batch undo / redo
|
|
92
|
+
// -----------------------------------------------------------------------
|
|
93
|
+
/**
|
|
94
|
+
* Undo up to `n` actions. Stops early if the undo stack is exhausted.
|
|
95
|
+
* Returns the list of actions that were undone (most-recent-first order --
|
|
96
|
+
* i.e. the first element is the action that was on top of the stack).
|
|
97
|
+
*/
|
|
98
|
+
undoN(n) {
|
|
99
|
+
if (n <= 0) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
const results = [];
|
|
103
|
+
for (let i = 0; i < n; i++) {
|
|
104
|
+
const action = this.undo();
|
|
105
|
+
if (action === null) {
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
results.push(action);
|
|
109
|
+
}
|
|
110
|
+
return results;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Redo up to `n` actions. Stops early if the redo stack is exhausted.
|
|
114
|
+
* Returns the list of actions that were re-applied (oldest-first order --
|
|
115
|
+
* i.e. the first element was the earliest undone action).
|
|
116
|
+
*/
|
|
117
|
+
redoN(n) {
|
|
118
|
+
if (n <= 0) {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
const results = [];
|
|
122
|
+
for (let i = 0; i < n; i++) {
|
|
123
|
+
const action = this.redo();
|
|
124
|
+
if (action === null) {
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
results.push(action);
|
|
128
|
+
}
|
|
129
|
+
return results;
|
|
130
|
+
}
|
|
131
|
+
// -----------------------------------------------------------------------
|
|
132
|
+
// Queries
|
|
133
|
+
// -----------------------------------------------------------------------
|
|
134
|
+
canUndo() {
|
|
135
|
+
return this.undoStack.length > 0;
|
|
136
|
+
}
|
|
137
|
+
canRedo() {
|
|
138
|
+
return this.redoStack.length > 0;
|
|
139
|
+
}
|
|
140
|
+
getUndoStack() {
|
|
141
|
+
// Return a shallow copy to prevent external mutation.
|
|
142
|
+
return [...this.undoStack];
|
|
143
|
+
}
|
|
144
|
+
getRedoStack() {
|
|
145
|
+
return [...this.redoStack];
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Returns a human-readable history combining both stacks.
|
|
149
|
+
*
|
|
150
|
+
* The undo entries are shown newest-first; the redo entries are shown
|
|
151
|
+
* oldest-first (which is the order in which they would be re-applied).
|
|
152
|
+
*/
|
|
153
|
+
getHistory() {
|
|
154
|
+
return {
|
|
155
|
+
undo: [...this.undoStack].reverse(),
|
|
156
|
+
redo: [...this.redoStack],
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
// -----------------------------------------------------------------------
|
|
160
|
+
// Lifecycle
|
|
161
|
+
// -----------------------------------------------------------------------
|
|
162
|
+
/**
|
|
163
|
+
* Clear both stacks. Cumulative stats counters are intentionally NOT
|
|
164
|
+
* reset so that `getStats()` retains a full session-level picture.
|
|
165
|
+
*/
|
|
166
|
+
clear() {
|
|
167
|
+
this.undoStack = [];
|
|
168
|
+
this.redoStack = [];
|
|
169
|
+
}
|
|
170
|
+
getSize() {
|
|
171
|
+
return {
|
|
172
|
+
undo: this.undoStack.length,
|
|
173
|
+
redo: this.redoStack.length,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
getStats() {
|
|
177
|
+
return {
|
|
178
|
+
totalUndos: this.totalUndos,
|
|
179
|
+
totalRedos: this.totalRedos,
|
|
180
|
+
totalActions: this.totalActionsPushed,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
// -----------------------------------------------------------------------
|
|
184
|
+
// File-system helpers
|
|
185
|
+
// -----------------------------------------------------------------------
|
|
186
|
+
/**
|
|
187
|
+
* Restore the file system to the state before `action` was performed.
|
|
188
|
+
*
|
|
189
|
+
* - **file_create** : delete the created file.
|
|
190
|
+
* - **file_modify** : restore `originalContent` (must be present).
|
|
191
|
+
* - **file_delete** : re-create the file with `originalContent` (must be
|
|
192
|
+
* present).
|
|
193
|
+
*/
|
|
194
|
+
applyUndo(action) {
|
|
195
|
+
switch (action.type) {
|
|
196
|
+
case 'file_create': {
|
|
197
|
+
// The file was created; remove it to undo.
|
|
198
|
+
if (!existsSync(action.path)) {
|
|
199
|
+
// File already absent -- nothing to do, but this is worth noting.
|
|
200
|
+
throw new UndoRedoError(`Cannot undo file_create: file does not exist at "${action.path}"`);
|
|
201
|
+
}
|
|
202
|
+
unlinkSync(action.path);
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
case 'file_modify': {
|
|
206
|
+
// Restore the previous content.
|
|
207
|
+
if (action.originalContent === undefined) {
|
|
208
|
+
throw new UndoRedoError(`Cannot undo file_modify: originalContent is missing for action "${action.id}"`);
|
|
209
|
+
}
|
|
210
|
+
this.ensureDir(action.path);
|
|
211
|
+
writeFileSync(action.path, action.originalContent, 'utf-8');
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
case 'file_delete': {
|
|
215
|
+
// Re-create the deleted file.
|
|
216
|
+
if (action.originalContent === undefined) {
|
|
217
|
+
throw new UndoRedoError(`Cannot undo file_delete: originalContent is missing for action "${action.id}"`);
|
|
218
|
+
}
|
|
219
|
+
this.ensureDir(action.path);
|
|
220
|
+
writeFileSync(action.path, action.originalContent, 'utf-8');
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
default: {
|
|
224
|
+
const exhaustive = action.type;
|
|
225
|
+
throw new UndoRedoError(`Unknown action type: ${String(exhaustive)}`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Re-apply a previously undone action to the file system.
|
|
231
|
+
*
|
|
232
|
+
* - **file_create** : re-create the file with `newContent` (must be
|
|
233
|
+
* present).
|
|
234
|
+
* - **file_modify** : write `newContent` (must be present).
|
|
235
|
+
* - **file_delete** : delete the file again.
|
|
236
|
+
*/
|
|
237
|
+
applyRedo(action) {
|
|
238
|
+
switch (action.type) {
|
|
239
|
+
case 'file_create': {
|
|
240
|
+
if (action.newContent === undefined) {
|
|
241
|
+
throw new UndoRedoError(`Cannot redo file_create: newContent is missing for action "${action.id}"`);
|
|
242
|
+
}
|
|
243
|
+
this.ensureDir(action.path);
|
|
244
|
+
writeFileSync(action.path, action.newContent, 'utf-8');
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
case 'file_modify': {
|
|
248
|
+
if (action.newContent === undefined) {
|
|
249
|
+
throw new UndoRedoError(`Cannot redo file_modify: newContent is missing for action "${action.id}"`);
|
|
250
|
+
}
|
|
251
|
+
this.ensureDir(action.path);
|
|
252
|
+
writeFileSync(action.path, action.newContent, 'utf-8');
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
case 'file_delete': {
|
|
256
|
+
if (!existsSync(action.path)) {
|
|
257
|
+
throw new UndoRedoError(`Cannot redo file_delete: file does not exist at "${action.path}"`);
|
|
258
|
+
}
|
|
259
|
+
unlinkSync(action.path);
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
default: {
|
|
263
|
+
const exhaustive = action.type;
|
|
264
|
+
throw new UndoRedoError(`Unknown action type: ${String(exhaustive)}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
// -----------------------------------------------------------------------
|
|
269
|
+
// Internal utilities
|
|
270
|
+
// -----------------------------------------------------------------------
|
|
271
|
+
/**
|
|
272
|
+
* Make sure the parent directory of `filePath` exists before writing.
|
|
273
|
+
*/
|
|
274
|
+
ensureDir(filePath) {
|
|
275
|
+
const dir = dirname(filePath);
|
|
276
|
+
if (!existsSync(dir)) {
|
|
277
|
+
mkdirSync(dir, { recursive: true });
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// ---------------------------------------------------------------------------
|
|
282
|
+
// Custom error
|
|
283
|
+
// ---------------------------------------------------------------------------
|
|
284
|
+
export class UndoRedoError extends Error {
|
|
285
|
+
constructor(message, options) {
|
|
286
|
+
super(message, options);
|
|
287
|
+
this.name = 'UndoRedoError';
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=undo-redo.js.map
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
export interface UpdateCheckResult {
|
|
2
|
+
hasUpdate: boolean;
|
|
3
|
+
currentVersion: string;
|
|
4
|
+
latestVersion: string;
|
|
5
|
+
source: 'npm' | 'github' | 'cache';
|
|
6
|
+
changelog?: string;
|
|
7
|
+
checkedAt: number;
|
|
8
|
+
}
|
|
9
|
+
export interface UpdaterConfig {
|
|
10
|
+
/** Package name on npm registry */
|
|
11
|
+
packageName: string;
|
|
12
|
+
/** Current installed version */
|
|
13
|
+
currentVersion: string;
|
|
14
|
+
/** GitHub owner/repo for releases fallback */
|
|
15
|
+
githubRepo: string;
|
|
16
|
+
/** How often to check for updates (ms), default: 24 hours */
|
|
17
|
+
checkInterval: number;
|
|
18
|
+
/** Directory to store update state */
|
|
19
|
+
stateDir: string;
|
|
20
|
+
/** Whether to auto-check on startup */
|
|
21
|
+
autoCheck: boolean;
|
|
22
|
+
/** Whether to auto-update without asking */
|
|
23
|
+
autoUpdate: boolean;
|
|
24
|
+
/** npm registry URL */
|
|
25
|
+
registryUrl: string;
|
|
26
|
+
/** Whether to show changelog on update */
|
|
27
|
+
showChangelog: boolean;
|
|
28
|
+
/** Whether to notify about prereleases */
|
|
29
|
+
includePrerelease: boolean;
|
|
30
|
+
/** Custom update command (default: npm update -g) */
|
|
31
|
+
updateCommand?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface UpdateState {
|
|
34
|
+
lastCheckTime: number;
|
|
35
|
+
lastKnownVersion: string;
|
|
36
|
+
lastCheckSource: 'npm' | 'github' | 'cache';
|
|
37
|
+
dismissedVersions: string[];
|
|
38
|
+
skippedCheckReason?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare class AutoUpdater {
|
|
41
|
+
private config;
|
|
42
|
+
private state;
|
|
43
|
+
private stateFile;
|
|
44
|
+
private lastCheckResult;
|
|
45
|
+
constructor(config: Partial<UpdaterConfig> & {
|
|
46
|
+
currentVersion: string;
|
|
47
|
+
});
|
|
48
|
+
private loadState;
|
|
49
|
+
private saveState;
|
|
50
|
+
/**
|
|
51
|
+
* Check if enough time has passed since last check
|
|
52
|
+
*/
|
|
53
|
+
shouldCheck(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Get time until next check is due
|
|
56
|
+
*/
|
|
57
|
+
timeUntilNextCheck(): number;
|
|
58
|
+
/**
|
|
59
|
+
* Check for updates from npm registry
|
|
60
|
+
*/
|
|
61
|
+
checkForUpdate(force?: boolean): Promise<UpdateCheckResult>;
|
|
62
|
+
/**
|
|
63
|
+
* Check npm registry API directly
|
|
64
|
+
*/
|
|
65
|
+
private checkNpmRegistry;
|
|
66
|
+
/**
|
|
67
|
+
* Check GitHub releases API
|
|
68
|
+
*/
|
|
69
|
+
private checkGitHubReleases;
|
|
70
|
+
/**
|
|
71
|
+
* Check using `npm view` command (fallback)
|
|
72
|
+
*/
|
|
73
|
+
private checkNpmView;
|
|
74
|
+
/**
|
|
75
|
+
* Extract changelog from npm package data
|
|
76
|
+
*/
|
|
77
|
+
private extractChangelog;
|
|
78
|
+
/**
|
|
79
|
+
* Perform the self-update
|
|
80
|
+
* Returns true if update was successful
|
|
81
|
+
*/
|
|
82
|
+
performUpdate(version?: string): Promise<{
|
|
83
|
+
success: boolean;
|
|
84
|
+
message: string;
|
|
85
|
+
newVersion?: string;
|
|
86
|
+
}>;
|
|
87
|
+
/**
|
|
88
|
+
* Verify that the update was successful
|
|
89
|
+
*/
|
|
90
|
+
private verifyUpdate;
|
|
91
|
+
/**
|
|
92
|
+
* Dismiss a specific version (don't notify again)
|
|
93
|
+
*/
|
|
94
|
+
dismissVersion(version: string): void;
|
|
95
|
+
/**
|
|
96
|
+
* Check if a version has been dismissed
|
|
97
|
+
*/
|
|
98
|
+
isDismissed(version: string): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Display update notification banner
|
|
101
|
+
*/
|
|
102
|
+
showUpdateNotification(result: UpdateCheckResult): void;
|
|
103
|
+
/**
|
|
104
|
+
* Display detailed update info with changelog
|
|
105
|
+
*/
|
|
106
|
+
showUpdateDetails(result: UpdateCheckResult): void;
|
|
107
|
+
/**
|
|
108
|
+
* Show "up to date" message
|
|
109
|
+
*/
|
|
110
|
+
showUpToDate(): void;
|
|
111
|
+
/**
|
|
112
|
+
* Format time duration in human-readable format
|
|
113
|
+
*/
|
|
114
|
+
private formatDuration;
|
|
115
|
+
/**
|
|
116
|
+
* Run background update check on startup.
|
|
117
|
+
* Returns the check result if an update is available, null otherwise.
|
|
118
|
+
*/
|
|
119
|
+
checkOnStartup(): Promise<UpdateCheckResult | null>;
|
|
120
|
+
/**
|
|
121
|
+
* Interactive update flow — check, show, and optionally update
|
|
122
|
+
*/
|
|
123
|
+
interactiveUpdate(): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* Set auto-check on/off
|
|
126
|
+
*/
|
|
127
|
+
setAutoCheck(enabled: boolean): void;
|
|
128
|
+
/**
|
|
129
|
+
* Set auto-update on/off
|
|
130
|
+
*/
|
|
131
|
+
setAutoUpdate(enabled: boolean): void;
|
|
132
|
+
/**
|
|
133
|
+
* Set check interval in hours
|
|
134
|
+
*/
|
|
135
|
+
setCheckInterval(hours: number): void;
|
|
136
|
+
/**
|
|
137
|
+
* Get current updater config
|
|
138
|
+
*/
|
|
139
|
+
getConfig(): Readonly<UpdaterConfig>;
|
|
140
|
+
/**
|
|
141
|
+
* Get last check result
|
|
142
|
+
*/
|
|
143
|
+
getLastCheck(): UpdateCheckResult | null;
|
|
144
|
+
/**
|
|
145
|
+
* Reset dismissed versions
|
|
146
|
+
*/
|
|
147
|
+
resetDismissed(): void;
|
|
148
|
+
/**
|
|
149
|
+
* Force next check on startup
|
|
150
|
+
*/
|
|
151
|
+
forceNextCheck(): void;
|
|
152
|
+
}
|
|
153
|
+
export declare function checkForUpdates(currentVersion: string): Promise<UpdateCheckResult>;
|
|
154
|
+
export declare function performSelfUpdate(currentVersion: string, version?: string): Promise<{
|
|
155
|
+
success: boolean;
|
|
156
|
+
message: string;
|
|
157
|
+
newVersion?: string;
|
|
158
|
+
}>;
|
|
159
|
+
//# sourceMappingURL=updater.d.ts.map
|