newo 2.0.3 → 2.0.4
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 +50 -29
- package/package.json +1 -1
- package/src/sync/skill-files.ts +56 -32
package/dist/sync/skill-files.js
CHANGED
|
@@ -102,44 +102,65 @@ 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
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const localLine = localLines[
|
|
120
|
-
const remoteLine = remoteLines[
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
// Show differences
|
|
128
|
-
if (localLine !== undefined) {
|
|
129
|
-
console.log(`${redBg} - ${lineNum} ${localLine} ${reset}`);
|
|
130
|
-
diffShown++;
|
|
113
|
+
// Find differences and show with 2 lines context before/after
|
|
114
|
+
const diffs = [];
|
|
115
|
+
// Simple diff algorithm to find changes
|
|
116
|
+
let localIdx = 0;
|
|
117
|
+
let remoteIdx = 0;
|
|
118
|
+
while (localIdx < localLines.length || remoteIdx < remoteLines.length) {
|
|
119
|
+
const localLine = localLines[localIdx];
|
|
120
|
+
const remoteLine = remoteLines[remoteIdx];
|
|
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' });
|
|
131
127
|
}
|
|
132
|
-
if (remoteLine !== undefined) {
|
|
133
|
-
|
|
134
|
-
diffShown++;
|
|
128
|
+
else if (remoteLine !== undefined) {
|
|
129
|
+
diffs.push({ localIndex: -1, remoteIndex: remoteIdx, type: 'add' });
|
|
135
130
|
}
|
|
136
131
|
}
|
|
132
|
+
if (localLine !== undefined)
|
|
133
|
+
localIdx++;
|
|
134
|
+
if (remoteLine !== undefined)
|
|
135
|
+
remoteIdx++;
|
|
137
136
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
// Show diffs with context (2 lines before/after each change)
|
|
138
|
+
let shown = 0;
|
|
139
|
+
const maxDiffGroups = 3;
|
|
140
|
+
for (const diff of diffs.slice(0, maxDiffGroups)) {
|
|
141
|
+
if (shown > 0)
|
|
142
|
+
console.log(''); // Separator between diff groups
|
|
143
|
+
// Show context before
|
|
144
|
+
const contextStart = Math.max(0, diff.localIndex - 2);
|
|
145
|
+
for (let i = contextStart; i < diff.localIndex && i < localLines.length; i++) {
|
|
146
|
+
console.log(` ${String(i + 1).padStart(3)} ${localLines[i]}`);
|
|
147
|
+
}
|
|
148
|
+
// Show the actual diff
|
|
149
|
+
if (diff.type === 'change' || diff.type === 'remove') {
|
|
150
|
+
console.log(`${redBg} - ${String(diff.localIndex + 1).padStart(3)} ${localLines[diff.localIndex]} ${reset}`);
|
|
142
151
|
}
|
|
152
|
+
if (diff.type === 'change' || diff.type === 'add') {
|
|
153
|
+
console.log(`${greenBg} + ${String(diff.remoteIndex + 1).padStart(3)} ${remoteLines[diff.remoteIndex]} ${reset}`);
|
|
154
|
+
}
|
|
155
|
+
// Show context after
|
|
156
|
+
const contextEnd = Math.min(localLines.length, diff.localIndex + 3);
|
|
157
|
+
for (let i = diff.localIndex + 1; i < contextEnd; i++) {
|
|
158
|
+
console.log(` ${String(i + 1).padStart(3)} ${localLines[i]}`);
|
|
159
|
+
}
|
|
160
|
+
shown++;
|
|
161
|
+
}
|
|
162
|
+
if (diffs.length > maxDiffGroups) {
|
|
163
|
+
console.log(`${gray}... (${diffs.length - maxDiffGroups} more diff groups)${reset}`);
|
|
143
164
|
}
|
|
144
165
|
const answer = await new Promise((resolve) => {
|
|
145
166
|
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.4",
|
|
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,49 +156,73 @@ 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
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const localLine = localLines[
|
|
178
|
-
const remoteLine = remoteLines[
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
console.log(`${redBg} - ${lineNum} ${localLine} ${reset}`);
|
|
188
|
-
diffShown++;
|
|
189
|
-
}
|
|
190
|
-
if (remoteLine !== undefined) {
|
|
191
|
-
console.log(`${greenBg} + ${lineNum} ${remoteLine} ${reset}`);
|
|
192
|
-
diffShown++;
|
|
169
|
+
// Find differences and show with 2 lines context before/after
|
|
170
|
+
const diffs: Array<{localIndex: number, remoteIndex: number, type: 'change' | 'add' | 'remove'}> = [];
|
|
171
|
+
|
|
172
|
+
// Simple diff algorithm to find changes
|
|
173
|
+
let localIdx = 0;
|
|
174
|
+
let remoteIdx = 0;
|
|
175
|
+
|
|
176
|
+
while (localIdx < localLines.length || remoteIdx < remoteLines.length) {
|
|
177
|
+
const localLine = localLines[localIdx];
|
|
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'});
|
|
193
187
|
}
|
|
194
188
|
}
|
|
189
|
+
|
|
190
|
+
if (localLine !== undefined) localIdx++;
|
|
191
|
+
if (remoteLine !== undefined) remoteIdx++;
|
|
195
192
|
}
|
|
196
193
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
194
|
+
// Show diffs with context (2 lines before/after each change)
|
|
195
|
+
let shown = 0;
|
|
196
|
+
const maxDiffGroups = 3;
|
|
197
|
+
|
|
198
|
+
for (const diff of diffs.slice(0, maxDiffGroups)) {
|
|
199
|
+
if (shown > 0) console.log(''); // Separator between diff groups
|
|
200
|
+
|
|
201
|
+
// Show context before
|
|
202
|
+
const contextStart = Math.max(0, diff.localIndex - 2);
|
|
203
|
+
for (let i = contextStart; i < diff.localIndex && i < localLines.length; i++) {
|
|
204
|
+
console.log(` ${String(i + 1).padStart(3)} ${localLines[i]}`);
|
|
201
205
|
}
|
|
206
|
+
|
|
207
|
+
// Show the actual diff
|
|
208
|
+
if (diff.type === 'change' || diff.type === 'remove') {
|
|
209
|
+
console.log(`${redBg} - ${String(diff.localIndex + 1).padStart(3)} ${localLines[diff.localIndex]} ${reset}`);
|
|
210
|
+
}
|
|
211
|
+
if (diff.type === 'change' || diff.type === 'add') {
|
|
212
|
+
console.log(`${greenBg} + ${String(diff.remoteIndex + 1).padStart(3)} ${remoteLines[diff.remoteIndex]} ${reset}`);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Show context after
|
|
216
|
+
const contextEnd = Math.min(localLines.length, diff.localIndex + 3);
|
|
217
|
+
for (let i = diff.localIndex + 1; i < contextEnd; i++) {
|
|
218
|
+
console.log(` ${String(i + 1).padStart(3)} ${localLines[i]}`);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
shown++;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (diffs.length > maxDiffGroups) {
|
|
225
|
+
console.log(`${gray}... (${diffs.length - maxDiffGroups} more diff groups)${reset}`);
|
|
202
226
|
}
|
|
203
227
|
|
|
204
228
|
const answer = await new Promise<string>((resolve) => {
|