open-index/open-npm huggingface dataset:
npm package: @hardlydifficult/ai-msg
Description: Extract structured data from AI model responses: JSON, typed schemas, code blocks, and multimodal content.
Latest version: 1.0.4

# @hardlydifficult/ai-msg

Extract structured data from AI model responses: JSON, typed schemas, code blocks, and multimodal content.

## Installation

```bash
npm install @hardlydifficult/ai-msg
```

## API

### `extractJson(text: string, sentinel?: string): unknown[]`

Extract JSON objects/arrays from AI response text. Uses a three-pass strategy:

1. Parse the entire text as JSON
2. Extract from fenced code blocks (json-tagged first, then any)
3. Find balanced `{}`/`[]` in prose

Pass a `sentinel` string to return `[]` when the response contains it (useful for "no results" markers).

````typescript
import { extractJson } from "@hardlydifficult/ai-msg";

extractJson('Here is the result:\n```json\n{"key": "value"}\n```\nDone.');
// [{ key: "value" }]

extractJson('First {"a": 1} then {"b": 2} done.');
// [{ a: 1 }, { b: 2 }]

extractJson("NO_FINDINGS: scan completed.", "NO_FINDINGS");
// []
````

### `extractTyped<T>(text: string, schema: SchemaLike<T>, sentinel?: string): T[]`

Extract and validate JSON against a schema. Works with Zod 3, Zod 4, or any object with a `safeParse` method. Only returns entries that pass validation.

```typescript
import { extractTyped } from "@hardlydifficult/ai-msg";
import { z } from "zod";

const Person = z.object({ name: z.string(), age: z.number() });

extractTyped('{"name": "Alice", "age": 30}', Person);
// [{ name: "Alice", age: 30 }]

extractTyped('{"name": "Alice", "age": "thirty"}', Person);
// [] — fails validation
```

### `extractCodeBlock(text: string, lang?: string): string[]`

Extract fenced code block contents. Optionally filter by language tag.

````typescript
import { extractCodeBlock } from "@hardlydifficult/ai-msg";

extractCodeBlock("```ts\nconst x = 1;\n```");
// ["const x = 1;"]

extractCodeBlock("```json\n{}\n```\n```ts\nconst x = 1;\n```", "json");
// ["{}"]
````

### `extractTextContent(content: string | { type: string; text?: string }[]): string`

Extract plain text from a message content field. Handles both plain strings and multimodal content arrays (AI SDK format).

```typescript
import { extractTextContent } from "@hardlydifficult/ai-msg";

extractTextContent("hello"); // "hello"
extractTextContent([
  { type: "text", text: "hello" },
  { type: "image_url", url: "..." },
]); // "hello"
```

### `toPlainTextMessages(messages: MultimodalMessage[]): { role, content }[]`

Convert multimodal messages to plain text messages by flattening content arrays.
npm package: @hardlydifficult/call
Description: CLI and client for triggering and monitoring outbound calls
Latest version: 1.0.5

# @hardlydifficult/call

Minimal CLI + SDK for submitting outbound calls and polling for completion.

## Install

```bash
npm install @hardlydifficult/call
```

## Quick start

```bash
export CALL_API_ENDPOINT="https://your-call-service.example.com"
export CALL_API_TOKEN="..."
npx @hardlydifficult/call "Quick update: PR is ready for review."
```

## Required environment variables

- `CALL_API_ENDPOINT`: base endpoint for the call API
- `CALL_API_TOKEN`: API token

## Optional environment variables

- `CALL_SYSTEM_PROMPT`: default system prompt
- `CALL_FIRST_MESSAGE`: default first message when not passed as CLI arg
- `CALL_SOURCE`: source identifier override

## CLI usage

```bash
npx @hardlydifficult/call [message] [options]
```

Options:

- `--endpoint` (or `CALL_API_ENDPOINT`)
- `--api-token` (or `CALL_API_TOKEN`)
- `--first-message`, `-m`
- `--system-prompt`, `-p`
- `--source`, `-s`

Run `npx @hardlydifficult/call --help` for details.
npm package: @hardlydifficult/collections
Description: Opinionated collection helpers for the patterns we actually use: batching work and walking paths bottom-up.
Latest version: 1.0.18

# @hardlydifficult/collections

Opinionated collection helpers for the patterns we actually use: batching work and walking paths bottom-up.

## Installation

```bash
npm install @hardlydifficult/collections
```

## Quick Start

