be4fter 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Be4fter 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 CHANGED
@@ -1,3 +1,115 @@
1
- # Temporary Holding Version
1
+ # Be4fter
2
+
3
+ Be4fter gives your coding agent persistent project memory. When it returns tomorrow, one command shows the goal, the current task and what still needs proof. If a later edit invalidates a passing check, the release report marks that evidence stale.
4
+
5
+ The local Rust CLI makes **zero model calls**. On the greeting example, its task handoff uses **53 tokens** and its status uses **51 tokens** with the `o200k_base` tokenizer. These measurements cover the CLI output for that fixture.
6
+
7
+ ![A terminal session initializes a greeting project, completes and verifies a task, detects stale evidence after an edit and restores the verified files.](https://raw.githubusercontent.com/timeqx/Be4fter/main/docs/demo.gif)
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npx be4fter@0.1.0 init
13
+ ```
14
+
15
+ For a persistent command use `npm install -g be4fter@0.1.0`. The package includes native binaries for x64 and ARM64 on Windows, macOS and Linux. Linux builds target glibc. [Release downloads](https://github.com/timeqx/Be4fter/releases/tag/v0.1.0)
16
+
17
+ ## Run it locally
18
+
19
+ From this checkout, build a standalone executable with Rust 1.89 or newer.
20
+
21
+ ```powershell
22
+ cargo build --release --locked
23
+ .\target\release\be4fter.exe --help
24
+ ```
25
+
26
+ On macOS and Linux, use `./target/release/be4fter`. To put the command on your Cargo bin path, run `cargo install --path . --locked`. Git is needed for checkpoints. Planning and verification also work in an ordinary directory. Check commands use the tools installed in the project environment.
27
+
28
+ The npm launcher supports Node 18 and newer. Build a package for your current machine with `npm run build` followed by `npm pack`. Install the resulting file with `npm install -g ./be4fter-0.1.0.tgz`. A packaged native binary runs directly without a Rust toolchain.
29
+
30
+ ## First project
31
+
32
+ In the project you want to track, run the following command.
33
+
34
+ ```sh
35
+ be4fter init --goal "Greet the reader by name."
36
+ ```
37
+
38
+ Initialization inspects the repository, appends a small section to `AGENTS.md` and installs the skill at `.agents/skills/be4fter/SKILL.md`. Rerunning it preserves your blueprint, tasks, custom skill and instructions. A Git worktree gets a baseline checkpoint. In a new folder, run `git init` first if you want recovery from the beginning.
39
+
40
+ Add more criteria with `be4fter requirement add "A blank name receives a default greeting"`. Link work with `be4fter task add "Handle a blank name" --requirement R002`. When the project has one requirement, you can omit the ID. New requirements start with manual verification. Set `checks` and `inputs` in the blueprint for automated evidence.
41
+
42
+ For a runnable, single-task example, copy `greet.mjs` and `greet.test.mjs` into a fresh project and copy the two example JSON files into its initialized `.be4fter/` directory. [Greeting fixture](examples/greeting)
43
+
44
+ ```sh
45
+ be4fter plan
46
+ be4fter approve "Reviewed the greeting criterion and its Node test"
47
+ be4fter before T001
48
+ be4fter context
49
+ be4fter after T001
50
+ be4fter check
51
+ be4fter report
52
+ ```
53
+
54
+ The example finishes with one completed task, one verified requirement and a ready report. Change `greet.mjs` afterward and the report shows stale evidence. Run `check` again to see the new result.
55
+
56
+ ## Everyday commands
57
+
58
+ | Command | Effect |
59
+ | --- | --- |
60
+ | `init [--goal TEXT] [--mode MODE]` | Inspect project structure, documentation, stack, Git status and candidate checks. A goal seeds a single task and requirement. |
61
+ | `plan`, `approve "reason"` | Review the draft, including check commands and the previous approved scope. Approval appends a dated revision. |
62
+ | `requirement add TEXT`, `task add TEXT [--requirement ID]` | Add an observable criterion or link a task to an existing requirement. |
63
+ | `decide "text"` | Record a local decision for the report. |
64
+ | `status`, `next`, `context` | Show completion, the next actionable task or a compact handoff. Active work comes first. |
65
+ | `before T001`, `after T001` | Start work and capture checkpoints. Finishing runs the task's automated checks. Failed checks keep the task in progress. |
66
+ | `checkpoint "label"`, `history`, `diff [ID]` | Save or list recovery points and inspect the working-file delta since a checkpoint. The default diff uses the latest point. |
67
+ | `restore ID --preview`, `restore ID --apply` | Inspect changes, then explicitly confirm recovery. A bare restore previews. |
68
+ | `review R001 pass review.txt` | Record a human-reviewed result with a nonempty evidence file. Use `fail` for an unsuccessful review. |
69
+ | `check`, `report` | Run approved checks or print a read-only Markdown readiness report. |
70
+
71
+ Commands find the enclosing Be4fter project. New Git projects initialize at the worktree root. Paths in the plan and review commands are relative to that root. Exit code 0 means success, 1 means checks or readiness are incomplete, and 2 indicates an invalid command, invalid project state or operational error.
72
+
73
+ ## Verification and project memory
74
+
75
+ Each requirement has an ID, title, criterion and a list of command argument arrays. For example, `"checks": [["cargo", "test"], ["cargo", "build", "--release"]]`. An empty list requires human review. An agent records a manual result only when a reviewer has supplied the outcome and evidence. Review commands and their underlying project scripts before executing a blueprint from another source.
76
+
77
+ Optional `inputs` entries name eligible files or directories. Include the implementation, tests, relevant configuration and lockfiles. Omitting inputs fingerprints the whole eligible project. Use forward slashes. Fingerprints include file names, content and executable mode, independent of Git commits or file timestamps. The report checks freshness again, including the contents of manual evidence. A check that changes its own inputs needs a clean rerun. Command output goes to the terminal. The local evidence record keeps the argument list, exit result, timestamp and fingerprint.
78
+
79
+ A release needs an approved blueprint, all tasks done and current passing evidence for every requirement. Blueprints keep their approval history in `.be4fter/approvals.json`. Editing a criterion or command makes the plan a draft until the revision is approved. Keep the blueprint, approvals, tasks and config under version control. Detection, decisions, verification results and the process lock live under the ignored `.be4fter/local/`. Run `init` after cloning to provision that checkout.
80
+
81
+ Review the blueprint and any referenced project scripts in each fresh checkout, then run `approve` before running automated checks. Approval is stored in the private Git worktree directory, or in the current user's local state directory for projects outside Git. Reconfirming an unchanged blueprint preserves its scope history.
82
+
83
+ The default `auto` mode uses quick for at most one task and one requirement, and standard for larger plans. Strict mode also requires task coverage for every requirement, at least one automated check and Git checkpoints for task transitions. Choose a mode during initialization or edit `.be4fter/config.json` later.
84
+
85
+ ## Checkpoints and recovery
86
+
87
+ Checkpoints capture eligible working files, including staged, unstaged and untracked work from anyone using the repository. Be4fter hashes the working bytes, builds a tree with a temporary Git index and retains it under `refs/worktree/be4fter/`. The normal branch and index stay intact. The default retention is 20 points per worktree. Adjust `keep_checkpoints` in the config. Expiring a ref lets Git reclaim unreferenced objects during its normal garbage collection.
88
+
89
+ The file set includes regular files with supported UTF-8 relative paths. Git ignore rules apply even to tracked files. Common credential names, key files, build directories, nested repositories, linked files and Be4fter's own state are excluded. Add project-specific secret locations to Git ignore rules before the first checkpoint. A file with credentials embedded under an ordinary source name can still enter a checkpoint. Outside Git, verification uses built-in exclusions and any explicit requirement inputs.
90
+
91
+ Restore lists each creation, replacement and removal. Applying it checkpoints the current files before the first write and checks each destination again. A collision with an ignored file, link or directory stops recovery. File-to-directory replacements need manual resolution. If a write fails partway through, the CLI names the pre-restore point. Unix executable bits and file contents are captured. Empty directories, ACLs and extended metadata are outside the snapshot.
92
+
93
+ ## Tests, packaging and token budget
94
+
95
+ ```sh
96
+ cargo test --locked
97
+ cargo clippy --all-targets --locked -- -D warnings
98
+ npm run build
99
+ npm run test:package
100
+ ```
101
+
102
+ The package test installs the generated tarball offline and exercises the greeting example through the installed npm command. The CI matrix builds and tests x64 and ARM64 on Windows, macOS and Linux. It collects six standalone binaries and assembles a single npm tarball with a platform-selecting launcher. The workflow produces downloadable artifacts. Registry publication and public releases are separate maintainer actions.
103
+
104
+ The greeting fixture measured 83 tokens for the persistent agent instructions, 362 for the installed skill, 51 for status and 53 for current task context with the `o200k_base` tokenizer. These counts cover the text emitted for that fixture. Actual agent context also depends on the client and the project text. Be4fter itself makes zero model calls and starts no background service.
105
+
106
+ Reproduce the measurement after a release build. On Windows append `.exe` to the binary path.
107
+
108
+ ```sh
109
+ cargo run --manifest-path bench/Cargo.toml --locked --target-dir target/bench -- target/release/be4fter
110
+ ```
111
+
112
+ MIT licensed. [License](LICENSE)
113
+
114
+ This project tracks its own release in [.be4fter](.be4fter). See the [client compatibility results](docs/agent-compatibility.md), [contributing guide](CONTRIBUTING.md) and [security policy](SECURITY.md).
2
115
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
@@ -0,0 +1,12 @@
1
+ {
2
+ "goal": "Greet the reader by name.",
3
+ "constraints": ["Run offline."],
4
+ "non_goals": ["Account management"],
5
+ "requirements": [{
6
+ "id": "R001",
7
+ "title": "Personal greeting",
8
+ "criterion": "Calling greet('Ada') returns 'Hello, Ada!'.",
9
+ "checks": [["node", "--test", "greet.test.mjs"]],
10
+ "inputs": ["greet.mjs", "greet.test.mjs"]
11
+ }]
12
+ }
@@ -0,0 +1,4 @@
1
+ export function greet(name) {
2
+ return 'Hello, ' + name + '!';
3
+ }
4
+
@@ -0,0 +1,7 @@
1
+ import assert from 'node:assert/strict';
2
+ import test from 'node:test';
3
+ import { greet } from './greet.mjs';
4
+
5
+ test('greets the named reader', () => {
6
+ assert.equal(greet('Ada'), 'Hello, Ada!');
7
+ });
@@ -0,0 +1,8 @@
1
+ [
2
+ {
3
+ "id": "T001",
4
+ "title": "Implement the greeting",
5
+ "requirements": ["R001"],
6
+ "status": "pending"
7
+ }
8
+ ]
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from 'node:child_process';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const target = process.platform + '-' + process.arch;
6
+ const name = process.platform === 'win32' ? 'be4fter.exe' : 'be4fter';
7
+ const binary = fileURLToPath(new URL('../native/' + target + '/' + name, import.meta.url));
8
+ const result = spawnSync(binary, process.argv.slice(2), { stdio: 'inherit' });
9
+
10
+ if (result.error) {
11
+ console.error('be4fter: cannot launch ' + target + ' binary (' + result.error.message + ').');
12
+ process.exitCode = 2;
13
+ } else if (result.signal) {
14
+ process.kill(process.pid, result.signal);
15
+ } else {
16
+ process.exitCode = result.status;
17
+ }
Binary file
Binary file
Binary file
Binary file
Binary file
package/npm/stage.mjs ADDED
@@ -0,0 +1,24 @@
1
+ import { accessSync, chmodSync, constants, copyFileSync, mkdirSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const root = fileURLToPath(new URL('../', import.meta.url));
6
+ const host = process.platform + '-' + process.arch;
7
+ const targets = ['win32-x64', 'win32-arm64', 'darwin-x64', 'darwin-arm64', 'linux-x64', 'linux-arm64'];
8
+ const flag = process.argv[2];
9
+
10
+ for (const target of flag === '--check-all' ? targets : [host]) {
11
+ const binary = target.startsWith('win32-') ? 'be4fter.exe' : 'be4fter';
12
+ const dest = join(root, 'npm', 'native', target, binary);
13
+ if (!flag) {
14
+ mkdirSync(dirname(dest), { recursive: true });
15
+ copyFileSync(join(root, 'target', 'release', binary), dest);
16
+ chmodSync(dest, 0o755);
17
+ } else {
18
+ try {
19
+ accessSync(dest, !target.startsWith('win32-') && process.platform !== 'win32' ? constants.X_OK : constants.R_OK);
20
+ } catch {
21
+ throw new Error('Missing or non-executable ' + target + ' binary. Build and stage the native artifacts before packaging.');
22
+ }
23
+ }
24
+ }
package/package.json CHANGED
@@ -1,6 +1,19 @@
1
1
  {
2
2
  "name": "be4fter",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Local project memory, recovery checkpoints and requirement verification for coding agents",
5
+ "license": "MIT",
6
+ "repository": { "type": "git", "url": "git+https://github.com/timeqx/Be4fter.git" },
7
+ "bugs": "https://github.com/timeqx/Be4fter/issues",
8
+ "type": "module",
9
+ "bin": { "be4fter": "npm/bin/be4fter.js" },
10
+ "engines": { "node": ">=18" },
11
+ "files": ["npm/bin", "npm/native", "npm/stage.mjs", "examples/greeting", "LICENSE", "README.md"],
12
+ "scripts": {
13
+ "build": "cargo build --release --locked && node npm/stage.mjs",
14
+ "test": "cargo test --locked",
15
+ "test:package": "node --test tests/package.test.mjs",
16
+ "prepack": "node npm/stage.mjs --check-host",
17
+ "prepublishOnly": "node npm/stage.mjs --check-all"
18
+ }
19
+ }