newo 2.0.2 → 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 +57 -21
- package/package.json +1 -1
- package/src/sync/skill-files.ts +60 -19
package/dist/sync/skill-files.js
CHANGED
|
@@ -101,30 +101,66 @@ export async function askForOverwrite(skillIdn, existingContent, newContent, fil
|
|
|
101
101
|
input: process.stdin,
|
|
102
102
|
output: process.stdout
|
|
103
103
|
});
|
|
104
|
-
console.log(`\n⚠️
|
|
105
|
-
// ANSI color codes
|
|
106
|
-
const
|
|
107
|
-
const
|
|
104
|
+
console.log(`\n⚠️ Local changes will be replaced by remote content for skill ${skillIdn} (${fileName}):`);
|
|
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
|
+
const gray = '\x1b[90m';
|
|
108
109
|
const reset = '\x1b[0m';
|
|
109
|
-
// Show a GitHub-style colored diff
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
|
|
110
|
+
// Show a GitHub-style colored diff with line numbers and context
|
|
111
|
+
const localLines = existingContent.trim().split('\n');
|
|
112
|
+
const remoteLines = newContent.trim().split('\n');
|
|
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' });
|
|
127
|
+
}
|
|
128
|
+
else if (remoteLine !== undefined) {
|
|
129
|
+
diffs.push({ localIndex: -1, remoteIndex: remoteIdx, type: 'add' });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (localLine !== undefined)
|
|
133
|
+
localIdx++;
|
|
134
|
+
if (remoteLine !== undefined)
|
|
135
|
+
remoteIdx++;
|
|
136
|
+
}
|
|
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}`);
|
|
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]}`);
|
|
124
159
|
}
|
|
160
|
+
shown++;
|
|
125
161
|
}
|
|
126
|
-
if (
|
|
127
|
-
console.log(
|
|
162
|
+
if (diffs.length > maxDiffGroups) {
|
|
163
|
+
console.log(`${gray}... (${diffs.length - maxDiffGroups} more diff groups)${reset}`);
|
|
128
164
|
}
|
|
129
165
|
const answer = await new Promise((resolve) => {
|
|
130
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
|
@@ -154,34 +154,75 @@ export async function askForOverwrite(skillIdn: string, existingContent: string,
|
|
|
154
154
|
output: process.stdout
|
|
155
155
|
});
|
|
156
156
|
|
|
157
|
-
console.log(`\n⚠️
|
|
157
|
+
console.log(`\n⚠️ Local changes will be replaced by remote content for skill ${skillIdn} (${fileName}):`);
|
|
158
158
|
|
|
159
|
-
// ANSI color codes
|
|
160
|
-
const
|
|
161
|
-
const
|
|
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
|
+
const gray = '\x1b[90m';
|
|
162
163
|
const reset = '\x1b[0m';
|
|
163
164
|
|
|
164
|
-
// Show a GitHub-style colored diff
|
|
165
|
-
const
|
|
166
|
-
const
|
|
165
|
+
// Show a GitHub-style colored diff with line numbers and context
|
|
166
|
+
const localLines = existingContent.trim().split('\n');
|
|
167
|
+
const remoteLines = newContent.trim().split('\n');
|
|
167
168
|
|
|
168
|
-
//
|
|
169
|
-
|
|
170
|
-
const maxDiffLines = 5;
|
|
169
|
+
// Find differences and show with 2 lines context before/after
|
|
170
|
+
const diffs: Array<{localIndex: number, remoteIndex: number, type: 'change' | 'add' | 'remove'}> = [];
|
|
171
171
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
// Simple diff algorithm to find changes
|
|
173
|
+
let localIdx = 0;
|
|
174
|
+
let remoteIdx = 0;
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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'});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (localLine !== undefined) localIdx++;
|
|
191
|
+
if (remoteLine !== undefined) remoteIdx++;
|
|
192
|
+
}
|
|
193
|
+
|
|
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]}`);
|
|
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}`);
|
|
180
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++;
|
|
181
222
|
}
|
|
182
223
|
|
|
183
|
-
if (
|
|
184
|
-
console.log(
|
|
224
|
+
if (diffs.length > maxDiffGroups) {
|
|
225
|
+
console.log(`${gray}... (${diffs.length - maxDiffGroups} more diff groups)${reset}`);
|
|
185
226
|
}
|
|
186
227
|
|
|
187
228
|
const answer = await new Promise<string>((resolve) => {
|