@shiyuphan/follow-me 0.4.0 → 0.4.1
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/src/comments.js +29 -11
- package/package.json +1 -1
package/dist/src/comments.js
CHANGED
|
@@ -187,7 +187,10 @@ export function parseNewDecision(concern, v) {
|
|
|
187
187
|
return "the decision is not an object";
|
|
188
188
|
return withDecision(concern, { ...v, decidedAt: undefined });
|
|
189
189
|
}
|
|
190
|
-
/**
|
|
190
|
+
/**
|
|
191
|
+
* Absent reads as none. The first item that does not parse names its index and reason. Items
|
|
192
|
+
* are objects so a string result can only mean a failure; string values go through parseIds.
|
|
193
|
+
*/
|
|
191
194
|
function parseList(raw, parse, what) {
|
|
192
195
|
if (raw === undefined)
|
|
193
196
|
return [];
|
|
@@ -202,8 +205,26 @@ function parseList(raw, parse, what) {
|
|
|
202
205
|
}
|
|
203
206
|
return out;
|
|
204
207
|
}
|
|
205
|
-
|
|
206
|
-
|
|
208
|
+
/** Absent reads as none. The first item that is not an id of the kind names its index. */
|
|
209
|
+
function parseIds(raw, is, what, kind) {
|
|
210
|
+
if (raw === undefined)
|
|
211
|
+
return [];
|
|
212
|
+
if (!isArray(raw))
|
|
213
|
+
return `${what} is not an array`;
|
|
214
|
+
const out = [];
|
|
215
|
+
for (const [i, item] of raw.entries()) {
|
|
216
|
+
if (!is(item))
|
|
217
|
+
return `${what}[${i}]: not a ${kind} id`;
|
|
218
|
+
out.push(item);
|
|
219
|
+
}
|
|
220
|
+
return out;
|
|
221
|
+
}
|
|
222
|
+
/** Keeps only the items that are ids of the kind. */
|
|
223
|
+
function lenientIds(raw, is) {
|
|
224
|
+
return isArray(raw) ? raw.filter(is) : [];
|
|
225
|
+
}
|
|
226
|
+
function isCommentIdValue(item) {
|
|
227
|
+
return typeof item === "string" && isCommentId(item);
|
|
207
228
|
}
|
|
208
229
|
/** Absent reads as nothing excluded. */
|
|
209
230
|
export function parseExcluded(v) {
|
|
@@ -211,17 +232,14 @@ export function parseExcluded(v) {
|
|
|
211
232
|
return { comments: [], concerns: [] };
|
|
212
233
|
if (!isFields(v))
|
|
213
234
|
return "excluded is not an object";
|
|
214
|
-
const comments =
|
|
235
|
+
const comments = parseIds(v.comments, isCommentIdValue, "excluded.comments", "comment");
|
|
215
236
|
if (typeof comments === "string")
|
|
216
237
|
return comments;
|
|
217
|
-
const concerns =
|
|
238
|
+
const concerns = parseIds(v.concerns, isConcernId, "excluded.concerns", "concern");
|
|
218
239
|
return typeof concerns === "string" ? concerns : { comments, concerns };
|
|
219
240
|
}
|
|
220
241
|
function asCommentId(item) {
|
|
221
|
-
return
|
|
222
|
-
}
|
|
223
|
-
function parseCommentId(item) {
|
|
224
|
-
return asCommentId(item) ?? "not a comment id";
|
|
242
|
+
return isCommentIdValue(item) ? item : null;
|
|
225
243
|
}
|
|
226
244
|
function parseEarlierReplies(v) {
|
|
227
245
|
if (!isFields(v))
|
|
@@ -286,7 +304,7 @@ export function parseReview(v) {
|
|
|
286
304
|
const concerns = parseList(v.concerns, parseDecision, "concerns");
|
|
287
305
|
if (typeof concerns === "string")
|
|
288
306
|
return concerns;
|
|
289
|
-
const resolved =
|
|
307
|
+
const resolved = parseIds(v.resolved, isCommentIdValue, "resolved", "comment");
|
|
290
308
|
if (typeof resolved === "string")
|
|
291
309
|
return resolved;
|
|
292
310
|
const excluded = parseExcluded(v.excluded);
|
|
@@ -329,7 +347,7 @@ export function parseDraft(v) {
|
|
|
329
347
|
return {
|
|
330
348
|
comments: lenient(v.comments, parseComment),
|
|
331
349
|
concerns: lenient(v.concerns, parseDecision),
|
|
332
|
-
resolved:
|
|
350
|
+
resolved: lenientIds(v.resolved, isCommentIdValue),
|
|
333
351
|
excluded: typeof excluded === "string" ? { comments: [], concerns: [] } : excluded,
|
|
334
352
|
earlierReplies: lenient(v.earlierReplies, parseEarlierReplies),
|
|
335
353
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shiyuphan/follow-me",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Split a branch's final changes into fine, ordered commits that read like the author's thought process, review them hunk by hunk, and hand the review back to a coding agent.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|