Commit Graph
127 Commits
Author SHA1 Message Date
weichen 2c7f55bfe8 Document svc.sh comprehensively and layer its help system
Why:
svc.sh grew into a three-kind service manager with database operations,
but its only documentation was a flat --help wall of text; the user asked
for a complete usage document and a better help experience.

Evidence:
- docs/svc.md: 14-section manual (prerequisites, quick start, concepts
  and directory layout, per-command reference for service/global/db
  commands, deploy sources, database operations handbook, configuration
  layering, registry fields and event types, safety boundaries, exit
  codes, troubleshooting table, recipe index) — every claim cross-checked
  against the implementation from the previous two rounds.
- Help layering: no-args and -h print a one-screen overview; --help
  renders the header comment reorganized into 7 labeled sections; the new
  "help [topic]" command deep-dives eight topics (model, deploy,
  lifecycle, db, dbops, config, examples, safety); usage errors now show
  the short overview plus a pointer to --help / help / docs/svc.md.
  All topics verified to render; unknown topic exits 2.
- No runtime behavior changed: end-to-end db lifecycle regression
  (create → start → backup → status → stop → rm --purge) passes after the
  refactor.
- Makefile help and README's documentation section point to docs/svc.md.

Impact:
Documentation-only plus display-layer changes; command semantics,
exit codes and file formats are untouched. Maintenance note: behavior
changes must now update both --help and docs/svc.md.

