Skip to content

Two private isObject copies duplicate the exported isJsonObject guard #99

Description

@Deepam02

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions