newo 2.0.3 → 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 +51 -28
- package/package.json +1 -1
- package/src/sync/skill-files.ts +57 -29
package/dist/sync/skill-files.js
CHANGED
|
@@ -102,45 +102,68 @@ export async function askForOverwrite(skillIdn, existingContent, newContent, fil
|
|
|
102
102
|
output: process.stdout
|
|
103
103
|
});
|
|
104
104
|
console.log(`\n⚠️ Local changes will be replaced by remote content for skill ${skillIdn} (${fileName}):`);
|
|
105
|
-
// ANSI color codes
|
|
106
|
-
const redBg = '\x1b[
|
|
107
|
-
const greenBg = '\x1b[
|
|
105
|
+
// ANSI color codes matching GitHub diff colors from screenshot
|
|
106
|
+
const redBg = '\x1b[101m\x1b[97m'; // Light red background, white text (like GitHub)
|
|
107
|
+
const greenBg = '\x1b[102m\x1b[30m'; // Light green background, black text (like GitHub)
|
|
108
108
|
const gray = '\x1b[90m';
|
|
109
109
|
const reset = '\x1b[0m';
|
|
110
|
-
// Show a GitHub-style colored diff with line numbers
|
|
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
|
-
//
|
|
114
|
-
|
|
115
|
-
let
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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;
|
|
121
|
+
}
|
|
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) {
|
|
140
|
+
console.log(` ${String(i + 1).padStart(3)} ${localLines[i]}`);
|
|
141
|
+
}
|
|
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++) {
|
|
119
146
|
const localLine = localLines[i];
|
|
120
147
|
const remoteLine = remoteLines[i];
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (localLine !== undefined && remoteLine !== undefined && localLine === remoteLine) {
|
|
124
|
-
console.log(`${gray} ${lineNum} ${localLine}${reset}`);
|
|
148
|
+
if (localLine !== undefined && (remoteLine === undefined || localLine !== remoteLine)) {
|
|
149
|
+
console.log(`${redBg} - ${String(i + 1).padStart(3)} ${localLine} ${reset}`);
|
|
125
150
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (localLine !== undefined) {
|
|
129
|
-
console.log(`${redBg} - ${lineNum} ${localLine} ${reset}`);
|
|
130
|
-
diffShown++;
|
|
131
|
-
}
|
|
132
|
-
if (remoteLine !== undefined) {
|
|
133
|
-
console.log(`${greenBg} + ${lineNum} ${remoteLine} ${reset}`);
|
|
134
|
-
diffShown++;
|
|
135
|
-
}
|
|
151
|
+
if (remoteLine !== undefined && (localLine === undefined || localLine !== remoteLine)) {
|
|
152
|
+
console.log(`${greenBg} + ${String(i + 1).padStart(3)} ${remoteLine} ${reset}`);
|
|
136
153
|
}
|
|
137
154
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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) {
|
|
159
|
+
console.log(` ${String(i + 1).padStart(3)} ${localLines[i]}`);
|
|
142
160
|
}
|
|
143
161
|
}
|
|
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}`);
|
|
166
|
+
}
|
|
144
167
|
const answer = await new Promise((resolve) => {
|
|
145
168
|
rl.question(`\nReplace local with remote? (y)es/(n)o/(a)ll/(q)uit: `, resolve);
|
|
146
169
|
});
|
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
|
@@ -156,51 +156,79 @@ export async function askForOverwrite(skillIdn: string, existingContent: string,
|
|
|
156
156
|
|
|
157
157
|
console.log(`\n⚠️ Local changes will be replaced by remote content for skill ${skillIdn} (${fileName}):`);
|
|
158
158
|
|
|
159
|
-
// ANSI color codes
|
|
160
|
-
const redBg = '\x1b[
|
|
161
|
-
const greenBg = '\x1b[
|
|
159
|
+
// ANSI color codes matching GitHub diff colors from screenshot
|
|
160
|
+
const redBg = '\x1b[101m\x1b[97m'; // Light red background, white text (like GitHub)
|
|
161
|
+
const greenBg = '\x1b[102m\x1b[30m'; // Light green background, black text (like GitHub)
|
|
162
162
|
const gray = '\x1b[90m';
|
|
163
163
|
const reset = '\x1b[0m';
|
|
164
164
|
|
|
165
|
-
// Show a GitHub-style colored diff with line numbers
|
|
165
|
+
// Show a GitHub-style colored diff with line numbers and context
|
|
166
166
|
const localLines = existingContent.trim().split('\n');
|
|
167
167
|
const remoteLines = newContent.trim().split('\n');
|
|
168
168
|
|
|
169
|
-
//
|
|
170
|
-
|
|
171
|
-
let
|
|
172
|
-
const maxDiffLines = 10;
|
|
169
|
+
// Find the first differing section and show it with context
|
|
170
|
+
let diffStart = -1;
|
|
171
|
+
let diffEnd = -1;
|
|
173
172
|
|
|
174
|
-
|
|
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;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
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
|
+
}
|
|
175
186
|
|
|
176
|
-
|
|
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
|
+
}
|
|
195
|
+
|
|
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) {
|
|
200
|
+
console.log(` ${String(i + 1).padStart(3)} ${localLines[i]}`);
|
|
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++) {
|
|
177
207
|
const localLine = localLines[i];
|
|
178
208
|
const remoteLine = remoteLines[i];
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
// Show differences
|
|
186
|
-
if (localLine !== undefined) {
|
|
187
|
-
console.log(`${redBg} - ${lineNum} ${localLine} ${reset}`);
|
|
188
|
-
diffShown++;
|
|
189
|
-
}
|
|
190
|
-
if (remoteLine !== undefined) {
|
|
191
|
-
console.log(`${greenBg} + ${lineNum} ${remoteLine} ${reset}`);
|
|
192
|
-
diffShown++;
|
|
193
|
-
}
|
|
209
|
+
|
|
210
|
+
if (localLine !== undefined && (remoteLine === undefined || localLine !== remoteLine)) {
|
|
211
|
+
console.log(`${redBg} - ${String(i + 1).padStart(3)} ${localLine} ${reset}`);
|
|
212
|
+
}
|
|
213
|
+
if (remoteLine !== undefined && (localLine === undefined || localLine !== remoteLine)) {
|
|
214
|
+
console.log(`${greenBg} + ${String(i + 1).padStart(3)} ${remoteLine} ${reset}`);
|
|
194
215
|
}
|
|
195
216
|
}
|
|
196
217
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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) {
|
|
222
|
+
console.log(` ${String(i + 1).padStart(3)} ${localLines[i]}`);
|
|
201
223
|
}
|
|
202
224
|
}
|
|
203
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}`);
|
|
230
|
+
}
|
|
231
|
+
|
|
204
232
|
const answer = await new Promise<string>((resolve) => {
|
|
205
233
|
rl.question(`\nReplace local with remote? (y)es/(n)o/(a)ll/(q)uit: `, resolve);
|
|
206
234
|
});
|