drafted 1.19.29 → 1.19.31

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.
Files changed (2) hide show
  1. package/mcp/server.mjs +23 -9
  2. package/package.json +1 -1
package/mcp/server.mjs CHANGED
@@ -3267,7 +3267,19 @@ tool('fs', 'Navigate Drafted like a local filesystem. A FOLDER is the single con
3267
3267
  // checkout you are sitting in. Refusing to SCOPE by that is the whole
3268
3268
  // point (it would be silent); refusing to NAME it is just unhelpful.
3269
3269
  // So lead with the likely answer and make the retry a copy-paste.
3270
- const likelyId = workingOrgId();
3270
+ let likelyId = workingOrgId();
3271
+ if (!likelyId) {
3272
+ // workingOrgId()'s repo rung is populated as a SIDE EFFECT of whoami,
3273
+ // so a session that searches before calling it gets no hint — and the
3274
+ // guard fires early, which makes that the common case, not the edge.
3275
+ // Resolve it here instead of depending on call order. getRepoAddress
3276
+ // is process-cached, so this costs nothing after the first hit.
3277
+ const addrNow = await getRepoAddress().catch(() => null);
3278
+ if (addrNow?.state === 'linked' && addrNow.orgId) {
3279
+ getSessionState().repoOrgId = addrNow.orgId; // and stop re-resolving
3280
+ likelyId = addrNow.orgId;
3281
+ }
3282
+ }
3271
3283
  const likely = likelyId ? orgs.find(o => o.id === likelyId) : null;
3272
3284
  const addr = (o) => o.slug || o.name || o.id;
3273
3285
  const others = orgs.filter(o => o.id !== likelyId).map(addr).filter(Boolean);
@@ -3320,19 +3332,21 @@ tool('fs', 'Navigate Drafted like a local filesystem. A FOLDER is the single con
3320
3332
  return list.length ? list.map(s => ` ${scope}/skills/${s.slug} — ${clip(s.description || s.name, 120)}`.trimEnd()).join('\n') : '';
3321
3333
  });
3322
3334
 
3323
- let allowed = null;
3335
+ // NO client-side org filter on either leg. Both endpoints scope server-side
3336
+ // from X-Drafted-Org now, and filtering here as well was worse than
3337
+ // redundant: it compared the path segment against `orgSlug`/`orgId` ONLY,
3338
+ // so addressing an org by NAME (/o/beoflow, which the server resolves
3339
+ // fine for wiki and skills) matched no project — and since the frame
3340
+ // filter reused that empty set, it silently zeroed BOTH sections. A
3341
+ // search that found nothing because of how you spelled the org is exactly
3342
+ // the invisible false negative this whole guard exists to prevent.
3324
3343
  section('Projects', projects, (v) => {
3325
- let rows = (Array.isArray(v?.projects) ? v.projects : []).filter(x => x.folder !== '__archived');
3326
- if (orgFromPath) rows = rows.filter(x => x.orgSlug === orgFromPath || x.orgId === orgFromPath);
3327
- allowed = new Set(rows.map(x => x.id));
3344
+ const rows = (Array.isArray(v?.projects) ? v.projects : []).filter(x => x.folder !== '__archived');
3328
3345
  const hits = rows.filter(x => matchesAllTerms([x.name, x.slug, x.description], q)).slice(0, 10);
3329
3346
  return hits.length ? hits.map(x => ` /o/${x.orgSlug || x.orgId}/projects/${x.slug || x.id}`).join('\n') : '';
3330
3347
  });
3331
3348
  section('Frames', frames, (v) => {
3332
- let hits = Array.isArray(v) ? v : (v?.results || []);
3333
- // Only gate on org when the projects leg actually resolved; an empty set
3334
- // from a FAILED projects call would silently zero out every frame hit.
3335
- if (orgFromPath && allowed) hits = hits.filter(f => allowed.has(f.projectId));
3349
+ const hits = Array.isArray(v) ? v : (v?.results || []);
3336
3350
  const note = archivedNote(Array.isArray(v) ? 0 : (v?.archivedCount || 0));
3337
3351
  return hits.length ? formatFrameHits(hits, { limit: 15 }) + note : (note ? note.trimStart() : '');
3338
3352
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drafted",
3
- "version": "1.19.29",
3
+ "version": "1.19.31",
4
4
  "description": "Drafted — visual thinking surface for humans and AI agents. Renders HTML, markdown, images, and code as frames on a zoomable canvas, with MCP tools for AI agents and real-time sync for humans.",
5
5
  "type": "module",
6
6
  "files": [