newo 2.0.4 → 2.0.5
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/dist/sync/skill-files.js +45 -43
- package/package.json +1 -1
- package/src/sync/skill-files.ts +46 -42
package/dist/sync/skill-files.js
CHANGED
|
@@ -110,57 +110,59 @@ export async function askForOverwrite(skillIdn, existingContent, newContent, fil
|
|
|
110
110
|
// Show a GitHub-style colored diff with line numbers and context
|
|
111
111
|
const localLines = existingContent.trim().split('\n');
|
|
112
112
|
const remoteLines = newContent.trim().split('\n');
|
|
113
|
-
// Find
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
let
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (localLine !== remoteLine) {
|
|
122
|
-
if (localLine !== undefined && remoteLine !== undefined) {
|
|
123
|
-
diffs.push({ localIndex: localIdx, remoteIndex: remoteIdx, type: 'change' });
|
|
124
|
-
}
|
|
125
|
-
else if (localLine !== undefined) {
|
|
126
|
-
diffs.push({ localIndex: localIdx, remoteIndex: -1, type: 'remove' });
|
|
127
|
-
}
|
|
128
|
-
else if (remoteLine !== undefined) {
|
|
129
|
-
diffs.push({ localIndex: -1, remoteIndex: remoteIdx, type: 'add' });
|
|
130
|
-
}
|
|
113
|
+
// Find the first differing section and show it with context
|
|
114
|
+
let diffStart = -1;
|
|
115
|
+
let diffEnd = -1;
|
|
116
|
+
// Find first difference
|
|
117
|
+
for (let i = 0; i < Math.max(localLines.length, remoteLines.length); i++) {
|
|
118
|
+
if (localLines[i] !== remoteLines[i]) {
|
|
119
|
+
diffStart = i;
|
|
120
|
+
break;
|
|
131
121
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
122
|
+
}
|
|
123
|
+
if (diffStart === -1) {
|
|
124
|
+
// No differences found (shouldn't happen, but handle gracefully)
|
|
125
|
+
console.log(`${gray} No differences found${reset}`);
|
|
126
|
+
return 'no';
|
|
127
|
+
}
|
|
128
|
+
// Find end of difference section
|
|
129
|
+
diffEnd = diffStart;
|
|
130
|
+
while (diffEnd < Math.max(localLines.length, remoteLines.length) &&
|
|
131
|
+
(localLines[diffEnd] !== remoteLines[diffEnd] ||
|
|
132
|
+
localLines[diffEnd] === undefined ||
|
|
133
|
+
remoteLines[diffEnd] === undefined)) {
|
|
134
|
+
diffEnd++;
|
|
135
|
+
}
|
|
136
|
+
// Show context before (2 lines)
|
|
137
|
+
const contextStart = Math.max(0, diffStart - 2);
|
|
138
|
+
for (let i = contextStart; i < diffStart; i++) {
|
|
139
|
+
if (localLines[i] !== undefined) {
|
|
146
140
|
console.log(` ${String(i + 1).padStart(3)} ${localLines[i]}`);
|
|
147
141
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
142
|
+
}
|
|
143
|
+
// Show the differences
|
|
144
|
+
const maxDiffLine = Math.min(diffEnd, Math.max(localLines.length, remoteLines.length));
|
|
145
|
+
for (let i = diffStart; i < maxDiffLine; i++) {
|
|
146
|
+
const localLine = localLines[i];
|
|
147
|
+
const remoteLine = remoteLines[i];
|
|
148
|
+
if (localLine !== undefined && (remoteLine === undefined || localLine !== remoteLine)) {
|
|
149
|
+
console.log(`${redBg} - ${String(i + 1).padStart(3)} ${localLine} ${reset}`);
|
|
151
150
|
}
|
|
152
|
-
if (
|
|
153
|
-
console.log(`${greenBg} + ${String(
|
|
151
|
+
if (remoteLine !== undefined && (localLine === undefined || localLine !== remoteLine)) {
|
|
152
|
+
console.log(`${greenBg} + ${String(i + 1).padStart(3)} ${remoteLine} ${reset}`);
|
|
154
153
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
}
|
|
155
|
+
// Show context after (2 lines)
|
|
156
|
+
const contextEnd = Math.min(localLines.length, diffEnd + 2);
|
|
157
|
+
for (let i = diffEnd; i < contextEnd; i++) {
|
|
158
|
+
if (localLines[i] !== undefined) {
|
|
158
159
|
console.log(` ${String(i + 1).padStart(3)} ${localLines[i]}`);
|
|
159
160
|
}
|
|
160
|
-
shown++;
|
|
161
161
|
}
|
|
162
|
-
if
|
|
163
|
-
|
|
162
|
+
// Show if there are more differences
|
|
163
|
+
const totalDiffs = Math.abs(localLines.length - remoteLines.length) + (diffEnd - diffStart);
|
|
164
|
+
if (totalDiffs > (diffEnd - diffStart)) {
|
|
165
|
+
console.log(`${gray}... (${totalDiffs - (diffEnd - diffStart)} more differences)${reset}`);
|
|
164
166
|
}
|
|
165
167
|
const answer = await new Promise((resolve) => {
|
|
166
168
|
rl.question(`\nReplace local with remote? (y)es/(n)o/(a)ll/(q)uit: `, resolve);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newo",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "NEWO CLI: Professional command-line tool with modular architecture for NEWO AI Agent development. Features IDN-based file management, real-time progress tracking, intelligent sync operations, and comprehensive multi-customer support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/sync/skill-files.ts
CHANGED
|
@@ -166,63 +166,67 @@ export async function askForOverwrite(skillIdn: string, existingContent: string,
|
|
|
166
166
|
const localLines = existingContent.trim().split('\n');
|
|
167
167
|
const remoteLines = newContent.trim().split('\n');
|
|
168
168
|
|
|
169
|
-
// Find
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
let
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const remoteLine = remoteLines[remoteIdx];
|
|
179
|
-
|
|
180
|
-
if (localLine !== remoteLine) {
|
|
181
|
-
if (localLine !== undefined && remoteLine !== undefined) {
|
|
182
|
-
diffs.push({localIndex: localIdx, remoteIndex: remoteIdx, type: 'change'});
|
|
183
|
-
} else if (localLine !== undefined) {
|
|
184
|
-
diffs.push({localIndex: localIdx, remoteIndex: -1, type: 'remove'});
|
|
185
|
-
} else if (remoteLine !== undefined) {
|
|
186
|
-
diffs.push({localIndex: -1, remoteIndex: remoteIdx, type: 'add'});
|
|
187
|
-
}
|
|
169
|
+
// Find the first differing section and show it with context
|
|
170
|
+
let diffStart = -1;
|
|
171
|
+
let diffEnd = -1;
|
|
172
|
+
|
|
173
|
+
// Find first difference
|
|
174
|
+
for (let i = 0; i < Math.max(localLines.length, remoteLines.length); i++) {
|
|
175
|
+
if (localLines[i] !== remoteLines[i]) {
|
|
176
|
+
diffStart = i;
|
|
177
|
+
break;
|
|
188
178
|
}
|
|
189
|
-
|
|
190
|
-
if (localLine !== undefined) localIdx++;
|
|
191
|
-
if (remoteLine !== undefined) remoteIdx++;
|
|
192
179
|
}
|
|
193
180
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
181
|
+
if (diffStart === -1) {
|
|
182
|
+
// No differences found (shouldn't happen, but handle gracefully)
|
|
183
|
+
console.log(`${gray} No differences found${reset}`);
|
|
184
|
+
return 'no';
|
|
185
|
+
}
|
|
197
186
|
|
|
198
|
-
|
|
199
|
-
|
|
187
|
+
// Find end of difference section
|
|
188
|
+
diffEnd = diffStart;
|
|
189
|
+
while (diffEnd < Math.max(localLines.length, remoteLines.length) &&
|
|
190
|
+
(localLines[diffEnd] !== remoteLines[diffEnd] ||
|
|
191
|
+
localLines[diffEnd] === undefined ||
|
|
192
|
+
remoteLines[diffEnd] === undefined)) {
|
|
193
|
+
diffEnd++;
|
|
194
|
+
}
|
|
200
195
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
196
|
+
// Show context before (2 lines)
|
|
197
|
+
const contextStart = Math.max(0, diffStart - 2);
|
|
198
|
+
for (let i = contextStart; i < diffStart; i++) {
|
|
199
|
+
if (localLines[i] !== undefined) {
|
|
204
200
|
console.log(` ${String(i + 1).padStart(3)} ${localLines[i]}`);
|
|
205
201
|
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Show the differences
|
|
205
|
+
const maxDiffLine = Math.min(diffEnd, Math.max(localLines.length, remoteLines.length));
|
|
206
|
+
for (let i = diffStart; i < maxDiffLine; i++) {
|
|
207
|
+
const localLine = localLines[i];
|
|
208
|
+
const remoteLine = remoteLines[i];
|
|
206
209
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
console.log(`${redBg} - ${String(diff.localIndex + 1).padStart(3)} ${localLines[diff.localIndex]} ${reset}`);
|
|
210
|
+
if (localLine !== undefined && (remoteLine === undefined || localLine !== remoteLine)) {
|
|
211
|
+
console.log(`${redBg} - ${String(i + 1).padStart(3)} ${localLine} ${reset}`);
|
|
210
212
|
}
|
|
211
|
-
if (
|
|
212
|
-
console.log(`${greenBg} + ${String(
|
|
213
|
+
if (remoteLine !== undefined && (localLine === undefined || localLine !== remoteLine)) {
|
|
214
|
+
console.log(`${greenBg} + ${String(i + 1).padStart(3)} ${remoteLine} ${reset}`);
|
|
213
215
|
}
|
|
216
|
+
}
|
|
214
217
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
+
// Show context after (2 lines)
|
|
219
|
+
const contextEnd = Math.min(localLines.length, diffEnd + 2);
|
|
220
|
+
for (let i = diffEnd; i < contextEnd; i++) {
|
|
221
|
+
if (localLines[i] !== undefined) {
|
|
218
222
|
console.log(` ${String(i + 1).padStart(3)} ${localLines[i]}`);
|
|
219
223
|
}
|
|
220
|
-
|
|
221
|
-
shown++;
|
|
222
224
|
}
|
|
223
225
|
|
|
224
|
-
if
|
|
225
|
-
|
|
226
|
+
// Show if there are more differences
|
|
227
|
+
const totalDiffs = Math.abs(localLines.length - remoteLines.length) + (diffEnd - diffStart);
|
|
228
|
+
if (totalDiffs > (diffEnd - diffStart)) {
|
|
229
|
+
console.log(`${gray}... (${totalDiffs - (diffEnd - diffStart)} more differences)${reset}`);
|
|
226
230
|
}
|
|
227
231
|
|
|
228
232
|
const answer = await new Promise<string>((resolve) => {
|