Skip to content

feat(onboarding): autodetect chat sources and first-run setup (#869) - #1116

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/onboarding-turnkey
May 17, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/onboarding-turnkey

Conversation

@Sinity

@Sinity Sinity commented May 17, 2026

Copy link
Copy Markdown
Owner

Summary

Adds polylogue init to make first-run setup turnkey: the command
auto-detects chat-export directories under the user's home and writes
a starter polylogue.toml into XDG_CONFIG_HOME. The bare-status
fallback now points new users at polylogue init until that file
exists, then shifts to polylogued run once a config is present. A
short docs/onboarding.md walks through install → init → daemon →
first search in three commands.

Problem

#869 calls for a fresh install (wheel, Nix package, or source) to
reach a usable archive without reading docs. Today, a new user on a
fresh wheel sees polylogue with no archive and a single-line hint
that says "start the daemon" — but the daemon discovers sources by
walking hard-coded paths and the user has no easy way to learn which
roots Polylogue cares about, whether their tools were detected, or
where the config file would live. The result is doc-driven onboarding.

The acceptance criteria in #869 are broader than this PR: doc
rewrites, ingest-truthfulness, distribution smoke gates, and
backup-boundary docs all remain for follow-up work tracked under
#829/#861/#830/#825/#844. This change owns the "fresh-install →
config exists → first run" slice — the missing seam that the rest
of the doc/UX work assumes is already there. It explicitly does not
modify polylogue ingest, the daemon CLI, or the source discovery
contracts owned by adjacent agents.

Solution

New module polylogue/cli/commands/init.py:

  • detect_chat_sources() enumerates the canonical roots
    (claude-code, codex, gemini-cli, hermes, antigravity,
    hooks) by reusing the same path accessors the live watcher
    consumes via default_sources(). Each candidate carries a
    present flag (no OSError propagation) and a one-line
    description.
  • render_starter_toml() emits a config body that lists detected
    roots under [sources] and writes absent ones as commented hints
    so a later install does not need a doc lookup.
  • init_command exposes the workflow with --dry-run, --force,
    and --format json. The text mode prints a per-source checklist
    and a three-step next-action summary; the JSON mode exposes
    present_families, the rendered body, and a written boolean
    for scripted setup.

polylogue/cli/commands/status.py:

  • _show_direct_status now distinguishes "no archive, no config"
    (suggests polylogue init) from "no archive, config present"
    (suggests polylogued run).
  • _show_direct_json exposes config_exists, config_path, and a
    next_action field so machine readers see the same routing
    decision.

polylogue/cli/click_command_registration.py:

  • Adds init to the lazy root-command registry and its short-help.

docs/onboarding.md:

  • Documents install → polylogue init → polylogued run → search,
    surfaces polylogue doctor as the recovery entry point, and
    links to daemon.md / internals.md for deeper recovery.

Generated surfaces (docs/cli-reference.md, docs/plans/topology-target.yaml,
docs/topology-status.md, docs/test-quality-workflows.md,
docs/verification-catalog.md, AGENTS.md) are refreshed via
devtools render-all to keep the catalogs in sync.

Out of scope (deliberately, per issue dependency list):

The existing doctor command already covers FTS-trigger / schema /
blob recovery; this PR points users at it from docs/onboarding.md
rather than re-implementing recovery logic in init.

Verification

Commands run:

nix develop -c pytest tests/unit/cli/test_init.py -x -q
# 10 passed in 8.15s
nix develop -c pytest tests/unit/cli/test_click_app.py tests/unit/cli/test_init.py \
  tests/unit/cli/test_help_contract.py tests/unit/cli/test_check.py -q
# 217 passed in 9.62s
nix develop -c devtools verify --quick
# total_duration_s: 20.81, exit_code: 0
nix develop -c devtools render-all --check
# all generated surfaces sync OK
nix develop -c polylogue init --help
# command appears in the registry with the expected flags

The init test module covers detection (missing/present roots), TOML
rendering (active vs commented entries), --dry-run, --force,
existing-file preservation, JSON output, and the new status hint
behavior before/after init runs.

Ref #869

Adds `polylogue init`, which scans the canonical chat-export roots
under the user's home directory (Claude Code, Codex, Gemini CLI,
Hermes, Antigravity, and the agent hook sidecar) and writes a starter
polylogue.toml into XDG_CONFIG_HOME. Both the CLI and the daemon read
the same file, so a fresh install reaches a usable archive without
needing to read docs.

The bare `polylogue` status fallback now distinguishes "no archive,
no config" (suggests `polylogue init`) from "no archive, config
present" (suggests `polylogued run`) so the next action is always one
copy-paste away. The direct-mode JSON status fallback exposes the
same `next_action` field for machine readers.

docs/onboarding.md walks through install → init → daemon → first
search in three commands, and surfaces `polylogue doctor` as the
recovery handle for FTS / schema / blob issues.

Ref #869

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 17, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 4 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 76b3c401-b8da-4131-a13e-e0b2e3175430

📥 Commits

Reviewing files that changed from the base of the PR and between 109ccfd and f8c43a1.

📒 Files selected for processing (12)
  • AGENTS.md
  • docs/cli-reference.md
  • docs/onboarding.md
  • docs/plans/topology-target.yaml
  • docs/test-quality-workflows.md
  • docs/topology-status.md
  • docs/verification-catalog.md
  • polylogue/cli/click_command_registration.py
  • polylogue/cli/commands/init.py
  • polylogue/cli/commands/status.py
  • tests/unit/cli/test_click_app.py
  • tests/unit/cli/test_init.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/onboarding-turnkey

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity
Sinity merged commit 3103d05 into master May 17, 2026
3 checks passed
@Sinity
Sinity deleted the feature/feat/onboarding-turnkey branch May 17, 2026 00:20

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f8c43a1be4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/cli/commands/init.py Resolved
Sinity added a commit that referenced this pull request May 17, 2026
…1126)

## Summary

Rewrites the project README around a new visitor's path of attention:
a single-sentence pitch, a 30-second install-to-first-search tour using
the current `polylogue init` + `polylogued run` flow, and a value-prop
section explaining the corpus framing. Surfaces the architecture
diagram that `devtools render-readme-media` already produces.

## Problem

