OpenSource-Hub

adhd

라이브러리

UditAkhourii/adhd

코딩 에이전트를 위한 병렬 발산 사고 트리 사고 스킬.

개요

ADHD는 가지치기를 적용한 사고 트리를 구현하여, 격리된 인지 프레임워크 내에서 병렬 발산 추론을 수행함으로써 조기 수렴을 방지합니다. 점수 평가, 함정 가지치기, 생존 항목 심화를 통해 AI 에이전트의 창의성과 학제간 작업 능력을 강화합니다.

README 미리보기

\n  \n    \n  \n\n\n# ADHD — a skill for agents\n\n[](https://github.com/UditAkhourii/adhd/actions/workflows/ci.yml)\n[](https://www.npmjs.com/package/adhd-agent)\n[](./LICENSE)\n[](./documentation/install.md)\n[](https://adhdstack.github.io/)\n[](https://thenewstack.io/claude-code-adhd/)\n[](https://discord.gg/NbWwkwwGw)\n\n\n\n> ### 🎮 [**Join the ADHD Discord →**](https://discord.gg/NbWwkwwGw)\n> This is where the real-time thinking happens: frame design, eval problems, trap-hunting, and neurodivergence-inspired research on reasoning architectures. If you've got opinions on premature convergence, cognitive frames, or just want to argue about the next eval problem — **[come argue with us live](https://discord.gg/NbWwkwwGw).**\n\n> 👉 [**Join the ADHD community →**](https://tally.so/r/WO1Nzj) as a contributor, maintainer, early adopter, or just a member. One short form. We coordinate frame contributions, eval problems, integrations, and adopter onboarding there.\n\n> **An architectural fix for premature convergence in autoregressive reasoning.**\n\nLinear Chain-of-Thought anchors on whatever it says first. Tree-of-Thought widens the search but still walks a single shared context, so the anchoring persists across branches. **ADHD treats this as an architectural problem, not a prompting one** — it spawns N isolated reasoning processes under deliberately distorted cognitive frames, with zero shared context during divergence, then runs a separate critic pass to score, cluster, prune traps, and deepen the survivors.\n\nReach for it on **design decisions, fuzzy debugging, naming, API surface design, strategy, and any prompt of the shape *"give me a few ways to…"***.\n\n📄 **Preprint:** [ADHD: Parallel Divergent Ideation for Coding Agents](https://adhdstack.github.io/) · 👤 **Author:** Udit Akhouri — [@akhouriudit](https://x.com/akhouriudit) · [LinkedIn](https://www.linkedin.com/in/udit-akhouri-10160a168/)\n\n---\n\n## Side-by-side: baseline vs ADHD\n\nOne eval problem, s

FAQ (2)

문제 해결
`adhd --frames 1`을 실행할 때 와일드카드 프레임이 약 절반의 경우 누락되는 문제를 해결하는 방법은?

n === 1일 때 src/frames.ts의 selectFrames()에 버그가 있습니다. 랜덤한 프레임 하나를 선택하고 와일드카드를 추가하지만, 첫 번째 프레임이 이미 wild 태그가 붙어 있지 않는 한 마지막 .slice(0, n)이 그 와일드카드를 제거합니다.

**즉시 우회 방법:** --frames 2 이상을 사용하세요. 와일드카드 보장은 n >= 2에서 올바르게 작동합니다:

adhd "your prompt" --frames 2

**영구 수정:** 남은 프레임을 선택하기 전에 와일드카드를 먼저 확보하여 절대 잘려 나가지 않도록 합니다:

const wildPick = wild[Math.floor(Math.random() * wild.length)];
const rest = shuffle(pool.filter((f) => f.id !== wildPick.id))
  .slice(0, Math.max(0, n - 1));

return n <= 1 ? [wildPick] : [...rest, wildPick].slice(0, n);

selectFrames(1)의 모든 결과가 wild 태그가 붙은 프레임을 정확히 하나 포함하는지 검증하는 단위 테스트를 추가하세요.

원본 Issue #37
문제 해결
하나의 실패한 LLM 호출로 인해 전체 브랜치 fan-out이 취소되고 완료된 결과가 버려지는 것을 어떻게 막을 수 있나요?

divergence 팬아웃(frames.map(...))과 deepen 패스(toDeepen.map(...)) 모두에서 Promise.all을 Promise.allSettled로 교체하세요. 그런 다음 첫 번째 rejection이 실행을 중단시키게 하지 말고, fulfilled 결과는 별도로 처리하고 rejected 분기는 수집하세요.

예시 패턴:

const settled = await Promise.allSettled(
  frames.map((frame) => divergeBranch(frame))
);

const branches: Branch[] = [];
const failedFrames: { frameId: string; error: string }[] = [];

settled.forEach((result, i) => {
  if (result.status === "fulfilled") {
    branches.push(result.value);
  } else {
    const frameId = frames[i].id;
    const error = String(result.reason);
    failedFrames.push({ frameId, error });
    emitter.emit("frame:failed", { frameId, error });
  }
});

deepen 패스에도 동일한 변경을 적용하세요. types.ts의 RunResult에 failedFrames를 추가하세요:

type RunResult = {
  // existing fields
  failedFrames: { frameId: string; error: string }[];
};

그러면 CLI가 ✗ <frame> failed: <reason>과 같은 부분 실패를 출력할 수 있습니다. 실행은 모든 분기가 실패한 경우에만 하드 실패해야 합니다:

if (branches.length === 0) {
  throw new Error("All LLM branches failed");
}

이렇게 하면 레이트 리밋, 타임아웃, 복구 불가능한 malformed 응답과 같은 네트워크/LLM 계층의 throw를 처리할 수 있습니다. divergeBranch, scoreIdeas, clusterIdeas 내부의 JSON 파싱 실패는 이미 빈 결과를 반환하는 방식으로 fail open됩니다. 재실행 지원을 위해서는 (frame_id, input_hash)를 키로 하는 선택적 체크포인트를 사용해 완료된 분기는 건너뛰고 실패한 분기는 백오프를 적용해 재시도할 수 있습니다.

원본 Issue #44