@hypercarrier/rarebit 0.1.0-alpha.1

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 (50) hide show
  1. package/AGENTS.md +14 -0
  2. package/CHANGELOG.md +10 -0
  3. package/LICENSE +21 -0
  4. package/README.md +142 -0
  5. package/RUNBOOK.md +36 -0
  6. package/SECURITY.md +11 -0
  7. package/VISUAL-LANGUAGE.md +89 -0
  8. package/bin/rarebit.mjs +20 -0
  9. package/package.json +96 -0
  10. package/schemas/rarebit.schema.json +618 -0
  11. package/scripts/e2e-recall-pi083.mjs +199 -0
  12. package/scripts/e2e-summary-cache.mjs +257 -0
  13. package/scripts/verify-package.mjs +81 -0
  14. package/src/automatic-summary-policy.mjs +210 -0
  15. package/src/extension.mjs +516 -0
  16. package/src/herdr-activity.mjs +111 -0
  17. package/src/index.mjs +13 -0
  18. package/src/lifecycle.mjs +322 -0
  19. package/src/rarebit-activity.mjs +48 -0
  20. package/src/rarebit-artifact-state.mjs +839 -0
  21. package/src/rarebit-cli.mjs +305 -0
  22. package/src/rarebit-command.mjs +281 -0
  23. package/src/rarebit-core.mjs +525 -0
  24. package/src/rarebit-model.mjs +226 -0
  25. package/src/rarebit-recall.mjs +182 -0
  26. package/src/rarebit-service.mjs +579 -0
  27. package/src/rarebit-session.mjs +227 -0
  28. package/src/rarebit-settings.mjs +79 -0
  29. package/src/rarebit-store.mjs +771 -0
  30. package/src/rarebit-visual-language.mjs +110 -0
  31. package/src/types.d.ts +601 -0
  32. package/test/automatic-summary-policy.test.mjs +476 -0
  33. package/test/extension-activity.test.mjs +73 -0
  34. package/test/fixtures/branch-mixed.json +117 -0
  35. package/test/fixtures/conformance-corpus.v1.json +306 -0
  36. package/test/fixtures/truncated-mixed.jsonl +2 -0
  37. package/test/herdr-activity.test.mjs +93 -0
  38. package/test/lifecycle-contract-independent.test.mjs +627 -0
  39. package/test/rarebit-activity.test.mjs +82 -0
  40. package/test/rarebit-artifact-state.test.mjs +440 -0
  41. package/test/rarebit-cli.test.mjs +222 -0
  42. package/test/rarebit-command.test.mjs +127 -0
  43. package/test/rarebit-core.test.mjs +461 -0
  44. package/test/rarebit-cross-consumer-conformance.test.mjs +150 -0
  45. package/test/rarebit-independent-contract.test.mjs +317 -0
  46. package/test/rarebit-recall.test.mjs +434 -0
  47. package/test/rarebit-sidecar-protocol.test.mjs +538 -0
  48. package/test/rarebit-visual-language.test.mjs +75 -0
  49. package/test/summary-attention-independent.test.mjs +172 -0
  50. package/test/types-history.ts +13 -0
