Skip to content

Commit da92a99

Browse files
authored
feat: add crab tax plugin (#66)
## Why Crabcode already had plugin-based workflows for promptfoo and Excalidraw, but there was no tax workflow for organizing personal tax documents into a reviewable filing handoff. This adds the new tax plugin, wires it into `crab`, and documents it where plugin-specific users will actually look. ## What - add the `crab tax` plugin with inventory, extraction, reconciliation, deterministic estimate, and TurboTax handoff generation - wire install, uninstall, update, help, and execution commands into `src/crabcode` - add top-level docs for `crab tax` and a plugin-local README at `plugins/tax/README.md` - add fixture-based tests and testdata for supported flows and failure cases - add plugin-local `.gitignore` so build artifacts and dependencies stay out of the repo ## How to Test - run `cd plugins/tax && npm test` - run `cd plugins/tax && npm run build` - run `bash -n src/crabcode` - note: `pnpm exec biome check --write .` is not runnable in this repo because there is no root package/workspace for `pnpm exec` to target
1 parent 7087f6b commit da92a99

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+4974
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,39 @@ pf: My API is at http://localhost:8080/chat, POST with JSON { "message": "the pr
197197

198198
File attachments (API specs, curl commands) are also supported. Results are posted back to the Slack thread as downloadable files.
199199

200+
### Tax Organizer (`crab tax`)
201+
202+
Tax document organizer and deterministic filing handoff generator for supported 2025 federal + California personal return scenarios.
203+
204+
```bash
205+
crab tax install # Install the plugin
206+
crab tax ./my-tax-docs # Process a folder of tax documents
207+
crab tax ./my-tax-docs --output ./tax-output # Write outputs to a directory
208+
crab tax ./my-tax-docs --profile ./profile.json
209+
crab tax uninstall # Remove the plugin
210+
```
211+
212+
**Supported inputs today:** `W-2`, `1099-INT`, `1099-DIV`, `1098`, `1099-B`, `1099-R`, `5498`, `1099-composite`, `property-tax-bill`
213+
214+
**Outputs:**
215+
- `taxpayer_profile.json`
216+
- `documents.json`
217+
- `reconciliation.json`
218+
- `issues_to_review.json`
219+
- `federal_return_inputs.json`
220+
- `ca_return_inputs.json`
221+
- `estimate_summary.json`
222+
- `turbotax_handoff.md`
223+
224+
See [plugins/tax/README.md](plugins/tax/README.md) for plugin-specific details.
225+
226+
**Modes:**
227+
- Mock extraction via `.mock.json` sidecars for deterministic fixture testing
228+
- Live OpenAI extraction for supported PDFs/images when `OPENAI_API_KEY` is set
229+
- Bounded agent research for unknown or unsupported forms using tool calls plus official-source web search
230+
231+
**Current scope:** single or MFJ, full-year California resident, no dependent-related federal credits, no RSU/ESPP handling, deterministic estimation for supported scenarios only
232+
200233
### Excalidraw Whiteboard (`crab draw`)
201234

202235
Collaborative whiteboarding with real-time collab via Excalidraw.

plugins/tax/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
dist/

plugins/tax/README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Crab Tax Plugin
2+
3+
`crab tax` organizes tax documents, extracts supported fields, computes deterministic 2025 federal and California estimates for supported scenarios, and writes a TurboTax-oriented handoff packet.
4+
5+
## Installation
6+
7+
```bash
8+
crab tax install
9+
```
10+
11+
## Usage
12+
13+
```bash
14+
crab tax ./my-tax-docs
15+
crab tax ./my-tax-docs --output ./tax-output
16+
crab tax ./my-tax-docs --profile ./profile.json
17+
crab tax uninstall
18+
```
19+
20+
## Outputs
21+
22+
The plugin writes:
23+
24+
```text
25+
tax-output/
26+
├── taxpayer_profile.json
27+
├── documents.json
28+
├── extracted/
29+
├── reconciliation.json
30+
├── issues_to_review.json
31+
├── federal_return_inputs.json
32+
├── ca_return_inputs.json
33+
├── estimate_summary.json
34+
└── turbotax_handoff.md
35+
```
36+
37+
## Supported Inputs
38+
39+
- `W-2`
40+
- `1099-INT`
41+
- `1099-DIV`
42+
- `1098`
43+
- `1099-B`
44+
- `1099-R`
45+
- `5498`
46+
- `1099-composite`
47+
- `property-tax-bill`
48+
49+
## Extraction Modes
50+
51+
### Mock Sidecars
52+
53+
For deterministic local tests, place a `.mock.json` file beside the document:
54+
55+
```text
56+
w2-2025.pdf
57+
w2-2025.pdf.mock.json
58+
```
59+
60+
### Deterministic Parsers
61+
62+
The plugin prefers deterministic extraction for supported document layouts such as composite brokerage statements and property tax bills.
63+
64+
### Live OpenAI Extraction
65+
66+
If no mock sidecar is present and deterministic parsing does not apply, the plugin attempts live extraction for supported PDFs and images when `OPENAI_API_KEY` is set. The current default model is `gpt-5.4`.
67+
68+
## Agent Research Loop
69+
70+
For unknown or unsupported tax forms, the plugin runs a bounded agent research pass:
71+
72+
- the agent inspects the unknown document inventory
73+
- it uses tool calls to perform official-source research
74+
- it records a handling strategy
75+
- unsupported forms remain blocking unless deterministic handling exists
76+
77+
This is intentionally different from letting an agent improvise tax math. The deterministic engine still owns reconciliation and final computations.
78+
79+
## Current Supported Scenario
80+
81+
The deterministic estimation path currently targets:
82+
83+
- 2025 tax year
84+
- `single` or `mfj`
85+
- California full-year resident
86+
- no dependent-related federal credits
87+
- no RSU / ESPP / inherited-share handling
88+
- no Schedule C, rental, or K-1 support
89+
90+
Unsupported scenarios are surfaced as blocking issues rather than silently guessed.
91+
92+
## Development
93+
94+
Run fixture-based end-to-end tests:
95+
96+
```bash
97+
cd plugins/tax
98+
npm test
99+
```

plugins/tax/bin/crab-tax.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
import('../dist/cli.js');

plugins/tax/package-lock.json

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/tax/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "@crabcode/tax",
3+
"version": "0.1.0",
4+
"description": "Tax document organizer and filing handoff plugin for crabcode",
5+
"type": "module",
6+
"main": "dist/index.js",
7+
"bin": {
8+
"crab-tax": "./bin/crab-tax.js"
9+
},
10+
"scripts": {
11+
"build": "tsc",
12+
"dev": "tsc --watch",
13+
"test": "node test/e2e.mjs && node test/classify.mjs && node test/deterministic.mjs"
14+
},
15+
"dependencies": {},
16+
"devDependencies": {
17+
"@types/node": "^22.0.0",
18+
"typescript": "^5.7.0"
19+
},
20+
"engines": {
21+
"node": ">=20.0.0"
22+
}
23+
}

0 commit comments

Comments
 (0)