2.8 KiB
2.8 KiB
AGENTS.md
Build & Run
- Compile:
npm run compile(ortsc -p ./) - Watch:
npm run watch - Package:
npm run build→ produces.vsixin project root - Test:
npm run test— currently a no-op (echo "No tests yet"); press F5 in VS Code to debug the extension - Verify:
npx tsc --noEmit— strict mode, TS 6.0 (usesignoreDeprecations: "6.0") - No linter or formatter is configured
Architecture
| File | Role |
|---|---|
src/extension.ts |
Entrypoint; registers aiCommitExt.generate command; orchestrates flow |
src/opencodeService.ts |
Spawns opencode run --format default --variant minimal with the prompt on stdin; parses stdout for the commit message |
src/gitService.ts |
Uses VS Code's built-in Git extension API (vscode.git) for diffs and repo root |
Key Behaviors
- Activation:
onCommandonly — not on startup - Diff logic: Prefers staged changes. Falls back to unstaged only if
aiCommitExt.includeUnstagedistrue(defaultfalse). - Prompt: Hardcoded in
opencodeService.ts— enforces Conventional Commit format (<type>(<scope>): <description>, max 72-char subject). Types: feat, fix, refactor, docs, style, test, chore, perf, ci, build, revert. - Parsing: Uses
\b(type)(\(scope\))?:\sregex that matches anywhere in a line (not just line-start), so backtick-wrapped or prose-embedded commit messages are found. ANSI escape sequences are stripped before matching. Falls back to first content line, then"chore: generated commit message". - Stdout is logged to the output channel ("ai-commit-ext") for debugging.
--pureflag: Not used — opencode loads its user config (~/.config/opencode/opencode.json) which needs to configure the model. The extension does NOT pass a hardcoded--modelflag; the user's config determines the model.shell: true: Spawn uses a shell so opencode can findgitand other tools via the shell's PATH (VS Code's GUI-launched process has a minimal PATH).- Timeout: 120 seconds for OpenCode response.
- Model: Default is whatever opencode's user config sets. Override via
aiCommitExt.modelsetting orGenerateOptions.model. - OpenCode CLI: Required on
$PATH; resolved to an absolute path viawhich opencodeand cached — used inspawn()to avoid PATH lookup mismatches between the shell and VS Code's process environment.
Configuration (aiCommitExt.*)
| Setting | Default | Purpose |
|---|---|---|
model |
"" |
OpenCode model override |
includeUnstaged |
false |
Use unstaged changes when nothing staged |
showNotification |
true |
Show VS Code notifications on success/error |
Build Artifacts & Cleanup
- Compiled output →
out/(gitignored) - Packaged extension →
*.vsix(gitignored) node_modules/(gitignored)npm run compilebefore packaging (vscode:prepublishhook)