|
| 1 | +# AgentRC Copilot Instructions |
| 2 | + |
| 3 | +`@microsoft/agentrc` is a CLI tool (and VS Code extension) that sets up repositories for AI-assisted development. It analyzes repos, generates instruction files, evaluates AI responses, and runs readiness reports. |
| 4 | + |
| 5 | +## Architecture |
| 6 | + |
| 7 | +``` |
| 8 | +src/ # CLI entry point and commands |
| 9 | + cli.ts # Commander program, withGlobalOpts helper |
| 10 | + commands/ # Thin command wrappers (parse args → call services) |
| 11 | + ui/ # Ink/React TUI components |
| 12 | +packages/core/src/ # Shared services and utilities (bundled into dist) |
| 13 | + services/ # analyzer, generator, instructions, readiness, policy, ... |
| 14 | + utils/ # fs, output, logger, repo, pr |
| 15 | +plugin/skills/ # Built-in skill markdown files (copied to dist/skills/ on build) |
| 16 | +vscode-extension/ # See .github/instructions/vscode-extension.instructions.md |
| 17 | +``` |
| 18 | + |
| 19 | +`@agentrc/core` (in `packages/core/`) is **bundled** into the CLI output — it is not an external npm package. Use the `@agentrc/core/*` path alias for all cross-package imports. |
| 20 | + |
| 21 | +## Build & Test |
| 22 | + |
| 23 | +```sh |
| 24 | +npm run build # tsup → dist/index.js (ESM, Node 20) |
| 25 | +npm run dev # tsx src/index.ts (run from source) |
| 26 | +npm run typecheck # tsc --noEmit |
| 27 | +npm run lint # eslint |
| 28 | +npm test # vitest run |
| 29 | +npm run test:coverage # vitest run --coverage |
| 30 | +``` |
| 31 | + |
| 32 | +Output is ESM (`"type": "module"`). All node_modules are external except `@agentrc/core`, `@github/copilot-sdk`, and `vscode-jsonrpc` (bundled via `noExternal` in `tsup.config.ts`). |
| 33 | + |
| 34 | +> **SDK shim**: `tsup.config.ts` patches `getBundledCliPath()` in the Copilot SDK. An identical shim lives in `vscode-extension/esbuild.mjs` — update **both** together if SDK internals change. |
| 35 | +
|
| 36 | +## Command Pattern |
| 37 | + |
| 38 | +Commands in `src/commands/` are thin wrappers: |
| 39 | + |
| 40 | +1. Resolve paths and options |
| 41 | +2. Call services from `@agentrc/core/services/*` |
| 42 | +3. Write output using the output utilities |
| 43 | + |
| 44 | +Wrap every command action with `withGlobalOpts` (from `src/cli.ts`) so `--json`, `--quiet`, and `--accessible` are merged into the options object. |
| 45 | + |
| 46 | +## Output Convention |
| 47 | + |
| 48 | +| Stream | Purpose | |
| 49 | +| -------- | ------------------------------------------------- | |
| 50 | +| `stdout` | Machine-readable JSON only (when `--json` is set) | |
| 51 | +| `stderr` | Human-readable progress, logs, warnings, errors | |
| 52 | + |
| 53 | +Never write progress to stdout. Use `outputResult` / `outputError` from `@agentrc/core/utils/output`. Use `shouldLog(options)` before writing stderr text. Use `createProgressReporter(silent)` for step-by-step progress. |
| 54 | + |
| 55 | +`CommandResult<T>` shape: `{ ok, status: "success"|"partial"|"noop"|"error", data?, errors? }`. |
| 56 | + |
| 57 | +## Skills |
| 58 | + |
| 59 | +Built-in skills live in `plugin/skills/<skill-name>/SKILL.md` with YAML frontmatter (`name`, `description`). They are copied to `dist/skills/` on build via `tsup.config.ts`'s `onSuccess` hook. Resolve the skills directory with `getSkillDirectory()` from `@agentrc/core/services/skills` — never hardcode paths. |
| 60 | + |
| 61 | +## Code Conventions |
| 62 | + |
| 63 | +- **Type imports**: always use `import type` for type-only imports (`@typescript-eslint/consistent-type-imports` is enforced). |
| 64 | +- **Import order**: alphabetical, grouped by node built-ins → external packages → internal (`@agentrc/core/*`) → relative. ESLint enforces this. |
| 65 | +- **Tests**: test files live in `src/services/__tests__/` and use vitest. Default timeout is 10 s. |
| 66 | +- **Unused vars**: prefix with `_` to suppress the lint warning. |
| 67 | +- **Strict TypeScript**: `strict: true`, `moduleResolution: Bundler`, target `ES2022`. |
0 commit comments