Skip to content

feat(cli): self-inspection surfaces — settings, cross-session recall, build identity - #889

Merged
huichen merged 8 commits into
mainfrom
feat/self-inspect
Oct 1, 2026
Merged

huichen merged 8 commits into
mainfrom
feat/self-inspect

Conversation

@huichen

@huichen huichen commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

DRAFT — awaiting review. Auto-merge is off; do not merge without the author's go-ahead.

What

Five things that let an agent (or a person) inspect and adjust this installation:

  1. future config get|set — read/write the global settings document
  2. future session history search --all — cross-session recall
  3. future version --json — which commit/target this binary is
  4. get_agent_info — the same build identity for the running Agent
  5. future-self skill — the agent-facing layer, now with the account surface
    folded in (skills submodule → feat(self): fold the account skill into future-self future-skills#63)

1. future config get|set

future config get                                   # effective settings + defaults
future config get defaultPermissionLevel            # one value, bare, for scripts
future config set defaultPermissionLevel workspace  # change one key

get reads through the Agent's typed Settings loader, so it reports what the
Agent would apply, not what the file literally contains (an omitted key still
shows its documented default). set edits the JSON document in place and
validates only the value it writes, so keys a newer build wrote — or a hand edit
added — survive untouched; an invalid value or unknown key leaves the file
byte-identical (the tests assert that). Neither needs a running Agent. Nested
keys keep the file's real spelling (compaction.reserve_tokens,
retry.max_retries — snake_case inside camelCase top level), round-tripped
through future_agent::load_settings in tests.

2. future session history search --all

The same literal search across the --sessions most recently updated sessions
(1..500, default 50) instead of one. Each match carries its sessionId; the
response reports scannedSessions and truncated, so a bounded scan is visible
rather than silently reported as "never discussed". --session/--all are
mutually exclusive; --sessions requires --all.

Agent side: optional int64 max_sessions = 147 (regenerated proto),
HISTORY_DEFAULT_SESSIONS/HISTORY_MAX_SESSIONS, registered as a bounded safe
read, and — the point — the per-session match SQL extracted into a shared helper
so the two searches cannot drift in fields, snippet trimming, character-boundary
handling or byteOffset.

3 + 4. Build identity

A version string cannot identify code: a release tag (1.2.3) and a coordinated
test/nightly build (0.0.2-<run>+test) carry no commit, and a dev build only
an abbreviated hash.

future version --json
# version, isRelease, bundleVersion, gitCommit, gitCommitShort, gitDirty,
# buildTarget, buildProfile

Bare future version / future --version still print exactly the old string.
get_agent_info gained the same fields (payload fields are Option; absent →
null, never a placeholder mistakable for a commit name), so a client can
compare the running Agent against a checkout — the check that has to happen
before attributing behaviour to source.

Both build scripts watch the git ref (HEAD, branch ref, packed-refs via
git rev-parse --git-path, which resolves a checkout and a worktree alike).
This is load-bearing, not hygiene: a rerun-if-* directive suppresses
Cargo's default "any package file changed" rule, so without the watch a rebuild
after committing keeps reporting the previous commit. Verified both ways —
disabling the watch and moving HEAD left the binary reporting the old hash.

5. Skill

Submodule bump to futuregene/future-skills#63: future-self v1.2.0, which
documents all of the above as the agent-facing entry point, folds the retired
future-account into §3 (with the remote/credential caveats and "a low balance
is reported, not remedied"), and keeps the discipline the surfaces need — never
read auth.json; never claim a negative a truncated/hasMore response cannot
support; ask before changing settings; reading code is for understanding, never
for patching.

Cross-crate checks worth noting

  • desktop/src-tauri/src/agent_bridge/client.rs builds proto::RpcCommand as an
    exhaustive literal (the only such site outside the agent), so the new proto
    field breaks it. Verified the failure first (missing field max_sessions,
    E0063), then the fix; checked in place with make desktop-sidecar-placeholder
    since that crate is not a workspace member.
  • packages/rpc encode/decode handlers for AgentInfo gained the fields, so the
    typed payload and the JSON view stay in step.

Docs

New bilingual docs/guide/self-inspection.md; --all in the session-history
guide; settings.json in the directory-layout guide; the wiki CLI page covers
the settings subcommands, --all, future version, and the account semantics.

Verification

cargo fmt -p future-agent -p future-cli -p future-rpc --check   # ok
cargo clippy -p future-rpc -p future-agent -p future-cli --all-targets -- -D warnings
cargo test -p future-agent -p future-cli -p future-rpc          # 2091 / 779 / … pass
cargo check -p future-tui -p future-channel -p future-loop      # ok
(cd desktop/src-tauri && cargo check --lib)                     # ok
(cd skills && python3 tests/run_offline.py)                     # PASS: 16 builtin entries
python3 scripts/docs/check-docs.py                              # 251 docs OK

…ession recall

The agent can already read its own configuration, sessions, skills and recorded
conversations through the CLI, but two gaps stopped that from answering the
questions a personal agent actually asks: the global settings document had no
read/write entry point, and history search was scoped to one session, so "have
we ever discussed this" required knowing which session first.

`future config get|set` — the settings document, without an Agent:

- `get` reads through the Agent's typed loader, so it reports the value the
  Agent would apply rather than what the file literally contains: a key the file
  omits still shows its documented default. A single key prints bare.
- `set` edits the JSON document in place and validates only the value it writes,
  so keys a newer build wrote (or a hand edit added) survive untouched, and an
  invalid value or unknown key leaves the file exactly as it was.
- `--json` on either side. No credential material is ever part of this surface.

`future session history search --all` — the same literal search across the
`--sessions` most recently updated sessions (1..500, default 50) instead of one.
Every match carries its `sessionId`, and the response reports `scannedSessions`
and `truncated`, so a bounded scan is visible rather than silently reported as
"never discussed". Wired as a new `search_all_session_history` command: an
`optional int64 max_sessions = 147` on `RpcCommand`, `HISTORY_DEFAULT_SESSIONS`/
`HISTORY_MAX_SESSIONS` on the manager, and the per-session match SQL shared with
the single-session search so fields, snippets and byte offsets stay identical.

Also: the desktop's exhaustive `proto::RpcCommand` literal gains the new field
(it is the one consumer that enumerates every field; verified that its absence
fails to compile), and the bundled `future-self` skill is bumped to the release
that documents all of this — including reading the agent's own implementation,
which is what turns "the agent seems to ignore X" into an answer.

Docs: new bilingual guide `docs/guide/self-inspection.md`, `--all` documented in
the session-history guide, and the wiki CLI page updated.
@huichen
huichen enabled auto-merge (squash) October 1, 2026 09:38
@huichen
huichen disabled auto-merge October 1, 2026 09:44
@huichen

huichen commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Withdrawn for local review at the user's request. The branch stays at feat/self-inspect (worktree: .worktrees/self-inspect); re-open or recreate the PR when it is ready to land. Auto-merge was disabled.

@huichen huichen closed this Oct 1, 2026
A version string cannot identify the code. A release tag (`1.2.3`) and a
coordinated test/nightly build (`0.0.2-<run>+test`) contain no commit at all,
and a local dev build only an abbreviated hash — so "is the binary I am running
the commit I am reading?" had no answer, and neither did "which target was this
built for?".

Both build scripts now embed the build identity alongside the display version
(`FUTURE_GIT_COMMIT`, `FUTURE_GIT_COMMIT_SHORT`, `FUTURE_GIT_DIRTY`,
`FUTURE_BUILD_TARGET`, `FUTURE_BUILD_PROFILE`), and it is surfaced on both sides:

- `future version --json` reports version, isRelease, bundleVersion, gitCommit,
  gitCommitShort, gitDirty, buildTarget, buildProfile. Bare `future version`
  still prints exactly what `future --version` always printed, so existing
  callers are unaffected. `cli/src/version.rs` also gains `is_release` /
  `bundle_version`, which only `scripts/version.mjs` had.
- `get_agent_info` gains the same fields, so a client can compare the *running*
  Agent against a checkout or against the CLI — the check that has to happen
  before attributing behaviour to source. The payload fields are `Option`, and
  absent/empty maps to `null`, not to a placeholder a caller could mistake for a
  commit name.

The build scripts also watch the git ref (`HEAD`, the branch ref, `packed-refs`
via `git rev-parse --git-path`, which resolves a checkout and a worktree alike).
This is load-bearing, not hygiene: a `rerun-if-*` directive suppresses Cargo's
default "any package file changed" rule, so without the watch a rebuild after
committing keeps reporting the *previous* commit — verified by disabling the
watch and watching HEAD move while the binary still reported the old hash.

Also folds the account surface into `future-self` (skills submodule bump to
futuregene/future-skills#63, which retires `future-account`) and documents
`future version --json` plus the merged account guidance in the bilingual
self-inspection guide and the wiki CLI page.
@huichen huichen reopened this Oct 1, 2026
@huichen
huichen marked this pull request as draft October 1, 2026 10:07
@huichen huichen changed the title feat(cli): self-inspection surfaces — settings read/write and cross-session recall feat(cli): self-inspection surfaces — settings, cross-session recall, build identity Oct 1, 2026
The guide told the reader to read the implementation without saying where it
lives. Name the checkout repository (github.com/futuregene/future-os) and the
skills repository (futuregene/future-skills, the `skills/` submodule), and keeps
the boundary that follows: no checkout means say so rather than answer from
memory.
CI caught what my local pass missed: `cargo check -p future-tui` (no
`--all-targets`) does not compile test code, and the only other exhaustive
`proto::AgentInfo` literal lives in a TUI test. Adding the identity fields broke
it with E0063 while the lib checked clean — the same trap whose clippy variant
is already called out in CLAUDE.md, applied to `check`.

The test now also sets and asserts the identity fields, so the decode path they
travel (typed payload → JSON object) is covered rather than merely compiling: a
client comparing the running Agent against a checkout must not silently read the
stale JSON `data` fallback instead of the real commit.

Also corrects `future tools` in the self-inspection guide/skill: it lists the
platform and browser tools the CLI can invoke, not the model's own
`read`/`write`/`edit`/`shell`, which are set per session or per run. Found by
running the skill's own commands against a real agent — `future tools describe
shell` fails with "Tool not found", which the old wording would have made look
like a broken install.

Skills pointer -> futuregene/future-skills#65 (future-self v1.3.1).
@huichen
huichen marked this pull request as ready for review October 1, 2026 11:15
@huichen
huichen enabled auto-merge (squash) October 1, 2026 11:15
@huichen
huichen disabled auto-merge October 1, 2026 11:15
@huichen
huichen enabled auto-merge (squash) October 1, 2026 11:16
@huichen
huichen merged commit c545f1e into main Oct 1, 2026
12 checks passed
@huichen
huichen deleted the feat/self-inspect branch October 1, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant