Skip to content

Project-id display truncation projectId.slice(0, 12) is duplicated as a magic number in status and reset #79

Description

@Deepam02

Problem

Two CLI commands shorten the (64-char SHA-256 hex) project id for display by hardcoding the same 12 independently. If the chosen display length ever changes, both must be edited in lockstep, and nothing ties them together.

  • File / line: packages/agentctx/src/cli/status.ts:53
    env.io.out(`agentctx status — project ${projectId.slice(0, 12)}… (${env.cwd})`);
  • File / line: packages/agentctx/src/cli/reset.ts:61
    `${result.edges} edge(s), ${result.sessions} session(s) for project ${projectId.slice(0, 12)}…`,

Both render <first 12 hex chars>…. The 12 is a bare literal in each spot with no shared constant — a small DRY/consistency gap (the sibling of the "hardcoded constant that can silently drift" point raised in #39 for the MCP tool descriptions).

What done looks like

  • A single named constant (e.g. PROJECT_ID_DISPLAY_LEN = 12) and a tiny shared helper (e.g. shortProjectId(projectId) returning `${projectId.slice(0, PROJECT_ID_DISPLAY_LEN)}…`) is defined once — a natural home is alongside resolveProjectId in packages/agentctx/src/storage/namespace.ts, or a shared CLI helper — and both status.ts:53 and reset.ts:61 call it instead of repeating slice(0, 12).
  • No change to the rendered output (still the first 12 chars + ); this is a pure refactor.
  • (Optional) a small test pinning the helper's output format.

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