attraverso 0.4.0 → 0.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attraverso",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Durable, structured project memory that Claude reads and writes over MCP, stored as version-controlled YAML.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/server.js CHANGED
@@ -21963,7 +21963,7 @@ var StdioServerTransport = class {
21963
21963
  };
21964
21964
  // package.json
21965
21965
  var name = "attraverso";
21966
- var version$1 = "0.4.0";
21966
+ var version$1 = "0.5.0";
21967
21967
  var description = "Durable, structured project memory that Claude reads and writes over MCP, stored as version-controlled YAML.";
21968
21968
  var license = "Apache-2.0";
21969
21969
  var repository = {
@@ -24792,6 +24792,9 @@ function mapRelationalRow(tablesConfig, tableConfig, row, buildQueryResultSelect
24792
24792
  function count(expression) {
24793
24793
  return sql`count(${expression || sql.raw("*")})`.mapWith(Number);
24794
24794
  }
24795
+ function max(expression) {
24796
+ return sql`max(${expression})`.mapWith(is(expression, Column) ? expression : String);
24797
+ }
24795
24798
  // src/db/rows.ts
24796
24799
  /**
24797
24800
  * Small helpers for reading Drizzle result arrays under `noUncheckedIndexedAccess`, where `rows[0]` and a
@@ -52613,8 +52616,13 @@ async function matching(db, projectId, q, rank, limit, headline) {
52613
52616
  // src/mcp/searchFeed.ts
52614
52617
  /** Enough to fill the dropdown under the box without scrolling it on a laptop. */
52615
52618
  var LIMIT = 12;
52616
- /** A ref as typed (`view-34`, `MCP-3.1`): a prefix, a dash, and a dotted number. */
52617
- var REF = /^([A-Za-z][A-Za-z0-9]*)-(\d+(?:\.\d+)*)$/;
52619
+ /**
52620
+ * A ref as typed: a prefix and a dotted number, with a dash, a space, an underscore or nothing between them -
52621
+ * `view-34`, `proj 3`, `MCP_3.1`, `plat9`. Only a dash was accepted at first, and "proj 3" found nothing by its
52622
+ * ref, which is how people say one out loud. Loose is safe here, because a match only leads when that item exists.
52623
+ * The prefix is lazy, so `plat9` splits before the digits while `A2-1` still keeps its digit.
52624
+ */
52625
+ var REF = /^([A-Za-z][A-Za-z0-9]*?)[\s_-]*(\d+(?:\.\d+)*)$/;
52618
52626
  /** Null when the owner has no project of that key, which a host answers with a 404. */
52619
52627
  async function searchFeed(db, ownerId, projectKey, query) {
52620
52628
  const project = await getProjectByKey(db, ownerId, projectKey);
@@ -53546,10 +53554,10 @@ function redact(url) {
53546
53554
  * new prefix invents one on the spot and nothing may reject it. The `areas` table is therefore metadata (a
53547
53555
  * name, a colour, a display order) and never a constraint.
53548
53556
  *
53549
- * Which forces the shape of this query: **the key list comes from `items`, not from `areas`.** Nothing writes
53550
- * an `areas` row today - `createItem` sets `areaKey` on the item and stops - so the rows that exist came in
53551
- * with the original YAML seed, and listing the table would silently omit every area created since. Reading
53552
- * items and left-joining the metadata cannot go stale, because the items are what defines the set.
53557
+ * Which forces the shape of this query: **the key list comes from `items`, not from `areas`.** `createItem` sets
53558
+ * `areaKey` on the item and stops, and a row is only written when somebody names the area (`setArea`, `PROJ-3`),
53559
+ * so listing the table would omit every area nobody has named. Reading items and left-joining the metadata cannot
53560
+ * go stale, because the items are what defines the set.
53553
53561
  *
53554
53562
  * Surfaced because the `PROJ-8` trim removed the thing that used to convey it. The pack once listed every open
53555
53563
  * item, so the area vocabulary was visible by accident; with the listing replaced by two short groups, nothing
@@ -53570,16 +53578,80 @@ async function listAreas(db, projectId) {
53570
53578
  }).from(items).where(and(eq(items.projectId, projectId), isNull(items.deletedAt))).groupBy(items.areaKey);
53571
53579
  const meta = new Map((await db.select().from(areas).where(eq(areas.projectId, projectId)).orderBy(asc(areas.sortOrder))).map((a) => [a.key, {
53572
53580
  name: a.name,
53581
+ description: a.description,
53573
53582
  sortOrder: a.sortOrder
53574
53583
  }]));
53575
53584
  const unnamed = Number.MAX_SAFE_INTEGER;
53576
53585
  return counts.map((row) => ({
53577
53586
  key: row.key,
53578
53587
  name: meta.get(row.key)?.name ?? null,
53588
+ description: meta.get(row.key)?.description ?? null,
53579
53589
  open: row.open,
53580
53590
  total: row.total
53581
53591
  })).sort((a, b) => (meta.get(a.key)?.sortOrder ?? unnamed) - (meta.get(b.key)?.sortOrder ?? unnamed) || a.key.localeCompare(b.key));
53582
53592
  }
53593
+ /**
53594
+ * The longest description an area takes. An area's description is what the viewer shows over it when zoomed out
53595
+ * (`VIEW-52`) and beside it in the pane, so it is a line or two about what the area holds; anything longer is a
53596
+ * context section's job, and the refusal says so, since a cap without a destination loses the content (`CTX-2`).
53597
+ */
53598
+ var MAX_AREA_DESCRIPTION = 400;
53599
+ /**
53600
+ * The longest name an area takes: a word or two, because it is read on the map at every zoom, including just
53601
+ * before the zoomed-out fade (`VIEW-52`), where a longer one could not be read in time. The longer wording is the
53602
+ * description's, and the refusal says so.
53603
+ */
53604
+ var MAX_AREA_NAME = 20;
53605
+ /** An area key as a ref prefix is written: letters first, then letters and digits, upper case. */
53606
+ var AREA_KEY = /^[A-Z][A-Z0-9]*$/;
53607
+ /**
53608
+ * Name an area, or describe it, or both (`PROJ-3`): the write path the `areas` table never had.
53609
+ *
53610
+ * **Written on demand, never by filing an item.** An area exists the moment an item uses its prefix, as it always
53611
+ * has; a row only says what that prefix is called. So the first `setArea` creates it, at the end of the display
53612
+ * order, and later ones change it. A row whose area has no items any more stays: it is a name, not a constraint,
53613
+ * and keeping it means the name comes back with the area rather than being lost with its last item.
53614
+ *
53615
+ * Omitting a field leaves it as it was; `description: null` clears it. A first call with no name takes the key,
53616
+ * since the table needs one and the key is what the area was called until now.
53617
+ */
53618
+ async function setArea(db, projectId, input, actor) {
53619
+ const key = input.key.trim().toUpperCase();
53620
+ if (!AREA_KEY.test(key)) throw new Error(`"${input.key}" is not an area key: letters then letters and digits, like VIEW or OPS2`);
53621
+ const name = input.name?.trim();
53622
+ if (name === "") throw new Error("an area's name cannot be empty; omit `name` to leave it as it is");
53623
+ if (name !== void 0 && name.length > 20) throw new Error(`an area's name is at most 20 characters (this is ${name.length}): a word or two, read on the map at every zoom. Put the longer wording in the description.`);
53624
+ const description = input.description === void 0 ? void 0 : input.description === null ? null : input.description.trim() || null;
53625
+ if (description !== void 0 && description !== null && description.length > 400) throw new Error(`an area's description is at most 400 characters (this is ${description.length}): it is a line or two shown over the area. Put the longer account in a context section with set_context, and point to it here.`);
53626
+ return mutate(db, actor, async (tx) => {
53627
+ const before = maybeOne(await tx.select().from(areas).where(and(eq(areas.projectId, projectId), eq(areas.key, key))));
53628
+ const after = before === null ? one(await tx.insert(areas).values({
53629
+ projectId,
53630
+ key,
53631
+ name: name ?? key,
53632
+ description: description ?? null,
53633
+ sortOrder: ((await tx.select({ last: max(areas.sortOrder) }).from(areas).where(eq(areas.projectId, projectId)))[0]?.last ?? -1) + 1
53634
+ }).returning()) : one(await tx.update(areas).set({
53635
+ ...name !== void 0 && { name },
53636
+ ...description !== void 0 && { description }
53637
+ }).where(eq(areas.id, before.id)).returning());
53638
+ return {
53639
+ result: {
53640
+ key: after.key,
53641
+ name: after.name,
53642
+ description: after.description
53643
+ },
53644
+ event: {
53645
+ projectId,
53646
+ entityType: "area",
53647
+ entityId: after.id,
53648
+ kind: before === null ? "created" : "edited",
53649
+ before,
53650
+ after
53651
+ }
53652
+ };
53653
+ });
53654
+ }
53583
53655
  // src/domain/memory.ts
53584
53656
  /**
53585
53657
  * `resumeProject` assembles what a returning session opens with (MCP-8): one read, deliberately small.
@@ -53866,7 +53938,7 @@ var fmtNext = (list) => list.map((n, index) => `${index + 1}. ${fmtItem(n)}${fmt
53866
53938
  var fmtAreas = (list) => {
53867
53939
  const key = Math.max(0, ...list.map((a) => a.key.length));
53868
53940
  const total = Math.max(0, ...list.map((a) => String(a.total).length));
53869
- return list.map((a) => `${a.key.padEnd(key)} ${String(a.open).padStart(3)} open of ${String(a.total).padEnd(total)}${a.name === null ? "" : ` ${a.name}`}`).join("\n");
53941
+ return list.map((a) => `${a.key.padEnd(key)} ${String(a.open).padStart(3)} open of ${String(a.total).padEnd(total)}${a.name === null ? "" : ` ${a.name}`}` + (a.description === null ? "" : ` - ${a.description}`)).join("\n");
53870
53942
  };
53871
53943
  /**
53872
53944
  * A recorded tree, as it was written: the occurrence first, its readings indented under it.
@@ -54145,7 +54217,8 @@ function registerTools(server, db, store, viewer, caller) {
54145
54217
  inputSchema: { project: string() },
54146
54218
  outputSchema: { areas: array(object({
54147
54219
  key: string().describe("The ref prefix, e.g. \"MCP\". This is what list_items takes as `area`."),
54148
- name: string().nullable().describe("Null for an area that exists only because an item uses the prefix."),
54220
+ name: string().nullable().describe("Null for an area nobody has named with set_area."),
54221
+ description: string().nullable().describe("What the area holds, in a line or two; null where nobody has said."),
54149
54222
  open: number().int().describe("Items not done and not deleted."),
54150
54223
  total: number().int()
54151
54224
  })) }
@@ -54157,6 +54230,24 @@ function registerTools(server, db, store, viewer, caller) {
54157
54230
  structuredContent: { areas: list }
54158
54231
  };
54159
54232
  }));
54233
+ server.registerTool("set_area", {
54234
+ annotations: WRITE,
54235
+ description: `Name an area or describe it, or both. An area is a ref prefix (MCP, VIEW); it exists as soon as an item uses it, and this only says what it is: a name of a word or two, as you would say it ("Viewer" for VIEW, at most 20 characters and shorter reads better, since it is read on the map at every zoom), and a line or two on what belongs in it, which the viewer shows with the area and list_areas returns. Omit a field to leave it; pass description: null to clear it. The description is at most 400 characters - a longer account is a context section (set_context).`,
54236
+ inputSchema: {
54237
+ project: string(),
54238
+ key: string().describe("The area's ref prefix, e.g. \"VIEW\"."),
54239
+ name: string().optional().describe(`A word or two, at most 20 characters; shorter reads better.`),
54240
+ description: string().nullable().optional().describe("What belongs in it, in a line or two. Null clears it.")
54241
+ }
54242
+ }, async ({ project, key, name, description }) => guarded(async () => {
54243
+ const area = await setArea(db, (await resolveProject(db, caller, project)).id, {
54244
+ key,
54245
+ name,
54246
+ description
54247
+ }, ACTOR);
54248
+ await store.persist();
54249
+ return text(`${area.key}: ${area.name}${area.description === null ? "" : `\n${area.description}`}`);
54250
+ }));
54160
54251
  server.registerTool("record_measurements", {
54161
54252
  annotations: WRITE,
54162
54253
  description: "Record dated readings: a weight, a meal's macros, a set of an exercise, a night's sleep. A *metric* is the name of a series (\"body_weight\") and there is one of it; a *measurement* is one dated reading of that metric and there are thousands. So you record measurements, and you list metrics. Numbers go in `value`, categoricals in `text` ('restless'), one or the other per reading. **Pass `group` whenever the readings belong to one occurrence** - a meal, a workout, a day - and they are written nested under it in this single call, which costs no more than a flat list. Nesting is what lets you later ask which calories were in which meal; `label` is a display name and is never grouped by, so if you want to total by something, it needs to be a `group`. `at` is when it was MEASURED, not now, so a backfilled log passes the day it is about. Readings are not items: they never appear on the board and carry no status.",