npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@raylin01/copilot-client

v0.1.3

Published

Node.js client for controlling GitHub Copilot CLI via ACP.

Readme

@raylin01/copilot-client

Node.js client for GitHub Copilot CLI with both a raw ACP transport wrapper and a higher-level structured session/turn API.

Install

npm install @raylin01/copilot-client

Requirements

  • Node.js 18+
  • GitHub Copilot CLI installed and authenticated, or runnable through npx @github/copilot

Quickstart

import { CopilotClient } from '@raylin01/copilot-client';

const client = await CopilotClient.init({
  cwd: process.cwd(),
  model: 'gpt-5-mini'
});

const turn = client.send('Hello Copilot. Give me a short intro.');

for await (const update of turn.updates()) {
  if (update.kind === 'output' && update.snapshot.currentOutputKind === 'text') {
    process.stdout.write(`\r${update.snapshot.text}`);
  }

  if (update.kind === 'request') {
    await client.approveRequest(update.snapshot.openRequests.at(-1)!.id);
  }
}

const finalSnapshot = await turn.done;
process.stdout.write(`\n\nStop reason: ${finalSnapshot.result?.stopReason || 'unknown'}\n`);
await client.close();

If Copilot CLI is not on your PATH, you can use npx instead:

const client = await CopilotClient.init({
  cwd: process.cwd(),
  model: 'gpt-5-mini',
  executable: 'npx',
  executableArgs: ['-y'],
  copilotPath: '@github/copilot'
});

Structured API

  • CopilotClient.init(options) starts Copilot CLI in ACP mode and returns a StructuredCopilotClient
  • client.send(input, options?) returns a turn handle immediately
  • turn.current(), turn.history(), turn.updates(), and turn.done expose normalized turn state
  • client.getOpenRequests() returns pending permission requests
  • client.approveRequest(...), client.denyRequest(...), and client.cancelRequest(...) resolve Copilot approval prompts

The structured permission helper prefers actual ACP shapes over invented scopes:

  • use scope: 'once' | 'always' when you want the coarse helper
  • inspect request.options when you need the underlying provider-native option kinds directly

Session Browser Examples

The sessions subpath reads persisted Copilot CLI session state and normalizes it into a provider-neutral transcript.

import {
  listCopilotSessionSummaries,
  readCopilotSessionRecord
} from '@raylin01/copilot-client/sessions';

const summaries = await listCopilotSessionSummaries({
  projectPath: process.cwd()
});

const latest = summaries[0];
if (latest) {
  const record = await readCopilotSessionRecord(latest.id, {
    projectPath: process.cwd()
  });

  console.log('Session:', record.summary.id);
  console.log('Workspace summary:', record.rawSession.summary);

  for (const message of record.transcript) {
    console.log(message.role, message.content.map((block) => block.type));
  }
}

These helpers inspect the persisted Copilot state under ~/.copilot/session-state, while still returning rawSession, rawMessages, and normalized transcript data together.

Raw ACP API

If you need direct access to Copilot CLI over ACP, the original new CopilotClient(...) API is unchanged.

Event Model

  • ready: ACP session established with sessionId
  • session_update: raw ACP session update
  • request_permission: Copilot requested approval for a tool call
  • stderr, error, exit

Examples

See /examples:

  • basic.ts

Notes

  • This package uses Copilot CLI's public preview ACP server rather than scraping terminal output.
  • The default testing model used in examples is gpt-5-mini.

License

ISC