```typescript
import { inBatches, bottomUp } from "@hardlydifficult/collections";

for (const batch of inBatches([1, 2, 3, 4, 5, 6, 7], 3)) {
  console.log(batch);
}
// [1, 2, 3]
// [4, 5, 6]
// [7]

for (const dirsAtDepth of bottomUp([
  "src/components/Button",
  "src/components",
  "src",
])) {
  console.log(dirsAtDepth);
}
// ["src/components/Button"]
// ["src/components"]
// ["src"]
```

## Work Batching

### `inBatches`

Split a readonly array into sequential batches.

```typescript
function inBatches<T>(items: readonly T[], size: number): T[][]
```

Use this when the caller is processing work, not thinking in terms of array chunking.

```typescript
import { inBatches } from "@hardlydifficult/collections";

for (const batch of inBatches(files, 5)) {
  await Promise.all(batch.map(processFile));
}
```

## Bottom-Up Path Processing

### `bottomUp`

Group paths deepest-first for bottom-up processing.

```typescript
function bottomUp(paths: readonly string[]): string[][]
```

Depth is computed from normalized slash-separated segments, so repeated or trailing slashes do not change grouping depth.

```typescript
import { bottomUp } from "@hardlydifficult/collections";

for (const dirsAtDepth of bottomUp(["a/b/c", "a/b", "a", "x/y"])) {
  console.log(dirsAtDepth);
}
// ["a/b/c"]
// ["a/b", "x/y"]
// ["a"]
```

## Compatibility Exports

The lower-level names are still available when they read better in a given call site:

- `chunk(items, size)` is the same behavior as `inBatches(items, size)`.
- `groupByDepth(paths)` returns `{ depth, paths }[]` when you need the numeric depth.
npm package: @hardlydifficult/cursor-cloud
Description: Opinionated client for Cursor Cloud remote agents
Latest version: 1.0.7

# @hardlydifficult/cursor-cloud

