ensemble-review 1.0.35 → 1.0.36
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/package.json +5 -2
- package/dist/ai/check-tool.js +0 -6
- package/dist/api/routes/auth.js +0 -194
- package/dist/api/routes/billing.js +0 -209
- package/dist/api/routes/claude-review.js +0 -522
- package/dist/api/routes/contact.js +0 -318
- package/dist/api/routes/feed.js +0 -21
- package/dist/api/routes/inbox.js +0 -45
- package/dist/api/routes/mentions.js +0 -22
- package/dist/api/routes/teams.js +0 -150
- package/dist/api/routes/webhooks.js +0 -181
- package/dist/coding/activity.js +0 -80
- package/dist/coding/agent.js +0 -147
- package/dist/coding/ai-fix/checks-preview.js +0 -58
- package/dist/coding/ai-fix/comment-seed.js +0 -519
- package/dist/coding/ai-fix/prompts.js +0 -283
- package/dist/coding/ai-resolve/prompt.js +0 -161
- package/dist/coding/ai-resolve/routes.js +0 -97
- package/dist/coding/ai-resolve/run.js +0 -343
- package/dist/coding/ai-resolve/schema.js +0 -26
- package/dist/coding/ai-resolve/validate.js +0 -136
- package/dist/coding/checks/deny-scan.js +0 -75
- package/dist/coding/checks/discover.js +0 -541
- package/dist/coding/checks/docker.js +0 -38
- package/dist/coding/checks/env.js +0 -88
- package/dist/coding/checks/hooks.js +0 -91
- package/dist/coding/checks/index.js +0 -8
- package/dist/coding/checks/local.js +0 -40
- package/dist/coding/checks/sandbox.js +0 -206
- package/dist/coding/checks/session.js +0 -518
- package/dist/coding/checks/spawn.js +0 -123
- package/dist/coding/checks/spec.js +0 -140
- package/dist/coding/checks/types.js +0 -6
- package/dist/coding/partial-spend.js +0 -19
- package/dist/coding/safe-path.js +0 -75
- package/dist/coding/story-build/build-prompts.js +0 -178
- package/dist/coding/story-build/build.js +0 -332
- package/dist/coding/story-build/checkouts.js +0 -66
- package/dist/coding/story-build/docs-runner.js +0 -178
- package/dist/coding/story-build/docs.js +0 -334
- package/dist/coding/story-build/manager.js +0 -999
- package/dist/coding/story-build/plan-agent.js +0 -190
- package/dist/coding/story-build/plan.js +0 -338
- package/dist/coding/story-build/prompts.js +0 -147
- package/dist/coding/story-build/routes-docs.js +0 -113
- package/dist/coding/story-build/routes.js +0 -295
- package/dist/coding/story-build/schema.js +0 -53
- package/dist/db/automation-output.js +0 -349
- package/dist/db/credits.js +0 -79
- package/dist/db/schema.js +0 -321
- package/dist/db/schema.pg.js +0 -2197
- package/dist/db/sprint-repo-suggest.js +0 -257
- package/dist/db/sprint-stories.js +0 -42
- package/dist/db/sprint-story.js +0 -505
- package/dist/db/sprint-ticket-repos.js +0 -195
- package/dist/db/story-selection.js +0 -270
- package/dist/db/team-comparison.js +0 -124
- package/dist/db/workspace-comparison.js +0 -98
- package/dist/feed/fyi-provider.js +0 -10
- package/dist/github/local-user.js +0 -92
- package/dist/github/repo-files.js +0 -26
- package/dist/ml/worker.js +0 -31
- package/dist/platform/advisor/discovery/tier2.js +0 -88
- package/dist/platform/advisor/discovery/tier3.js +0 -57
- package/dist/platform/advisor/emitters/adapter.js +0 -5
- package/dist/platform/advisor/emitters/coderabbit.js +0 -175
- package/dist/platform/advisor/emitters/copilot-prose.js +0 -118
- package/dist/platform/advisor/emitters/greptile.js +0 -176
- package/dist/platform/advisor/emitters/lint.js +0 -37
- package/dist/platform/advisor/emitters/manifest.js +0 -239
- package/dist/platform/advisor/emitters/prose.js +0 -183
- package/dist/platform/advisor/emitters/registry.js +0 -20
- package/dist/platform/advisor/emitters/yaml-doc.js +0 -95
- package/dist/platform/advisor/evidence.js +0 -79
- package/dist/platform/advisor/findings.js +0 -15
- package/dist/platform/advisor/intents.js +0 -269
- package/dist/platform/advisor/measure/effect.js +0 -18
- package/dist/platform/advisor/outputs/brief.js +0 -68
- package/dist/platform/advisor/outputs/config-pr.js +0 -156
- package/dist/platform/advisor/refine/diff-guard.js +0 -38
- package/dist/platform/advisor/refine/refine.js +0 -35
- package/dist/platform/advisor/retro-check.js +0 -98
- package/dist/platform/advisor/routes.js +0 -648
- package/dist/platform/advisor/store.js +0 -321
- package/dist/platform/advisor/taxonomy.js +0 -67
- package/dist/platform/annotations/prompts.js +0 -84
- package/dist/platform/annotations/routes.js +0 -86
- package/dist/platform/annotations/runner.js +0 -234
- package/dist/platform/annotations/targets.js +0 -203
- package/dist/platform/insights/grounded-figures.js +0 -162
- package/dist/platform/insights/period-questions.js +0 -235
- package/dist/platform/work-plan/hash.js +0 -99
- package/dist/platform/work-plan/prompt.js +0 -209
- package/dist/platform/work-plan/routes.js +0 -350
- package/dist/pro/bind.js +0 -309
- package/dist/pro/contract.js +0 -36
- package/dist/pro/event-hooks.js +0 -37
- package/dist/pro/migrate.js +0 -64
- package/dist/review/events.js +0 -24
- package/dist/review/local-settings.js +0 -78
- package/dist/review/memory/capture.js +0 -0
- package/dist/review/memory/retrieval.js +0 -272
- package/dist/review/memory/routes.js +0 -78
- package/dist/review/persist.js +0 -203
- package/dist/review/plugin-providers.js +0 -12
- package/dist/review/prompt.js +0 -264
- package/dist/review/review-manager.js +0 -259
- package/dist/review/routing.js +0 -164
- package/dist/review/sprint-assess/agent.js +0 -145
- package/dist/review/sprint-assess/manager.js +0 -382
- package/dist/review/sprint-assess/prompts.js +0 -99
- package/dist/review/sprint-assess/routes.js +0 -109
- package/dist/review/sprint-assess/schema.js +0 -70
- package/dist/review/sprint-assess/validate.js +0 -180
- package/dist/review/sprint-story/manager.js +0 -98
- package/dist/review/sprint-story/prompt.js +0 -45
- package/dist/review/sprint-story/validate.js +0 -127
- package/dist/review/story-docs/build-prompts.js +0 -153
- package/dist/review/story-docs/build-validate.js +0 -162
- package/dist/review/story-report/agent.js +0 -203
- package/dist/review/story-report/fingerprint.js +0 -45
- package/dist/review/story-report/manager.js +0 -287
- package/dist/review/story-report/routes.js +0 -154
- package/dist/review/story-report/story-detail.js +0 -148
- package/dist/review/story-report/validate.js +0 -105
- package/dist/review/ticket-review/sweep-waits.js +0 -20
- package/dist/review/write-deny.js +0 -170
- package/dist/shared/conflict-ai.js +0 -24
- package/dist/sync/benchmark-rollup.js +0 -50
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
// The public contact form: POST /api/contact, delivered to a Slack incoming webhook.
|
|
2
|
-
//
|
|
3
|
-
// WHY SLACK AND NOT EMAIL. A contact form's job is to make sure a message ARRIVES.
|
|
4
|
-
// Email is the medium with the worst odds of that: it bounces, it lands in spam, and
|
|
5
|
-
// it needs SPF/DKIM/DMARC on the domain plus a transactional provider before the first
|
|
6
|
-
// message even has a chance. A webhook POST either returns 2xx or throws, and the
|
|
7
|
-
// failure is visible in this process's logs at the moment it happens. There is also
|
|
8
|
-
// precedent and a working shape already in the repo — the Pro plugin's per-workspace
|
|
9
|
-
// digest delivery (packages/pro/src/slack/) — though core cannot import from the
|
|
10
|
-
// plugin, so the URL validation below is a deliberate small copy rather than a shared
|
|
11
|
-
// helper. Email can be added later as a SECOND sink; it should never be the only one.
|
|
12
|
-
//
|
|
13
|
-
// ⚠ NO NEW DEPENDENCY, AND THAT IS A CONSTRAINT RATHER THAN A PREFERENCE.
|
|
14
|
-
// scripts/build-release.mjs generates release/package.json from a CURATED dependency
|
|
15
|
-
// list, so an SDK here ships to every `npx pierre-review` install for the sake of a
|
|
16
|
-
// hosted-only marketing page. Node ≥20's global fetch is the whole client.
|
|
17
|
-
//
|
|
18
|
-
// ---- Deciding a submission is genuine ----
|
|
19
|
-
//
|
|
20
|
-
// Three layers, none of which needs a third party, a script tag or a CSP change (the
|
|
21
|
-
// landing's CSP is `default-src 'self'` with `frame-src` absent entirely — a Turnstile
|
|
22
|
-
// or reCAPTCHA widget would need `script-src` AND `frame-src` widened, plus a line in
|
|
23
|
-
// the privacy policy, which is a decision worth taking deliberately rather than as a
|
|
24
|
-
// side effect of shipping a form):
|
|
25
|
-
//
|
|
26
|
-
// 1. A HONEYPOT field. `website` is rendered, labelled and reachable in the DOM, and
|
|
27
|
-
// hidden from sighted users by CSS + aria-hidden + tabindex=-1. A person never
|
|
28
|
-
// fills it; a form-filling bot fills every input it finds. A filled honeypot is
|
|
29
|
-
// answered with 200 and DROPPED — never a 400, because an error tells whoever is
|
|
30
|
-
// running the bot exactly which field gave them away.
|
|
31
|
-
//
|
|
32
|
-
// 2. A SIGNED TICKET with a minimum fill time. GET /api/contact/ticket returns
|
|
33
|
-
// `<issuedAtMs>.<hmac>`; the POST verifies the signature and requires the age to
|
|
34
|
-
// sit between MIN_FILL_MS and MAX_TICKET_MS. This is the layer that a client-sent
|
|
35
|
-
// "elapsed" number cannot be: the timestamp is signed by this server, so a bot
|
|
36
|
-
// cannot forge an age, and to get a valid one it has to make a second request and
|
|
37
|
-
// then WAIT. Stateless on purpose — no store, no replay table. A ticket is
|
|
38
|
-
// therefore reusable within its window, which the rate limit below bounds.
|
|
39
|
-
//
|
|
40
|
-
// 3. A RATE LIMIT. The `contact` tier in api/plugins/rate-limit.ts, keyed by IP
|
|
41
|
-
// because this route is deliberately anonymous. Five an hour.
|
|
42
|
-
//
|
|
43
|
-
// A determined human will still get a message through, which is correct — the target
|
|
44
|
-
// is automated submission volume, not a wall.
|
|
45
|
-
import { createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
46
|
-
import { config } from '../../config.js';
|
|
47
|
-
// ---------------------------------------------------------------------------
|
|
48
|
-
// The ticket
|
|
49
|
-
// ---------------------------------------------------------------------------
|
|
50
|
-
/** A person needs longer than this to write a message. Below it, it was not typed. */
|
|
51
|
-
export const MIN_FILL_MS = 3_000;
|
|
52
|
-
/** Past this the ticket is stale — a page left open, or one harvested days ago. */
|
|
53
|
-
export const MAX_TICKET_MS = 6 * 60 * 60 * 1000;
|
|
54
|
-
// The signing key. SESSION_SECRET where there is one (cloud, where this form actually
|
|
55
|
-
// runs), otherwise a per-process random — which means a restart invalidates every
|
|
56
|
-
// outstanding ticket. That is acceptable and better than a constant: the failure mode
|
|
57
|
-
// is one visitor being asked to reload, and the alternative is a key an attacker can
|
|
58
|
-
// read out of the source.
|
|
59
|
-
//
|
|
60
|
-
// Derived rather than used directly so this never shares key material with the session
|
|
61
|
-
// cookie: the same secret signing two different things is how one forgery becomes two.
|
|
62
|
-
const TICKET_KEY = createHmac('sha256', config.sessionSecret || randomBytes(32))
|
|
63
|
-
.update('pierre:contact-ticket:v1')
|
|
64
|
-
.digest();
|
|
65
|
-
function sign(issuedAtMs) {
|
|
66
|
-
return createHmac('sha256', TICKET_KEY).update(String(issuedAtMs)).digest('hex');
|
|
67
|
-
}
|
|
68
|
-
/** Mint a ticket for a form that is being opened now. */
|
|
69
|
-
export function issueTicket(nowMs = Date.now()) {
|
|
70
|
-
return `${nowMs}.${sign(nowMs)}`;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Check a ticket's signature and age. Pure — `nowMs` is injected so the windows can be
|
|
74
|
-
* tested without waiting for them.
|
|
75
|
-
*/
|
|
76
|
-
export function verifyTicket(raw, nowMs = Date.now()) {
|
|
77
|
-
if (typeof raw !== 'string')
|
|
78
|
-
return 'malformed';
|
|
79
|
-
const dot = raw.indexOf('.');
|
|
80
|
-
if (dot <= 0)
|
|
81
|
-
return 'malformed';
|
|
82
|
-
const issuedAt = Number.parseInt(raw.slice(0, dot), 10);
|
|
83
|
-
const mac = raw.slice(dot + 1);
|
|
84
|
-
if (!Number.isFinite(issuedAt) || mac === '')
|
|
85
|
-
return 'malformed';
|
|
86
|
-
// Constant-time, and length-checked first: timingSafeEqual THROWS on a length
|
|
87
|
-
// mismatch rather than returning false, so an attacker-supplied short mac would be a
|
|
88
|
-
// 500 instead of a 400.
|
|
89
|
-
const expected = Buffer.from(sign(issuedAt), 'utf-8');
|
|
90
|
-
const got = Buffer.from(mac, 'utf-8');
|
|
91
|
-
if (got.length !== expected.length || !timingSafeEqual(got, expected)) {
|
|
92
|
-
return 'bad_signature';
|
|
93
|
-
}
|
|
94
|
-
const age = nowMs - issuedAt;
|
|
95
|
-
// A negative age means a clock moved, not an attack — it is signed, so it can only
|
|
96
|
-
// have been minted here. Treated as "too fast", which is the safe side.
|
|
97
|
-
if (age < MIN_FILL_MS)
|
|
98
|
-
return 'too_fast';
|
|
99
|
-
if (age > MAX_TICKET_MS)
|
|
100
|
-
return 'expired';
|
|
101
|
-
return 'ok';
|
|
102
|
-
}
|
|
103
|
-
// ---------------------------------------------------------------------------
|
|
104
|
-
// The webhook URL
|
|
105
|
-
// ---------------------------------------------------------------------------
|
|
106
|
-
const SLACK_WEBHOOK_HOST = 'hooks.slack.com';
|
|
107
|
-
/**
|
|
108
|
-
* Validate and normalise a Slack incoming-webhook URL.
|
|
109
|
-
*
|
|
110
|
-
* A near-copy of the Pro plugin's `normalizeSlackWebhookUrl` — core cannot import from
|
|
111
|
-
* `packages/pro` (it is a private submodule loaded by path, absent in OSS builds), so
|
|
112
|
-
* this is duplicated deliberately rather than shared. Keep the two in step.
|
|
113
|
-
*
|
|
114
|
-
* The value arrives from the environment, so the threat is a misconfiguration or a
|
|
115
|
-
* compromised variable turning this process into an SSRF proxy, not a user submission.
|
|
116
|
-
* Validating at the SINK makes the guarantee structural.
|
|
117
|
-
*/
|
|
118
|
-
export function normalizeContactWebhookUrl(raw) {
|
|
119
|
-
const t = raw.trim();
|
|
120
|
-
if (t === '')
|
|
121
|
-
return null;
|
|
122
|
-
let url;
|
|
123
|
-
try {
|
|
124
|
-
url = new URL(t);
|
|
125
|
-
}
|
|
126
|
-
catch {
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
// https only: the secret is in the path, so http would leak it on the wire, and the
|
|
130
|
-
// scheme check also rules out file:/gopher:/ftp: redirect tricks.
|
|
131
|
-
if (url.protocol !== 'https:')
|
|
132
|
-
return null;
|
|
133
|
-
// Exact host. NOT endsWith('slack.com'), which accepts hooks.slack.com.evil.example.
|
|
134
|
-
if (url.hostname.toLowerCase() !== SLACK_WEBHOOK_HOST)
|
|
135
|
-
return null;
|
|
136
|
-
// A real webhook is /services/<team>/<bot>/<token>.
|
|
137
|
-
if (!url.pathname.startsWith('/services/'))
|
|
138
|
-
return null;
|
|
139
|
-
// Query and fragment are dropped — nothing legitimate uses them, and they are a
|
|
140
|
-
// place to hide a redirect target.
|
|
141
|
-
return `https://${SLACK_WEBHOOK_HOST}${url.pathname}`;
|
|
142
|
-
}
|
|
143
|
-
/** What the form offers, and what each one means when it lands in Slack. */
|
|
144
|
-
export const CONTACT_TOPICS = {
|
|
145
|
-
pro_trial: 'Free Pro month',
|
|
146
|
-
question: 'Question about the product',
|
|
147
|
-
problem: 'Something is broken',
|
|
148
|
-
other: 'Something else',
|
|
149
|
-
};
|
|
150
|
-
/**
|
|
151
|
-
* Slack's own escaping rules: `&`, `<` and `>` are the only three characters that are
|
|
152
|
-
* special in message text, and they must be escaped BEFORE the markup is assembled.
|
|
153
|
-
* Applied to every visitor-supplied string so a submission cannot forge a link, a
|
|
154
|
-
* channel reference or an @-mention in the notification it produces.
|
|
155
|
-
*/
|
|
156
|
-
function slackEscape(s) {
|
|
157
|
-
return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Build the Block Kit payload. Pure, so the test asserts the shape and the escaping
|
|
161
|
-
* without a network.
|
|
162
|
-
*
|
|
163
|
-
* The message is ONE block per fact plus the body, because a contact form's whole
|
|
164
|
-
* value is that the reply address is readable at a glance on a phone.
|
|
165
|
-
*/
|
|
166
|
-
export function buildContactMessage(s) {
|
|
167
|
-
// `?? 'Something else'` rather than `?? CONTACT_TOPICS['other']`: under
|
|
168
|
-
// noUncheckedIndexedAccess the second lookup is `string | undefined` too, so it
|
|
169
|
-
// would not narrow. The literal is the same string the 'other' key holds.
|
|
170
|
-
const topic = CONTACT_TOPICS[s.topic] ?? 'Something else';
|
|
171
|
-
// Angle brackets around the address would only be escaped back into literal ones, so
|
|
172
|
-
// the notification line uses parentheses and reads the same in every client.
|
|
173
|
-
const summary = `${topic} — ${s.name} (${s.email})`;
|
|
174
|
-
return {
|
|
175
|
-
// `text` is the notification line and the fallback for any client that cannot
|
|
176
|
-
// render blocks. Escaped like everything else.
|
|
177
|
-
text: slackEscape(summary),
|
|
178
|
-
blocks: [
|
|
179
|
-
{
|
|
180
|
-
type: 'section',
|
|
181
|
-
text: { type: 'mrkdwn', text: `*${slackEscape(topic)}*` },
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
type: 'section',
|
|
185
|
-
fields: [
|
|
186
|
-
{ type: 'mrkdwn', text: `*From*\n${slackEscape(s.name)}` },
|
|
187
|
-
{ type: 'mrkdwn', text: `*Reply to*\n${slackEscape(s.email)}` },
|
|
188
|
-
],
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
type: 'section',
|
|
192
|
-
text: { type: 'mrkdwn', text: slackEscape(s.message) },
|
|
193
|
-
},
|
|
194
|
-
],
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
/** POST the message. Throws on a non-2xx so the route can log it and 502. */
|
|
198
|
-
export async function postContactToSlack(webhookUrl, message) {
|
|
199
|
-
const safe = normalizeContactWebhookUrl(webhookUrl);
|
|
200
|
-
if (!safe)
|
|
201
|
-
throw new Error('CONTACT_SLACK_WEBHOOK_URL is not a Slack webhook URL');
|
|
202
|
-
const res = await fetch(safe, {
|
|
203
|
-
method: 'POST',
|
|
204
|
-
headers: { 'content-type': 'application/json' },
|
|
205
|
-
body: JSON.stringify(message),
|
|
206
|
-
// Never follow a redirect: a 30x is the standard way past a host allowlist that
|
|
207
|
-
// was only applied to the first URL.
|
|
208
|
-
redirect: 'error',
|
|
209
|
-
signal: AbortSignal.timeout(10_000),
|
|
210
|
-
});
|
|
211
|
-
if (!res.ok) {
|
|
212
|
-
// The response BODY is deliberately not surfaced — including it would turn a
|
|
213
|
-
// failed request into a read primitive (point the webhook at something internal
|
|
214
|
-
// and the error tells you what it said). The status is enough to diagnose.
|
|
215
|
-
throw new Error(`Slack webhook responded ${res.status}`);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
// ---------------------------------------------------------------------------
|
|
219
|
-
// The routes
|
|
220
|
-
// ---------------------------------------------------------------------------
|
|
221
|
-
// Length caps are on the SCHEMA, so an oversized body is rejected by Fastify before any
|
|
222
|
-
// of this file runs. Sized for a real message rather than for an essay: Slack truncates
|
|
223
|
-
// a section block past 3000 characters anyway, and a 4000-character contact-form
|
|
224
|
-
// message is not a contact-form message.
|
|
225
|
-
const BODY_SCHEMA = {
|
|
226
|
-
type: 'object',
|
|
227
|
-
required: ['name', 'email', 'message', 'ticket'],
|
|
228
|
-
additionalProperties: false,
|
|
229
|
-
properties: {
|
|
230
|
-
name: { type: 'string', minLength: 1, maxLength: 120 },
|
|
231
|
-
// A deliberately loose pattern. Email addresses that are legal and that a strict
|
|
232
|
-
// regex rejects are common; the address is only ever used as a reply-to that a
|
|
233
|
-
// human reads, never as a delivery target, so a wrong one costs a reply and
|
|
234
|
-
// nothing else.
|
|
235
|
-
email: { type: 'string', minLength: 3, maxLength: 254, pattern: '^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$' },
|
|
236
|
-
topic: { type: 'string', enum: Object.keys(CONTACT_TOPICS) },
|
|
237
|
-
message: { type: 'string', minLength: 1, maxLength: 2500 },
|
|
238
|
-
ticket: { type: 'string', minLength: 1, maxLength: 200 },
|
|
239
|
-
// The honeypot, and IT MUST BE DECLARED HERE OR THE WHOLE LAYER IS INERT. Fastify
|
|
240
|
-
// configures ajv with `removeAdditional: true`, so an undeclared property is
|
|
241
|
-
// SILENTLY STRIPPED from req.body before the handler runs — the request still 200s,
|
|
242
|
-
// the check below still sees `undefined`, and every bot passes. Verified by injection,
|
|
243
|
-
// not assumed: an unknown field posted to this route returns 200 with the field gone.
|
|
244
|
-
website: { type: 'string', maxLength: 200 },
|
|
245
|
-
},
|
|
246
|
-
};
|
|
247
|
-
export async function contactRoutes(app) {
|
|
248
|
-
const configured = normalizeContactWebhookUrl(config.contactSlackWebhookUrl) != null;
|
|
249
|
-
// Mint a ticket. Also the form's readiness probe: with no webhook configured it 503s
|
|
250
|
-
// here, so the page can say so BEFORE someone writes two hundred words into a form
|
|
251
|
-
// that has nowhere to send them.
|
|
252
|
-
app.get('/api/contact/ticket', async (_req, reply) => {
|
|
253
|
-
if (!configured) {
|
|
254
|
-
return reply.code(503).send({ error: 'contact_unavailable' });
|
|
255
|
-
}
|
|
256
|
-
// A ticket is a signed timestamp and nothing else — it identifies no one and
|
|
257
|
-
// carries no state — but it must not be cached by anything in front of this
|
|
258
|
-
// server, or every visitor shares one issue time.
|
|
259
|
-
reply.header('cache-control', 'no-store');
|
|
260
|
-
return { ticket: issueTicket() };
|
|
261
|
-
});
|
|
262
|
-
app.post('/api/contact', { schema: { body: BODY_SCHEMA } }, async (req, reply) => {
|
|
263
|
-
if (!configured) {
|
|
264
|
-
return reply.code(503).send({
|
|
265
|
-
error: 'contact_unavailable',
|
|
266
|
-
message: 'The contact form is not available right now.',
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
const body = req.body;
|
|
270
|
-
// Layer 1. Answered with the SUCCESS shape on purpose: a bot that is told it failed
|
|
271
|
-
// learns which field to leave alone next time, and a person can never reach this.
|
|
272
|
-
if (typeof body.website === 'string' && body.website.trim() !== '') {
|
|
273
|
-
req.log.info({ ip: req.ip }, 'contact form: honeypot filled, dropped');
|
|
274
|
-
return { ok: true };
|
|
275
|
-
}
|
|
276
|
-
// Layer 2.
|
|
277
|
-
const verdict = verifyTicket(body.ticket);
|
|
278
|
-
if (verdict !== 'ok') {
|
|
279
|
-
req.log.warn({ ip: req.ip, verdict }, 'contact form: ticket rejected');
|
|
280
|
-
// Two answers, because they mean different things to a person. An expired ticket
|
|
281
|
-
// is a page that sat open and the fix is to reload; anything else is either a bot
|
|
282
|
-
// or a genuinely broken client, and the message says what to do without saying
|
|
283
|
-
// which check failed.
|
|
284
|
-
return reply.code(400).send({
|
|
285
|
-
error: verdict === 'expired' ? 'ticket_expired' : 'ticket_invalid',
|
|
286
|
-
message: verdict === 'expired'
|
|
287
|
-
? 'This form has been open for a while. Reload the page and send it again.'
|
|
288
|
-
: 'We could not verify that form. Reload the page and try again.',
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
try {
|
|
292
|
-
await postContactToSlack(config.contactSlackWebhookUrl, buildContactMessage({
|
|
293
|
-
name: body.name.trim(),
|
|
294
|
-
email: body.email.trim(),
|
|
295
|
-
topic: body.topic ?? 'other',
|
|
296
|
-
message: body.message.trim(),
|
|
297
|
-
}));
|
|
298
|
-
}
|
|
299
|
-
catch (err) {
|
|
300
|
-
// The submitter's words only exist in the request they just made, so a failure
|
|
301
|
-
// here loses them. Log enough to reconstruct the message by hand, and tell the
|
|
302
|
-
// visitor plainly that it did not send rather than showing a success screen over
|
|
303
|
-
// a dropped message.
|
|
304
|
-
// ⚠ `from:`, NEVER `name:`. Pino treats `name` as the LOGGER's name, so a `name`
|
|
305
|
-
// key here is swallowed into the log prefix — the line came out as
|
|
306
|
-
// `ERROR (Sam Okafor/19949)` with the submitter's name where the process name
|
|
307
|
-
// belongs and no `name` field in the body at all. Observed, not theorised.
|
|
308
|
-
req.log.error({ err, from: body.name, email: body.email, topic: body.topic, message: body.message }, 'contact form: delivery FAILED — the message is in this log line and nowhere else');
|
|
309
|
-
return reply.code(502).send({
|
|
310
|
-
error: 'delivery_failed',
|
|
311
|
-
message: 'That did not send. Please try again in a minute.',
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
req.log.info({ topic: body.topic }, 'contact form: delivered');
|
|
315
|
-
return { ok: true };
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
//# sourceMappingURL=contact.js.map
|
package/dist/api/routes/feed.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { getFeed } from '../../db/queries.js';
|
|
2
|
-
import { accountIdOf } from '../plugins/auth.js';
|
|
3
|
-
// The activity Feed: recent events (last 14 days) across the account's repos, newest first,
|
|
4
|
-
// commit pushes excluded. The frontend mirrors these into an append-only IndexedDB store
|
|
5
|
-
// (see lib/feedStore.ts). Account-scoped.
|
|
6
|
-
//
|
|
7
|
-
// ⚠ THIS ROUTE IS DELIBERATELY *NOT* WORKSPACE-SCOPED, and the omission is not an oversight.
|
|
8
|
-
// It is the superseded legacy mirror of `GET /api/activity/feed` and has NO caller left (the only
|
|
9
|
-
// reference anywhere is a stub in the e2e mock server); it was account-wide before workspaces
|
|
10
|
-
// existed, so leaving it account-wide is not a regression, and adding `?workspace=` to a route
|
|
11
|
-
// nothing calls would be untested churn. The five CONTENT routes that DID need the parameter —
|
|
12
|
-
// /api/activity, /api/activity/feed, /api/timeline, /api/open-prs, /api/branch-status — all take
|
|
13
|
-
// it. If this endpoint ever gains a caller, scope it through `resolveWorkspaceScope` like they do,
|
|
14
|
-
// or delete it.
|
|
15
|
-
export async function feedRoutes(app) {
|
|
16
|
-
// Account-wide by default. This used to pass `watchedOnly: true`, which narrowed the feed to
|
|
17
|
-
// repos flagged `inbox_watch`; that column is DELETED — every repo an account has added is now
|
|
18
|
-
// fully live — so there is nothing left to narrow by and the default is the whole account.
|
|
19
|
-
app.get('/api/feed', async (req) => getFeed(accountIdOf(req), { daysBefore: 14 }));
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=feed.js.map
|
package/dist/api/routes/inbox.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { getInbox, getConsolidatedFeed, listClaudeReviewsByRepo } from '../../db/queries.js';
|
|
2
|
-
import { accountIdOf } from '../plugins/auth.js';
|
|
3
|
-
function parseIntList(raw) {
|
|
4
|
-
if (!raw)
|
|
5
|
-
return null;
|
|
6
|
-
const ids = raw
|
|
7
|
-
.split(',')
|
|
8
|
-
.map((s) => Number.parseInt(s.trim(), 10))
|
|
9
|
-
.filter((n) => Number.isFinite(n));
|
|
10
|
-
return ids.length > 0 ? ids : null;
|
|
11
|
-
}
|
|
12
|
-
export async function inboxRoutes(app) {
|
|
13
|
-
// The Inbox aggregate: per repo, current-state stats + thread totals +
|
|
14
|
-
// attention/unread flags + open PRs. Scoped to the account; `repoIds` + `userIds`
|
|
15
|
-
// narrow to the active FilterBar repo + member selection (across ALL the account's
|
|
16
|
-
// repos — watched-only was dropped). Pure DB read — no GitHub sync, no AI.
|
|
17
|
-
app.get('/api/inbox', async (req) => {
|
|
18
|
-
const q = req.query;
|
|
19
|
-
return getInbox(accountIdOf(req), parseIntList(q.repoIds), parseIntList(q.userIds));
|
|
20
|
-
});
|
|
21
|
-
// The consolidated Feed (the Inbox "Feed" entry): one flat, chronological stream
|
|
22
|
-
// merging My Turn actionables + the activity feed, deduped. Scoped by the FilterBar
|
|
23
|
-
// repo + member selection across ALL the account's repos (watched-only dropped).
|
|
24
|
-
// Pure DB read — no GitHub sync, no AI.
|
|
25
|
-
app.get('/api/inbox/feed', async (req) => {
|
|
26
|
-
const q = req.query;
|
|
27
|
-
const limit = q.limit != null ? Number(q.limit) : null;
|
|
28
|
-
const offset = q.offset != null ? Number(q.offset) : 0;
|
|
29
|
-
return getConsolidatedFeed(accountIdOf(req), {
|
|
30
|
-
repoIds: parseIntList(q.repoIds),
|
|
31
|
-
userIds: parseIntList(q.userIds),
|
|
32
|
-
limit: Number.isFinite(limit) && limit != null && limit > 0 ? limit : null,
|
|
33
|
-
offset: Number.isFinite(offset) && offset > 0 ? offset : 0,
|
|
34
|
-
excludeBots: q.excludeBots === 'true',
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
// Repo-scoped Claude-review history for the Inbox single-repo console. Ownership +
|
|
38
|
-
// feature-gating are handled inside the query (an unowned repo / disabled feature
|
|
39
|
-
// both return an empty list), so the caller never leaks another account's data.
|
|
40
|
-
app.get('/api/repos/:id/claude-reviews', async (req) => {
|
|
41
|
-
const { id } = req.params;
|
|
42
|
-
return listClaudeReviewsByRepo(Number.parseInt(id, 10), accountIdOf(req));
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=inbox.js.map
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { getScopeMentionCandidates, resolveWorkspaceScope } from '../../db/queries.js';
|
|
2
|
-
import { accountIdOf } from '../plugins/auth.js';
|
|
3
|
-
// Workspace-wide @mention candidates (CORE) — the scope-wide sibling of
|
|
4
|
-
// GET /api/prs/:id/mention-candidates. Powers the ad-hoc Insights "Ask about the workspace" box,
|
|
5
|
-
// whose questions span the whole selected scope rather than one PR.
|
|
6
|
-
//
|
|
7
|
-
// `?workspace=<id>` is a plain integer; absent / unparseable / another tenant's id all resolve to
|
|
8
|
-
// the account's DEFAULT workspace (never a 404 — every id yields the same response shape, so it is
|
|
9
|
-
// not an existence oracle). `resolveWorkspaceScope` turns it into the workspace's repo ids
|
|
10
|
-
// server-side, so a caller cannot widen it, and an empty workspace yields `[]` → no candidates,
|
|
11
|
-
// rather than the account's whole roster. Self + bots excluded. Returns a bare MentionCandidate[]
|
|
12
|
-
// exactly like the PR route so MentionTextarea can consume it directly — each row carrying
|
|
13
|
-
// `isMaintainer` (has merged a PR in the SCOPE's repos), which the picker sorts and shields on.
|
|
14
|
-
export async function mentionsRoutes(app) {
|
|
15
|
-
app.get('/api/mention-candidates', async (req) => {
|
|
16
|
-
const q = req.query;
|
|
17
|
-
const accountId = accountIdOf(req);
|
|
18
|
-
const scope = await resolveWorkspaceScope(accountId, q.workspace);
|
|
19
|
-
return getScopeMentionCandidates(accountId, scope.repoIds);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=mentions.js.map
|
package/dist/api/routes/teams.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { assignReposToTeam, createTeam, deleteTeam, getTeamRepoIds, listTeams, removeRepoFromTeam, renameTeam, } from '../../db/queries.js';
|
|
2
|
-
import { accountIdOf } from '../plugins/auth.js';
|
|
3
|
-
// Teams (CORE): group an account's repos into named teams. Every handler is accountId-scoped;
|
|
4
|
-
// id-addressed routes verify ownership (→ 404). Assigning a repo to a team auto-Watches it.
|
|
5
|
-
const nameBodySchema = {
|
|
6
|
-
body: {
|
|
7
|
-
type: 'object',
|
|
8
|
-
required: ['name'],
|
|
9
|
-
additionalProperties: false,
|
|
10
|
-
properties: { name: { type: 'string', minLength: 1, maxLength: 120 } },
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
const idParamSchema = {
|
|
14
|
-
params: {
|
|
15
|
-
type: 'object',
|
|
16
|
-
required: ['id'],
|
|
17
|
-
properties: { id: { type: 'integer' } },
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
const patchSchema = {
|
|
21
|
-
...idParamSchema,
|
|
22
|
-
body: {
|
|
23
|
-
type: 'object',
|
|
24
|
-
additionalProperties: false,
|
|
25
|
-
properties: {
|
|
26
|
-
name: { type: 'string', minLength: 1, maxLength: 120 },
|
|
27
|
-
repoIds: { type: 'array', items: { type: 'integer' } },
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
const addRepoSchema = {
|
|
32
|
-
...idParamSchema,
|
|
33
|
-
body: {
|
|
34
|
-
type: 'object',
|
|
35
|
-
required: ['repoId'],
|
|
36
|
-
additionalProperties: false,
|
|
37
|
-
properties: { repoId: { type: 'integer' } },
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
const removeRepoSchema = {
|
|
41
|
-
params: {
|
|
42
|
-
type: 'object',
|
|
43
|
-
required: ['id', 'repoId'],
|
|
44
|
-
properties: { id: { type: 'integer' }, repoId: { type: 'integer' } },
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
export async function teamRoutes(app) {
|
|
48
|
-
// Account-scoped ownership lookup (→ null for a foreign/unknown team).
|
|
49
|
-
const findTeam = async (accountId, id) => (await listTeams(accountId)).find((t) => t.id === id) ?? null;
|
|
50
|
-
app.get('/api/teams', async (req) => ({
|
|
51
|
-
teams: await listTeams(accountIdOf(req)),
|
|
52
|
-
}));
|
|
53
|
-
app.post('/api/teams', { schema: nameBodySchema }, async (req, reply) => {
|
|
54
|
-
const accountId = accountIdOf(req);
|
|
55
|
-
const name = req.body.name.trim();
|
|
56
|
-
if (!name) {
|
|
57
|
-
reply.status(400);
|
|
58
|
-
return { error: 'BadRequest', message: 'Team name must not be empty' };
|
|
59
|
-
}
|
|
60
|
-
const existing = await listTeams(accountId);
|
|
61
|
-
if (existing.some((t) => t.name === name)) {
|
|
62
|
-
reply.status(400);
|
|
63
|
-
return { error: 'BadRequest', message: `A team named "${name}" already exists` };
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
const team = await createTeam(accountId, name);
|
|
67
|
-
reply.status(201);
|
|
68
|
-
return { team };
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
// Unique-constraint fallback (a concurrent create raced us to the same name).
|
|
72
|
-
reply.status(400);
|
|
73
|
-
return { error: 'BadRequest', message: `A team named "${name}" already exists` };
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
// Rename and/or REPLACE membership (set the team's repos to exactly `repoIds`). Ownership → 404.
|
|
77
|
-
app.patch('/api/teams/:id', { schema: patchSchema }, async (req, reply) => {
|
|
78
|
-
const accountId = accountIdOf(req);
|
|
79
|
-
const { id } = req.params;
|
|
80
|
-
const { name, repoIds } = req.body;
|
|
81
|
-
if (!(await findTeam(accountId, id))) {
|
|
82
|
-
reply.status(404);
|
|
83
|
-
return { error: 'NotFound', message: `Team ${id} not found` };
|
|
84
|
-
}
|
|
85
|
-
if (name !== undefined) {
|
|
86
|
-
const trimmed = name.trim();
|
|
87
|
-
if (!trimmed) {
|
|
88
|
-
reply.status(400);
|
|
89
|
-
return { error: 'BadRequest', message: 'Team name must not be empty' };
|
|
90
|
-
}
|
|
91
|
-
// Reject a rename that collides with another team's name.
|
|
92
|
-
const others = (await listTeams(accountId)).filter((t) => t.id !== id);
|
|
93
|
-
if (others.some((t) => t.name === trimmed)) {
|
|
94
|
-
reply.status(400);
|
|
95
|
-
return { error: 'BadRequest', message: `A team named "${trimmed}" already exists` };
|
|
96
|
-
}
|
|
97
|
-
await renameTeam(id, accountId, trimmed);
|
|
98
|
-
}
|
|
99
|
-
if (repoIds !== undefined) {
|
|
100
|
-
// Diff current membership → target: assign the new ones (auto-watch), remove the missing.
|
|
101
|
-
const current = await getTeamRepoIds(id, accountId);
|
|
102
|
-
const target = new Set(repoIds);
|
|
103
|
-
const toAdd = repoIds.filter((r) => !current.includes(r));
|
|
104
|
-
const toRemove = current.filter((r) => !target.has(r));
|
|
105
|
-
if (toAdd.length > 0)
|
|
106
|
-
await assignReposToTeam(id, accountId, toAdd);
|
|
107
|
-
for (const repoId of toRemove)
|
|
108
|
-
await removeRepoFromTeam(id, repoId, accountId);
|
|
109
|
-
}
|
|
110
|
-
const team = await findTeam(accountId, id);
|
|
111
|
-
return { team };
|
|
112
|
-
});
|
|
113
|
-
app.delete('/api/teams/:id', { schema: idParamSchema }, async (req, reply) => {
|
|
114
|
-
const accountId = accountIdOf(req);
|
|
115
|
-
const { id } = req.params;
|
|
116
|
-
const ok = await deleteTeam(id, accountId);
|
|
117
|
-
if (!ok) {
|
|
118
|
-
reply.status(404);
|
|
119
|
-
return { error: 'NotFound', message: `Team ${id} not found` };
|
|
120
|
-
}
|
|
121
|
-
reply.status(204);
|
|
122
|
-
return null;
|
|
123
|
-
});
|
|
124
|
-
// Assign ONE repo to a team (auto-watch). Ownership → 404.
|
|
125
|
-
app.post('/api/teams/:id/repos', { schema: addRepoSchema }, async (req, reply) => {
|
|
126
|
-
const accountId = accountIdOf(req);
|
|
127
|
-
const { id } = req.params;
|
|
128
|
-
const { repoId } = req.body;
|
|
129
|
-
if (!(await findTeam(accountId, id))) {
|
|
130
|
-
reply.status(404);
|
|
131
|
-
return { error: 'NotFound', message: `Team ${id} not found` };
|
|
132
|
-
}
|
|
133
|
-
await assignReposToTeam(id, accountId, [repoId]);
|
|
134
|
-
const team = await findTeam(accountId, id);
|
|
135
|
-
return { team };
|
|
136
|
-
});
|
|
137
|
-
// Unassign ONE repo from a team. Ownership → 404; idempotent (unassigning a non-member 204s).
|
|
138
|
-
app.delete('/api/teams/:id/repos/:repoId', { schema: removeRepoSchema }, async (req, reply) => {
|
|
139
|
-
const accountId = accountIdOf(req);
|
|
140
|
-
const { id, repoId } = req.params;
|
|
141
|
-
if (!(await findTeam(accountId, id))) {
|
|
142
|
-
reply.status(404);
|
|
143
|
-
return { error: 'NotFound', message: `Team ${id} not found` };
|
|
144
|
-
}
|
|
145
|
-
await removeRepoFromTeam(id, repoId, accountId);
|
|
146
|
-
reply.status(204);
|
|
147
|
-
return null;
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
//# sourceMappingURL=teams.js.map
|