@profullstack/gov-contracts 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Profullstack, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,79 @@
1
- # Temporary Holding Version
1
+ # @profullstack/gov-contracts
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Find government contract opportunities, read the RFP, score the fit, draft the proposal, and queue every step that needs a person. Hosted at **gov.procurement** (Moshpit name; clearnet relay `https://gov.procurement.pit.world`).
4
+
5
+ ```
6
+ our website -> spider (c0mpute crawl.fetch) -> index (FTS5) -> AI names our niches (weekly, /profile)
7
+ |
8
+ ingest -> niche filter -> read the RFP -> score the fit -> draft a proposal -> human queue
9
+ (6 h) out-of-niche notice + PDFs c0mpute AI letter, approach, price it, sign forms,
10
+ bids stop here (OpenAI/Claude compliance, forms, register on the portal,
11
+ fallback) pricing structure review and SUBMIT BY HAND
12
+ ```
13
+
14
+ ## The hard line
15
+
16
+ The system **never** submits a proposal, registers a vendor account, signs or certifies anything, sets a price, or contacts an agency. Those are legal and business commitments, so each one is an intervention card a person works and marks done (with the confirmation number, UEI, vendor number...). There is no mail transport, portal login or form posting in this package, and `test/safety.test.js` keeps it that way. Source adapters only `GET`, from a fixed list of read-only hosts, politely (robots.txt, one request at a time per host, 2 s apart, 429 hold-back).
17
+
18
+ ## Sources
19
+
20
+ Where to look comes from Datamart's contracts registry (the Profullstack connector's `contracts_sources`, served at `mcp.profullstack.com/contracts`). gov-contracts reads the ones with a public feed:
21
+
22
+ | Source | Level | How |
23
+ |---|---|---|
24
+ | SAM.gov contract opportunities | federal | Public search every 6 h (7 niche queries); the official Opportunities API instead when `SAM_API_KEY` is set. Full notice, NAICS, set-aside, contacts, up to 3 public PDF attachments read per notice. |
25
+ | County of Los Angeles (LACoBids) | county | The county's open-solicitations CSV every 6 h. |
26
+ | Forwarded bid digests (email) | any | `POST /api/v1/ingest/digest` or `gov-contracts digest < mail.txt`. MyGovWatch parsed exactly; other layouts by a model. Tracking links are dropped, never opened. |
27
+
28
+ Cal eProcure and most city portals block automated reads; their bids arrive through digests, and the queue tells a person where to look.
29
+
30
+ ## Our niches, read from our website
31
+
32
+ Bids are filtered by what the bidder actually sells, read from its own site (`PROFILE_DOMAIN`, default `profullstack.com`), not a hand-written list:
33
+
34
+ 1. **Spider** (`src/spider.js`): sitemap first, then same-site links, service and about pages first, up to `PROFILE_MAX_PAGES` (40). Each page is fetched through c0mpute's `crawl.fetch` workload first, via a `c0mpute jobs serve` bridge (`C0MPUTE_JOBS_URL` + `C0MPUTE_JOBS_TOKEN`) or the local `c0mpute crawl fetch` CLI (`C0MPUTE_CRAWL_CLI=1`). When the network has no free crawl worker (`network_busy`, twice) or neither is set, pages are read directly (robots.txt, public addresses only, one request at a time). Every page records which path read it.
35
+ 2. **Index** (`src/profile.js`): pages go into SQLite with an FTS5 index (`/api/v1/profile/search`, MCP `search_profile_pages`), so a proposal can cite what the site says.
36
+ 3. **Niches**: a model (c0mpute first, OpenAI/Claude fallback) names 3-8 niches, the words a bid title uses for each, NAICS codes and what is never a fit. A niche whose keywords never appear on the site is dropped; generic one-word keywords ("services", "solutions") are dropped; library niches the site clearly uses (`NICHE_LIBRARY` in `src/niche.js`: software development, software consulting, agentic engineering, automation, cybersecurity, cloud, GPU rental...) are added by name. With no model the library alone decides.
37
+ 4. **Filter**: every bid gets a niche match (title first; body words count only with a tech title or one of our NAICS codes; never-a-fit words sink it). Out-of-niche bids are never read, scored or drafted. `/solicitations` and the queue show **Our niches** by default, with one chip per niche and "Everything". A new or edited profile re-screens every open bid.
38
+
39
+ Operators edit it at `/profile` (switch niches off, change keywords, add a niche, NAICS, never-a-fit words); switched-off niches stay off after the weekly re-read. CLI: `gov-contracts niches`, `gov-contracts profile crawl profullstack.com --local` (crawl from your machine with the c0mpute spider, then upload), `gov-contracts profile set --off "Blockchain and payments"`.
40
+
41
+ ## Fit and drafts
42
+
43
+ The niche filter keeps the model to the bids that could matter. The model (c0mpute first via `@profullstack/ai-providers`, Anthropic/OpenAI fallback, short c0mpute timeout) returns a 0-100 score, verdict, requirements, forms and registrations. Brand-name license/renewal/maintenance buys are capped at 45 (they need an authorized reseller). 60+ gets a draft in three small parts; 40-59 gets a "worth a bid?" card. Drafts never contain a price, and only list forms whose names appear in what was read.
44
+
45
+ ## Surfaces
46
+
47
+ - **Web / PWA**: `/` (stats, best fits in our niches), `/solicitations?niche=`, `/profile` (our niches), `/s/:id`, `/queue?niche=` (Sign in with CoinPay; operators by CoinPay `sub` allowlist, never email), `/p/:id` proposal. Installable.
48
+ - **HTTP API**: `/api/v1/solicitations?niche=in|out|all|<name>`, `/profile`, `/profile/search`, `/sources`, `/stats`; operator: `/interventions?niche=`, `/proposals/:id`, `/solicitations/:id/draft`, `/ingest/digest`, `/run/:job` (`profile`, `rescreen`), `POST /profile/crawl`, `POST /profile/pages`, `PUT /profile`. See `/docs`.
49
+ - **MCP**: streamable HTTP at `/mcp`: `search_solicitations` (niche filter), `get_solicitation`, `list_sources`, `stats`, `get_profile`, `search_profile_pages`; operator (Bearer key): `list_interventions`, `get_proposal`, `resolve_intervention`, `draft_proposal`, `ingest_digest`, `crawl_profile`, `update_profile`.
50
+ - **CLI + TUI**: `npx @profullstack/gov-contracts search software --niche "Agentic engineering"`, `niches`, `site <words>`, `profile crawl|set|rescreen`, `queue`, `card`, `done`, `tui`, `mcp` (stdio bridge), `serve`.
51
+
52
+ Public reads: 60 a minute free, then a $1 USDC day pass (CoinPay / x402). Operators are not metered.
53
+
54
+ ## Run your own
55
+
56
+ ```sh
57
+ pnpm install
58
+ DB_PATH=./data/gov.db OPERATOR_API_KEY=... C0MPUTE_API_KEY=... node src/server.js
59
+ ```
60
+
61
+ | Env | |
62
+ |---|---|
63
+ | `DB_PATH` | SQLite file (`/data/gov-contracts.db` in the image) |
64
+ | `OPERATOR_API_KEY` | Bearer key for operator API/MCP/CLI |
65
+ | `OPERATOR_SUBS` | CoinPay `sub`s allowed to work the queue (comma-separated) |
66
+ | `COINPAY_OAUTH_CLIENT_ID`, `COINPAY_OAUTH_CLIENT_SECRET` | Sign in with CoinPay |
67
+ | `C0MPUTE_API_KEY`, `C0MPUTE_MODELS`, `C0MPUTE_TIMEOUT_MS` | AI (c0mpute first) |
68
+ | `ANTHROPIC_API_KEY` / `OPENAI_API_KEY` | AI fallback |
69
+ | `SAM_API_KEY` | optional: official SAM.gov API |
70
+ | `COINPAY_X402_KEY`, `CRAWL_PAY_TO` | paid day pass past the free rate |
71
+ | `DRAFT_MIN_FIT` (60), `DECIDE_MIN_FIT` (40) | thresholds |
72
+ | `PROFILE_DOMAIN` (profullstack.com), `PROFILE_MAX_PAGES` (40), `PROFILE_EVERY` (7d), `PROFILE_DISABLED` | the website the niches are read from |
73
+ | `C0MPUTE_JOBS_URL`, `C0MPUTE_JOBS_TOKEN` / `C0MPUTE_CRAWL_CLI=1`, `C0MPUTE_CRAWL_TIMEOUT_MS` (25000), `C0MPUTE_CRAWL_MAX_PRICE` (0.01) | spider through c0mpute `crawl.fetch`; `C0MPUTE_CRAWL=0` reads directly |
74
+
75
+ Deploy: `sh deploy/deploy.sh` (c0mpute Apps, state in `/data`).
76
+
77
+ ## License
78
+
79
+ MIT, Profullstack, Inc.
@@ -0,0 +1,225 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * gov-contracts CLI + TUI. Talks to the hosted API (GOV_CONTRACTS_API, default
4
+ * https://gov.procurement.pit.world). Operator commands need GOV_CONTRACTS_KEY.
5
+ * `serve` runs your own instance (API, MCP, PWA and the scheduled updater).
6
+ * Nothing here submits, registers, signs, prices or emails: `done` only
7
+ * records what a person did.
8
+ */
9
+ import { createInterface } from 'node:readline/promises';
10
+ import { readFileSync } from 'node:fs';
11
+
12
+ const API = (process.env.GOV_CONTRACTS_API || 'https://gov.procurement.pit.world').replace(/\/$/, '');
13
+ const KEY = process.env.GOV_CONTRACTS_KEY || '';
14
+ const [, , cmd = 'help', ...args] = process.argv;
15
+
16
+ const flags = {};
17
+ const pos = [];
18
+ for (let i = 0; i < args.length; i++) {
19
+ if (args[i].startsWith('--')) {
20
+ const k = args[i].slice(2);
21
+ flags[k] = args[i + 1] && !args[i + 1].startsWith('--') ? args[++i] : true;
22
+ } else pos.push(args[i]);
23
+ }
24
+
25
+ async function call(path, { method = 'GET', body, raw } = {}) {
26
+ const headers = { accept: 'application/json' };
27
+ if (KEY) headers.authorization = `Bearer ${KEY}`;
28
+ if (body !== undefined) headers['content-type'] = 'application/json';
29
+ const r = await fetch(`${API}${path}`, { method, headers, body: body === undefined ? undefined : JSON.stringify(body) });
30
+ if (raw) return r.text();
31
+ const j = await r.json().catch(() => ({}));
32
+ if (!r.ok) throw new Error(j?.error?.message || j?.error?.code || `HTTP ${r.status}`);
33
+ return j.data ?? j;
34
+ }
35
+
36
+ const out = (v) => (flags.json ? console.log(JSON.stringify(v, null, 2)) : null);
37
+ const line = (s) => `${s.fit_score != null ? String(s.fit_score).padStart(3) + ' ' : ''}${String(s.due_at || '').slice(0, 10).padEnd(10)} ${s.title.slice(0, 80)}\n${' '.repeat(s.fit_score != null ? 5 : 0)}${' '.repeat(12)}${s.agency || ''} · ${s.id}`;
38
+ const stdin = async () => {
39
+ if (process.stdin.isTTY) return '';
40
+ const chunks = [];
41
+ for await (const c of process.stdin) chunks.push(c);
42
+ return Buffer.concat(chunks).toString('utf8');
43
+ };
44
+
45
+ const HELP = `gov-contracts: government contract opportunities, read and drafted. Submitting stays human.
46
+
47
+ gov-contracts search [words] [--niche in|out|all|<name>] [--level federal|state|county|city] [--source sam|lacounty|digest] [--order fit|due|new|niche] [--limit N]
48
+ gov-contracts niches our niche profile (read from our website) and bids per niche
49
+ gov-contracts site <words> search our indexed website pages
50
+ gov-contracts show <id> one solicitation (e.g. sam:<notice id>, lacounty:50629)
51
+ gov-contracts sources where opportunities come from
52
+ gov-contracts stats
53
+ operator (GOV_CONTRACTS_KEY):
54
+ gov-contracts queue [--status open|done|dismissed|all] [--niche in|all|<name>]
55
+ gov-contracts profile crawl [domain] [--pages 40] [--local] re-read the site; --local crawls from here
56
+ (c0mpute crawl.fetch via C0MPUTE_JOBS_URL or the c0mpute CLI, direct fallback)
57
+ gov-contracts profile set --niches '[{"name":"...","keywords":["..."]}]' | --naics 541511,541512 | --off "Niche name"
58
+ gov-contracts profile rescreen
59
+ gov-contracts card <id> one card, with the text to copy
60
+ gov-contracts done <id> [note] record that YOU did it (confirmation number, UEI...)
61
+ gov-contracts dismiss <id> [note]
62
+ gov-contracts proposal <id> markdown of a draft (proposal id or solicitation id)
63
+ gov-contracts draft <solicitation id>
64
+ gov-contracts digest [file] add the bids listed in a forwarded digest (or stdin)
65
+ gov-contracts run ingest-sam|ingest-lacounty|work
66
+ gov-contracts tui work the queue in the terminal
67
+ other:
68
+ gov-contracts mcp stdio MCP bridge to ${API}/mcp
69
+ gov-contracts serve run your own instance (PORT, DB_PATH, ...)
70
+ --json for machine output. GOV_CONTRACTS_API=${API}`;
71
+
72
+ async function tui() {
73
+ if (!KEY) throw new Error('tui needs GOV_CONTRACTS_KEY (the operator key).');
74
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
75
+ try {
76
+ for (;;) {
77
+ const items = await call('/api/v1/interventions?status=open');
78
+ console.log(`\n\x1b[1mgov.procurement queue\x1b[0m ${items.length} open (${API})\n`);
79
+ items.slice(0, 30).forEach((iv, i) => console.log(`${String(i + 1).padStart(2)}. [${iv.kind}] ${iv.title.slice(0, 90)}${iv.due_at ? ` due ${String(iv.due_at).slice(0, 10)}` : ''}`));
80
+ const a = (await rl.question('\nNumber to open, r = refresh, q = quit: ')).trim().toLowerCase();
81
+ if (a === 'q' || a === '') break;
82
+ if (a === 'r') continue;
83
+ const iv = items[Number(a) - 1];
84
+ if (!iv) continue;
85
+ const full = await call(`/api/v1/interventions/${iv.id}`);
86
+ console.log(`\n\x1b[1m${full.title}\x1b[0m\n${full.agency || ''}\n\n${full.body}\n${full.open_url ? `\nOpen: ${full.open_url}` : ''}`);
87
+ if (full.copy_text) console.log(`\n--- text to copy (${full.copy_text.length} chars) ---\n${full.copy_text.slice(0, 3000)}${full.copy_text.length > 3000 ? '\n[...] (gov-contracts card ' + full.id + ' for all of it)' : ''}`);
88
+ const act = (await rl.question('\nd = mark done, x = dismiss, enter = back: ')).trim().toLowerCase();
89
+ if (act === 'd' || act === 'x') {
90
+ const note = await rl.question('Note (confirmation number, UEI, reason): ');
91
+ await call(`/api/v1/interventions/${iv.id}`, { method: 'POST', body: { status: act === 'd' ? 'done' : 'dismissed', note } });
92
+ console.log('Recorded.');
93
+ }
94
+ }
95
+ } finally {
96
+ rl.close();
97
+ }
98
+ }
99
+
100
+ /** stdio <-> streamable HTTP: one JSON-RPC message per line. */
101
+ async function mcpBridge() {
102
+ const rl = createInterface({ input: process.stdin });
103
+ for await (const l of rl) {
104
+ if (!l.trim()) continue;
105
+ let msg;
106
+ try { msg = JSON.parse(l); } catch { continue; }
107
+ try {
108
+ const r = await fetch(`${API}/mcp`, {
109
+ method: 'POST',
110
+ headers: { 'content-type': 'application/json', accept: 'application/json, text/event-stream', ...(KEY ? { authorization: `Bearer ${KEY}` } : {}) },
111
+ body: JSON.stringify(msg),
112
+ });
113
+ const t = await r.text();
114
+ if (msg.id === undefined) continue;
115
+ const data = t.startsWith('event:') || t.startsWith('data:') ? t.split('\n').filter((x) => x.startsWith('data:')).map((x) => x.slice(5).trim()).join('') : t;
116
+ process.stdout.write((data || JSON.stringify({ jsonrpc: '2.0', id: msg.id, error: { code: -32000, message: `HTTP ${r.status}` } })) + '\n');
117
+ } catch (e) {
118
+ if (msg.id !== undefined) process.stdout.write(JSON.stringify({ jsonrpc: '2.0', id: msg.id, error: { code: -32000, message: String(e.message || e) } }) + '\n');
119
+ }
120
+ }
121
+ }
122
+
123
+ const commands = {
124
+ async help() { console.log(HELP); },
125
+ async search() {
126
+ const p = new URLSearchParams();
127
+ if (pos.length) p.set('q', pos.join(' '));
128
+ for (const k of ['level', 'source', 'order', 'limit', 'niche']) if (flags[k]) p.set(k, flags[k]);
129
+ const rows = await call(`/api/v1/solicitations?${p}`);
130
+ if (flags.json) return out(rows);
131
+ rows.forEach((s) => console.log(line(s)));
132
+ if (!rows.length) console.log('No open solicitations match.');
133
+ },
134
+ async show() {
135
+ const s = await call(`/api/v1/solicitations/${encodeURIComponent(pos[0] || '')}`);
136
+ if (flags.json) return out(s);
137
+ console.log(`${s.title}\n${s.agency || ''}\nNumber: ${s.number || 'n/a'} Due: ${s.due_at || 'n/a'} Level: ${s.level}\n${s.url || ''}\n\n${(s.description || '').slice(0, 2500)}`);
138
+ if (s.fit) console.log(`\nFit ${s.fit_score}/100 (${s.fit.verdict}): ${s.fit.summary}`);
139
+ },
140
+ async sources() {
141
+ const rows = await call('/api/v1/sources');
142
+ if (flags.json) return out(rows);
143
+ rows.forEach((r) => console.log(`${r.gov_contracts ? '●' : '○'} ${r.name} [${r.level || ''}] ${r.gov_contracts ? r.gov_contracts.ingest : 'link only'}\n ${r.official_url || ''}`));
144
+ },
145
+ async niches() {
146
+ const p = await call('/api/v1/profile');
147
+ if (flags.json) return out(p);
148
+ console.log(`${p.company} (${p.domain || 'no site'}) source: ${p.source}${p.method ? ` · ${p.method}` : ''}${p.crawled_at ? ` · read ${p.crawled_at.slice(0, 16)}` : ''} · ${p.indexed_pages} pages${p.crawling ? ` · reading ${p.crawling} now` : ''}\n${p.summary}\n`);
149
+ const counts = Object.fromEntries((p.niche_counts || []).map((r) => [r.niche, r.n]));
150
+ for (const n of p.niches) console.log(`${n.enabled === false ? '○' : '●'} ${n.name} (${counts[n.name] || 0} open bids)\n ${n.keywords.slice(0, 12).join(', ')}`);
151
+ console.log(`\nNAICS ${p.naics.join(', ')}`);
152
+ },
153
+ async site() {
154
+ const rows = await call(`/api/v1/profile/search?q=${encodeURIComponent(pos.join(' '))}`);
155
+ if (flags.json) return out(rows);
156
+ rows.forEach((r) => console.log(`${r.title || r.url}\n ${r.url}\n ${r.snippet}`));
157
+ if (!rows.length) console.log('No indexed page matches.');
158
+ },
159
+ async profile() {
160
+ const sub = pos[0] || 'show';
161
+ if (sub === 'show') return commands.niches();
162
+ if (sub === 'rescreen') return console.log(JSON.stringify(await call('/api/v1/run/rescreen', { method: 'POST' }), null, 2));
163
+ if (sub === 'crawl') {
164
+ const domain = pos[1] || (await call('/api/v1/profile')).domain;
165
+ const maxPages = Number(flags.pages || 40);
166
+ if (!flags.local) return console.log(JSON.stringify(await call('/api/v1/profile/crawl', { method: 'POST', body: { domain, max_pages: maxPages } }), null, 2));
167
+ if (!process.env.C0MPUTE_JOBS_URL && process.env.C0MPUTE_CRAWL_CLI === undefined) process.env.C0MPUTE_CRAWL_CLI = '1';
168
+ process.env.GOV_CONTRACTS_LOCAL = '1';
169
+ const { crawlSite, makePageFetcher } = await import('../src/spider.js');
170
+ const fetchPage = makePageFetcher();
171
+ console.error(`reading ${domain} (up to ${maxPages} pages; c0mpute ${fetchPage.mode || 'off'}, direct fallback)`);
172
+ const crawl = await crawlSite(domain, { maxPages, fetchPage, onPage: (p) => console.error(` ${p.via.padEnd(14)} ${p.url}`) });
173
+ for (const n of crawl.notes) console.error(` note: ${n}`);
174
+ if (!crawl.pages.length) throw new Error(`no readable pages: ${crawl.errors.map((e) => e.error).slice(0, 3).join('; ')}`);
175
+ console.error(`read ${crawl.pages.length} pages ${JSON.stringify(crawl.via)}; uploading`);
176
+ return console.log(JSON.stringify(await call('/api/v1/profile/pages', { method: 'POST', body: { domain, pages: crawl.pages } }), null, 2));
177
+ }
178
+ if (sub === 'set') {
179
+ const body = {};
180
+ if (flags.niches) body.niches = JSON.parse(flags.niches);
181
+ if (flags.naics) body.naics = String(flags.naics).split(',');
182
+ if (flags.negative) body.negative_keywords = String(flags.negative).split(',');
183
+ if (flags.off || flags.on) {
184
+ const cur = await call('/api/v1/profile');
185
+ const flip = (name, on) => { const n = cur.niches.find((x) => x.name.toLowerCase() === String(name).toLowerCase()); if (!n) throw new Error(`no niche named ${name}`); n.enabled = on; };
186
+ if (flags.off) flip(flags.off, false);
187
+ if (flags.on) flip(flags.on, true);
188
+ body.niches = cur.niches;
189
+ }
190
+ return console.log(JSON.stringify((await call('/api/v1/profile', { method: 'PUT', body })).screened, null, 2));
191
+ }
192
+ throw new Error('profile show | crawl [domain] [--local] | set ... | rescreen');
193
+ },
194
+ async stats() { console.log(JSON.stringify(await call('/api/v1/stats'), null, 2)); },
195
+ async queue() {
196
+ const rows = await call(`/api/v1/interventions?status=${flags.status || 'open'}&niche=${encodeURIComponent(flags.niche || 'in')}`);
197
+ if (flags.json) return out(rows);
198
+ rows.forEach((iv) => console.log(`${iv.id} [${iv.kind}] ${iv.title.slice(0, 90)}${iv.due_at ? ` due ${String(iv.due_at).slice(0, 10)}` : ''}`));
199
+ if (!rows.length) console.log('Nothing waiting.');
200
+ },
201
+ async card() {
202
+ const iv = await call(`/api/v1/interventions/${pos[0]}`);
203
+ if (flags.json) return out(iv);
204
+ console.log(`${iv.title}\n\n${iv.body}\n${iv.open_url ? `\nOpen: ${iv.open_url}\n` : ''}${iv.copy_text ? `\n${iv.copy_text}` : ''}`);
205
+ },
206
+ async done() { console.log(JSON.stringify(await call(`/api/v1/interventions/${pos[0]}`, { method: 'POST', body: { status: 'done', note: pos.slice(1).join(' ') } }), null, 2)); },
207
+ async dismiss() { console.log(JSON.stringify(await call(`/api/v1/interventions/${pos[0]}`, { method: 'POST', body: { status: 'dismissed', note: pos.slice(1).join(' ') } }), null, 2)); },
208
+ async proposal() { process.stdout.write(await call(`/api/v1/proposals/${encodeURIComponent(pos[0] || '')}?format=md`, { raw: true })); },
209
+ async draft() { console.log(JSON.stringify(await call(`/api/v1/solicitations/${encodeURIComponent(pos[0] || '')}/draft`, { method: 'POST' }), null, 2)); },
210
+ async digest() {
211
+ const text = pos[0] ? readFileSync(pos[0], 'utf8') : await stdin();
212
+ if (!text.trim()) throw new Error('Give a file or pipe the digest text on stdin.');
213
+ console.log(JSON.stringify(await call('/api/v1/ingest/digest', { method: 'POST', body: { text } }), null, 2));
214
+ },
215
+ async run() { console.log(JSON.stringify(await call(`/api/v1/run/${pos[0] || 'work'}`, { method: 'POST' }), null, 2)); },
216
+ tui,
217
+ mcp: mcpBridge,
218
+ async serve() { await import('../src/server.js'); },
219
+ };
220
+
221
+ const fn = commands[cmd] || commands.help;
222
+ fn().catch((e) => {
223
+ console.error(`gov-contracts: ${e.message || e}`);
224
+ process.exit(1);
225
+ });
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@profullstack/gov-contracts",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Find government contract opportunities (SAM.gov, LA County, forwarded bid digests), filter them by the niches read from your own website, read the RFP, score the fit, draft a proposal and queue every human step. Never submits anything on its own. API, CLI, MCP, TUI and PWA.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Profullstack, Inc.",
8
+ "homepage": "https://gov.procurement.pit.world",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/profullstack/gov-contracts.git"
12
+ },
13
+ "keywords": ["government contracts", "rfp", "procurement", "sam.gov", "proposals", "mcp", "bids"],
14
+ "engines": {
15
+ "node": ">=24"
16
+ },
17
+ "packageManager": "pnpm@10.34.6",
18
+ "bin": {
19
+ "gov-contracts": "bin/gov-contracts.js"
20
+ },
21
+ "exports": {
22
+ ".": "./src/index.js",
23
+ "./sources": "./src/sources/index.js",
24
+ "./digest": "./src/sources/digest.js",
25
+ "./fit": "./src/fit.js",
26
+ "./safety": "./src/safety.js",
27
+ "./niche": "./src/niche.js",
28
+ "./spider": "./src/spider.js",
29
+ "./profile": "./src/profile.js",
30
+ "./server": "./src/app.js"
31
+ },
32
+ "files": ["bin", "src", "public", "README.md", "LICENSE"],
33
+ "scripts": {
34
+ "start": "node src/server.js",
35
+ "dev": "node --watch src/server.js",
36
+ "test": "DB_PATH=:memory: GOV_OFFLINE=1 node --test test/*.test.js"
37
+ },
38
+ "dependencies": {
39
+ "@hono/node-server": "^2.1.11",
40
+ "@modelcontextprotocol/sdk": "^1.32.2",
41
+ "@profullstack/ai-providers": "0.3.3",
42
+ "@profullstack/coinpay-onboard": "0.5.1",
43
+ "@profullstack/footer": "0.7.3",
44
+ "@profullstack/scraper-daemon": "0.4.0",
45
+ "@profullstack/stack": "0.6.2",
46
+ "@profullstack/throttle": "0.5.2",
47
+ "@profullstack/x402-gateway": "0.20.0",
48
+ "hono": "^4.13.23",
49
+ "unpdf": "2.2.3",
50
+ "zod": "^4.6.7"
51
+ }
52
+ }
package/src/ai.js ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * AI: c0mpute first through @profullstack/ai-providers, then OpenAI/Anthropic
3
+ * (alternating) when c0mpute fails or times out. House rule.
4
+ *
5
+ * A fresh router per call: the shared one parks c0mpute for 30 s after one
6
+ * dropped job, which would push every following call to a paid provider.
7
+ * The c0mpute timeout is kept short (C0MPUTE_TIMEOUT_MS, default 120 s) so a
8
+ * stuck job falls back instead of holding the pipeline.
9
+ */
10
+ import { createAiProviders } from '@profullstack/ai-providers';
11
+
12
+ export const DEFAULT_MODELS = 'huihui_ai/qwen3.5-abliterated:4b,qwen3:4b';
13
+
14
+ export function aiConfigured(env = process.env) {
15
+ return !!(env.C0MPUTE_API_KEY || env.INFERNET_API_KEY || env.OPENAI_API_KEY || env.ANTHROPIC_API_KEY);
16
+ }
17
+
18
+ export function makeAi(env = process.env) {
19
+ if (env.AI_DISABLED === '1' || !aiConfigured(env)) return null;
20
+ const router = createAiProviders({
21
+ env: { C0MPUTE_MODELS: DEFAULT_MODELS, ...env },
22
+ c0mpute: {
23
+ timeoutMs: Number(env.C0MPUTE_TIMEOUT_MS || 120_000),
24
+ stallMs: Number(env.C0MPUTE_STALL_MS || 60_000),
25
+ },
26
+ openai: { timeoutMs: 90_000 },
27
+ anthropic: { timeoutMs: 90_000 },
28
+ router: {
29
+ onAttempt: (e) => {
30
+ if (!e.ok) console.error(`ai ${e.feature || ''} ${e.provider} failed after ${e.ms} ms: ${e.kind || ''} ${String(e.error || '').slice(0, 160)}`);
31
+ },
32
+ },
33
+ });
34
+ return router;
35
+ }
36
+
37
+ /** Which providers are configured (never the keys). */
38
+ export function aiStatus(env = process.env) {
39
+ return {
40
+ c0mpute: !!(env.C0MPUTE_API_KEY || env.INFERNET_API_KEY),
41
+ openai: !!env.OPENAI_API_KEY,
42
+ anthropic: !!env.ANTHROPIC_API_KEY,
43
+ models: (env.C0MPUTE_MODELS || DEFAULT_MODELS).split(','),
44
+ c0mpute_timeout_ms: Number(env.C0MPUTE_TIMEOUT_MS || 120_000),
45
+ };
46
+ }