The previous README opened with operator-shaped quickstart instructions
(`direnv allow`, `nix run`, `devtools lab-corpus seed`) and led with the
source checkout flow. A new visitor arriving from a link had no
one-line "what is this," no end-user install path, no `polylogue init`
reference (PR #1116), and no visual anchor for the architecture
despite `docs/media/` already carrying rendered Mermaid diagrams.

Issue #952 asked for a README revamp plus an assurance-visual pipeline
(screencasts + extension screenshots). Issue #1082 / PR #1096 then
established the policy that committed screenshots and VHS tapes are
not desirable — they drift faster than the code. The README revamp can
still happen; visuals stay on the on-demand rendering path through
`devtools render-readme-media`.

## Solution

`README.md` rewritten:

- New opener: bold one-sentence pitch, paragraph explaining the system,
  three-bullet value prop (local-first, source-agnostic, idempotent).
- New "30-second tour" using the production path: `pip install` →
  `polylogue init` → `polylogued run --enable-api` → `polylogue
  "query"` → `polylogue --latest open`. Links to
  `docs/onboarding.md`.
- New "Why this exists" section frames Polylogue as a corpus layer,
  not an operator tool.
- New "Architecture at a glance" section embeds
  `docs/media/architecture-overview.svg` (already rendered by
  `devtools render-readme-media`), keeps the ASCII data-flow as a
  text-renderable fallback, and links the on-demand media policy
  (`docs/media/README.md`).
- "Installing from source" demoted into its own section so the first
  install instruction a new visitor sees is `pip install polylogue`,
  not `direnv allow`.
- "Synthetic demo" demoted to a subsection under source install.
- Surfaces section reordered around current CLI: web reader → MCP →
  browser capture → Python API.
- Generated `docs-surface` block preserved unchanged
  (`devtools render-docs-surface --check` confirms).

No committed binary screenshots or VHS tapes were added — the existing
SVG architecture diagram is the only embedded visual and is regenerated
deterministically from `devtools/generate_readme_media.py`.

Inherited stale generated surface (`docs/topology-status.md`) was
regenerated in a separate commit so the pre-push gate passes; that
drift came from a previously landed PR adding a module without
refreshing the rendered surface, not from this README work.

`Ref #952` rather than `Closes` — the issue's screencast/extension
screenshot acceptance criteria were superseded by the #1082/#1096
policy decision and the README is now the readable-by-new-visitor
artifact the issue asked for, but a future visual-rendering pass
(if any beyond the existing Mermaid diagrams) would still belong to
#952.

## Verification

```
nix develop -c devtools render-readme-media --check
  Wrote 4 .mmd source(s) in docs/media

nix develop -c devtools render-docs-surface --check
  render-docs-surface: sync OK

nix develop -c devtools verify --quick
  exit_code: 0   (after regenerating docs/topology-status.md, which
                  was inherited stale on master)
```

`docs/media/architecture-overview.svg` is unchanged on disk — the
README now references the existing rendered diagram. No new binary
assets were committed.

Ref #952
Ref #1082
Ref #1116

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sinity added a commit that referenced this pull request May 17, 2026
…829) (#1143)

## Summary

Establishes the five-layer config precedence chain described in #829
(defaults → site → user → env → CLI) and surfaces layer provenance
through `polylogue config --show-layers`.

## Problem

`polylogue/config.py` already had a `PolylogueConfig` loader that read a
single TOML and `POLYLOGUE_*` env vars, but it did not match the
contract in #829 in three ways:

1. No site-wide config layer. Issue specifies
   `/etc/polylogue/polylogue.toml` so packaging can ship defaults that
   are themselves overridable per user.
2. No provenance. Operators could read the resolved values but had no
   way to ask "which layer did this come from?" — the very question
   #829 calls out for `polylogue config --show-layers`.
3. The `config` CLI command did not expose layer information at all.

## Solution

`polylogue/config.py`:
- Adds `DEFAULT_SITE_CONFIG_PATH = /etc/polylogue/polylogue.toml` and
  `_site_config_path()` with a `POLYLOGUE_SITE_CONFIG` override (empty
  string disables, e.g. for tests and ephemeral environments).
- Splits the loader into a pure `_default_config_values()` and an
  `_apply_toml_layer()` helper that records which keys each layer
  actually changed.
- `load_polylogue_config(site_config_path=..., config_path=...,
cli_overrides=...)`
  now walks defaults → site TOML → user TOML → env → CLI in order and
  builds a `layers` map alongside the resolved values.
- `PolylogueConfig` gains `layers` (dict) and `layer_of(key)` accessors;
  malformed TOML is swallowed silently so a broken site config cannot
  brick the CLI.
- `describe_config_layers()` returns a JSON-friendly view of the
  resolved site and user config paths plus existence flags, used by
  `polylogue config --show-layers`.

`polylogue/cli/commands/config.py`:
- Adds `--show-layers` to the existing `polylogue config` command.
- Emits the layer descriptor + per-key `{value, layer}` map in either
  TOML or JSON (both via `console.print(..., markup=False)` so JSON and
  TOML headers survive Rich markup parsing).

`tests/unit/core/test_config.py`:
- `TestPolylogueConfigLayerPrecedence` covers every transition
  (default → site → user → env → CLI), the missing-file fallthrough,
  and the malformed-TOML graceful fallback.
- `TestDescribeConfigLayers` covers the structured report including
  the `POLYLOGUE_SITE_CONFIG=""` disable case.

The inherited `init`-command snapshot drift on master (#1116 landed
without refreshing
`tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr`)
is included so `pytest tests/unit/cli/test_terminal_snapshots.py` is
green again on this branch.

## Verification

```
nix develop -c devtools verify --quick
# total_duration_s 20.29, exit_code 0

nix develop -c pytest tests/unit/core/test_config.py -q
# 81 passed in 7.88s

nix develop -c pytest tests/unit/cli/test_terminal_snapshots.py -q
# 9 passed in 8.48s

POLYLOGUE_SITE_CONFIG='' POLYLOGUE_API_PORT=9999 \
  POLYLOGUE_FORCE_PLAIN=1 nix develop -c polylogue config --show-layers
# api_port = 9999  # layer = env
```

Ref #829

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 61.F021 / P2: fixed-already at the checked revision: polylogue/cli/commands/init.py:159 captures existed_before before writing the file. The already-exists branch checks that captured value at line 205, leaving a fresh successful write on the success/next-steps path.

Only the rows listed above are dispositioned. Held findings remain open.

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