package/AGENTS.md ADDED
@@ -0,0 +1,14 @@
1
+ # Rarebit contributor guidance
2
+
3
+ Rarebit is a standalone Pi package in a sharing-stage public alpha. Native Pi
4
+ Session JSONL is historical evidence authority. Rarebit selections and sidecars
5
+ must not replace it or claim Task, Project, runtime, or delivery truth.
6
+
7
+ Keep the public surface small. Test CLI behavior, package boundaries, and Pi
8
+ installation paths. Do not add private-helper mocks, export-count tests,
9
+ coverage targets, or tautological snapshots. Run `npm ci`, `npm test`, and
10
+ `npm run verify:package` before a release candidate.
11
+
12
+ Do not record Session prose, provider credentials, Recall bundles, or private
13
+ paths in issues, fixtures, logs, or release records. `README.md` owns user
14
+ setup and privacy guidance. `RUNBOOK.md` owns operator recovery details.
package/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0-alpha.1 — 2026-08-02
4
+
5
+ First standalone public-alpha candidate. It preserves the committed Rarebit
6
+ source from HyperCarrier commit `945533d41e6c1f88718d12b744bc96202afbac21`.
7
+ The package name is `@hypercarrier/rarebit` and the CLI is `rarebit`.
8
+
9
+ This is an unstable alpha. Public APIs, CLI output, sidecar details, and visual
10
+ marks can change before a stable release.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 HyperCarrier contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # Rarebit
2
+
3
+ `@hypercarrier/rarebit` recovers decision-bearing conversational evidence from
4
+ one persisted Pi Session. It deterministically selects readable user messages
5
+ and assistant continuation or stop prose on the active branch. It excludes tool
6
+ payloads, tool results, and hidden reasoning.
7
+
8
+ Rarebit is public alpha software. Its CLI output, exports, sidecar protocol,
9
+ and visual language can change. It is not a Task, Project, runtime, priority,
10
+ attention, or delivery authority. Native Pi Session JSONL remains the evidence
11
+ authority.
12
+
13
+ ## Install
14
+
15
+ Use Node 22 or later and Pi 0.83 or later. Install it in Pi from npm:
16
+
17
+ ```sh
18
+ pi install npm:@hypercarrier/rarebit@0.1.0-alpha.1
19
+ pi list
20
+ ```
21
+
22
+ For a local checkout, Pi loads a directory without copying it:
23
+
24
+ ```sh
25
+ pi install /absolute/path/to/rarebit
26
+ pi list
27
+ ```
28
+
29
+ The package imports Pi's bundled `@earendil-works/pi-ai` as a peer dependency.
30
+ Do not install or bundle a second Pi core. Pi packages execute with your user
31
+ permissions, so review source before installation.
32
+
33
+ To use the CLI in a normal Node project, install it and invoke the local bin
34
+ with npm:
35
+
36
+ ```sh
37
+ npm install @hypercarrier/rarebit@0.1.0-alpha.1
38
+ npm exec -- rarebit --help
39
+ ```
40
+
41
+ ## First query and extract
42
+
43
+ Give the CLI an exact Session JSONL path or supported Pi Session identifier.
44
+ `query` returns metadata only. `extract` returns selected raw Session prose.
45
+
46
+ ```sh
47
+ npm exec -- rarebit query --session /absolute/path/to/session.jsonl --json
48
+ npm exec -- rarebit extract --session /absolute/path/to/session.jsonl --json
49
+ ```
50
+
51
+ The Pi extension adds `/rarebit` controls after installation. It has `status`,
52
+ `config`, `auto-title`, `title`, `summarize`, and `recall` subcommands.
53
+
54
+ ## Model setup and optional derivations
55
+
56
+ Summary and Title use a dedicated configured model. They never inherit Pi's
57
+ interactive `defaultModel`. Put this in global Pi settings, or in a trusted
58
+ project's `.pi/settings.json`:
59
+
60
+ ```json
61
+ {
62
+ "rarebit": {
63
+ "model": "provider/model",
64
+ "min_total_length": 80000,
65
+ "max_rarebit_ratio": 0.4,
66
+ "auto_title": true
67
+ }
68
+ }
69
+ ```
70
+
71
+ Then request explicit model work when you want it:
72
+
73
+ ```sh
74
+ npm exec -- rarebit summarize --session /absolute/path/to/session.jsonl --json --force
75
+ npm exec -- rarebit title --session /absolute/path/to/session.jsonl --json
76
+ ```
77
+
78
+ A Summary is a lossy assessment of an identified selection. It can report only
79
+ Session-scoped appearance, not completed Project or Task work. A Title is a
80
+ mutable label proposal, not Session identity. Automatic Summary work runs only
81
+ at persisted direct-input or settled-agent boundaries and only when its policy
82
+ permits it.
83
+
84
+ ## Privacy, local data, and provider egress
85
+
86
+ Rarebit reads Pi Session JSONL locally and does not modify it. `extract` prints
87
+ selected raw prose, so handle its output as sensitive.
88
+
89
+ Summary and Title send selected Rarebit prose to the provider and model that you
90
+ configure. When input exceeds the fixed limit, Rarebit sends a newest suffix
91
+ with an explicit omission marker. It does not send tool inputs, tool results,
92
+ hidden reasoning, provider credentials, or HTTP headers as Rarebit content.
93
+
94
+ Derived receipts live below `~/.pi/agent/rarebit/materializations-v4/`; job
95
+ leases live below `~/.pi/agent/rarebit/jobs-v4/`. These directories use mode
96
+ 0700 and their files use mode 0600. Receipts retain compact metadata but no
97
+ selected prose, prompt, provider response body, headers, or credentials. They
98
+ remain until you remove them. Session JSONL retention is controlled by Pi.
99
+
100
+ ## First Recall
101
+
102
+ Run `/rarebit recall <prompt>` in a Pi Session. Rarebit writes the exact active
103
+ branch selection to two private files: a conversation view and detailed
104
+ lineage evidence. It then sends one atomic user message. The message contains
105
+ your exact request and absolute pointers to both files.
106
+
107
+ When Pi is idle, that message starts one turn. When Pi is busy, it queues one
108
+ steering message. Recall does not send a second follow-up, add a custom Session
109
+ entry, or create a durable Recall receipt.
110
+
111
+ The temporary directory is mode 0700 and its JSON files are mode 0600. The
112
+ files remain after the request so Pi can read them; delete the directory after
113
+ the turn no longer needs it. Both files and the persisted Pi envelope are
114
+ sensitive. Do not put their paths or content in a ticket.
115
+
116
+ ## Update, uninstall, and rollback
117
+
118
+ Pin alpha versions for reproducible installs:
119
+
120
+ ```sh
121
+ pi install npm:@hypercarrier/rarebit@0.1.0-alpha.1
122
+ pi update npm:@hypercarrier/rarebit
123
+ pi remove npm:@hypercarrier/rarebit
124
+ ```
125
+
126
+ To roll back, reinstall a known version with `pi install npm:@hypercarrier/rarebit@<version>`.
127
+ Removal stops package loading. It does not alter Pi Session JSONL or delete
128
+ Rarebit sidecars, job leases, or Recall temp files. Remove retained local data
129
+ only after you review it.
130
+
131
+ ## Compatibility and support
132
+
133
+ This alpha supports Node 22+ and Pi 0.83+. It works as a deterministic CLI
134
+ without a model. Summary, Title, and the Pi extension require a compatible Pi
135
+ installation and configured provider credentials.
136
+
137
+ Report security issues privately as described in [SECURITY.md](SECURITY.md).
138
+ Use https://github.com/deephbz/rarebit/issues for normal support. Include no
139
+ Session prose, credentials, or Recall files in public reports.
140
+
141
+ See [RUNBOOK.md](RUNBOOK.md) for recovery and sidecar details, and
142
+ [VISUAL-LANGUAGE.md](VISUAL-LANGUAGE.md) for evidence-mark meaning.
package/RUNBOOK.md ADDED
@@ -0,0 +1,36 @@
1
+ # Rarebit runbook
2
+
3
+ Set `rarebit.model` in global Pi settings or in a trusted Project's
4
+ `.pi/settings.json`. It must be `provider/model` or an object with `provider`
5
+ and `id`. Rarebit fails closed when it is missing or invalid. It does not use
6
+ Pi's interactive `defaultModel`.
7
+
8
+ Run `pi update npm:@hypercarrier/rarebit` to update an npm installation. Run
9
+ `pi remove npm:@hypercarrier/rarebit` to stop loading it. These commands do not
10
+ modify native Sessions or remove Rarebit retained data.
11
+
12
+ Inspect derived state without treating it as a transcript:
13
+
14
+ ```sh
15
+ npm exec -- rarebit query --session <exact-session.jsonl> --json
16
+ npm exec -- rarebit extract --session <exact-session.jsonl> --json
17
+ ```
18
+
19
+ The current protocol reads only `materializations-v4`. A `rarebit_head` is the
20
+ fenced semantic-current pointer. Do not select the physical last JSONL line.
21
+
22
+ If a crash leaves an adjacent `.commit-lock`, first verify no Rarebit writer for
23
+ that Session is alive. Then remove only that lock. Age alone does not authorize
24
+ removal.
25
+
26
+ Automatic summaries require both the configured minimum estimated length and
27
+ maximum selected-prose ratio. `npm exec -- rarebit summarize --force` and
28
+ `/rarebit summarize` are explicit requests. The receipt records input coverage.
29
+
30
+ Selected evidence contains user messages.
31
+
32
+ Recall bundles are private OS-temp files with selected content. One user
33
+ message contains the exact request and both private file pointers. When Pi is
34
+ idle it starts one turn. When Pi is busy it queues one steering message. Delete
35
+ the bundle after that turn no longer needs it. Do not put its paths or contents
36
+ in a ticket.
package/SECURITY.md ADDED
@@ -0,0 +1,11 @@
1
+ # Security
2
+
3
+ Report a security issue privately through GitHub Security Advisories for
4
+ `deephbz/rarebit`. Do not put credentials, Session content, or Recall files in
5
+ a public issue.
6
+
7
+ For non-sensitive help, use the GitHub issue tracker:
8
+ https://github.com/deephbz/rarebit/issues
9
+
10
+ This alpha has no response-time commitment. Include the Rarebit version, Pi
11
+ version, Node version, and safe reproduction steps.
@@ -0,0 +1,89 @@
1
+ # Rarebit visual language
2
+
3
+ Status: first-version implementation; awaiting cross-surface real-trace ratification
4
+
5
+ This file is the canonical visual guidance shipped with the Rarebit extension. A fork may deliberately replace it. The typed roles, statuses, and reasons in [`src/types.d.ts`](src/types.d.ts) remain the semantic machine contract; [`src/rarebit-visual-language.mjs`](src/rarebit-visual-language.mjs) owns the executable marks, labels, tones, and source-pending attention gate. This document owns perceptual intent and the human-review projection of that mapping. It does not claim every consumer already conforms.
6
+
7
+ ## Marker grammar and preview
8
+
9
+ This single table is the human-review projection and preview of the executable marker grammar. It uses inline HTML, so there is no second authored preview document. Renderers that preserve raw HTML and `style` attributes show the color column; restrictive renderers retain the monochrome-safe column.
10
+
11
+ The scopes are deliberately different: Session-history events are repeatable, time- or sequence-anchored evidence; a Summary status snapshot is one as-of assessment and never becomes an event on that axis.
12
+
13
+ <table aria-label="Official Rarebit marker grammar and preview">
14
+ <thead>
15
+ <tr>
16
+ <th>Scope</th>
17
+ <th>Meaning</th>
18
+ <th>Color</th>
19
+ <th>Monochrome</th>
20
+ <th>Salience</th>
21
+ </tr>
22
+ </thead>
23
+ <tbody>
24
+ <tr>
25
+ <td rowspan="4">Session-history event</td>
26
+ <td>User message</td>
27
+ <td><span style="color: #15803d; font-size: 1.35em">□</span> user message</td>
28
+ <td>□ user message</td>
29
+ <td>standard</td>
30
+ </tr>
31
+ <tr>
32
+ <td>Agent continuation</td>
33
+ <td><span style="color: #2563eb; font-size: 1.1em">•</span> agent continues</td>
34
+ <td>• agent continues</td>
35
+ <td>smaller</td>
36
+ </tr>
37
+ <tr>
38
+ <td>Agent stop</td>
39
+ <td><span style="color: #334155; font-size: 1.35em">●</span> agent stops</td>
40
+ <td>● agent stops</td>
41
+ <td>larger</td>
42
+ </tr>
43
+ <tr>
44
+ <td>Exceptional terminal</td>
45
+ <td><span style="color: #b91c1c; font-size: 1.25em">×</span> terminal error</td>
46
+ <td>× terminal error</td>
47
+ <td>diagnostic</td>
48
+ </tr>
49
+ <tr>
50
+ <td rowspan="5">Summary status snapshot</td>
51
+ <td><code>user_requested</code></td>
52
+ <td><span style="color: #334155">request recorded</span></td>
53
+ <td>request recorded</td>
54
+ <td>ordinary</td>
55
+ </tr>
56
+ <tr>
57
+ <td><code>finished</code></td>
58
+ <td><span style="color: #334155">appears finished</span></td>
59
+ <td>appears finished</td>
60
+ <td>ordinary</td>
61
+ </tr>
62
+ <tr>
63
+ <td><code>needs_attention</code></td>
64
+ <td><span style="color: #9a3412; background: #fff7ed">◆!</span> needs you</td>
65
+ <td>◆! needs you</td>
66
+ <td>attention</td>
67
+ </tr>
68
+ <tr>
69
+ <td><code>ineligible</code></td>
70
+ <td><span style="color: #71717a; font-weight: 300">ineligible</span></td>
71
+ <td><span style="font-weight: 300">ineligible</span></td>
72
+ <td>muted</td>
73
+ </tr>
74
+ <tr>
75
+ <td><code>error</code></td>
76
+ <td><span style="color: #b91c1c">×</span> error</td>
77
+ <td>× error</td>
78
+ <td>diagnostic</td>
79
+ </tr>
80
+ </tbody>
81
+ </table>
82
+
83
+ There is one user-message category, and every selected user message uses the same visual role. The smaller solid continuation dot means work continues. The larger solid stop circle marks a reported response boundary, not verified completion. Supporting intervals paint first, then continuations, stops and errors, and user messages last. Selection adds a halo without replacing the canonical mark.
84
+
85
+ Summary reasons such as `decision`, `blocker`, or `unfinished` are secondary text, never new colors or shapes. Summary prose uses normal body styling. Attention is the only Summary result with a high-salience mark or optional sound. Finished has no green, checkmark, or success treatment because it is an appearance-level Session assessment, not proof that a Task, Project, tool run, or delivery succeeded. Error is diagnostic and never produces the attention sound.
86
+
87
+ Synchronization and applicability qualify a result; they are not additional statuses. Append `· source pending` when applicable, expose detailed sync/applicability in an inspector, and withhold the attention mark and sound until readable native evidence confirms a current result. Never publish `syncing` as a Summary status. Consumers support only the current package projection and don't translate unsupported receipt shapes into visual meaning.
88
+
89
+ Every mark has an accessible text label. Do not rely on color, hover, or sound. A muted monochrome snapshot may use lighter weight or terminal `dim`, but its text must remain readable and meet WCAG 2.2 AA where applicable. Terminal renderers preserve the monochrome mark and label with the closest theme-safe ANSI treatment. Consumers import the package mapping rather than inventing another one, cite this file for perceptual intent, and keep application layout local.
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ RAREBIT_CLI_USAGE,
4
+ parseRarebitCliArgs,
5
+ runRarebitCli,
6
+ } from "../src/rarebit-cli.mjs";
7
+
8
+ try {
9
+ const options = parseRarebitCliArgs(process.argv.slice(2));
10
+ if (options.help) process.stdout.write(`${RAREBIT_CLI_USAGE}\n`);
11
+ else
12
+ process.stdout.write(
13
+ `${JSON.stringify(await runRarebitCli(options), null, 2)}\n`,
14
+ );
15
+ } catch (error) {
16
+ process.stderr.write(
17
+ `${error?.message ?? String(error)}\n${RAREBIT_CLI_USAGE}\n`,
18
+ );
19
+ process.exitCode = 1;
20
+ }
package/package.json ADDED
@@ -0,0 +1,96 @@
1
+ {
2
+ "name": "@hypercarrier/rarebit",
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "Sparse, provenance-bearing conversational evidence recovery for Pi sessions.",
5
+ "license": "MIT",
6
+ "author": "HyperCarrier contributors",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/deephbz/rarebit.git"
10
+ },
11
+ "homepage": "https://github.com/deephbz/rarebit#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/deephbz/rarebit/issues"
14
+ },
15
+ "keywords": [
16
+ "pi-package",
17
+ "rarebit",
18
+ "pi",
19
+ "session"
20
+ ],
21
+ "type": "module",
22
+ "engines": {
23
+ "node": ">=22"
24
+ },
25
+ "types": "./src/types.d.ts",
26
+ "bin": {
27
+ "rarebit": "./bin/rarebit.mjs"
28
+ },
29
+ "scripts": {
30
+ "test": "node --test test/*.test.mjs",
31
+ "test:e2e:summary-cache": "node scripts/e2e-summary-cache.mjs",
32
+ "test:e2e:recall": "node scripts/e2e-recall-pi083.mjs",
33
+ "verify:package": "node scripts/verify-package.mjs"
34
+ },
35
+ "peerDependencies": {
36
+ "@earendil-works/pi-ai": "*"
37
+ },
38
+ "devDependencies": {
39
+ "ajv": "^6.15.0",
40
+ "typescript": "^5.9.3"
41
+ },
42
+ "pi": {
43
+ "extensions": [
44
+ "./src/extension.mjs"
45
+ ]
46
+ },
47
+ "exports": {
48
+ ".": {
49
+ "types": "./src/types.d.ts",
50
+ "import": "./src/index.mjs"
51
+ },
52
+ "./core": {
53
+ "types": "./src/types.d.ts",
54
+ "import": "./src/rarebit-core.mjs"
55
+ },
56
+ "./session": {
57
+ "types": "./src/types.d.ts",
58
+ "import": "./src/rarebit-session.mjs"
59
+ },
60
+ "./service": {
61
+ "types": "./src/types.d.ts",
62
+ "import": "./src/rarebit-service.mjs"
63
+ },
64
+ "./artifact-state": {
65
+ "types": "./src/types.d.ts",
66
+ "import": "./src/rarebit-artifact-state.mjs"
67
+ },
68
+ "./visual-language": {
69
+ "types": "./src/types.d.ts",
70
+ "import": "./src/rarebit-visual-language.mjs"
71
+ },
72
+ "./extension": {
73
+ "types": "./src/types.d.ts",
74
+ "import": "./src/extension.mjs"
75
+ },
76
+ "./types": "./src/types.d.ts"
77
+ },
78
+ "publishConfig": {
79
+ "access": "public",
80
+ "provenance": true
81
+ },
82
+ "files": [
83
+ "bin/rarebit.mjs",
84
+ "src",
85
+ "schemas",
86
+ "scripts",
87
+ "test",
88
+ "README.md",
89
+ "RUNBOOK.md",
90
+ "VISUAL-LANGUAGE.md",
91
+ "AGENTS.md",
92
+ "CHANGELOG.md",
93
+ "LICENSE",
94
+ "SECURITY.md"
95
+ ]
96
+ }