Refs: .task/feature-svc-docs-help.md(任务卡=PR 描述)
2026-09-30 14:29:39 +00:00
weichen 96dfac6bc4 Record the task card for feature-svc-docs-help 2026-09-30 14:17:54 +00:00
weichen dc24d6d612 Close 1 merged task card(s) and archive them
ci / test (pull_request) Failing after 1m37s
Why: branches merged into main had left their task cards open; backfill status and archive to prevent bookkeeping debt.
Evidence: feature-svc-db-ops.md(PR#59) — merges verified via git log --merges against origin/main.
Impact: .task/*.md moved to .task/archive/ with status backfilled; no code or submodule change.
Refs: task.sh close (card-autoclose-r1)
2026-09-30 14:12:13 +00:00
weichen 9bbbdf22ac Record the sync checkpoint
ci / test (pull_request) Failing after 1m40s
2026-09-30 14:11:30 +00:00
weichen 69871136e5 Add db ops to svc.sh: port change, backup, restore, clone, cross-instance copy
Why:
The service manager could create and run postgres instances but had no
way to retarget a port explicitly, back data up, clone an instance to
another port, or move a database between instances — the user asked for
exactly these operations.

Evidence:
- "set <name> [--port N] [--host H] [--apply] [--tag T...]": explicit
  registration change; running postgres requires --apply (stop → rewrite
  registration → start); port availability checked against both
  registrations and live listeners. Verified: 8890→8895 with data intact
  and DSN updated, old port freed; refusal without --apply.
- "db backup <name> [--db X] [--out F]": pg_dump -Fc into
  runtime/<name>/backups/ (0600) with pg_restore --list self-check;
  "db backups" lists them.
- "db restore <name> --file F [--db X] [--force]": restores into a new db
  or refuses on a non-empty target unless --force (drop with FORCE +
  recreate + restore), reporting table counts afterwards. Verified all
  three paths.
- "db clone <src> <dst> [--port P] [--password PW] [--tag] [--online]":
  default physical clone (brief source stop, cp -a of pgdata minus
  postmaster files, new registration, source restarted on its own port);
  --online copies via dump/restore without stopping the source (verified
  source pid unchanged). Clone lands on the requested or derived port.
- "db copy <src> <dst> [--db X] [--force]": single-database logical move
  between two running instances with the same non-empty-target guard.
  "db ls <name>" lists databases.
- Fixed during verification: clone/copy leaked the CLI --port into the
  source restart path (source briefly came up on the clone's port); the
  address overrides are now cleared inside those commands.

Impact:
All operations stay inside runtime/<name>/, append to history.jsonl, and
reuse the existing safety constraints (own-process stop, port conflicts
reported not seized, secrets in 0600 files). Overwriting a non-empty
database requires an explicit --force everywhere. Makefile help line
mentions the new db subcommands.

Refs: .task/feature-svc-db-ops.md(任务卡=PR 描述)
2026-09-30 14:11:30 +00:00
weichen d6b9c2e07a Record the task card for feature-svc-db-ops 2026-09-30 14:01:04 +00:00
weichen 24d558ab64 Close 1 merged task card and archive it
ci / test (pull_request) Failing after 19m12s
Why: feature/svc-services-registry merged via PR #57 (merge 33fe7fb);
its card must be marked done and archived per the no-pending-cards rule.
Evidence: git log --merges origin/main shows 33fe7fb merging the branch;
card backfilled with PR link and moved to .task/archive/.
Impact: .task bookkeeping only (main checkout holds an unrelated untracked
.video_agent/ dir which is left untouched).
Refs: task.sh close
2026-09-30 13:45:55 +00:00
weichen ba48c35e09 Record the sync checkpoint
ci / test (pull_request) Failing after 1m35s
2026-09-30 13:45:01 +00:00
weichen 60261a835a Generalize svc.sh into a multi-kind service manager with tags and persistence
Why:
svc.sh only managed agent-system environments; databases, standalone
frontend serving, per-service tags and reusable start configs were out of
scope, and the user asked for a unified service lifecycle on this host.

Evidence:
- Service model v2: kind=agent|static|postgres registered in
  runtime/<name>/svc.env (dotenv, mode 600); legacy entries without kind=
  are adopted as agent.
- postgres: "db create <name> --port/--user/--password/--db/--auth-mode/
  --tag" runs initdb (scram-sha-256, pwfile 0600), start/stop/restart use
  pg_ctl (-m fast, never SIGKILL on postmaster) with pg_isready checks and
  first-start database creation; "db dsn <name> [--reveal]" prints a
  composable DSN (password masked by default). Verified end to end against
  a real postgresql@18 instance: data survives restart, wrong passwords
  rejected, stop/restart clean.
- static: "deploy --kind static --from dev[@sha]|local" builds frontend
  dist into htdocs/ in an isolated worktree, or "--dir PATH" serves an
  existing directory; verified serving HTTP 200, restart, stop, dry-run
  plan, and explicit rejection of release sources.
- agent: unchanged three deploy sources plus --tag; bare start/restart now
  reuses the persisted exec= from svc.env (verified: same custom port and
  args across restart); old binaries lacking --dsn/--auth get those flags
  auto-omitted with a warning.
- "list|status [--tag]" shows NAME/KIND/STATE/PID/ADDR/SOURCE/TAGS for all
  registered services; "<name> status" gives per-kind detail; "rm <name>
  [--purge]" unregisters (and optionally deletes) only runtime/<name>/.
- Fixed during verification: psql arg mangling (-c -c), tags lost because
  record_state read svc.env inside its own redirect block, postgres
  --version field parsing, unbound vars for unregistered names.

Impact:
Same invariants as before: writes stay under runtime/<name>/ and
runtime/.worktrees/ (only --from local also writes main-checkout build
outputs, all gitignored), stops only own pidfile+cmdline-verified
processes, port conflicts reported not seized. Prompt output moved to
stderr so stdout (tables, DSNs) stays pipeable. Makefile gains svc-list.

Refs: .task/feature-svc-services-registry.md(任务卡=PR 描述)
2026-09-30 13:44:58 +00:00
weichen 0eff7abf3e Record the task card for feature-svc-services-registry 2026-09-30 13:30:43 +00:00
weichen 71fb2aff89 Close 1 merged task card and archive it
ci / test (pull_request) Failing after 1m37s
Why: feature/svc-deploy-source-registry merged via PR #55 (merge 8523415);
its card must be marked done and archived per the no-pending-cards rule.
Evidence: git log --merges origin/main shows 8523415 merging the branch;
card backfilled with PR link and moved to .task/archive/.
Impact: .task bookkeeping only.
Refs: task.sh close
2026-09-30 13:22:23 +00:00
weichen 3a91fda7c3 Link the svc registry task card to PR #55
ci / test (pull_request) Failing after 31s
Why: 任务卡与 PR 描述为同一份文档,主记录链接须回填。
Evidence: PR #55 已建立(head=feature/svc-deploy-source-registry)。
Impact: 仅任务卡元数据。
2026-09-30 13:21:35 +00:00
weichen b4f9e93d56 Record the sync checkpoint
ci / test (pull_request) Failing after 1m31s
2026-09-30 13:20:32 +00:00
weichen 8ba1b0e715 Add commit-picked deploys and a service registry to svc.sh
Why:
svc.sh only knew two hardcoded environments (dev/prod) and always built
the current workspace, so there was no way to deploy a specific Dev- repo
commit or a Releases artifact, and no record of what was actually started.

Evidence:
- scripts/svc.sh commits dev|release lists deployable commits (release
  entries annotated with version + devCommit; both mark HEAD and the
  environments already running them).
- deploy --from local|dev@<sha>|release@<version|sha> materializes the
  chosen source: dev commits build in an isolated worktree
  (runtime/.worktrees/<sha>, submodule pins verified to land exactly),
  release artifacts are sha256-verified against versions/<v>/manifest.json
  (a forged manifest is refused); --pick offers an interactive numbered
  choice and --dry-run prints the plan.
- Environment names are generalized (^[a-z][a-z0-9-]{0,15}$, derived port
  8800-9099 on collision-free scan); each env is self-contained under
  runtime/<env>/{bin,plugins,data} with svc.env (current state) and
  history.jsonl (append-only deploy/start/stop events). status scans all
  registered envs and history [env] [N] merges the event stream.
- Old artifacts that predate --dsn/--auth have those flags auto-omitted
  (probed via serve usage); legacy svc.env files still render in status.
- Verified end to end in the task worktree: stub-binary lifecycle, a real
  release@0.1.0 deploy (HTTP 200, source shown in status, commits marked),
  failure paths (sha mismatch, immediate exit, non-TTY --pick).

Impact:
scripts/svc.sh users gain multi-version side-by-side environments and
rollback by redeploying an older source; existing dev/prod defaults and
safety constraints (own-pidfile-only stop, port-occupancy check) are
unchanged. Environments deployed by the previous script need one fresh
deploy before start/restart works again. Makefile gains svc-commits and
svc-history targets.

Refs: .task/feature-svc-deploy-source-registry.md(任务卡=PR 描述)
2026-09-30 13:20:32 +00:00
weichen ab7f18d5d4 Record the task card for feature-svc-deploy-source-registry 2026-09-30 13:03:31 +00:00
weichen d26187e43c Close 1 merged task card(s) and archive them
ci / test (pull_request) Failing after 1m34s
Why: branches merged into main had left their task cards open; backfill status and archive to prevent bookkeeping debt.
Evidence: feature-visual-refresh-r4.md(PR#53) — merges verified via git log --merges against origin/main.
Impact: .task/*.md moved to .task/archive/ with status backfilled; no code or submodule change.
Refs: task.sh close (card-autoclose-r1)
2026-09-30 12:46:02 +00:00
weichen 4789fb917e Record the sync checkpoint 2026-09-30 12:41:46 +00:00
weichen 599a6448d4 Land the R4 visual refresh across repos (gitlinks + task card)
Why: R4 spans ui (token scale) and frontend (icon set + restyle); the
Dev repo advances pointers and the task record.

Evidence: make test full suite green on this head (exit 0); headless
journey on the real binary across both themes with zero console errors
and zero leftover emoji glyphs.

Impact: pure visual layer. Merge order: ui -> frontend -> this PR.

Refs: proposal 2026-09-30-ui-redesign-and-auth.md (R4)
2026-09-30 12:41:45 +00:00
weichen c233773c69 Record the task card for feature-visual-refresh-r4 2026-09-30 12:24:50 +00:00
weichen 346714141d Close the svc-envfile task card and archive it
ci / test (pull_request) Failing after 1m37s
Why: merged card needs its PR link backfilled and archived per the
no-bookkeeping-debt rule.

Evidence: Dev PR #51 merged; card records the env-file test matrix.

Impact: card archived with link; no code change.
2026-09-30 12:00:43 +00:00
weichen 53fbfd7efd Record the sync checkpoint
ci / test (pull_request) Failing after 17m24s
2026-09-30 12:00:26 +00:00
weichen 52d0e45c81 Record the svc-envfile task card results 2026-09-30 12:00:25 +00:00
weichen 78fe0201e9 Record the task card for feature-svc-envfile 2026-09-30 11:59:27 +00:00
weichen 53462641c2 Close the svc-auto-seed task card and archive it
ci / test (pull_request) Failing after 1m57s
Why: merged card needs its PR link backfilled and archived per the
no-bookkeeping-debt rule.

Evidence: Dev PR #49 merged; card records the seeding test matrix.

Impact: card archived with link; no code change.
2026-09-30 11:56:59 +00:00
weichen e371a3c4fa Record the sync checkpoint
ci / test (pull_request) Failing after 1m56s
2026-09-30 11:56:42 +00:00
weichen 5c2fa4562b Record the svc-auto-seed task card results 2026-09-30 11:56:41 +00:00
weichen 82c2417edb Record the task card for feature-svc-auto-seed 2026-09-30 11:54:54 +00:00
weichen 1615eb5996 Close the svc-cli-args task card and archive it
ci / test (pull_request) Failing after 1m34s
Why: merged card needs its PR link backfilled and archived per the
no-bookkeeping-debt rule.

Evidence: Dev PR #47 merged; card records the live flag matrix.

Impact: card archived with link; no code change.
2026-09-30 11:50:41 +00:00
weichen 604b12ab06 Record the sync checkpoint
ci / test (pull_request) Failing after 17m6s
2026-09-30 11:50:25 +00:00
weichen e3ba86aa16 Record the svc-cli-args task card results 2026-09-30 11:50:24 +00:00
weichen 1ac864a0b5 Record the task card for feature-svc-cli-args 2026-09-30 11:47:03 +00:00
weichen 4cdeeabfb9 Close the svc-env-script task card and archive it
ci / test (pull_request) Failing after 31s
Why: merged card needs its PR link backfilled and archived per the
no-bookkeeping-debt rule.

Evidence: Dev PR #45 merged; card records the live test matrix.

Impact: card archived with link; no code change.
2026-09-30 11:39:12 +00:00
weichen c1eea4b05b Record the sync checkpoint
ci / test (pull_request) Failing after 1m31s
2026-09-30 11:38:44 +00:00
weichen f0e7831ed1 Record the svc-env-script task card results 2026-09-30 11:38:43 +00:00
weichen c2e5ca5211 Record the task card for feature-svc-env-script 2026-09-30 11:19:29 +00:00
weichen ac38507cee Close 1 merged task card(s) and archive them
ci / test (pull_request) Failing after 1m41s
Why: branches merged into main had left their task cards open; backfill status and archive to prevent bookkeeping debt.
Evidence: feature-auth-admin-accounts.md(PR#43) — merges verified via git log --merges against origin/main.
Impact: .task/*.md moved to .task/archive/ with status backfilled; no code or submodule change.
Refs: task.sh close (card-autoclose-r1)
2026-09-30 11:18:08 +00:00
weichen a633f76a99 Merge origin/main (tavily-search sync; backend/documents rebased) 2026-09-30 11:15:49 +00:00
weichen e6ad8f06ac Land admin-issued auth R2 across repos (gitlinks + task card)
Why: R2 spans backend (migration v10, auth/session APIs, CLI user
subcommands), frontend (login page, forced change gate, admin user
management), documents (decision record).

Evidence: make test full suite green on this head (exit 0); headless
journey on the real binary with --auth on covers admin bootstrap,
first-login forced change for created and reset passwords, non-admin
menu gating, API-key login, logout.

Impact: auth-enabled deployments gain password login and admin account
management; embedded no-auth mode unchanged. Merge order: backend ->
frontend -> documents -> this PR.

Refs: proposal 2026-09-30-ui-redesign-and-auth.md (R2 admin-issued)
2026-09-30 11:15:06 +00:00
weichen 024d60b362 Close the tavily-search task card and archive it
ci / test (pull_request) Failing after 31s
Why: merged combo card needs its PR link backfilled and the card
archived per the no-bookkeeping-debt rule.

Evidence: Dev PR #41 merged; card records both boot-state checks.

Impact: card archived with link; no code change.
2026-09-30 11:00:44 +00:00
weichen 68712bd619 Record the sync checkpoint
ci / test (pull_request) Failing after 31s
2026-09-30 11:00:17 +00:00
weichen 940e9bd871 Record the tavily-search task card 2026-09-30 10:59:59 +00:00
weichen 9a4f4b5002 Record the task card for feature-tavily-search-tool 2026-09-30 10:55:00 +00:00
weichen ba8317e136 Record the task card for feature-auth-admin-accounts 2026-09-30 10:53:50 +00:00
weichen 953a426dab Close the catalog-coverage task card and archive it
ci / test (pull_request) Failing after 1m31s
Why: merged combo card needs its PR link backfilled and the card
archived per the no-bookkeeping-debt rule.

Evidence: Dev PR #38 merged; card carries the coverage test records.

Impact: card moved to .task/archive/ with the link filled; no code
change.
2026-09-30 10:50:49 +00:00
weichen 6775d9d6cf Record the sync checkpoint
ci / test (pull_request) Failing after 17m16s
2026-09-30 10:49:21 +00:00
weichen b4a632b27e Record the catalog-coverage task card 2026-09-30 10:48:38 +00:00
weichen 455e245d30 Record the task card for feature-prompt-catalog-coverage 2026-09-30 10:48:38 +00:00
weichen 52f2c7db56 Close 1 merged task card(s) and archive them
ci / test (pull_request) Failing after 1m35s
Why: branches merged into main had left their task cards open; backfill status and archive to prevent bookkeeping debt.
Evidence: feature-task-sidebar-r1.md(PR#37) — merges verified via git log --merges against origin/main.
Impact: .task/*.md moved to .task/archive/ with status backfilled; no code or submodule change.
Refs: task.sh close (card-autoclose-r1)
2026-09-30 10:47:44 +00:00
weichen 6cfdb89f21 Sync main before merge
ci / test (pull_request) Failing after 1m34s
2026-09-30 10:46:34 +00:00
weichen 6345f15ba3 Merge origin/main (prompt-library sync; submodules rebased) 2026-09-30 10:44:06 +00:00