Skip to content
This repository was archived by the owner on May 14, 2026. It is now read-only.
This repository was archived by the owner on May 14, 2026. It is now read-only.

docs(agents): document how to add log events when porting from pnpm #346

@zkochan

Description

@zkochan

Summary

Document how to add log emissions when porting code from pnpm, so future
ports — especially AI-generated ones — don't silently skip events and
recreate the coverage gap we're fixing.

Scope

  • Add a "Reporting" section to AGENTS.md (or a subsection in
    CODE_STYLE_GUIDE.md, whichever fits the surrounding structure better)
    covering:
    • Finding upstream emissions. Patterns to grep for in pnpm/pnpm:
      globalLogger.<channel>.<level>(...),
      logger.<level>({ name: 'pnpm:<channel>', ... }), and direct
      streamParser.write(...) calls.
    • Channel mapping. How upstream name: 'pnpm:<channel>' maps to a
      LogEvent variant in crates/reporter. Include the canonical list
      and where to look it up.
    • Generic threading convention. Per Use pnpm's @pnpm/cli.default-reporter for terminal output (via NDJSON) #344's architecture: any function
      that emits takes R: Reporter and calls R::emit(...). Production
      callers turbofish at the entry point. Same shape as the DI pattern in
      Refactor and document the dependency injection pattern for tests #339.
    • Where to put the emit calls. Match the upstream call site —
      typically immediately before or after the side effect the event
      describes. Keep ordering consistent with pnpm so the rendered output
      stays identical.
    • Testing. Declare a recording fake inside the #[test] fn per
      Refactor and document the dependency injection pattern for tests #339, recording into a static Mutex<Vec<LogEvent>> declared in the
      same body; assert against the captured sequence.
    • What not to do. Don't reformat upstream messages, don't invent new
      channels, don't emit at higher granularity than pnpm (the JS reporter
      expects pnpm's event cadence).
  • One worked example: pick a small ported pnpm function that emits one or
    two log events, show the before/after Rust diff, link the upstream
    permalink (pinned SHA per CLAUDE.md), and reference the test fake.
  • Add a pointer from the cardinal-rule section of AGENTS.md: matching
    pnpm's behavior includes its log emissions — see the new section.

Acceptance criteria

  • A reviewer can read the new section and answer, given an upstream pnpm
    function: which log events does it emit, where do those map in pacquet,
    where do the emit calls go, and how do I test them.
  • The worked example builds and matches the canonical reporter shape from
    feat(reporter): implement the reporting engine (NDJSON + Reporter trait) #345.
  • AGENTS.md's cardinal-rule section explicitly mentions log emissions as
    part of what "match pnpm" entails.

Depends on

Parent

Design: #344.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No 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