Where to Find the i-have-adhd VS Code Plugin Source Code
The complete i-have-adhd VS Code plugin source code resides in the extensions/ directory of the ayghri/i-have-adhd repository, with the main logic implemented in extensions/i-have-adhd.ts and OpenCode runtime integration handled by .opencode/plugins/i-have-adhd.mjs.
The i-have-adhd VS Code extension provides ADHD-friendly output formatting for AI coding assistants. According to the ayghri/i-have-adhd repository source code, the plugin is implemented as a TypeScript extension that integrates with both VS Code and OpenCode-compatible runtimes. All source files are version-controlled under the main branch and available for inspection or forking directly from GitHub.
Core Extension Implementation (extensions/i-have-adhd.ts)
The primary VS Code extension logic lives in extensions/i-have-adhd.ts. This file exports the iHaveAdhdExtension function, which serves as the entry point for the Pi/OMP runtime.
Entry Point and State Management
The extension initializes by loading the ADHD ruleset from skills/i-have-adhd/SKILL.md and setting up state management through a filesystem flag at .i-have-adhd-always within the agent directory. The iHaveAdhdExtension function receives the ExtensionAPI object (aliased as pi) and configures the extension context.
// extensions/i-have-adhd.ts – main VS Code extension entry point
import { existsSync, readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import {
getAgentDir,
type ExtensionAPI,
type ExtensionContext,
} from "@earendil-works/pi-coding-agent";
import { contextMessages, latestMarkerIsActive } from "./context-compat";
const EXTENSION_DIR = dirname(fileURLToPath(import.meta.url));
const SKILL_PATH = join(
EXTENSION_DIR,
"..",
"skills",
"i-have-adhd",
"SKILL.md"
);
// … (omitted for brevity: rule loading, state handling, UI updates)
export default function iHaveAdhdExtension(pi: ExtensionAPI) {
const rules = loadRules();
const alwaysOnFlag = join(getAgentDir(), ".i-have-adhd-always");
let enabled = false;
// Register a flag (`/i-have-adhd`) and a command to toggle the mode
pi.registerFlag("adhd", { description: "Start with ADHD‑friendly output enabled", type: "boolean", default: false });
pi.registerCommand("i-have-adhd", {
description: "Toggle ADHD‑friendly output for this session",
handler: async (args, ctx) => { /* … toggle logic … */ },
});
// Hook into the session lifecycle to restore state / sync context
pi.on("session_start", async (_, ctx) => restoreState(ctx));
pi.on("session_tree", async (_, ctx) => restoreState(ctx));
pi.on("session_compact", async (_, ctx) => syncContext(ctx));
}
Command and Flag Registration
The extension registers a boolean flag adhd via pi.registerFlag() to control the default startup behavior, and a slash command i-have-adhd via pi.registerCommand() to allow users to toggle ADHD-friendly output dynamically during a session.
Session Lifecycle Integration
State persistence and context synchronization are handled through three event hooks: session_start, session_tree, and session_compact. These hooks invoke restoreState() to reload the previous configuration and syncContext() to update the conversation context with the current ruleset.
OpenCode Plugin Integration (.opencode/plugins/i-have-adhd.mjs)
For runtimes that support the OpenCode contract, the plugin exposes its functionality through .opencode/plugins/i-have-adhd.mjs. This wrapper makes the skill discoverable and implements an "always-on" transformer that prepends the ADHD ruleset to every system prompt when the opt-in flag is present.
// .opencode/plugins/i-have-adhd.mjs – OpenCode plug‑in wrapper
export default async () => ({
// Expose the skill directory to the OpenCode runtime
config: async (config) => {
const skillsDir = path.resolve(__dirname, '../../skills');
config.skills = config.skills || {};
config.skills.paths = config.skills.paths || [];
if (!config.skills.paths.includes(skillsDir)) config.skills.paths.push(skillsDir);
},
// “always‑on” transformer that injects the ADHD ruleset each turn
'experimental.chat.system.transform': async (_input, output) => {
const flagPath = /* path to the opt‑in flag */;
if (!fs.existsSync(flagPath)) return;
const body = fs.readFileSync(skillPath, "utf8")
.replace(/^---[\s\S]*?---/, "")
.trim();
const header = 'ADHD MODE ACTIVE (always‑on)…';
const injected = `${header}\n\n${body}`;
output.system.push(injected);
},
});
The experimental.chat.system.transform hook specifically checks for the existence of the opt-in flag before injecting the processed SKILL.md content into the output.system array.
Skill Definition (skills/i-have-adhd/SKILL.md)
The actual ADHD-friendly ruleset that the extension injects into prompts is maintained as a single source of truth in skills/i-have-adhd/SKILL.md. This markdown file contains the formatting instructions and behavioral guidelines that the AI assistant follows when ADHD mode is active. The TypeScript loader strips the YAML frontmatter from this file before injecting the rules into the conversation context.
Package Manifest Configuration (package.json)
The extension is declared to Pi/OMP runtimes through the package.json file, which includes the omp.extensions and pi.extensions fields. This manifest registers the compiled extension and defines its entry points for the package manager, ensuring the plugin is discoverable when installed via the OpenCode or Pi package ecosystems.
Summary
extensions/i-have-adhd.ts– Core VS Code extension implementation containing state handling, command registration, and lifecycle hooks.opencode/plugins/i-have-adhd.mjs– OpenCode runtime wrapper that exposes the skill directory and implements the system prompt transformerskills/i-have-adhd/SKILL.md– Runtime-agnostic skill file containing the ADHD-friendly ruleset injected into AI promptspackage.json– Package manifest declaring the extension for Pi/OMP runtimes with extension metadataplugin.json– OpenCode-specific plugin manifest used by the OpenCode runtime loader
Frequently Asked Questions
What is the main source file for the i-have-adhd VS Code plugin?
The main source file is extensions/i-have-adhd.ts in the ayghri/i-have-adhd repository. This file exports the iHaveAdhdExtension function, which initializes the extension, registers commands and flags, and manages session state.
How does the plugin inject ADHD-friendly rules into system prompts?
The plugin uses the experimental.chat.system.transform hook defined in .opencode/plugins/i-have-adhd.mjs to automatically prepend the content of skills/i-have-adhd/SKILL.md to the system prompt whenever the opt-in flag file (.i-have-adhd-always) exists in the agent directory.
Can I modify the skill rules without changing the extension code?
Yes, you can modify skills/i-have-adhd/SKILL.md directly, as this file is the single source of truth for the ADHD-friendly ruleset. The extension dynamically reads this file at runtime, so changes take effect immediately without recompiling the TypeScript extension code.
Is the plugin compatible with OpenCode runtimes?
Yes, the plugin is designed for dual compatibility. While the TypeScript implementation in extensions/i-have-adhd.ts targets VS Code and Pi/OMP runtimes, the .opencode/plugins/i-have-adhd.mjs wrapper ensures full functionality within OpenCode-compatible environments through the standard OpenCode plugin manifest.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →