Skip to content

phuryn/product-engineering / app-stack/skills/embedded-agents-messages-api

embedded-agents-messages-api

Verified

Building, adding or wiring up an agent or an agent chat inside a Next.js app: embed Claude agents on the Messages API, the default way.

examples/knowledge-agent.live.test.ts

View on GitHub
import { describe, test, expect, vi } from 'vitest';

vi.mock('server-only', () => ({}));
import { askAgent } from '@/lib/agent';

// The example knowledge-agent's own behaviour, against the real model (outside the gate).

async function ask(prompt: string): Promise<string> {
  let text = '';
  for await (const ev of askAgent({ agent: 'knowledge-agent', prompt })) if (ev.type === 'text') text += ev.text;
  return text;
}

describe('knowledge-agent', () => {
  test('its AGENTS.md is in force: the sign-off', async () => {
    expect(await ask('Say hello in one short sentence.')).toContain('Best, Knowledge Agent');
  });

  test('answers a covered topic from its knowledge file, and cites it', async () => {
    const reply = await ask('What is the recommended OKR scoring target, and why? Quote a short phrase from the knowledge file.');
    expect(reply).toContain('0.7');
    expect(reply).toMatch(/knowledge\/okrs\.md/);
  });

  test('refuses a topic its files do not cover', async () => {
    const reply = await ask('What is the capital of Mongolia?');
    expect(reply.toLowerCase()).toMatch(/not covered|knowledge base|don't (have|know)|isn't covered/);
    expect(reply).not.toMatch(/Ulaanbaatar|Ulan Bator/i);
  });
});
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 470kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall