@localpulse/cli 0.0.5 → 0.0.7

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localpulse/cli",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Local Pulse CLI — ingest event posters, search events, manage credentials",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/index.test.ts CHANGED
@@ -153,20 +153,88 @@ describe("localpulse", () => {
153
153
  const { exitCode, stdout } = runCli("ingest", "../../README.md", "--research", researchFile, "--dry-run");
154
154
  expect(exitCode).toBe(0);
155
155
  expect(stdout).toContain("Dry run passed");
156
+ expect(stdout).toContain("Title: Test Night");
157
+ expect(stdout).toContain("Date: 2026-03-14T22:00:00+01:00");
158
+ expect(stdout).toContain("Venue: Shelter (Amsterdam) [ChIJ123]");
159
+ expect(stdout).toContain("Featured: 1");
160
+ expect(stdout).toContain("DJ Nobu — 1 socials, ");
161
+ expect(stdout).toContain("Organizer: Dekmantel");
162
+ expect(stdout).toContain("URLs: 2 source(s)");
163
+ expect(stdout).toContain("Ticket: https://tickets.example.com");
164
+ expect(stdout).toContain("Audit: passed (0 issues)");
156
165
  });
157
166
 
158
- it("rejects thin research payload with audit findings", async () => {
167
+ it("includes parsed fields in --dry-run --json output", async () => {
168
+ const researchFile = join(tmpdir(), `lp-test-${Date.now()}.json`);
169
+ await writeFile(researchFile, JSON.stringify({
170
+ featured: [
171
+ { name: "DJ Nobu", type: "DJ", socials: ["https://instagram.com/djnobu"], context: "Berlin-based" },
172
+ { name: "Nene H", type: "DJ", socials: ["https://instagram.com/neneh"], context: "Tehran-born" },
173
+ ],
174
+ organizer: { name: "Dekmantel", socials: ["https://instagram.com/dekmantel"] },
175
+ venue: { name: "Shelter", city: "Amsterdam", google_place_id: "ChIJ123" },
176
+ event: {
177
+ title: "Test Night",
178
+ date: "2026-03-14T22:00:00+01:00",
179
+ type: "club night",
180
+ urls: ["https://ra.co/events/123", "https://example.com/event"],
181
+ ticket_url: "https://tickets.example.com",
182
+ },
183
+ }));
184
+
185
+ const { exitCode, stdout } = runCli("ingest", "../../README.md", "--research", researchFile, "--dry-run", "--json");
186
+ expect(exitCode).toBe(0);
187
+ const result = JSON.parse(stdout);
188
+ expect(result.dry_run).toBe(true);
189
+ expect(result.valid).toBe(true);
190
+ expect(result.parsed.title).toBe("Test Night");
191
+ expect(result.parsed.datetime).toBe("2026-03-14T22:00:00+01:00");
192
+ expect(result.parsed.venue).toBe("Shelter");
193
+ expect(result.parsed.city).toBe("Amsterdam");
194
+ expect(result.parsed.venue_place_id).toBe("ChIJ123");
195
+ expect(result.parsed.featured_count).toBe(2);
196
+ expect(result.parsed.featured[0].name).toBe("DJ Nobu");
197
+ expect(result.parsed.featured[0].socials_count).toBe(1);
198
+ expect(result.parsed.featured[1].name).toBe("Nene H");
199
+ expect(result.parsed.featured[1].socials_count).toBe(1);
200
+ expect(result.parsed.organizer).toBe("Dekmantel");
201
+ expect(result.parsed.urls_count).toBe(2);
202
+ expect(result.parsed.ticket_url).toBe("https://tickets.example.com");
203
+ expect(result.audit.pass).toBe(true);
204
+ expect(result.audit.issues).toBe(0);
205
+ });
206
+
207
+ it("shows required annotations in ingest help", () => {
208
+ const { exitCode, stdout } = runCli("ingest", "--help");
209
+ expect(exitCode).toBe(0);
210
+ expect(stdout).toContain("Who is featured (required, at least one)");
211
+ expect(stdout).toContain("Their role (required per person)");
212
+ expect(stdout).toContain("Profile URLs (required per person)");
213
+ expect(stdout).toContain("Bio and background (required per person)");
214
+ expect(stdout).toContain("Venue name (required)");
215
+ expect(stdout).toContain("City name (required)");
216
+ expect(stdout).toContain("Google Places ID (required)");
217
+ expect(stdout).toContain("Event name (required)");
218
+ expect(stdout).toContain("ISO 8601 datetime (required)");
219
+ expect(stdout).toContain("Kind of event (required)");
220
+ expect(stdout).toContain("Scrapeable source pages (required, 1+)");
221
+ expect(stdout).toContain('required unless price is "Free"');
222
+ });
223
+
224
+ it("rejects thin research payload with audit findings in dry-run", async () => {
159
225
  const researchFile = join(tmpdir(), `lp-test-${Date.now()}.json`);
160
226
  await writeFile(researchFile, JSON.stringify({
161
227
  featured: [],
162
228
  event: { title: "Test" },
163
229
  }));
164
230
 
165
- const { exitCode, stderr } = runCli("ingest", "../../README.md", "--research", researchFile, "--dry-run");
231
+ const { exitCode, stdout } = runCli("ingest", "../../README.md", "--research", researchFile, "--dry-run");
166
232
  expect(exitCode).toBe(1);
167
- expect(stderr).toContain("audit failed");
168
- expect(stderr).toContain("featured");
169
- expect(stderr).toContain("Fix these issues");
233
+ expect(stdout).toContain("Dry run failed");
234
+ expect(stdout).toContain("Title: Test");
235
+ expect(stdout).toContain("audit failed");
236
+ expect(stdout).toContain("featured");
237
+ expect(stdout).toContain("Fix these issues");
170
238
  });
171
239
 
172
240
  it("outputs structured audit findings with --json", async () => {
package/src/index.ts CHANGED
@@ -5,9 +5,9 @@ import { stdin, stdout } from "node:process";
5
5
  import { hasOption, parseArgv, readNumberOption, readStringArrayOption, readStringOption } from "./lib/argv";
6
6
  import { requireToken } from "./lib/auth";
7
7
  import { toFrontendBaseUrl } from "./lib/api-url";
8
- import { fetchDrafts, searchCliEvents } from "./lib/cli-read-client";
8
+ import { fetchDrafts, fetchEditable, patchEntity, patchEvent, searchCliEvents } from "./lib/cli-read-client";
9
9
  import { DRAFT_STATUSES } from "./lib/cli-read-types";
10
- import type { DraftListItem, DraftStatus, SearchEventCard } from "./lib/cli-read-types";
10
+ import type { DraftListItem, DraftStatus, EditableEntity, EditableResult, SearchEventCard } from "./lib/cli-read-types";
11
11
  import {
12
12
  deleteCredentials,
13
13
  getCredentialsPath,
@@ -17,7 +17,7 @@ import {
17
17
  } from "./lib/credentials";
18
18
  import { loginWithToken } from "./lib/login";
19
19
  import { exitCodeForError, printError } from "./lib/output";
20
- import { auditResearchPayload, formatAuditFindings } from "./lib/research-audit";
20
+ import { type AuditResult, auditResearchPayload, formatAuditFindings } from "./lib/research-audit";
21
21
  import { readResearchPayload } from "./lib/research-reader";
22
22
  import {
23
23
  generateResearchSkeleton,
@@ -25,8 +25,10 @@ import {
25
25
  stitchResearchContext,
26
26
  } from "./lib/research-schema";
27
27
  import { isLikelyCliToken } from "./lib/token";
28
+ import type { ResearchPayload } from "./lib/research-schema";
28
29
  import {
29
30
  type UploadPosterResult,
31
+ type UploadDryRunResult,
30
32
  type DraftResult,
31
33
  uploadPoster,
32
34
  createDraft,
@@ -66,6 +68,9 @@ async function main(argv: string[]): Promise<void> {
66
68
  case "drafts":
67
69
  await runDrafts(parsed);
68
70
  break;
71
+ case "edit":
72
+ await runEdit(parsed);
73
+ break;
69
74
  default:
70
75
  throw new Error(`Unknown command: ${command}. Run \`localpulse --help\` for usage.`);
71
76
  }
@@ -191,8 +196,38 @@ async function runIngest(parsed: ReturnType<typeof parseArgv>): Promise<void> {
191
196
 
192
197
  const payload = await readResearchPayload(researchPath);
193
198
  const jsonOutput = hasOption(parsed, "json");
199
+ const dryRun = hasOption(parsed, "dry-run");
200
+
201
+ const mapped = mapResearchToUploadFields(payload);
202
+ const uploadFields = {
203
+ urls: readStringArrayOption(parsed, "urls") ?? mapped.urls,
204
+ city: readStringOption(parsed, "city") ?? mapped.city,
205
+ venuePlaceId: readStringOption(parsed, "google-place-id") ?? mapped.venuePlaceId,
206
+ ticketUrl: readStringOption(parsed, "ticket-url") ?? mapped.ticketUrl,
207
+ title: readStringOption(parsed, "title") ?? mapped.title,
208
+ datetime: readStringOption(parsed, "date") ?? mapped.datetime,
209
+ venue: readStringOption(parsed, "venue") ?? mapped.venue,
210
+ };
194
211
 
195
212
  const audit = auditResearchPayload(payload);
213
+
214
+ if (dryRun) {
215
+ const result = {
216
+ dry_run: true as const,
217
+ valid: true as const,
218
+ file,
219
+ extra_media_count: readStringArrayOption(parsed, "extra-media")?.length ?? 0,
220
+ api_url: (await resolveApiUrl()),
221
+ };
222
+ if (jsonOutput) {
223
+ stdout.write(`${JSON.stringify(buildDryRunJsonResult(payload, uploadFields, result, audit))}\n`);
224
+ } else {
225
+ stdout.write(formatDryRunSummary(payload, uploadFields, result, audit));
226
+ }
227
+ if (!audit.pass) process.exitCode = 1;
228
+ return;
229
+ }
230
+
196
231
  if (!audit.pass) {
197
232
  if (jsonOutput) {
198
233
  stdout.write(`${JSON.stringify({ audit_failed: true, findings: audit.findings })}\n`);
@@ -203,42 +238,21 @@ async function runIngest(parsed: ReturnType<typeof parseArgv>): Promise<void> {
203
238
  return;
204
239
  }
205
240
 
206
- const mapped = mapResearchToUploadFields(payload);
207
241
  const stitched = stitchResearchContext(payload);
208
242
  const explicitContext = readStringOption(parsed, "context");
209
243
  const context = [stitched, explicitContext].filter(Boolean).join("\n\n") || undefined;
210
244
 
211
245
  const apiUrl = await resolveApiUrl();
212
- const dryRun = hasOption(parsed, "dry-run");
213
246
  const force = hasOption(parsed, "force");
214
- const token = dryRun ? "" : await requireToken();
247
+ const token = await requireToken();
215
248
 
216
249
  const uploadOptions = {
217
250
  file,
218
- urls: readStringArrayOption(parsed, "urls") ?? mapped.urls,
219
- city: readStringOption(parsed, "city") ?? mapped.city,
220
- venuePlaceId: readStringOption(parsed, "google-place-id") ?? mapped.venuePlaceId,
251
+ ...uploadFields,
221
252
  context,
222
- ticketUrl: readStringOption(parsed, "ticket-url") ?? mapped.ticketUrl,
223
- title: readStringOption(parsed, "title") ?? mapped.title,
224
- datetime: readStringOption(parsed, "date") ?? mapped.datetime,
225
- venue: readStringOption(parsed, "venue") ?? mapped.venue,
226
253
  extraMedia: readStringArrayOption(parsed, "extra-media"),
227
- dryRun,
228
254
  };
229
255
 
230
- if (dryRun) {
231
- const result = await uploadPoster(apiUrl, token, uploadOptions);
232
- if ("dry_run" in result) {
233
- if (jsonOutput) {
234
- stdout.write(`${JSON.stringify(result)}\n`);
235
- } else {
236
- stdout.write(`Dry run passed: ${result.file} (${result.extra_media_count} extra media)\n`);
237
- }
238
- }
239
- return;
240
- }
241
-
242
256
  if (force) {
243
257
  const result = await uploadPoster(apiUrl, token, uploadOptions);
244
258
  if (!("dry_run" in result)) {
@@ -309,6 +323,100 @@ function printIngestResult(result: UploadPosterResult): void {
309
323
  }
310
324
  }
311
325
 
326
+ type DryRunUploadOptions = {
327
+ title?: string;
328
+ datetime?: string;
329
+ venue?: string;
330
+ city?: string;
331
+ venuePlaceId?: string;
332
+ urls?: string[];
333
+ ticketUrl?: string;
334
+ };
335
+
336
+ function formatDryRunSummary(
337
+ payload: ResearchPayload,
338
+ opts: DryRunUploadOptions,
339
+ result: UploadDryRunResult,
340
+ audit: AuditResult,
341
+ ): string {
342
+ const header = audit.pass
343
+ ? `Dry run passed: ${result.file} (${result.extra_media_count} extra media)`
344
+ : `Dry run failed: ${result.file} (${audit.findings.length} issue${audit.findings.length === 1 ? "" : "s"})`;
345
+
346
+ const lines: string[] = [header];
347
+
348
+ if (opts.title) lines.push(` Title: ${opts.title}`);
349
+ if (opts.datetime) lines.push(` Date: ${opts.datetime}`);
350
+
351
+ if (opts.venue) {
352
+ let venueStr = opts.venue;
353
+ if (opts.city) venueStr += ` (${opts.city})`;
354
+ if (opts.venuePlaceId) venueStr += ` [${opts.venuePlaceId}]`;
355
+ lines.push(` Venue: ${venueStr}`);
356
+ }
357
+
358
+ if (payload.featured?.length) {
359
+ lines.push(` Featured: ${payload.featured.length}`);
360
+ for (const p of payload.featured) {
361
+ const socialsCount = p.socials?.length ?? 0;
362
+ const contextWords = p.context?.trim().split(/\s+/).length ?? 0;
363
+ lines.push(` ${p.name} — ${socialsCount} socials, ${contextWords}w context`);
364
+ }
365
+ }
366
+
367
+ if (payload.organizer?.name) {
368
+ lines.push(` Organizer: ${payload.organizer.name}`);
369
+ }
370
+
371
+ if (opts.urls?.length) {
372
+ lines.push(` URLs: ${opts.urls.length} source(s)`);
373
+ }
374
+
375
+ if (opts.ticketUrl) lines.push(` Ticket: ${opts.ticketUrl}`);
376
+
377
+ if (audit.pass) {
378
+ lines.push(" Audit: passed (0 issues)");
379
+ } else {
380
+ lines.push("");
381
+ lines.push(formatAuditFindings(audit.findings));
382
+ }
383
+
384
+ lines.push("");
385
+ return lines.join("\n");
386
+ }
387
+
388
+ function buildDryRunJsonResult(
389
+ payload: ResearchPayload,
390
+ opts: DryRunUploadOptions,
391
+ result: UploadDryRunResult,
392
+ audit: AuditResult,
393
+ ): Record<string, unknown> {
394
+ return {
395
+ ...result,
396
+ parsed: {
397
+ title: opts.title ?? null,
398
+ datetime: opts.datetime ?? null,
399
+ venue: opts.venue ?? null,
400
+ city: opts.city ?? null,
401
+ venue_place_id: opts.venuePlaceId ?? null,
402
+ featured_count: payload.featured?.length ?? 0,
403
+ featured: payload.featured?.map((p) => ({
404
+ name: p.name,
405
+ socials_count: p.socials?.length ?? 0,
406
+ context_words: p.context?.trim().split(/\s+/).length ?? 0,
407
+ })) ?? [],
408
+ organizer: payload.organizer?.name ?? null,
409
+ urls_count: opts.urls?.length ?? 0,
410
+ ticket_url: opts.ticketUrl ?? null,
411
+ },
412
+ audit: {
413
+ pass: audit.pass,
414
+ issues: audit.findings.length,
415
+ ...(audit.findings.length ? { findings: audit.findings } : {}),
416
+ },
417
+ };
418
+ }
419
+
312
420
  async function runSearch(parsed: ReturnType<typeof parseArgv>): Promise<void> {
313
421
  if (hasOption(parsed, "help")) {
314
422
  stdout.write(searchHelp());
@@ -425,6 +533,143 @@ function printDraftListItem(draft: DraftListItem, baseUrl: string): void {
425
533
  stdout.write(` ${baseUrl}/publish/edit/${draft.id}\n`);
426
534
  }
427
535
 
536
+ // ---------------------------------------------------------------------------
537
+ // edit command
538
+ // ---------------------------------------------------------------------------
539
+
540
+ async function runEdit(parsed: ReturnType<typeof parseArgv>): Promise<void> {
541
+ if (hasOption(parsed, "help")) {
542
+ stdout.write(editHelp());
543
+ return;
544
+ }
545
+
546
+ const subcommand = parsed.positionals[0];
547
+
548
+ if (!subcommand) {
549
+ throw new Error("Usage: localpulse edit <poster_id> [options]. Run `localpulse edit --help` for details.");
550
+ }
551
+
552
+ const jsonOutput = hasOption(parsed, "json");
553
+ const apiUrl = await resolveApiUrl();
554
+ const token = await requireToken();
555
+ const posterId = subcommand;
556
+
557
+ // If --set is present, this is an update; otherwise show editable fields
558
+ const setValues = readStringArrayOption(parsed, "set");
559
+ const entityId = readStringOption(parsed, "entity");
560
+
561
+ if (setValues && setValues.length > 0) {
562
+ const fields = parseSetFlags(setValues);
563
+
564
+ if (entityId) {
565
+ const result = await patchEntity(apiUrl, token, posterId, entityId, fields);
566
+ if (jsonOutput) {
567
+ stdout.write(`${JSON.stringify(result, null, 2)}\n`);
568
+ } else {
569
+ stdout.write(`Entity ${entityId} updated.\n`);
570
+ }
571
+ } else {
572
+ const result = await patchEvent(apiUrl, token, posterId, fields);
573
+ if (jsonOutput) {
574
+ stdout.write(`${JSON.stringify(result, null, 2)}\n`);
575
+ } else {
576
+ stdout.write("Event updated.\n");
577
+ }
578
+ }
579
+ return;
580
+ }
581
+
582
+ // Default: show editable fields
583
+ const editable = await fetchEditable(apiUrl, token, posterId);
584
+ if (jsonOutput) {
585
+ stdout.write(`${JSON.stringify(editable, null, 2)}\n`);
586
+ return;
587
+ }
588
+ printEditable(editable);
589
+ }
590
+
591
+ function parseSetFlags(pairs: string[]): Record<string, unknown> {
592
+ const fields: Record<string, unknown> = {};
593
+ for (const pair of pairs) {
594
+ const eqIdx = pair.indexOf("=");
595
+ if (eqIdx === -1) {
596
+ throw new Error(`Invalid --set format: "${pair}". Expected key=value (e.g. --set title="New Title").`);
597
+ }
598
+ const key = pair.slice(0, eqIdx).trim();
599
+ const rawValue = pair.slice(eqIdx + 1);
600
+ if (!key) {
601
+ throw new Error(`Empty key in --set: "${pair}".`);
602
+ }
603
+ fields[key] = parseFieldValue(rawValue);
604
+ }
605
+ return fields;
606
+ }
607
+
608
+ function parseFieldValue(raw: string): unknown {
609
+ // Boolean
610
+ if (raw === "true") return true;
611
+ if (raw === "false") return false;
612
+ // Null
613
+ if (raw === "null") return null;
614
+ // JSON array or object
615
+ if ((raw.startsWith("[") && raw.endsWith("]")) || (raw.startsWith("{") && raw.endsWith("}"))) {
616
+ try { return JSON.parse(raw); } catch { /* fall through to string */ }
617
+ }
618
+ // String (default)
619
+ return raw;
620
+ }
621
+
622
+ function printEditable(editable: EditableResult): void {
623
+ const { event, entities, media } = editable;
624
+
625
+ stdout.write(`Event: ${event.title ?? "(no title)"}\n`);
626
+ stdout.write(`Poster: ${editable.poster_id}\n\n`);
627
+
628
+ stdout.write("Event fields:\n");
629
+ const fieldOrder: (keyof typeof event)[] = [
630
+ "title", "description", "event_datetime", "event_datetimes",
631
+ "location", "venue_city", "ticketing_url", "pricing",
632
+ "is_cancelled", "is_sold_out", "is_postponed",
633
+ "event_type", "overall_theme",
634
+ "atmosphere_tags", "genre_tags", "vibe_tags", "type_tags",
635
+ "lineup_text", "description_paragraphs", "embed_urls",
636
+ ];
637
+ for (const key of fieldOrder) {
638
+ const value = event[key];
639
+ if (value === null || value === undefined) continue;
640
+ const display = Array.isArray(value) ? JSON.stringify(value) :
641
+ typeof value === "object" ? JSON.stringify(value) : String(value);
642
+ // Truncate long values for readability
643
+ const truncated = display.length > 120 ? `${display.slice(0, 117)}...` : display;
644
+ stdout.write(` ${key}: ${truncated}\n`);
645
+ }
646
+
647
+ if (entities.length > 0) {
648
+ stdout.write("\nEntities:\n");
649
+ for (const entity of entities) {
650
+ const role = entity.event_role ? ` (${entity.event_role})` : "";
651
+ stdout.write(` ${entity.entity_id} ${entity.name}${role} [${entity.entity_type}]\n`);
652
+ }
653
+ }
654
+
655
+ if (media.length > 0) {
656
+ stdout.write("\nMedia:\n");
657
+ for (const item of media) {
658
+ const primary = item.is_primary ? " [primary]" : "";
659
+ stdout.write(` ${item.id} ${item.media_type}${primary}\n`);
660
+ }
661
+ }
662
+
663
+ stdout.write("\nTo update, use --set:\n");
664
+ stdout.write(` localpulse edit ${editable.poster_id} --set title="New Title"\n`);
665
+ stdout.write(` localpulse edit ${editable.poster_id} --set is_sold_out=true\n`);
666
+ stdout.write(` localpulse edit ${editable.poster_id} --set 'genre_tags=["techno","house"]'\n`);
667
+ if (entities.length > 0) {
668
+ const first = entities[0];
669
+ stdout.write(` localpulse edit ${editable.poster_id} --entity ${first.entity_id} --set event_role="headliner"\n`);
670
+ }
671
+ }
672
+
428
673
  async function resolveLoginToken(explicitToken?: string): Promise<string> {
429
674
  if (explicitToken?.trim()) {
430
675
  return explicitToken.trim();
@@ -469,6 +714,7 @@ Commands:
469
714
  ingest Ingest an event poster into Local Pulse
470
715
  search Search upcoming events
471
716
  drafts List your submission drafts
717
+ edit View and update published event fields
472
718
  auth Login and logout
473
719
 
474
720
  Options:
@@ -484,6 +730,8 @@ Quick start:
484
730
  localpulse auth login --token <token>
485
731
  localpulse search "amsterdam"
486
732
  localpulse ingest poster.jpg --research data.json
733
+ localpulse edit <poster_id>
734
+ localpulse edit <poster_id> --set title="New Title"
487
735
  `;
488
736
  }
489
737
 
@@ -548,8 +796,9 @@ Research payload:
548
796
  2. Browse their recent posts or Reels for the event announcement.
549
797
  3. Check who is tagged in that post — these are verified performer handles.
550
798
  4. Also check the caption for @mentions, #hashtags, and links.
551
- 5. Visit each tagged profile: their bio contains verified links (website,
552
- Spotify, Bandcamp, YouTube) and genre/context info for featured[].context.
799
+ 5. OPEN each tagged profile in the browser. Extract every link from their bio
800
+ (website, Spotify, Bandcamp, YouTube, SoundCloud). This is how you populate
801
+ featured[].socials[] and featured[].context. Do NOT just find the URL — visit it.
553
802
  6. Check the venue's Tagged tab for posts where others tag the venue —
554
803
  artists promoting the event often tag the venue and each other.
555
804
 
@@ -562,7 +811,9 @@ Research payload:
562
811
  should appear in featured[] with a type that fits (chef, DJ, host…).
563
812
 
564
813
  Quality checklist (aim to fill as many as possible):
565
- ✓ Featured person socials: Instagram (verified via tags), website, Spotify, Bandcamp, RA
814
+ ✓ Featured person socials: Instagram (verified via tags), website, and:
815
+ - Musicians/DJs: Spotify, Bandcamp, SoundCloud, RA
816
+ - Other types (chefs, hosts, speakers): personal website is usually enough
566
817
  ✓ Featured person context: pull from Instagram bio — genre, notable work, links
567
818
  ✓ Organizer socials: Instagram, website, RA promoter page
568
819
  ✓ Venue google_place_id (search Google Maps → share → extract place ID)
@@ -571,34 +822,41 @@ Research payload:
571
822
  ✓ All featured people as separate entries (support acts, guest chefs, co-hosts)
572
823
  ✓ Discover unlisted performers via Instagram tags (support acts, guest hosts)
573
824
 
574
- featured[] Who is featured — performers, chefs, hosts, speakers
825
+ featured[] Who is featured (required, at least one)
575
826
  .name Full name (required per person)
576
- .type Their role: "DJ", "chef", "band", "host", "speaker",
577
- "visual artist", "cook"
827
+ .type Their role (required per person): "DJ", "chef", "band",
828
+ "host", "speaker", "visual artist", "cook"
578
829
  .genre Style, genre, or cuisine: "techno", "jazz", "Kerala"
579
- .socials[] Profile URLs: Instagram, RA, Bandcamp, personal site
580
- .context Anything else: bio, notable work, affiliations
830
+ .socials[] Profile URLs (required per person): Instagram, RA,
831
+ Bandcamp, personal site
832
+ .context Bio and background (required per person): notable work,
833
+ affiliations, links from their profiles
581
834
 
582
835
  organizer Who is putting on the event
583
836
  .name Collective, promoter, or brand name (required)
584
- .socials[] Profile URLs
837
+ .socials[] Profile URLs (required)
585
838
  .context History, reputation, previous events, affiliation
586
839
 
587
840
  venue Where the event happens
588
- .name Venue name
589
- .city City name
590
- .google_place_id Google Places ID (skips venue matching if provided)
841
+ .name Venue name (required)
842
+ .city City name (required)
843
+ .google_place_id Google Places ID (required); search Google Maps for
844
+ "{venue} {city}" and extract place ID from share URL
591
845
  .context Capacity, room layout, vibe, accessibility, location tips
592
846
 
593
847
  event What the event is
594
- .title Event name
595
- .date ISO 8601 datetime (e.g. "2026-03-14T22:00:00+01:00")
596
- .type Kind of event: "club night", "festival", "exhibition",
597
- "workshop", "concert", "open air", "listening session",
598
- "pop-up dinner", "food event", "tasting", "market"
848
+ .title Event name (required)
849
+ .date ISO 8601 datetime (required), e.g. "2026-03-14T22:00:00+01:00"
850
+ .type Kind of event (required): "club night", "festival",
851
+ "exhibition", "workshop", "concert", "open air",
852
+ "listening session", "pop-up dinner", "food event",
853
+ "tasting", "market"
599
854
  .price Ticket price info: "€15-25", "Free", "Sold out"
600
- .urls[] Source pages: RA, venue site, Facebook event
601
- .ticket_url Direct ticketing / purchase URL
855
+ .urls[] Scrapeable source pages (required, 1+): venue page, artist
856
+ site, event listing. These get scraped for enrichment —
857
+ use publicly accessible, content-rich pages. NOT ticket URLs.
858
+ .ticket_url Ticketing/purchase URL only (required unless price is "Free");
859
+ do NOT duplicate in event.urls
602
860
  .context Schedule, door policy, age restrictions, special notes
603
861
 
604
862
  context Anything that doesn't fit above: background on the
@@ -664,6 +922,69 @@ Examples:
664
922
  `;
665
923
  }
666
924
 
925
+ function editHelp(): string {
926
+ return `Usage: localpulse edit <poster_id> [options]
927
+
928
+ View and update published event fields. Without --set, prints the current
929
+ editable values. With --set, applies partial updates to the event or entity.
930
+
931
+ Arguments:
932
+ poster_id Poster UUID of the published event
933
+
934
+ View current fields:
935
+ localpulse edit <poster_id> Show all editable fields
936
+ localpulse edit <poster_id> --json Output as structured JSON
937
+
938
+ Update event fields:
939
+ --set key=value Set a field (repeatable for multiple fields)
940
+ --json Output full updated event detail as JSON
941
+
942
+ Values are auto-parsed: true/false → boolean, null → null,
943
+ JSON arrays/objects → parsed, everything else → string.
944
+
945
+ Update entity fields:
946
+ --entity <entity_id> Target a specific entity (performer/venue)
947
+ --set key=value Set entity field (description, event_role, social_media)
948
+
949
+ Options:
950
+ --json Output structured JSON
951
+ --help Show this help
952
+
953
+ Event fields:
954
+ title, description, event_datetime, event_datetimes, location,
955
+ ticketing_url, pricing, is_cancelled, is_sold_out, is_postponed,
956
+ atmosphere_tags, genre_tags, vibe_tags, type_tags, event_type,
957
+ overall_theme, venue_city, lineup_text, embed_urls,
958
+ description_paragraphs
959
+
960
+ Entity fields:
961
+ description, event_role, social_media
962
+
963
+ Examples:
964
+ # View editable fields
965
+ localpulse edit abc-123
966
+
967
+ # Update event title
968
+ localpulse edit abc-123 --set title="Updated Event Name"
969
+
970
+ # Mark as sold out
971
+ localpulse edit abc-123 --set is_sold_out=true
972
+
973
+ # Update multiple fields
974
+ localpulse edit abc-123 --set title="New Name" --set is_cancelled=false
975
+
976
+ # Set genre tags (JSON array)
977
+ localpulse edit abc-123 --set 'genre_tags=["techno","house"]'
978
+
979
+ # Update entity
980
+ localpulse edit abc-123 --entity 42 --set event_role="headliner"
981
+
982
+ # JSON output for programmatic use
983
+ localpulse edit abc-123 --json
984
+ localpulse edit abc-123 --set title="X" --json
985
+ `;
986
+ }
987
+
667
988
  function draftsHelp(): string {
668
989
  return `Usage: localpulse drafts [options]
669
990
 
@@ -9,6 +9,7 @@ import type {
9
9
  CliInfoResult,
10
10
  DraftListItem,
11
11
  DraftStatus,
12
+ EditableResult,
12
13
  SearchEventsResult,
13
14
  } from "./cli-read-types";
14
15
 
@@ -122,6 +123,78 @@ export async function fetchDrafts(
122
123
  return parsed as DraftListItem[];
123
124
  }
124
125
 
126
+ export async function fetchEditable(
127
+ apiUrl: string,
128
+ token: string,
129
+ posterId: string,
130
+ ): Promise<EditableResult> {
131
+ const payload = await authedJson(
132
+ apiUrl, token, "GET",
133
+ `/api/cli/events/${encodeURIComponent(posterId)}/editable`,
134
+ "Fetch editable failed",
135
+ );
136
+ return payload as unknown as EditableResult;
137
+ }
138
+
139
+ export async function patchEvent(
140
+ apiUrl: string,
141
+ token: string,
142
+ posterId: string,
143
+ fields: Record<string, unknown>,
144
+ ): Promise<ApiResponseBody> {
145
+ return authedJson(
146
+ apiUrl, token, "PATCH",
147
+ `/api/events/${encodeURIComponent(posterId)}`,
148
+ "Patch event failed",
149
+ fields,
150
+ );
151
+ }
152
+
153
+ export async function patchEntity(
154
+ apiUrl: string,
155
+ token: string,
156
+ posterId: string,
157
+ entityId: string,
158
+ fields: Record<string, unknown>,
159
+ ): Promise<ApiResponseBody> {
160
+ return authedJson(
161
+ apiUrl, token, "PATCH",
162
+ `/api/poster/${encodeURIComponent(posterId)}/entity/${encodeURIComponent(entityId)}`,
163
+ "Patch entity failed",
164
+ fields,
165
+ );
166
+ }
167
+
168
+ async function authedJson(
169
+ apiUrl: string,
170
+ token: string,
171
+ method: string,
172
+ path: string,
173
+ fallbackMessage: string,
174
+ body?: Record<string, unknown>,
175
+ ): Promise<ApiResponseBody> {
176
+ const headers: Record<string, string> = {
177
+ accept: "application/json",
178
+ authorization: `Bearer ${token}`,
179
+ };
180
+ if (body) headers["content-type"] = "application/json";
181
+
182
+ const response = await fetch(buildApiUrl(apiUrl, path), {
183
+ method,
184
+ headers,
185
+ body: body ? JSON.stringify(body) : undefined,
186
+ });
187
+
188
+ const payload = await parseApiJsonBody(response);
189
+ if (!response.ok) {
190
+ throw new CliApiError(
191
+ extractApiErrorMessage(payload, `${fallbackMessage} (${response.status})`),
192
+ { httpStatus: response.status, body: payload },
193
+ );
194
+ }
195
+ return payload;
196
+ }
197
+
125
198
  function parseSearchEventsResult(payload: ApiResponseBody): SearchEventsResult {
126
199
  const result = payload as Partial<SearchEventsResult>;
127
200
  if (
@@ -37,3 +37,57 @@ export type DraftListItem = {
37
37
  created_at: string;
38
38
  updated_at: string;
39
39
  };
40
+
41
+ // ---------------------------------------------------------------------------
42
+ // Edit types
43
+ // ---------------------------------------------------------------------------
44
+
45
+ export type EditableEventFields = {
46
+ title: string | null;
47
+ description: string | null;
48
+ event_datetime: string | null;
49
+ event_datetimes: string[] | null;
50
+ location: string | null;
51
+ ticketing_url: string | null;
52
+ pricing: Record<string, unknown> | null;
53
+ is_cancelled: boolean;
54
+ is_sold_out: boolean;
55
+ is_postponed: boolean;
56
+ atmosphere_tags: string[] | null;
57
+ genre_tags: string[] | null;
58
+ vibe_tags: string[] | null;
59
+ type_tags: string[] | null;
60
+ event_type: string | null;
61
+ overall_theme: string | null;
62
+ venue_city: string | null;
63
+ description_paragraphs: string[] | null;
64
+ lineup_text: string | null;
65
+ embed_urls: Array<{ url: string; platform: string; context?: string }> | null;
66
+ };
67
+
68
+ export type EditableEntity = {
69
+ entity_id: string | number;
70
+ name: string;
71
+ entity_type: string;
72
+ description: string | null;
73
+ event_role: string | null;
74
+ social_media: Record<string, string> | null;
75
+ };
76
+
77
+ export type EditableMediaItem = {
78
+ id: string;
79
+ poster_id: string;
80
+ media_type: string;
81
+ sort_order: number;
82
+ is_primary: boolean;
83
+ media_url: string | null;
84
+ preview_url: string | null;
85
+ };
86
+
87
+ export type EditableResult = {
88
+ poster_id: string;
89
+ event: EditableEventFields;
90
+ entities: EditableEntity[];
91
+ media: EditableMediaItem[];
92
+ endpoints: Record<string, string>;
93
+ };
@@ -81,8 +81,8 @@ describe("auditResearchPayload", () => {
81
81
  const result = auditResearchPayload({
82
82
  featured: [{ name: "Sherin Kalam" }],
83
83
  });
84
- const socials = result.findings.find((f) => f.field === "featured[0].socials");
85
- expect(socials!.action).toContain("Sherin Kalam");
84
+ const context = result.findings.find((f) => f.field === "featured[0].context");
85
+ expect(context!.action).toContain("Sherin Kalam");
86
86
  });
87
87
 
88
88
  // --- organizer ---
@@ -159,16 +159,7 @@ describe("auditResearchPayload", () => {
159
159
  expect(result.findings.find((f) => f.field === "event.urls")).toBeDefined();
160
160
  });
161
161
 
162
- it("flags event with only 1 url", () => {
163
- const result = auditResearchPayload({
164
- event: { urls: ["https://example.com"] },
165
- });
166
- const f = result.findings.find((f) => f.field === "event.urls");
167
- expect(f).toBeDefined();
168
- expect(f!.message).toContain("Only 1");
169
- });
170
-
171
- it("does not flag event with 2+ urls", () => {
162
+ it("does not flag event with 1+ urls", () => {
172
163
  const result = auditResearchPayload({
173
164
  event: { urls: ["https://example.com", "https://ra.co/events/123"] },
174
165
  });
@@ -57,7 +57,7 @@ function auditFeatured(payload: ResearchPayload): AuditFinding[] {
57
57
  finding(
58
58
  `featured[${i}].socials`,
59
59
  `${label} has no social profiles.`,
60
- `Check the venue/organizer's Instagram for posts about this eventlook for @${person.name.toLowerCase().replace(/\s+/g, '')} in tags or caption. If not tagged, search '${person.name} instagram'. Add verified URLs to featured[${i}].socials[].`,
60
+ `Find their Instagram (check venue/organizer posts for @tags). Then OPEN the profile extract every link from their bio (Spotify, Bandcamp, YouTube, website). Add all verified URLs to featured[${i}].socials[].`,
61
61
  ),
62
62
  );
63
63
  }
@@ -67,7 +67,7 @@ function auditFeatured(payload: ResearchPayload): AuditFinding[] {
67
67
  finding(
68
68
  `featured[${i}].context`,
69
69
  `${label} has no context.`,
70
- `Visit ${person.name}'s Instagram profile pull genre, bio, and notable work for featured[${i}].context. Include any Spotify/Bandcamp/website links from their bio.`,
70
+ `Open ${person.name}'s Instagram profile and website. Pull their bio, genre, notable releases/work, and collaborations for featured[${i}].context. For musicians: include Spotify/Bandcamp links from their bio.`,
71
71
  ),
72
72
  );
73
73
  }
@@ -88,7 +88,7 @@ function auditOrganizer(payload: ResearchPayload): AuditFinding[] {
88
88
  finding(
89
89
  "organizer.socials",
90
90
  `Organizer '${name}' has no social profiles.`,
91
- `Find '${name}' on Instagram (browse their profile directly). Pull socials from their bio. Add URLs to organizer.socials[].`,
91
+ `Find '${name}' on Instagram. OPEN the profile extract website, RA page, and other links from their bio. Add all to organizer.socials[].`,
92
92
  ),
93
93
  ];
94
94
  }
@@ -159,16 +159,8 @@ function auditEvent(payload: ResearchPayload): AuditFinding[] {
159
159
  findings.push(
160
160
  finding(
161
161
  "event.urls",
162
- "No event URLs provided.",
163
- "Add the source page URL to event.urls[]. Search for the event on RA, Facebook, or the venue's website and add those too.",
164
- ),
165
- );
166
- } else if (payload.event.urls.length === 1) {
167
- findings.push(
168
- finding(
169
- "event.urls",
170
- "Only 1 event URL provided.",
171
- "Search for this event on RA (ra.co), Facebook Events, or the venue's website and add additional URLs to event.urls[].",
162
+ "No source URLs provided.",
163
+ "Add the event/venue page URL to event.urls[]. These pages get scraped for enrichment use publicly accessible pages with useful content (venue page, artist site, event listing). Do NOT put ticketing URLs here.",
172
164
  ),
173
165
  );
174
166
  }