counterparts 0.3.13 → 0.3.15
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/CHANGELOG.md +264 -0
- package/docs/QUICKSTART.md +22 -0
- package/docs/README.md +1 -0
- package/package.json +1 -1
- package/src/adapters/claude-code/CONTRACT.md +48 -0
- package/src/adapters/claude-code/NOTES.md +148 -0
- package/src/adapters/claude-code/bin/hook.mjs +4 -2
- package/src/adapters/claude-code/bin/hook.ts +61 -7
- package/src/adapters/claude-code/bin/nightly.ts +5 -1
- package/src/adapters/claude-code/bin/runner.ts +11 -3
- package/src/adapters/claude-code/claim.ts +319 -0
- package/src/adapters/claude-code/doctor.ts +170 -16
- package/src/adapters/claude-code/embed-client.ts +3 -0
- package/src/adapters/cli/CONTRACT.md +5 -0
- package/src/adapters/cli/NOTES.md +25 -0
- package/src/adapters/cli/bin/counterparts.mjs +4 -2
- package/src/adapters/cli/bin/counterparts.ts +49 -3
- package/src/adapters/cli/commands.ts +169 -32
- package/src/adapters/cli/desktop.ts +112 -7
- package/src/adapters/cli/help.ts +10 -0
- package/src/adapters/cli/index.ts +1 -0
- package/src/adapters/cli/install.ts +94 -14
- package/src/adapters/cli/self-page.ts +5 -8
- package/src/adapters/cli/settle.ts +39 -2
- package/src/adapters/cli/wire.ts +18 -1
- package/src/adapters/config.ts +29 -1
- package/src/adapters/dashboard/NOTES.md +33 -0
- package/src/adapters/dashboard/bin/dashboard.mjs +4 -2
- package/src/adapters/dashboard/bin/dashboard.ts +11 -3
- package/src/adapters/dashboard/index.ts +14 -0
- package/src/adapters/dashboard/registries.ts +3 -0
- package/src/adapters/dashboard/source.ts +0 -8
- package/src/adapters/dashboard/web/fired.ts +8 -0
- package/src/adapters/dashboard/web/flow.ts +1 -0
- package/src/adapters/dashboard/web/lanes.ts +1 -0
- package/src/adapters/dashboard/web/narrate.ts +11 -0
- package/src/adapters/dashboard/web/pages/flow/sections/fired.js +1 -1
- package/src/adapters/dashboard/web/pages/health/sections/cycle.js +7 -10
- package/src/adapters/dashboard/web/pages/memories/memories.css +3 -0
- package/src/adapters/dashboard/web/pages/memories/row.js +5 -2
- package/src/adapters/dashboard/web/pages/memories/sections/hold.js +2 -1
- package/src/adapters/dashboard/web/pages/memories/sections/search.js +19 -3
- package/src/adapters/dashboard/web/server.ts +16 -4
- package/src/adapters/dashboard/web/shared/dates.js +6 -16
- package/src/adapters/dashboard/web/shared/memory-modal.js +21 -8
- package/src/adapters/dashboard/web/views/health.ts +19 -5
- package/src/adapters/dashboard/web/views/mechanism-panel.ts +8 -5
- package/src/adapters/dashboard/web/views/memories.ts +26 -7
- package/src/adapters/dashboard/web/views/memory-words.ts +16 -0
- package/src/adapters/dashboard/web/views/memory.ts +51 -2
- package/src/adapters/dashboard/web/views/mind.ts +38 -6
- package/src/adapters/empty-bunfig.toml +5 -0
- package/src/adapters/fired.ts +16 -2
- package/src/adapters/host-wiring.ts +112 -17
- package/src/adapters/log/index.ts +2 -2
- package/src/adapters/mcp/CONTRACT.md +17 -2
- package/src/adapters/mcp/INTERFACE-GAPS.md +15 -1
- package/src/adapters/mcp/NOTES.md +269 -0
- package/src/adapters/mcp/bin/serve.mjs +4 -2
- package/src/adapters/mcp/bin/serve.ts +17 -6
- package/src/adapters/mcp/facts.ts +72 -4
- package/src/adapters/mcp/meaning.ts +218 -15
- package/src/adapters/mcp/server.ts +21 -6
- package/src/adapters/mcp/tools.ts +86 -61
- package/src/adapters/plugin-run.sh +413 -34
- package/src/adapters/plugin.ts +141 -17
- package/src/adapters/runtime.ts +192 -17
- package/src/adapters/sessions.ts +2 -2
- package/src/core/associate/NOTES.md +10 -0
- package/src/core/bridge.ts +1 -1
- package/src/core/briefing.ts +20 -3
- package/src/core/contradictions.ts +56 -20
- package/src/core/counterpart.ts +72 -23
- package/src/core/dream/CONTRACT.md +6 -14
- package/src/core/dream/INTERFACE-GAPS.md +3 -2
- package/src/core/dream/NOTES.md +10 -0
- package/src/core/dream/index.ts +11 -53
- package/src/core/dream/reflect.ts +11 -2
- package/src/core/embed/static.ts +5 -1
- package/src/core/encode/INTERFACE-GAPS.md +2 -1
- package/src/core/encode/NOTES.md +12 -0
- package/src/core/encode/chunk.ts +6 -30
- package/src/core/encode/index.ts +0 -1
- package/src/core/encode/types.ts +1 -13
- package/src/core/handoff/INTERFACE-GAPS.md +1 -1
- package/src/core/handoff/index.ts +2 -1
- package/src/core/handoff/last-here.ts +18 -2
- package/src/core/physics/CONTRACT.md +6 -0
- package/src/core/physics/NOTES.md +33 -2
- package/src/core/physics/index.ts +22 -7
- package/src/core/prospective/CONTRACT.md +3 -1
- package/src/core/prospective/NOTES.md +15 -0
- package/src/core/recall/activate.ts +1 -1
- package/src/core/recall/time-ask.ts +173 -19
- package/src/core/self/CONTRACT.md +56 -19
- package/src/core/self/NOTES.md +172 -0
- package/src/core/self/behind.ts +6 -3
- package/src/core/self/briefing.ts +384 -28
- package/src/core/self/index.ts +105 -44
- package/src/core/self/page.ts +12 -85
- package/src/core/self/tunables.ts +16 -19
- package/src/core/self/writer.ts +31 -4
- package/src/core/sleep/NOTES.md +32 -0
- package/src/core/store/NOTES.md +21 -2
- package/src/core/store/index.ts +2 -1
- package/src/core/time.ts +15 -0
|
@@ -1337,3 +1337,272 @@ right (asked on 2023-02-01: 01-16..01-22, checked on a benchmark store).
|
|
|
1337
1337
|
be the coming one), "last weekend" (no time), a two-digit year (`7/22/23` is still 7/22
|
|
1338
1338
|
with `yearFor`'s year, `/23` left in), `2023/07/22`. The learned-date fallback for a row
|
|
1339
1339
|
with no `occurred_on` is the owner's decision and untouched.
|
|
1340
|
+
|
|
1341
|
+
## 2026-10-09 — tool descriptions inside the host's 2,048-character cut
|
|
1342
|
+
|
|
1343
|
+
The review of #328 read the 2.1.295 binary: Claude Code keeps each MCP tool description
|
|
1344
|
+
twice, cut at 2,048 and at 16,384 characters, and sends the long copy only to a tool
|
|
1345
|
+
loaded through tool search (on by default). A tool loaded up front gets the 2,048 copy
|
|
1346
|
+
and `… [truncated]`: with `ENABLE_TOOL_SEARCH=false`, behind a custom base URL or proxy,
|
|
1347
|
+
on a model without tool search, or for an always-loaded tool. Seven of the nine
|
|
1348
|
+
descriptions run past 2,048 (session_end 7,218, recall 6,176, note 5,091, self_page
|
|
1349
|
+
4,522, dream 3,785, reflect 2,815, chapter 2,097).
|
|
1350
|
+
|
|
1351
|
+
- **What was cut, measured.** Not the "Do NOT" lines: `renderDescription` already puts
|
|
1352
|
+
the summary, the When: line and every negative example before the guarantees list, and
|
|
1353
|
+
on every tool they end before 2,048 (the longest, dream, at 1,782; wake at 1,229). What
|
|
1354
|
+
a host cuts is the tail of the guarantees list.
|
|
1355
|
+
- **The field descriptions are not cut** (2.1.296: the schema goes through
|
|
1356
|
+
`param_descriptions` overrides and two Chrome/computer-use injectors, none of which
|
|
1357
|
+
shortens anything). The longest is session_end's `handoff`, 1,005 characters, served
|
|
1358
|
+
whole. They already carry most of the how-to-call detail (`updates` is a field, the
|
|
1359
|
+
date shapes, `[]` is an answer, `ifVersion`), which is why that detail was put there.
|
|
1360
|
+
- **The change: order only, no wording.** Each list leads with the claims that say how to
|
|
1361
|
+
call the tool, then the ones about what the engine does with it:
|
|
1362
|
+
- note: `updates` and `eventDate` are fields, the salience floor, the default floor,
|
|
1363
|
+
the three dimensions, a stub is refused. Out of the cut: the same road, credentials
|
|
1364
|
+
(a Do NOT already says it), the same content twice, the buffer span.
|
|
1365
|
+
`DATE_PRIVILEGES` is split into `EVENT_DATE_FIELD_PRIVILEGE` and
|
|
1366
|
+
`REMINDER_PRIVILEGES` for this; session_end renders them in the old order.
|
|
1367
|
+
- recall: mode, handle, ids; "a search strengthens nothing" now starts at 1,823 and is cut.
|
|
1368
|
+
- session_end: bound session, `updates`, both salience claims (still pinned by
|
|
1369
|
+
`test/stop-ask-quiet.test.ts`), and the empty-`memories` answer. The id check, the
|
|
1370
|
+
same road and the authorship record moved out. The settle claims stay last.
|
|
1371
|
+
- reflect: `settle` moved up to third.
|
|
1372
|
+
- chapter (only the observer line is cut), self_page (one claim fits), dream (none fits
|
|
1373
|
+
whole in 179 characters; its `begin` prompt states the limits) and status, scope and
|
|
1374
|
+
wake (served whole) are unchanged.
|
|
1375
|
+
- **`test/description-cut.test.ts`** holds the layout (summary, When:, each Do NOT whole
|
|
1376
|
+
inside 2,048 and before the list, for both Claude Code's and Desktop's lists), the
|
|
1377
|
+
leading claims per tool, and records each description's total and pre-list length in
|
|
1378
|
+
one table. A change of length fails it until the table is updated, so the growth shows
|
|
1379
|
+
in the diff.
|
|
1380
|
+
- The CONTRACT promises content (G2: every claim mechanized; G3: an admission test and
|
|
1381
|
+
a negative example), not an order, so it is unchanged.
|
|
1382
|
+
|
|
1383
|
+
## 2026-10-09 — meaning mode: a name asked about that has no card
|
|
1384
|
+
|
|
1385
|
+
0.3.13's release check, on a real store with one card (the owner's): "what has Han been
|
|
1386
|
+
to Mike?" came back as Mike's arc with nothing about Han, because Han had no card.
|
|
1387
|
+
`subjectOf` only ever ranked cards, so the one card in the question won from an aside.
|
|
1388
|
+
|
|
1389
|
+
- **A name with no card is read in place like a card's.** The asker's capitalised
|
|
1390
|
+
mid-sentence words (`feeling-ask.ts#askedNames`) that no card with memories covers,
|
|
1391
|
+
two in a row joined ("Han Seo"), not the owner's name, not a month or a weekday
|
|
1392
|
+
(`uncardedNames`). In an aside it is passed over ("what has Mike been to Han" is Mike's,
|
|
1393
|
+
and says nothing). It takes part in the joined rule, so "how have Han and Oskar been"
|
|
1394
|
+
asks about both.
|
|
1395
|
+
- **Above every card, or level with the owner's alone, the name leads.** The answer is a
|
|
1396
|
+
`words` lens on the name as typed (`holdByWords`, "Han" not "han"), and its first line
|
|
1397
|
+
is `MeaningResult.noCard`: "No card for Han yet; here is what mentions Han" (nothing
|
|
1398
|
+
mentions it: "…, and nothing in memory mentions Han"). The cards it named are
|
|
1399
|
+
one-liners under "also named". The question's vector is not used here: it carries the
|
|
1400
|
+
other names too, and brought "Mike" back.
|
|
1401
|
+
- **Level with another card, the card leads** (it has an arc to show) and the first line
|
|
1402
|
+
is "No card for Han yet; this follows Oskar".
|
|
1403
|
+
- **A question about feeling** keeps its own path: with the name leading, no card is
|
|
1404
|
+
chosen, and the feeling branch's topic words (which include the name) find the felt
|
|
1405
|
+
moments, under its existing note `no card names "Han"`.
|
|
1406
|
+
- `renderMeaning` prints `noCard` first, and so does the dashboard's `meaningHead`
|
|
1407
|
+
(`find-lead`), so the tool, `counterparts ask --mode meaning` and the page agree.
|
|
1408
|
+
- *Choices:* a lower-case name ("what has han been to mike") is not detected: nothing
|
|
1409
|
+
says it is a name. A card that exists but holds nothing the asker may see reads as no
|
|
1410
|
+
card ("No card for Han yet"): saying it has one would tell a non-owner something about
|
|
1411
|
+
confidential memories.
|
|
1412
|
+
- **Review of #347, on the demo store** (cards under full names: Marguerite Solberg,
|
|
1413
|
+
Teodoro Whitlock, Nkechi Abernathy, Ilya Broadbent; master's answers compared
|
|
1414
|
+
question by question). Three ways the rule over-fired, fixed:
|
|
1415
|
+
- *A first name of a card's longer name* ("what has Marguerite been like") said "No
|
|
1416
|
+
card for Marguerite yet" while Marguerite Solberg has one (`subjectsIn` reads only
|
|
1417
|
+
a registered name or alias). Such a word is not a name with no card (`cardWord`,
|
|
1418
|
+
only cards with something the asker may see, as above): the question goes as it
|
|
1419
|
+
did on master. Leading with that card instead would be better, and is the alias
|
|
1420
|
+
index's business, not this rule's.
|
|
1421
|
+
- *A question that names no card* went to a `words` lens on the capitalised word
|
|
1422
|
+
alone, dropping the rest of the question and its meaning: "how has the Q3 roadmap
|
|
1423
|
+
gone" lost the 2 chapters "roadmap" had found and said "nothing in memory mentions
|
|
1424
|
+
Q3"; "what did I learn about Postgres indexing" lost "indexing"; "Hey Claude, what
|
|
1425
|
+
do you remember about the pilot" answered about Claude. With no card named nothing
|
|
1426
|
+
is answered in the name's place, so the rule now needs a card mention (`kept`);
|
|
1427
|
+
otherwise master's words-and-meaning answer stands, with its "no card names it"
|
|
1428
|
+
note. "What has Han been to me" is one of these now.
|
|
1429
|
+
- *Acronyms, digits, Title Case*: "API", "Q3", "OKRs" (a capital second letter or a
|
|
1430
|
+
digit) are labels, not names; a question with a capitalised function word
|
|
1431
|
+
mid-sentence ("What Has Changed Since Monday", `TITLE_CASE_TELLS`) names nobody,
|
|
1432
|
+
as `askedNames` already reads an all-capitals question.
|
|
1433
|
+
- *Beside a card asked about or named plainly*, a capitalised thing in an about place
|
|
1434
|
+
still led: "what did Teodoro Whitlock say about Postgres" answered "No card for
|
|
1435
|
+
Postgres yet, and nothing in memory mentions Postgres" where master gave Teodoro's
|
|
1436
|
+
arc, and "how did I feel about Han at Driftwood" left Driftwood's arc for every felt
|
|
1437
|
+
moment. No word-level rule tells Postgres from Han, but the card's place does: the
|
|
1438
|
+
motivating question had its one card in an aside ("been to Mike"). So the name with
|
|
1439
|
+
no card now leads only when EVERY card named sits in an aside ("been to Mike",
|
|
1440
|
+
"since Y", "after Y"). Otherwise the card leads as on master, and the first line
|
|
1441
|
+
says the name has none ("No card for Postgres yet; this follows Teodoro Whitlock")
|
|
1442
|
+
for each such name asked about as high as that card, or higher. This replaces
|
|
1443
|
+
"above every card, or level with the owner's alone" and "level with another card"
|
|
1444
|
+
above: "how have Mike and Han been" is now Mike's, with "No card for Han yet; this
|
|
1445
|
+
follows Mike". With the name leading in a question about feeling, the feeling
|
|
1446
|
+
branch's topic is that name alone (`nameTopic`), so its note says `no card names
|
|
1447
|
+
"Han"` and not the card it outranked.
|
|
1448
|
+
- Sentence-initial words were never read as names (`askedNames` skips them); every
|
|
1449
|
+
probe whose first word is capitalised ("What has changed since Monday", "How has
|
|
1450
|
+
Driftwood gone", "Tell me about Rosalind", "When did I feel proud", "What happened
|
|
1451
|
+
in October") answers exactly as on master.
|
|
1452
|
+
|
|
1453
|
+
## 2026-10-09 — facts mode: amounts, fractions, and a day not yet come
|
|
1454
|
+
|
|
1455
|
+
Three of #338's reviewer's findings predated it (items 3 and 4 of that review), all in
|
|
1456
|
+
`recall/time-ask.ts`; this is them.
|
|
1457
|
+
|
|
1458
|
+
- **What changed meaning, exactly.** (1) A `M-D` or `M/D` with a unit or counting noun
|
|
1459
|
+
right after it is an amount, not a date: "7-8 hours", "3-4pm", "5-10%", "3/4 cup", "1/2
|
|
1460
|
+
of the budget", "lost 5-10 lbs" (a decimal tail too: "7-8.5 hours"). A price is one too:
|
|
1461
|
+
"$5-10". They were dates ("7-8 hours" July 8, and under "up to" through 07-08; "$5-10"
|
|
1462
|
+
May 10). The scan goes on past an
|
|
1463
|
+
amount, so "slept 7-8 hours before 9/21" is through 09-20; anything else stops it where
|
|
1464
|
+
it stopped before. (2) "Cut it by 1/2", "reduced the dose to 1/3": a fraction after a
|
|
1465
|
+
word of quantity is no date. It was through 01-02 (master before #338: 01-02 alone).
|
|
1466
|
+
(3) "Since" and "after" a month and day with no year that has not come yet this year
|
|
1467
|
+
(a later day of this month, the only case `yearFor` left in the future) now mean last
|
|
1468
|
+
year's. "Since 10/25" asked on 10-03 was empty (10-25..10-03); now it is
|
|
1469
|
+
2025-10-25..10-03. "After 10/25" was only what is still to come; now it is 2025-10-26
|
|
1470
|
+
onward, which holds that too. The event form follows ("after the 10/25 launch" is
|
|
1471
|
+
2025-10-25 onward). A Feb 29 not yet come reaches back to the last Feb 29 there was.
|
|
1472
|
+
- *Choices:*
|
|
1473
|
+
- The fraction rule is narrow on purpose: a slash, no year written, the number above
|
|
1474
|
+
smaller than the one below and the one below at most 10 (halves to tenths), and a
|
|
1475
|
+
word of quantity (cut, reduce, increase, decrease, divide, multiply, grow, shrink,
|
|
1476
|
+
raise, lower, halve, trim, slash, boost, scale, drop, fall, rise, in their forms) at
|
|
1477
|
+
most three words before the "by" or "to". Anything else stays a date: "finish by
|
|
1478
|
+
1/2" is through 01-02, "cut costs by 3/15" is a March deadline. When it guesses
|
|
1479
|
+
wrong the other way ("drop it off by 1/2"), nothing is filtered, which hides nothing.
|
|
1480
|
+
- The year moves only under "since" and "after". Under "before", "until", "by" and a
|
|
1481
|
+
day alone this year's coming day is kept: "before 10/25" asked on 10-03 is through
|
|
1482
|
+
this year's 10-24, which holds everything that has happened plus the plans before
|
|
1483
|
+
it, where last year's would hide a year; "by 10/25" is a deadline ahead; "on 10/25"
|
|
1484
|
+
can be a plan. So the CONTRACT's "before 1/5" asked on 01-03 (through this year's
|
|
1485
|
+
01-04) stands.
|
|
1486
|
+
- "Today" is the person's own day (the store's zone), as everywhere here: at 04:00 UTC
|
|
1487
|
+
on 10-04, "since 10/4" is last year's in Denver (still 10-03) and today on Kiritimati.
|
|
1488
|
+
- The event-day rule of #338 ("before the 7/22 flight" keeps 07-22) is unchanged and
|
|
1489
|
+
now tested in Denver and on Kiritimati.
|
|
1490
|
+
- **Not done:** an amount written with words between the number and the unit ("7-8 full
|
|
1491
|
+
hours"), a score ("rated it 8/10" is still August 10), a later MONTH under "by" or
|
|
1492
|
+
"until" (still last year's by `yearFor`, as before; *done* the same day, the next
|
|
1493
|
+
section but one), and a number range with "to"
|
|
1494
|
+
("7 to 8 hours" was never a date).
|
|
1495
|
+
- *Review of #345:* two follow-ons of the amount rule. (1) Passing "2-3" over as an amount
|
|
1496
|
+
left "3 weeks ago" to be read alone: the week three back, which hid the week two back
|
|
1497
|
+
(and "3-4 days ago" left "3-" in the question). A range in front of the count ("2-3",
|
|
1498
|
+
"2/3", "two or three", "2 to 3") now covers both ends: "2-3 weeks ago" asked on 10-03
|
|
1499
|
+
is 09-07..09-20 before the stretch, "3-4 days ago" 09-29..09-30. "3 or 4 days ago" was
|
|
1500
|
+
the same misreading on master. (2) A zero-padded month or day ("the 09-28 minutes",
|
|
1501
|
+
"7/08 hours") is a date: no amount is written that way, and this owner writes his dates
|
|
1502
|
+
so. Probed and left as they are: a date followed with no comma by a unit or counting
|
|
1503
|
+
noun ("on 7/8 hours were cut", "on 9/12 people came", "the 9/28 minutes") is no time,
|
|
1504
|
+
because "on 7-8 hours of sleep" is an amount after the same "on" and no time hides
|
|
1505
|
+
nothing; with a comma ("on 5/6, days later") it is a date. "7/8 hours before the
|
|
1506
|
+
launch" is no time (an amount, and the launch is not resolved).
|
|
1507
|
+
|
|
1508
|
+
## 2026-10-09 — facts mode names its corrected versions
|
|
1509
|
+
|
|
1510
|
+
Found by the LongMemEval run; the owner approved the fix. A memory settled `corrected` is
|
|
1511
|
+
archived (`contradictions.ts#settle`), so it is out of `recallRows` and out of the word
|
|
1512
|
+
index, and facts mode said only "N corrected versions hidden" under the one that corrected
|
|
1513
|
+
it. Nothing on the page reached it, even a search that named it: "Summer Solstice Market
|
|
1514
|
+
potted plants sold" came back with the herb-sale memory and that line. Answers that showed
|
|
1515
|
+
the line passed 18 of 26, against 409 of 472 otherwise. The worst case is a wrong
|
|
1516
|
+
correction (pointed at an unrelated memory), which made a true one unreachable; #340's
|
|
1517
|
+
guard makes that rarer, but older stores already hold some.
|
|
1518
|
+
|
|
1519
|
+
- **What changed.** Each corrected version is named under the memory that corrected it,
|
|
1520
|
+
in the shape of `earlier:` and marked wrong in front:
|
|
1521
|
+
`corrected (was wrong): "…" (learned 09-10), corrected 09-11 · mem_…`. Three at most
|
|
1522
|
+
(`FACTS_CORRECTED_SHOWN`), the rest counted (`+N more corrected (was wrong)`). Its id
|
|
1523
|
+
opens it: `recall` by id reads an archived row whole, with its standing ("corrected by
|
|
1524
|
+
mem_…") in front, so the reader sees both sides before deciding. `FactItem` keeps
|
|
1525
|
+
`corrected` (every one) and gains `correctedShown`, present only when one is named, so
|
|
1526
|
+
a facts answer with none is byte-identical to before (six questions compared on a demo
|
|
1527
|
+
store: answer, structured payload and `FactsResult` JSON).
|
|
1528
|
+
- *Choices:*
|
|
1529
|
+
- Three, one more than the earlier versions' two: a `changed` earlier one is live, so
|
|
1530
|
+
the question's words reach it and fold it under its current one; a corrected one is
|
|
1531
|
+
archived, and this line is its only way in from a question.
|
|
1532
|
+
- Order: those sharing a content word with the question first (it is out of the index,
|
|
1533
|
+
so this is the only "matched" there is), then the latest corrected. The market
|
|
1534
|
+
question puts the potted-plants memory first; a pier question the pier one.
|
|
1535
|
+
- Not a result and not in the answer's `ids`, like an earlier version: it is not
|
|
1536
|
+
offered as a fact, so it does not join the seen set or the quotable `asked` record.
|
|
1537
|
+
- Not named, and still counted ("N corrected versions hidden", as before) when this
|
|
1538
|
+
asker may not be told of it — a confidential one outside the owner's session, a
|
|
1539
|
+
removed one — or nothing of it is left to read.
|
|
1540
|
+
- The dashboard's Ask draws the same: each one a line under the words like an earlier
|
|
1541
|
+
one, "corrected (was wrong): “…”", dated, with the id as a link; the rest counted.
|
|
1542
|
+
The console's `ask` needed nothing: its short list shows neither, `--full` is this
|
|
1543
|
+
answer and `--json` the `FactsResult`.
|
|
1544
|
+
- **Not done:** a question whose words reach ONLY the corrected memory, and nothing of
|
|
1545
|
+
the one that corrected it, still does not bring that one in: the archived row is out of
|
|
1546
|
+
the index, so nothing matched. In the benchmark case the two shared the market's name.
|
|
1547
|
+
Folding through `corrected` pairs as `changed` ones fold (a match on the wrong one
|
|
1548
|
+
bringing in the one that holds) would need the archived rows' words searched; left for
|
|
1549
|
+
when a case shows it is needed. And a corrected memory is listed under the memory that
|
|
1550
|
+
corrected it directly: when that one was later `changed` and folds under its successor,
|
|
1551
|
+
the corrected one is not listed under the successor (nor counted there, as before).
|
|
1552
|
+
Opening the earlier one by id shows it ("corrects mem_…").
|
|
1553
|
+
|
|
1554
|
+
## 2026-10-09 — facts mode: "by 12/20" asked in October (review of #345, item 2)
|
|
1555
|
+
|
|
1556
|
+
`yearFor` picks a yearless month's year by the month alone: this year's once it has begun,
|
|
1557
|
+
else last year's. Under "since" and "after" that is right (the roll of the section before
|
|
1558
|
+
last covers a later day of this month). Under "before", "until", "up to" and "by" a month
|
|
1559
|
+
not yet begun went to last year: "what's due by 12/20" asked on 10-09 was `OPEN_START` to
|
|
1560
|
+
2025-12-20, which hid 2025-12-21 to today, about ten months. Now `dated` moves such a date
|
|
1561
|
+
to this year's when this year's is the nearer of the two: through 2026-12-20, which hides
|
|
1562
|
+
nothing that has happened.
|
|
1563
|
+
|
|
1564
|
+
- *Choices:*
|
|
1565
|
+
- The nearer, not "this year's" outright (the reviewer's wording). The new-year test
|
|
1566
|
+
already pins "until Dec 30" asked on Jan 3 as the one four days back; this year's
|
|
1567
|
+
would have been 361 days ahead and no filter at all. Asked on 05-01, "by 12/20" is
|
|
1568
|
+
last year's (132 days back against 233 ahead), as before. On a tie this year's wins
|
|
1569
|
+
(it hides less).
|
|
1570
|
+
- Scoped to a month not yet begun, where `yearFor` went back a year. A month already
|
|
1571
|
+
begun keeps its year: "before 9/30" asked on 10-09 is through this year's 09-29, and
|
|
1572
|
+
"by 1/5" asked in October is through this year's 01-05, as before. The event form
|
|
1573
|
+
follows ("before the 12/20 flight" keeps this year's 12-20); a date alone ("on
|
|
1574
|
+
12/20") and a written year are not moved. A Feb 29 this year lacks keeps its year.
|
|
1575
|
+
- Tested in Denver and on Kiritimati, at 10-09 and across the 12-01 edge (11-30 in
|
|
1576
|
+
Denver, 12-01 on Kiritimati: both now read this year's 12-20, where Denver read last
|
|
1577
|
+
year's).
|
|
1578
|
+
- **Not done:** the year-end mirror (*done* 2026-10-10, the next section). "By 1/5" asked on 12-28 is through this year's 01-05,
|
|
1579
|
+
nearly a year back, where the person likely means the coming one; moving it would also
|
|
1580
|
+
move "finish by 1/2" asked in October, which the amount tests pin as this year's. "By
|
|
1581
|
+
the end of December" and "through December" asked in October are read as a month
|
|
1582
|
+
(`yearFor`, last year's), not as a bound; unchanged.
|
|
1583
|
+
|
|
1584
|
+
## 2026-10-10 — facts mode: "by 1/5" asked on 12-28 (the year-end mirror)
|
|
1585
|
+
|
|
1586
|
+
The section before left the mirror of #352's rule undone. Under "before", "until", "up
|
|
1587
|
+
to" and "by", a yearless date now takes the year, last, this or next, whose date is
|
|
1588
|
+
nearest today (`time-ask.ts#nearestYear`): "by 1/5" asked on 12-28 is through 2027-01-05,
|
|
1589
|
+
eight days ahead, where it was through 2026-01-05, 357 days back, which hid the whole year
|
|
1590
|
+
since. #352's rule is the same rule over two years instead of three, so every case it
|
|
1591
|
+
pinned holds: "by 12/20" asked on 10-09 (this year's), on 05-01 (last year's), "until Dec
|
|
1592
|
+
30" asked on Jan 3 (four days back), "before 1/2" asked on 01-10 (eight days back), a Feb
|
|
1593
|
+
29 a year lacks.
|
|
1594
|
+
|
|
1595
|
+
- *What moved, and was pinned before:* three answers asked in early October, where the
|
|
1596
|
+
coming date is now the nearer. "Finish by 1/2" reads through 2027-01-02 (91 days ahead
|
|
1597
|
+
against 274 back), "cut costs by 3/15" through 2027-03-15 (163 against 202), and "by
|
|
1598
|
+
1/5" through 2027-01-05 (88 against 277). The amount test's point stands: "by 1/2" there
|
|
1599
|
+
is still January 2, a date. The section before named this cost and stopped there; a
|
|
1600
|
+
deadline written without a year in October means the coming one more often than the
|
|
1601
|
+
last, and a cutoff moved ahead hides nothing that has happened.
|
|
1602
|
+
- *Unchanged:* "since" and "after" still reach back to the last time the day came round
|
|
1603
|
+
("since 1/5" asked on 12-28 runs from this year's 01-05): a "since" ahead would be
|
|
1604
|
+
empty. A date alone ("on 1/5") keeps `yearFor`'s year, and a written year is the year
|
|
1605
|
+
meant.
|
|
1606
|
+
- Tested in Denver and on Kiritimati on 12-28, and across the new-year edge (12-31 in
|
|
1607
|
+
Denver, already 01-01 on Kiritimati: both read 2027-01-05, where Denver read
|
|
1608
|
+
2026-01-05); midyear the nearer decides (07-01: last January's; 07-10: next).
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
|
-
':' //; if command -v bun >/dev/null 2>&1; then exec bun "$0" "$@"; elif command -v node >/dev/null 2>&1; then exec node "$0" "$@"; else echo "counterparts: needs Bun 1.3+ or Node 22.15+ on PATH" >&2; exit 127; fi
|
|
2
|
+
':' //; s="$0"; n=0; while [ -h "$s" ] && [ $n -lt 32 ]; do n=$((n+1)); l="$(readlink "$s")"; case "$l" in /*) s="$l" ;; *) s="${s%/*}/$l" ;; esac; done; c="${s%/*}/../../empty-bunfig.toml"; [ -f "$c" ] || c=/dev/null; if command -v bun >/dev/null 2>&1; then exec bun --no-env-file "--config=$c" "$0" "$@"; elif command -v node >/dev/null 2>&1; then exec node "$0" "$@"; else echo "counterparts: needs Bun 1.3+ or Node 22.15+ on PATH" >&2; exit 127; fi
|
|
3
3
|
// A shell script and an ES module at once: the line above is a no-op string to
|
|
4
|
-
// JavaScript and, to sh, the runtime choice (Bun if it is on PATH, else Node
|
|
4
|
+
// JavaScript and, to sh, the runtime choice (Bun if it is on PATH, else Node;
|
|
5
|
+
// Bun with --no-env-file and --config=<empty-bunfig.toml>, found through any
|
|
6
|
+
// bin symlink, so a project's .env and bunfig.toml stay out: adapters/runtime.ts).
|
|
5
7
|
// See `adapters/launch.mjs`.
|
|
6
8
|
import { launch } from "../../launch.mjs";
|
|
7
9
|
|
|
@@ -63,9 +63,10 @@ import type { LogEvent, ProcessLog } from "../../log/index.js";
|
|
|
63
63
|
import { serveStdio } from "../stdio.js";
|
|
64
64
|
import { stoodDownServer } from "../stood-down.js";
|
|
65
65
|
import { npmWiring } from "../../host-wiring.js";
|
|
66
|
-
import { ensureFirstRun, mcpGate, runningAsPlugin } from "../../plugin.js";
|
|
66
|
+
import { ensureFirstRun, mcpGate, pluginOrigin, runningAsPlugin } from "../../plugin.js";
|
|
67
67
|
import { DATA_DIR_ENV, describeGuardRefusal } from "../../../core/store/index.js";
|
|
68
|
-
import { scriptArgs } from "../../runtime.js";
|
|
68
|
+
import { BINARY, scriptArgs } from "../../runtime.js";
|
|
69
|
+
import type { Binary } from "../../runtime.js";
|
|
69
70
|
import {
|
|
70
71
|
OBSERVER_ENV,
|
|
71
72
|
OWNER_ENV,
|
|
@@ -330,7 +331,11 @@ async function main(): Promise<void> {
|
|
|
330
331
|
if (runningAsPlugin(process.env)) {
|
|
331
332
|
const home = homedir();
|
|
332
333
|
const projectDir = process.env["CLAUDE_PROJECT_DIR"] ?? process.cwd();
|
|
333
|
-
const gate = mcpGate(
|
|
334
|
+
const gate = mcpGate(
|
|
335
|
+
npmWiring({ home, env: process.env, cwd: projectDir, read: { hooks: false } }),
|
|
336
|
+
home,
|
|
337
|
+
pluginOrigin({ home, env: process.env, cwd: projectDir }),
|
|
338
|
+
);
|
|
334
339
|
if (gate.standDown) {
|
|
335
340
|
process.stderr.write("[counterparts] plugin server stood down: the npm install's server is registered in this host\n");
|
|
336
341
|
await serveStdio(stoodDownServer(gate.instructions ?? ""), process.stdin, {
|
|
@@ -502,12 +507,16 @@ async function main(): Promise<void> {
|
|
|
502
507
|
|
|
503
508
|
/** True only when this file is the process entry point — so a test may import
|
|
504
509
|
* `launchOptions` without the server starting itself on stdin. */
|
|
505
|
-
export function isEntryPoint(argv1: string | undefined, url: string): boolean {
|
|
506
|
-
|
|
510
|
+
export function isEntryPoint(argv1: string | undefined, url: string, binary: Binary | null = BINARY): boolean {
|
|
511
|
+
// Never in the single binary, where every module shares one URL: its
|
|
512
|
+
// dispatcher (tools/single-binary/main.ts) calls `start()` itself.
|
|
513
|
+
if (argv1 === undefined || binary !== null) return false;
|
|
507
514
|
return resolve(argv1) === fileURLToPath(new URL(url));
|
|
508
515
|
}
|
|
509
516
|
|
|
510
|
-
|
|
517
|
+
/** Run the server until stdin closes — what this file does as a script, and
|
|
518
|
+
* what the single binary's `mcp` mode calls. */
|
|
519
|
+
export function start(): void {
|
|
511
520
|
void main().then(
|
|
512
521
|
// `process.exitCode` is 1 when the launch refused a named configuration it
|
|
513
522
|
// could not honour; every other path ends 0.
|
|
@@ -528,3 +537,5 @@ if (isEntryPoint(process.argv[1], import.meta.url)) {
|
|
|
528
537
|
},
|
|
529
538
|
);
|
|
530
539
|
}
|
|
540
|
+
|
|
541
|
+
if (isEntryPoint(process.argv[1], import.meta.url)) start();
|
|
@@ -43,8 +43,12 @@
|
|
|
43
43
|
* folded under it: in-place revisions (`versions` rows whose words differ)
|
|
44
44
|
* and memories it settled as `changed` (a contradiction pair) — an earlier
|
|
45
45
|
* one that matched brings its current one in as the result. Corrected
|
|
46
|
-
* versions
|
|
47
|
-
*
|
|
46
|
+
* versions (they were wrong) are never results — archived, they are out of
|
|
47
|
+
* the word index — but are named under the memory that corrected them, up to
|
|
48
|
+
* `FACTS_CORRECTED_SHOWN` with a count for the rest, each labeled "corrected
|
|
49
|
+
* (was wrong)" with its id, so one a wrong correction archived can still be
|
|
50
|
+
* opened (2026-10-09). An `open` pair says "disagrees with", an unsettled
|
|
51
|
+
* older one "may be out of date".
|
|
48
52
|
*
|
|
49
53
|
* FADED. A matched memory that has kept `deliberate.ts#FADED_RETAINED` of
|
|
50
54
|
* its strength or less (it was not used for a long while; `hasFaded`, the
|
|
@@ -63,6 +67,7 @@
|
|
|
63
67
|
* you said · done · happened 09-28
|
|
64
68
|
* learned 09-28 in ~/counterparts · session a1b2c3d4 · CURRENT
|
|
65
69
|
* earlier: "gym at 7" (learned 09-12), changed 09-28 · mem_…
|
|
70
|
+
* corrected (was wrong): "gym on Tuesdays" (learned 09-10), corrected 09-11 · mem_…
|
|
66
71
|
* <the body whole when short, else a 300-character excerpt>
|
|
67
72
|
*
|
|
68
73
|
* faded (3):
|
|
@@ -121,6 +126,14 @@ export const FACTS_FADED_LINES = 5;
|
|
|
121
126
|
export const FACTS_WEAK_FRACTION = 0.2;
|
|
122
127
|
/** Earlier versions shown under a result; the rest are counted. */
|
|
123
128
|
export const FACTS_EARLIER_SHOWN = 2;
|
|
129
|
+
/**
|
|
130
|
+
* Corrected versions named under a result; the rest are counted. One more than
|
|
131
|
+
* the earlier ones: an earlier (`changed`) memory is still live, so a question's
|
|
132
|
+
* words reach it and fold it under its current one, while a corrected one is
|
|
133
|
+
* archived and out of the word index — this line is its only way in from a
|
|
134
|
+
* question (2026-10-09).
|
|
135
|
+
*/
|
|
136
|
+
export const FACTS_CORRECTED_SHOWN = 3;
|
|
124
137
|
/** Token overlap at or above which two results are near-duplicates (the gate's `NEAR_DUPLICATE`). */
|
|
125
138
|
export const FACTS_NEAR_DUPLICATE = 0.85;
|
|
126
139
|
/** How far an event anchor's window reaches each side of its date. */
|
|
@@ -185,6 +198,20 @@ export interface EarlierVersion {
|
|
|
185
198
|
readonly id?: string;
|
|
186
199
|
}
|
|
187
200
|
|
|
201
|
+
/**
|
|
202
|
+
* A version settled as `corrected` — it was wrong. Archived, so never a result
|
|
203
|
+
* of its own; named under the memory that corrected it so it can be opened by
|
|
204
|
+
* id (a wrong correction must not make a true memory unreachable).
|
|
205
|
+
*/
|
|
206
|
+
export interface CorrectedVersion {
|
|
207
|
+
/** Its title, or the start of its words. */
|
|
208
|
+
readonly text: string;
|
|
209
|
+
readonly learned: string | null;
|
|
210
|
+
/** When it was corrected, `YYYY-MM-DD` in the store's zone. */
|
|
211
|
+
readonly corrected: string | null;
|
|
212
|
+
readonly id: string;
|
|
213
|
+
}
|
|
214
|
+
|
|
188
215
|
export interface FactItem {
|
|
189
216
|
readonly id: string;
|
|
190
217
|
readonly title: string | null;
|
|
@@ -213,8 +240,14 @@ export interface FactItem {
|
|
|
213
240
|
readonly now?: string;
|
|
214
241
|
readonly earlier: readonly EarlierVersion[];
|
|
215
242
|
readonly earlierMore: number;
|
|
216
|
-
/** Corrected (wrong) versions of it,
|
|
243
|
+
/** Corrected (wrong) versions of it: every one, named or not. */
|
|
217
244
|
readonly corrected: number;
|
|
245
|
+
/**
|
|
246
|
+
* The corrected versions named, at most `FACTS_CORRECTED_SHOWN`: those the
|
|
247
|
+
* question's words reach first, then the latest corrected. Absent when none
|
|
248
|
+
* is named (none corrected, or none this asker may be told of).
|
|
249
|
+
*/
|
|
250
|
+
readonly correctedShown?: readonly CorrectedVersion[];
|
|
218
251
|
/** Pair labels besides earlier/corrected: disagrees with, unsettled. */
|
|
219
252
|
readonly standing: readonly string[];
|
|
220
253
|
readonly ways: readonly FactWay[];
|
|
@@ -814,6 +847,8 @@ function factItem(
|
|
|
814
847
|
});
|
|
815
848
|
}
|
|
816
849
|
let corrected = 0;
|
|
850
|
+
const wrong: (CorrectedVersion & { reached: number })[] = [];
|
|
851
|
+
const asked = new Set(tokens);
|
|
817
852
|
const standing: string[] = [];
|
|
818
853
|
let now: string | undefined;
|
|
819
854
|
for (const p of pairs) {
|
|
@@ -832,6 +867,19 @@ function factItem(
|
|
|
832
867
|
now = canName(p.holds) ? p.holds : "a later version";
|
|
833
868
|
} else if (p.state === "settled" && p.how === "corrected" && p.holds === c.id) {
|
|
834
869
|
corrected += 1;
|
|
870
|
+
// Named so it can be opened by id: counted, but not named, when this
|
|
871
|
+
// asker may not be told of it or nothing of it is left to read.
|
|
872
|
+
const over = p.over;
|
|
873
|
+
const o = over === null ? undefined : safe(() => store.row(over), undefined);
|
|
874
|
+
if (over === null || o === undefined || o.body.length === 0 || !canName(over)) continue;
|
|
875
|
+
const held = new Set(tokenize(`${o.title ?? ""}\n${o.body}`));
|
|
876
|
+
wrong.push({
|
|
877
|
+
text: plainLine(o.title ?? o.body, 60),
|
|
878
|
+
learned: o.learned_on.length > 0 ? o.learned_on : null,
|
|
879
|
+
corrected: localDate(p.updated_at, zone),
|
|
880
|
+
id: over,
|
|
881
|
+
reached: [...asked].filter((t) => held.has(t)).length,
|
|
882
|
+
});
|
|
835
883
|
} else if (p.state === "settled" && p.how === "open") {
|
|
836
884
|
if (canName(other)) standing.push(`disagrees with ${other}`);
|
|
837
885
|
} else if (p.state === "unsettled" && p.a === c.id) {
|
|
@@ -845,6 +893,10 @@ function factItem(
|
|
|
845
893
|
const fb = b.id !== undefined && c.foldedEarlier.has(b.id) ? 0 : 1;
|
|
846
894
|
return fa - fb || (b.changed ?? "").localeCompare(a.changed ?? "");
|
|
847
895
|
});
|
|
896
|
+
// Corrected: those the question's words reach first (a search that names
|
|
897
|
+
// one should find it here), then the latest corrected.
|
|
898
|
+
wrong.sort((a, b) => b.reached - a.reached || (b.corrected ?? "").localeCompare(a.corrected ?? "") || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
899
|
+
const correctedShown = wrong.slice(0, FACTS_CORRECTED_SHOWN).map(({ text, learned, corrected: on, id }) => ({ text, learned, corrected: on, id }));
|
|
848
900
|
const title = row.title ?? doc.title;
|
|
849
901
|
return {
|
|
850
902
|
id: c.id,
|
|
@@ -868,6 +920,7 @@ function factItem(
|
|
|
868
920
|
earlier: earlier.slice(0, FACTS_EARLIER_SHOWN),
|
|
869
921
|
earlierMore: Math.max(0, earlier.length - FACTS_EARLIER_SHOWN),
|
|
870
922
|
corrected,
|
|
923
|
+
...(correctedShown.length === 0 ? {} : { correctedShown }),
|
|
871
924
|
standing: standing.slice(0, 2),
|
|
872
925
|
ways: (["words", "meaning", "subject", "session", "time"] as const).filter((x) => c.ways.has(x)),
|
|
873
926
|
...(c.timeBy === undefined ? {} : { timeBy: c.timeBy }),
|
|
@@ -1002,7 +1055,22 @@ function itemLines(m: FactItem, i: number, today: string, excerptChars: number):
|
|
|
1002
1055
|
out.push(` earlier: "${e.text}"${learned}${changed}${e.id === undefined ? "" : ` · ${e.id}`}`);
|
|
1003
1056
|
}
|
|
1004
1057
|
if (m.earlierMore > 0) out.push(` +${String(m.earlierMore)} more earlier`);
|
|
1005
|
-
|
|
1058
|
+
// Corrected versions were WRONG: said so in front, never read as a fact,
|
|
1059
|
+
// each with its id so it can be opened (a correction can itself be wrong).
|
|
1060
|
+
const named = m.correctedShown ?? [];
|
|
1061
|
+
for (const e of named) {
|
|
1062
|
+
const learned = e.learned === null ? "" : ` (learned ${shortDate(e.learned, today)})`;
|
|
1063
|
+
const on = e.corrected === null ? "" : `, corrected ${shortDate(e.corrected, today)}`;
|
|
1064
|
+
out.push(` corrected (was wrong): "${e.text}"${learned}${on} · ${e.id}`);
|
|
1065
|
+
}
|
|
1066
|
+
const unnamed = m.corrected - named.length;
|
|
1067
|
+
if (unnamed > 0) {
|
|
1068
|
+
out.push(
|
|
1069
|
+
named.length === 0
|
|
1070
|
+
? ` ${String(unnamed)} corrected version${unnamed === 1 ? "" : "s"} hidden`
|
|
1071
|
+
: ` +${String(unnamed)} more corrected (was wrong)`,
|
|
1072
|
+
);
|
|
1073
|
+
}
|
|
1006
1074
|
const words = m.body.length <= excerptChars ? m.body : cutExcerpt(m.body, excerptChars);
|
|
1007
1075
|
out.push(` ${words}`);
|
|
1008
1076
|
return out;
|