@meshpoint/cli 1.1.0 → 1.3.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/README.md CHANGED
@@ -33,6 +33,8 @@ meshpoint items put --item gotcha 'title' 'body' # write items for the current
33
33
  meshpoint items put < items.json # same, as a JSON array of {kind, title, body}
34
34
  meshpoint items retract 3f9c1a2b # retract by id or unique id prefix
35
35
  meshpoint items confirm 3f9c1a2b # confirm by id or prefix (counts toward rank)
36
+ meshpoint items put --item decision 'New choice' 'Why.' --supersedes 7d0e44aa # replaces the old item
37
+ meshpoint items put --item convention 'Tests: pnpm test' 'scripts.test' --key test-runner # stable slot
36
38
  ```
37
39
 
38
40
  `connect <harness>` without `--project` writes to your user config, so every repo you open is on the mesh. `--project <dir>` writes into one repo instead; the files then travel with the repo in git. The meshpoint testbed on the maintainers' machines uses `--project` only.
@@ -31,7 +31,9 @@ Each item is an object \`{"kind", "title", "body"}\`. \`kind\` is one of:
31
31
 
32
32
  - Only what this session established. Never invent.
33
33
  - Skip anything already listed under "Team knowledge" in the session-start context unless it changed; a changed decision or status gets a new item.
34
- - Retract items that this session made wrong or obsolete: a finished todo, a superseded status, a reversed decision. The first column of "Team knowledge" is the item id.
34
+ - An item that replaces an older one (a changed decision, a convention that moved, a todo now split differently) names the old id: add \`--supersedes <id>\` after the \`--item\`. The old item leaves recall and stays linked to the new one. A \`status\` item always replaces the branch's previous status on its own.
35
+ - Retract items that this session made wrong: a finished todo, a reversed decision with nothing in its place. The first column of "Team knowledge" is the item id.
36
+ - \`status\` and \`todo\` items leave recall on their own after 30 days without confirmation; the durable kinds stay until replaced or retracted.
35
37
  - Items under "Possibly stale" name a file that is gone from this checkout. Check whether each still holds; retract it or write a corrected item. Do not leave them.
36
38
  - Name files by their repo-relative path (\`src/auth/token.ts\`, not "the token file"). Meshpoint links the item to those files, checks them in later checkouts, and shows the item when someone edits them. The command warns about paths it cannot find.
37
39
  - Prefer durable knowledge over moment-to-moment detail. Aim for 5 to 30 items; one \`status\` item at most.
@@ -39,11 +41,12 @@ Each item is an object \`{"kind", "title", "body"}\`. \`kind\` is one of:
39
41
 
40
42
  ## Procedure
41
43
 
42
- Run \`meshpoint items put\` once, one \`--item kind title body\` per item. Single-quote title and body and keep the single quote character out of them (write "do not", not "don't"). No JSON, no heredoc.
44
+ Run \`meshpoint items put\` once, one \`--item kind title body\` per item, each optionally followed by \`--supersedes <id>\` (the item it replaces) or \`--key <slot>\` (a stable slot such as \`test-runner\`; a later item with the same key replaces this one). Single-quote title and body and keep the single quote character out of them (write "do not", not "don't"). No JSON, no heredoc.
43
45
 
44
46
  \`\`\`bash
45
47
  meshpoint items put \\
46
- --item decision 'Short title' 'What was chosen and why, with file names and values.' \\
48
+ --item decision 'Short title' 'What was chosen and why, with file names and values.' --supersedes 7d0e44aa \\
49
+ --item convention 'Tests run with pnpm test' 'package.json scripts.test; CI runs the same.' --key test-runner \\
47
50
  --item gotcha 'Short title' 'What bit and how to avoid it.'
48
51
  \`\`\`
49
52
 
package/dist/context.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
2
  import path from "node:path";
3
+ import { isExpired } from "@meshpoint/sdk";
3
4
  // Per-session state for the edit hook: the branch's items as seen at session start (with the
4
5
  // local verdicts) and the files already noticed, so one file gets one notice per session.
5
6
  export const EDIT_ITEMS_MAX = 2;
@@ -69,9 +70,9 @@ export class SessionCache {
69
70
  // Items worth showing when a file is edited: those naming it, of the kinds that bite, not dropped
70
71
  // locally stale, ranked the way recall ranks them (kind weight, then recency, then confirmations).
71
72
  const KIND_WEIGHT = { decision: 5, gotcha: 4, convention: 3, fact: 2, status: 2, todo: 1 };
72
- export function itemsForFile(items, verdicts, filePath) {
73
+ export function itemsForFile(items, verdicts, filePath, now = Date.now()) {
73
74
  return items
74
- .filter((i) => !i.retracted && i.state !== "dropped" && EDIT_KINDS.has(i.kind) && verdicts[i.id] !== "stale")
75
+ .filter((i) => !i.retracted && i.state !== "dropped" && i.state !== "superseded" && !isExpired(i, now) && EDIT_KINDS.has(i.kind) && verdicts[i.id] !== "stale")
75
76
  .filter((i) => i.refs.includes(filePath) || i.paths.includes(filePath))
76
77
  .sort((a, b) => (KIND_WEIGHT[b.kind] ?? 0) - (KIND_WEIGHT[a.kind] ?? 0) || b.created_at - a.created_at || b.confirmations - a.confirmations)
77
78
  .slice(0, EDIT_ITEMS_MAX);
package/dist/items.js CHANGED
@@ -6,6 +6,22 @@ export const ID_PREFIX_CHARS = 8;
6
6
  const ALL_ITEMS_BUDGET = 100_000;
7
7
  const TITLE_MAX = 200;
8
8
  const BODY_MAX = 2000;
9
+ const KEY_RE = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;
10
+ const SUPERSEDES_MAX = 20;
11
+ function withKey(d, i, key) {
12
+ if (typeof key !== "string" || !KEY_RE.test(key))
13
+ throw new Error(`item ${i}: key must be 1-128 characters of letters, digits, . _ : / -`);
14
+ return { ...d, key };
15
+ }
16
+ function withSupersedes(d, i, ids) {
17
+ const list = typeof ids === "string" ? ids.split(",") : ids;
18
+ if (!Array.isArray(list) || !list.every((s) => typeof s === "string"))
19
+ throw new Error(`item ${i}: supersedes must be a list of item ids`);
20
+ const clean = list.map((s) => s.trim()).filter(Boolean);
21
+ if (clean.length === 0 || clean.length > SUPERSEDES_MAX)
22
+ throw new Error(`item ${i}: supersedes takes 1 to ${SUPERSEDES_MAX} item ids`);
23
+ return { ...d, supersedes: [...(d.supersedes ?? []), ...clean] };
24
+ }
9
25
  function isRecord(v) {
10
26
  return typeof v === "object" && v !== null && !Array.isArray(v);
11
27
  }
@@ -18,14 +34,27 @@ function draft(i, kind, title, body) {
18
34
  throw new Error(`item ${i}: body required`);
19
35
  return { kind: kind, title: title.trim().slice(0, TITLE_MAX), body: body.trim().slice(0, BODY_MAX) };
20
36
  }
21
- // `--item <kind> <title> <body>`, repeated. Plain arguments: no JSON for a shell guard to object to.
37
+ // `--item <kind> <title> <body>`, repeated, each followed by optional `--key <key>` and
38
+ // `--supersedes <id>[,<id>]` modifiers. Plain arguments: no JSON for a shell guard to object to.
22
39
  export function parseItemArgs(args) {
23
40
  const drafts = [];
24
41
  for (let i = 0; i < args.length; i += 1) {
25
- if (args[i] !== "--item")
26
- throw new Error(`unexpected argument ${args[i]}`);
27
- drafts.push(draft(drafts.length, args[i + 1], args[i + 2], args[i + 3]));
28
- i += 3;
42
+ const arg = args[i];
43
+ const last = drafts.length - 1;
44
+ if (arg === "--item") {
45
+ drafts.push(draft(drafts.length, args[i + 1], args[i + 2], args[i + 3]));
46
+ i += 3;
47
+ }
48
+ else if (arg === "--key" && last >= 0) {
49
+ drafts[last] = withKey(drafts[last], last, args[i + 1]);
50
+ i += 1;
51
+ }
52
+ else if (arg === "--supersedes" && last >= 0) {
53
+ drafts[last] = withSupersedes(drafts[last], last, args[i + 1]);
54
+ i += 1;
55
+ }
56
+ else
57
+ throw new Error(`unexpected argument ${arg}`);
29
58
  }
30
59
  if (drafts.length === 0)
31
60
  throw new Error("no items");
@@ -49,7 +78,12 @@ export function parseItems(raw) {
49
78
  return parsed.map((v, i) => {
50
79
  if (!isRecord(v))
51
80
  throw new Error(`item ${i}: not an object`);
52
- return draft(i, v.kind, v.title, v.body);
81
+ let d = draft(i, v.kind, v.title, v.body);
82
+ if (v.key !== undefined && v.key !== "")
83
+ d = withKey(d, i, v.key);
84
+ if (v.supersedes !== undefined)
85
+ d = withSupersedes(d, i, v.supersedes);
86
+ return d;
53
87
  });
54
88
  }
55
89
  function clientFor(deps) {
@@ -63,21 +97,26 @@ function clientFor(deps) {
63
97
  }
64
98
  // Each item gets its refs (paths named in its text that exist in the checkout), the paths edited
65
99
  // since the branch's last checkpoint, and HEAD. Path-like tokens that resolve to nothing come
66
- // back as `missing` so the writer can fix a typo.
100
+ // back as `missing` so the writer can fix a typo. Supersedes prefixes are resolved against the
101
+ // branch's live items before the write, the way retract resolves them.
67
102
  export async function putItems(drafts, deps) {
68
103
  const now = deps.now ?? Date.now;
69
104
  const { project, branch, root } = deps.repo;
105
+ const client = clientFor(deps);
70
106
  const since = deps.checkpoints.lastCheckpoint(project, branch);
71
107
  const paths = deps.touched?.since(project, branch, since) ?? [];
72
108
  const commit_sha = (deps.sha ?? headSha)(root);
73
109
  const missing = new Set();
74
- const items = drafts.map((d) => {
110
+ const items = [];
111
+ for (const d of drafts) {
112
+ const { supersedes: prefixes, ...rest } = d;
75
113
  const found = extractRefs(`${d.title}\n${d.body}`, root, deps.exists);
76
114
  for (const m of found.missing)
77
115
  missing.add(m);
78
- return { id: randomUUID(), ...d, refs: found.refs, paths, ...(commit_sha ? { commit_sha } : {}) };
79
- });
80
- const out = await clientFor(deps).putItems(items);
116
+ const supersedes = prefixes ? await resolveIds(prefixes, deps, client) : undefined;
117
+ items.push({ id: randomUUID(), ...rest, refs: found.refs, paths, ...(commit_sha ? { commit_sha } : {}), ...(supersedes ? { supersedes } : {}) });
118
+ }
119
+ const out = await client.putItems(items);
81
120
  deps.checkpoints.markCheckpoint(project, branch, now());
82
121
  deps.touched?.clear(project, branch);
83
122
  return { ...out, missing: [...missing] };
package/dist/tap.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import path from "node:path";
2
- import { MeshpointClient, MeshpointError, redact } from "@meshpoint/sdk";
2
+ import { isExpired, MeshpointClient, MeshpointError, redact } from "@meshpoint/sdk";
3
3
  import { SKILL_NAME } from "./claude-code/skill.js";
4
4
  import { instructionFiles, itemsForFile, renderEditNotice, renderImportNudge } from "./context.js";
5
5
  import { ID_PREFIX_CHARS } from "./items.js";
@@ -153,6 +153,7 @@ export class Tap {
153
153
  token: this.config.token,
154
154
  project: this.repo.project,
155
155
  branch,
156
+ session: this.deps.session,
156
157
  ...(this.deps.fetch ? { fetch: this.deps.fetch } : {}),
157
158
  ...(onError ? { onError } : {}),
158
159
  });
@@ -238,10 +239,12 @@ export function renderInject(repo, recall, presence, now, verdicts = new Map())
238
239
  if (recall.checkpoint) {
239
240
  lines.push("", `## Last checkpoint (${age(now - recall.checkpoint.created_at)})`, recall.checkpoint.body);
240
241
  }
241
- const stale = recall.items.filter((i) => verdicts.get(i.id) === "stale");
242
+ // A blob served from the edge may predate an item's expiry or replacement; apply both rules here too.
243
+ const current = recall.items.filter((i) => !i.retracted && i.state !== "dropped" && i.state !== "superseded" && !isExpired(i, now));
244
+ const stale = current.filter((i) => verdicts.get(i.id) === "stale");
242
245
  const live = [];
243
246
  let used = 0;
244
- for (const i of recall.items) {
247
+ for (const i of current) {
245
248
  if (verdicts.get(i.id) === "stale")
246
249
  continue;
247
250
  const t = estimateTokens(i);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshpoint/cli",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "Meshpoint CLI and harness adapters: shared agent memory for developer teams",
5
5
  "keywords": [
6
6
  "meshpoint",
@@ -38,7 +38,7 @@
38
38
  "prepublishOnly": "npm run check && npm run build"
39
39
  },
40
40
  "dependencies": {
41
- "@meshpoint/sdk": "^1.1.0"
41
+ "@meshpoint/sdk": "^1.3.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/node": "^22.0.0",