open-index/open-npm huggingface dataset:
npm package: @khanacademy/format-claude-stream
Description: Formats output from `claude --output-format stream-json` as human-readable text
Latest version: 0.1.3

# format-claude-stream

> [!NOTE]
> format-claude-stream is not accepting contributions. We’re releasing the
> code for others to refer to and learn from, but we are not open to pull
> requests or issues at this time.
>
> Khan Academy is a non-profit organization with a mission to provide a free,
> world-class education to anyone, anywhere. You can help us in that mission
> by [donating](https://khanacademy.org/donate) or looking at
> [career opportunities](https://khanacademy.org/careers).

## Summary

A CLI filter to turn Claude's streaming JSON output into human-readable text.

In addition to the usual Claude output, `format-claude-stream` prints:

- Chain-of-thought
- All tool calls, and their results, in an easy-to-read format
- Tool call errors
- A raw JSON dump of any events it doesn't understand.

Output is color-coded to make it easier to scan.

With `format-claude-stream`, you can print the live stream or dump the JSON to
a file and audit it later. With `tee` (see below), you can do both!

## Installation

```
npm install -g @khanacademy/format-claude-stream
```

## Usage

### CLI

```
claude --print --verbose --output-format stream-json | format-claude-stream
```

You can use [tee] to duplicate the output to a timestamped file:

```
claude --print --verbose --output-format stream-json \
  | tee "claude-$(date +'%Y-%m-%d_%H%M%S').jsonl" \
  | format-claude-stream
```

### Library

```ts
import {ClaudeStreamFormatter, StandardOutput, ChalkColorizer} from "@khanacademy/format-claude-stream";

const claudeStreamFormatter = new ClaudeStreamFormatter(
    new StandardOutput(),
    new ChalkColorizer(),
);

await claudeStreamFormatter.write(JSON.parse(streamLine));
```

## Development

Requirements:

```
node >= 20.20.0
pnpm >= 10.26.0
```

Everyday commands:

```bash
pnpm install     # install dependencies (one-time setup)
pnpm test        # run unit tests once
pnpm test:watch  # run unit tests in watch mode
pnpm tsc -w      # watch for type errors
pnpm verify      # run all checks
pnpm fix         # fix formatting
```

## Releasing

Releases are managed via [changesets].

The workflow is:

- Each feature PR must include a changeset file, generated by running
  `pnpm changeset`, describing what is in that change and whether a major,
  minor, or patch version bump is required.
- A GitHub workflow watches the `main` branch and updates a "Version Packages"
  PR whenever a feature PR is landed.
- When the "Version Packages" PR is landed, a GitHub workflow updates the
  package version and changelog based on outstanding changesets, builds a new
  version of the package, and publishes it to NPM.

Merging the "Version Packages" PR is a manual action (you can use `git land`
for this). The package is built and released automatically when the "Version
Packages" PR is merged.

[changesets]: https://www.npmjs.com/package/@changesets/cli
[tee]: https://man7.org/linux/man-pages/man1/tee.1.html
npm package: @khanacademy/graphql-flow
Description: This is a tool for generating flow types from graphql queries in javascript frontends.
Latest version: 4.0.1

# Graphql Flow Generation

This is a tool for generating flow types from graphql queries in javascript frontends.

## Using as a CLI tool

Write a config file, following the schema defined in [src/cli/schema.json](src/cli/schema.json), either as a `.json` file, or a `.js` file that `module.exports` an object adhering to the schema.

Then run from the CLI, like so:

```bash
$ graphql-flow path/to/config.json
```

Files will be discovered relative to the `crawl.root`.

### Multiple generate configs

To customize type generation for certain directories or files, you can provide multiple
`generate` configs as an array, using `match` and `exclude` to customize behavior.

For a given file containing operations, the first `generate` config that matches that path
(and doesn't exclude it) will be used to generate types for those operations. If a `generate`
config doesn't have a `match` attribute, it will match all files (but might exclude some via the
`exclude` attribute).

For example:

```js
// dev/graphql-flow/config.js

const options = {
    schemaFilePath: "../../gengraphql/composed-schema.graphql",
    regenerateCommand: "make gqlflow",
    generatedDirectory: "__graphql-types__",
    exclude: [
        /_test.js$/,
        /.fixture.js$/,
        /\b__flowtests__\b/,
    ],
};

module.exports = {
    crawl: {
        root: "../../",
    },
    generate: [
        {
            ...options,
            schemaFilePath: "../../gengraphql/course-editor-schema.graphql",
            match: [/\bcourse-editor-package\b/, /\bcourse-editor\b/],
        },
        {
            ...options,
            match: [/\bdiscussion-package\b/]
            experimentalEnums: true,
        },
        options,
    ],
};
```

## Introspecting your backend's graphql schema
Here's how to get your backend's schema in the way that this tool expects, using the builtin 'graphql introspection query':

```js
import {getIntrospectionQuery} from 'graphql';
import fs from 'fs';
import fetch from 'node-fetch';

const query = getIntrospectionQuery({descriptions: true}),

const response = await fetch(`https://my-backend.com`, {
    method: 'POST',
    body: query,
    headers: {
        // You definitely shouldn't be allowing arbitrary queries without
        // some strict access control.
        'X-header-that-allows-arbitrary-queries': 'my-secret-key',
    },
    contentType: 'application/json',
});
const fullResponse = await response.json();
fs.writeFileSync('./server-introspection-response.json', JSON.stringify(fullResponse.data, null, 2));
```