Problem
claude/json-file.ts:33 already exports a plain-object type guard:
export function isJsonObject(value: unknown): value is JsonObject {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
The identical predicate is reimplemented as a private isObject in two other modules:
packages/agentctx/src/mcp/server.ts:152
packages/agentctx/src/profile/detect.ts:295
Both have the exact same body. (extract/schema.ts:172 has a closely related asObject that returns the object-or-null — worth a glance but it has a different return shape, so it may stay separate.) Same "duplicated helper" cleanup family as #89 / #90.
What done looks like
- Have
mcp/server.ts and profile/detect.ts import and use the existing isJsonObject instead of their local isObject (the JsonObject vs Record<string, unknown> narrowing is compatible for these call sites — adjust types if needed).
- Delete the two private copies.
npm run check stays green.
Why it's a good first issue
Small, mechanical de-duplication confined to two files, with an already-exported helper to reuse.
Problem
claude/json-file.ts:33already exports a plain-object type guard:The identical predicate is reimplemented as a private
isObjectin two other modules:packages/agentctx/src/mcp/server.ts:152packages/agentctx/src/profile/detect.ts:295Both have the exact same body. (
extract/schema.ts:172has a closely relatedasObjectthat returns the object-or-null — worth a glance but it has a different return shape, so it may stay separate.) Same "duplicated helper" cleanup family as #89 / #90.What done looks like
mcp/server.tsandprofile/detect.tsimport and use the existingisJsonObjectinstead of their localisObject(theJsonObjectvsRecord<string, unknown>narrowing is compatible for these call sites — adjust types if needed).npm run checkstays green.Why it's a good first issue
Small, mechanical de-duplication confined to two files, with an already-exported helper to reuse.