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.
@@ -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⚠️ Content differs for skill ${skillIdn} (${fileName}):`);
105
- // ANSI color codes
106
- const red = '\x1b[31m';
107
- const green = '\x1b[32m';
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 existingLines = existingContent.trim().split('\n');
111
- const newLines = newContent.trim().split('\n');
112
- // Show first few different lines with colors
113
- let diffShown = 0;
114
- const maxDiffLines = 5;
115
- for (let i = 0; i < Math.max(existingLines.length, newLines.length) && diffShown < maxDiffLines; i++) {
116
- const existingLine = existingLines[i] || '';
117
- const newLine = newLines[i] || '';
118
- if (existingLine !== newLine) {
119
- if (existingLine)
120
- console.log(`${red}-${existingLine}${reset}`);
121
- if (newLine)
122
- console.log(`${green}+${newLine}${reset}`);
123
- diffShown++;
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 (diffShown === maxDiffLines) {
127
- console.log(' ... (more differences)');
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.2",
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": {
@@ -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⚠️ Content differs for skill ${skillIdn} (${fileName}):`);
157
+ console.log(`\n⚠️ Local changes will be replaced by remote content for skill ${skillIdn} (${fileName}):`);
158
158
 
159
- // ANSI color codes
160
- const red = '\x1b[31m';
161
- const green = '\x1b[32m';
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 existingLines = existingContent.trim().split('\n');
166
- const newLines = newContent.trim().split('\n');
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
- // Show first few different lines with colors
169
- let diffShown = 0;
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
- for (let i = 0; i < Math.max(existingLines.length, newLines.length) && diffShown < maxDiffLines; i++) {
173
- const existingLine = existingLines[i] || '';
174
- const newLine = newLines[i] || '';
172
+ // Simple diff algorithm to find changes
173
+ let localIdx = 0;
174
+ let remoteIdx = 0;
175
175
 
176
- if (existingLine !== newLine) {
177
- if (existingLine) console.log(`${red}-${existingLine}${reset}`);
178
- if (newLine) console.log(`${green}+${newLine}${reset}`);
179
- diffShown++;
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 (diffShown === maxDiffLines) {
184
- console.log(' ... (more differences)');
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) => {