Typed client for the [Cursor Cloud Agent API](https://api.cursor.com).

## Installation

```bash
npm install @hardlydifficult/cursor-cloud
```

## Configuration

```typescript
import { createCursorCloud } from "@hardlydifficult/cursor-cloud";

// Reads CURSOR_API_KEY from env by default.
const cursor = createCursorCloud();

// Or pass options explicitly:
const cursor = createCursorCloud({
  apiKey: "your-api-key",
  baseUrl: "https://api.cursor.com", // optional
  webhook: {
    url: "https://example.com/webhook", // optional default for all sessions
    secret: "shared-secret", // optional
  },
});
```

Authentication uses **HTTP Basic auth** — the API key is sent as the username with an empty password.

## Fluent API

```typescript
const agent = cursor.select("owner/repo", "main", "cursor-small");
const session = agent.prompt("hi");
session.reply("tell me more").reply("keep going");
const final = await session;
```

- `select(repo, branch?, model?)` scopes repo/branch/model.
- `prompt(message)` launches a session.
- `reply(message)` is chainable and sends followups.
- `session` is thenable/promisable (`await session` or `session.then(...)`).

### `listAgents(options?)` — `GET /v0/agents`

List agents with optional filters and pagination.

By default, archived agents are hidden to match Cursor's browser view. To include archived agents, pass `includeArchived: true` or filter explicitly with `status: "archived"`.

```typescript
const list = await cursor.listAgents({
  repo: "owner/repo",
  status: "running",
  limit: 20,
  offset: 0,
});

console.log(list.agents, list.total, list.hasMore);

const archived = await cursor.listAgents({
  status: "archived",
});

const allIncludingArchived = await cursor.listAgents({
  includeArchived: true,
});
```

### `getAgent(id)` — `GET /v0/agents/{id}`

Get current status and metadata for an agent.

```typescript
const agent = await cursor.getAgent("agent-id");
console.log(agent.status);       // "queued" | "running" | "completed" | ...
console.log(agent.pullRequestUrl);
```

### `getConversation(id)` — `GET /v0/agents/{id}/conversation`

Retrieve the full conversation history for an agent.

```typescript
const { messages } = await cursor.getConversation("agent-id");
for (const msg of messages) {
  console.log(msg.role, msg.content); // "user" | "assistant"
}
```

`session.stop()` and `session.interrupt(message)` are also available when needed.

## Polling Helpers

```typescript
// Poll by id when needed (completed / failed / cancelled / timeout)
const final = await cursor.waitForAgent("agent-id", {
  pollIntervalMs: 5_000,  // default 5s
  timeoutMs: 20 * 60_000, // default 20 min
  onPoll: (status) => console.log(status.status),
});
```

## Zod Schemas

All request/response shapes are exported as Zod schemas for use in your own validation:

```typescript
import { LaunchCursorAgentInputSchema, GetConversationResponseSchema } from "@hardlydifficult/cursor-cloud";
```
npm package: @hardlydifficult/date-time
Description: A small TypeScript utility for expressive durations and Unix-second timestamps.
Latest version: 1.0.27

# @hardlydifficult/date-time

A small TypeScript utility for expressive durations and Unix-second timestamps.

## Installation

```bash
npm install @hardlydifficult/date-time
```

## Quick Start

```typescript
import { dateFromUnixSeconds, duration } from "@hardlydifficult/date-time";

setInterval(run, duration({ seconds: 30 }));

const maxAgeMs = duration({ days: 7 });
const createdAt = dateFromUnixSeconds("1735689600");
```

## `duration(...)`

Convert one or more duration parts into milliseconds.

```typescript
import { duration } from "@hardlydifficult/date-time";

duration({ seconds: 30 }); // 30_000
duration({ minutes: 5 }); // 300_000
duration({ minutes: 1, seconds: 30 }); // 90_000
duration({ hours: 1, minutes: 15 }); // 4_500_000
duration({ days: 7 }); // 604_800_000
```

Supported fields:

- `milliseconds`
- `seconds`
- `minutes`
- `hours`
- `days`

Behavior:

- Accepts any mix of supported fields.
- Supports fractional and negative values.
- Throws if no supported fields are provided.
- Throws if any provided value is not finite.

## `dateFromUnixSeconds(...)`

Convert a Unix timestamp in seconds to a `Date`.

```typescript
import { dateFromUnixSeconds } from "@hardlydifficult/date-time";

dateFromUnixSeconds(1735689600);
dateFromUnixSeconds("1735689600.5");
```
npm package: @hardlydifficult/http
Description: Opinionated HTTP helpers for small Node servers. The API is intentionally narrow: - request bodies default to a 1 MB limit - JSON responses default to `200` with CORS open to `*` - constant-time comparison accepts nullable values and fails closed on missi
Latest version: 1.0.23

# @hardlydifficult/http

Opinionated HTTP helpers for small Node servers. The API is intentionally narrow:
- request bodies default to a 1 MB limit
- JSON responses default to `200` with CORS open to `*`
- constant-time comparison accepts nullable values and fails closed on missing tokens

## Installation

```bash
npm install @hardlydifficult/http
```

## Quick Start

```typescript
import http from "http";
import { json, readJson, safeCompare } from "@hardlydifficult/http";

const server = http.createServer(async (req, res) => {
  const body = await readJson<{ token?: string }>(req);

  if (!safeCompare(body.token, "secret-token")) {
    json(res, { error: "Unauthorized" }, { status: 401 });
    return;
  }

  json(res, { success: true });
});

server.listen(3000);
```

## Request Helpers

### `readBody`

Reads the full HTTP request body as a string.

```typescript
function readBody(
  req: IncomingMessage,
  options?: { maxBytes?: number }
): Promise<string>
```

```typescript
import { readBody } from "@hardlydifficult/http";

const body = await readBody(req);
const smallBody = await readBody(req, { maxBytes: 500 * 1024 });
```

### `readJson`

Reads and parses a JSON request body.

```typescript
function readJson<T>(
  req: IncomingMessage,
  options?: { maxBytes?: number }
): Promise<T>
```

Throws `"Invalid JSON body"` when parsing fails.

```typescript
import { readJson } from "@hardlydifficult/http";

const payload = await readJson<{ name: string }>(req);
```

### `MAX_BODY_BYTES`

The default maximum body size.

```typescript
import { MAX_BODY_BYTES } from "@hardlydifficult/http";

console.log(MAX_BODY_BYTES); // 1048576
```

## Response Helpers

### `json`

Short alias for sending a JSON response.

```typescript
function json(
  res: ServerResponse,
  body: unknown,
  options?: { status?: number; corsOrigin?: string }
): void
```

```typescript
import { json } from "@hardlydifficult/http";

json(res, { ok: true });
json(res, { error: "Unauthorized" }, { status: 401 });
json(res, { id: 1 }, { corsOrigin: "https://trusted.com" });
```

### `sendJson`

Identical to `json` if you prefer the longer name.

## Security

### `safeCompare`

Constant-time string comparison for secrets and tokens.
Missing values never match.

```typescript
function safeCompare(
  a: string | null | undefined,
  b: string | null | undefined
): boolean
```

```typescript
import { safeCompare } from "@hardlydifficult/http";

if (safeCompare(request.headers.authorization, process.env.API_TOKEN)) {
  // Grant access
}
```
npm package: @hardlydifficult/poller
Description: Opinionated polling with one entrypoint: `watch()`.
Latest version: 1.0.27

# @hardlydifficult/poller

Opinionated polling with one entrypoint: `watch()`.

The package starts immediately, emits only when the value changes, and keeps the returned handle small.

## Installation

```bash
npm install @hardlydifficult/poller
```

## Quick Start

```ts
import { watch } from "@hardlydifficult/poller";

const userWatcher = await watch({
  everyMs: 5_000,
  read: () => fetch("/api/user").then((r) => r.json()),
  onChange: (user, previous) => {
    console.log("User changed", user, previous);
  },
});

await userWatcher.refresh();
userWatcher.stop();
```

## API

### `watch(options)`

Starts reading immediately and resolves after the first read attempt completes.

```ts
const watcher = await watch({
  everyMs: 30_000,
  read: () => fetch("/api/data").then((r) => r.json()),
  onChange: (current, previous) => {
    console.log("Changed:", current, previous);
  },
  onError: (error) => {
    console.error("Read failed:", error.message);
  },
  isEqual: (current, previous) => current.id === previous?.id,
});
```

Options:

- `read: () => Promise<T>`
- `onChange: (current: T, previous: T | undefined) => void`
- `everyMs: number`
- `isEqual?: (current: T, previous: T | undefined) => boolean`
- `onError?: (error: Error) => void`

### `watcher.current`

The last emitted value. This stays `undefined` until a read succeeds and is accepted as changed.

### `watcher.refresh()`

Runs a read immediately and returns the current emitted value. If a read is already in flight, the same promise is reused.

```ts
const current = await watcher.refresh();
```

### `watcher.stop()`

Stops the interval and makes future `refresh()` calls a no-op.

```ts
watcher.stop();
```

## Behavior

- The first successful read calls `onChange(current, undefined)`.
- Reads never overlap.
- Deep equality is the default change detection for primitives, arrays, and plain objects.
- Polling continues after read failures.
- If `onError` is omitted, errors are logged with `console.error`.
npm package: @hardlydifficult/rest-client
Description: Opinionated REST client helpers for APIs that should feel small and obvious at the call site.
Latest version: 1.0.65

# @hardlydifficult/rest-client

Opinionated REST client helpers for APIs that should feel small and obvious at the call site.

## Installation

```bash
npm install @hardlydifficult/rest-client
```

## Preferred API

```typescript
import { createRestClient, operation } from "@hardlydifficult/rest-client";
import { z } from "zod";

interface User {
  id: string;
  name: string;
}

const api = createRestClient(
  {
    baseUrl: "https://api.example.com/v1",
    auth: {
      type: "oauth2",
      tokenUrl: "https://auth.example.com/oauth/token",
      clientId: "client-id",
      clientSecret: "secret",
    },
  },
  {
    getUser: operation.get<User>({
      params: z.object({ id: z.string() }),
      path: ({ id }) => `/users/${id}`,
    }),
    listUsers: operation.get<User[]>({
      path: "/users",
    }),
    createUser: operation.post<User>({
      params: z.object({ name: z.string().min(1) }),
      path: "/users",
      body: ({ name }) => ({ name }),
    }),
  }
);

const user = await api.getUser({ id: "123" });
const users = await api.listUsers();
await api.createUser({ name: "Alice" });
```

What this gives you:

- No subclass ceremony just to bind a few endpoints.
- Relative `path` values resolve against `baseUrl`.
- Zero-input operations are zero-arg functions.
- `body` derives request payloads from validated params.

## Parsing Responses

Use `parse` when the server shape is not the shape you want in client code.

```typescript
const api = createRestClient(
  { baseUrl: "https://api.example.com" },
  {
    searchUserNames: operation.get<
      string[],
      { q: string },
      { items: Array<{ name: string }> }
    >({
      params: z.object({ q: z.string().min(1) }),
      path: ({ q }) => `/users/search?q=${encodeURIComponent(q)}`,
      parse: (response) => response.items.map((user) => user.name),
    }),
  }
);

const names = await api.searchUserNames({ q: "ali" });
```

## Direct Requests

Direct HTTP helpers also accept relative paths.

```typescript
const api = createRestClient({ baseUrl: "https://api.example.com/v1" }, {});

const health = await api.get<{ ok: boolean }>("/health");
await api.post("/users", { name: "Alice" });
```

## Advanced Usage

`RestClient` is still available if you want a class-based wrapper:

```typescript
import { operation, RestClient } from "@hardlydifficult/rest-client";
import { z } from "zod";

const GetUser = operation.get<User>({
  params: z.object({ id: z.string() }),
  path: ({ id }) => `/users/${id}`,
});

class MyApi extends RestClient {
  getUser = this.bind(GetUser);
}
```

## Authentication

Supported auth config types:

- `none`
- `bearer`
- `generator`
- `oauth2`

`createRestClient` and `RestClient` share the same auth, retry, logging, and error behavior.
npm package: @hardlydifficult/social
Description: Opinionated social read client for X.
Latest version: 1.0.69

# @hardlydifficult/social

Opinionated social read client for X.

This package is intentionally narrow:

- One factory: `createSocial()`
- One authenticated account
- Flat verbs: `post()`, `timeline()`, `likes()`, `watchLikes()`
- Like watching as an async stream

## Installation

```bash
npm install @hardlydifficult/social
```

## Quick Start

```ts
import { createSocial } from "@hardlydifficult/social";

const social = createSocial(process.env.X_BEARER_TOKEN);

const timeline = await social.timeline(10);
const liked = await social.likes();
const post = await social.post("1234567890");
```

If you omit the token, the client reads `X_BEARER_TOKEN` from the environment.

## API

### `createSocial(options?)`

Creates the social client.

```ts
const social = createSocial({
  token: process.env.X_BEARER_TOKEN,
  limit: 25,
});
```

You can also pass the token directly:

```ts
const social = createSocial(process.env.X_BEARER_TOKEN);
```

Options:

- `token?: string`
- `limit?: number`

### `social.post(id)`

Fetch a single post.

```ts
const post = await social.post("123");
```

### `social.timeline(limit?)`

Fetch the authenticated user timeline.

```ts
const recent = await social.timeline();
const firstTen = await social.timeline(10);
```

### `social.likes(limit?)`

Fetch posts liked by the authenticated user.

```ts
const liked = await social.likes();
const latestLiked = await social.likes(20);
```

### `social.watchLikes(options?)`

Returns an async stream of newly liked posts. The first poll seeds the current
likes and emits nothing, so iteration only yields likes discovered after the
stream starts.

```ts
const controller = new AbortController();

for await (const like of social.watchLikes({
  everyMs: 30_000,
  signal: controller.signal,
})) {
  console.log(`[${like.seenAt}] ${like.post.url}`);
}
```

You can also pass the interval directly:

```ts
for await (const like of social.watchLikes(30_000)) {
  console.log(like.post.url);
}
```

Options:

- `everyMs?: number`
- `signal?: AbortSignal`

## Types

Core types exported by the package:

- `CreateSocialInput`
- `CreateSocialOptions`
- `Social`
- `SocialPost`
- `SocialAuthor`
- `SocialPostMetrics`
- `LikeNotification`
- `WatchLikesInput`
- `WatchLikesOptions`

## Scope

This package is read-only for now:

- Read timeline content
- Read liked posts
- Watch for newly liked posts

Posting, liking, and reposting are intentionally out of scope.
npm package: @hardmakerpd/ds2u-lib
Description: This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.2.0.
Latest version: 0.0.41

# Ds2uLib

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.2.0.

## Code scaffolding

Run `ng generate component component-name --project ds2u-lib` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ds2u-lib`.
> Note: Don't forget to add `--project ds2u-lib` or else it will be added to the default project in your `angular.json` file. 

## Use

Bootstrap@5.1.3 is necessary to fully use the scss components.
npm package: @hardocs-project/tangram-json-editor
Description: An npm package version, in progress, of a schema awareable JSON editor
Author: Narration SD
Latest version: 0.8.34

# json-editor

> A schema-aware editor for JSON document. It provides a tree view to present the structure of JSON document, user could manipulate the JSON from context menu. It also has a text view to present the content of JSON document, user may edit JSON within.
> Develop with Vue.js 2.
> Please reference the [project website](https://json-editor.tangramjs.com) fro detail.

## Features
#### Tree View of JSON document
The structure of JSON document, could expend or collapse at any level.
#### Context Menu
Right-click on the element in tree view could bring out the context menu for that element, and perform actions specific for that element.
#### Text View of JSON document
A text view to display content of schema. User could also edit the document directly in text view.
#### Schema validation
The JSON document would validate with current selected schema after every update.
#### Undo/Redo
Undo and Redo could keep track of every update of JSON document.
#### Copy JSON document to clipboard
Copy JSON document to system clipboard.
#### Download JSON document to file
Download JSON document as a json file.
#### Load JSON document from file
Load JSON document from a json schema file.

## Install
``` bash
git clone https://github.com/tangram-js/json-editor.git
```
## Build

``` bash
# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

# build for production and view the bundle analyzer report
npm run build --report
```
## Live demo
Live demo of source code: [https://tangram-js.github.io/json-editor/](https://tangram-js.github.io/json-editor/)