Import brains from hasna/brains (history preserved) - #17
Merged
Conversation
- package.json with Commander.js, Ink, MCP SDK, Drizzle, OpenAI dependencies - DB schema: fine_tuned_models, training_jobs, training_datasets (Drizzle/SQLite) - OpenAI fine-tuning provider: upload, createJob, getStatus, listModels, cancel - Thinker Labs fine-tuning provider: REST adapter with matching interface - Data gatherers: todos, mementos, conversations, sessions (JSONL training data) - CLI commands: models list/show, finetune start/status/list, data gather/preview/list - MCP server: 6 tools for list_models, start_finetune, gather_training_data, etc
…ions - Replace better-sqlite3 with bun:sqlite throughout (db, gatherers) - Fix data gather CLI to use gatherAll() instead of broken dynamic imports - Add display_name, description, collection, tags to fine_tuned_models schema - Add brains models rename/describe/tag/untag/set-collection commands - Add brains collections list/show/rename commands - Verify end-to-end: gathered 100 training examples, started fine-tune job ftjob-E8Xb2NbeqHXmjM4FgpommF82 on gpt-4o-mini-2024-07-18
- Add package-metadata.ts to read version from package.json at runtime - Refactor MCP server into createMcpServer() factory for testability - Refactor HTTP server into startServer() / createServerFetchHandler() for testability - Export MCP_SERVER_INFO constant; server/MCP version now tracks package.json automatically - Add test files for server and package-metadata Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… API, tests - Wire mementos/conversations/sessions gatherers in MCP server (BRA-00014) - Add `brains finetune watch` command with polling loop (BRA-00015) - Add `brains data merge` command with deduplication (BRA-00016) - Auto-detect latest dataset when --dataset omitted (BRA-00017) - Full REST API on HTTP server: /models, /jobs, /datasets (BRA-00018) - Add `brains models import` to pull external fine-tuned models (BRA-00019) - Deduplicate examples in mergeAndWriteJSONL across sources (BRA-00020) - Per-source progress output during brains data gather (BRA-00021) - Add `brains config` command for API key management (BRA-00022) - Add Zod validation to all MCP tool inputs (BRA-00023) - Add --json flag to all CLI list/show/status commands (BRA-00024) - Write README.md with install, configure, quickstart guide (BRA-00025) - Fix hardcoded version in HTTP server (BRA-00026) - Migrate DB schema to drizzle-kit migrations (BRA-00027) - Add retry with exponential backoff to all provider API calls (BRA-00028) - Add 25 new tests covering retry, config, gatherers, MCP, schemas (BRA-00029)
…ets, economy, recordings, assistants)
- protocol.ts: shared GatherTrainingDataFn + TrainingDataProvider interface
- registry.ts: dynamic registry replacing switch/case in gatherAll()
- Gatherers for: styles, researcher, tickets, economy, recordings, assistants
- All use optional dynamic import — gracefully skip if SDK not installed
- Prefer gatherTrainingData() from SDK if exported, fall back to list*() calls
- gatherAll("all") now expands to all registered sources dynamically
- brains data gather --source styles/researcher/tickets/economy/recordings/assistants all work
Move config from ~/.brains/config.json to ~/.hasna/brains/config.json. Move database from ~/.brains/brains.db to ~/.hasna/brains/brains.db. Auto-migrates all files from old directory when new doesn't exist yet. Existing ~/.brains/ is never deleted.
…ld path references
- Replace manual SqliteAdapter path resolution with createDatabase({ service: "brains" }) from @hasna/cloud
- Use migrateDotfile("brains") for ~/.brains/ → ~/.hasna/brains/ migration
- Add src/db/pg-migrate.ts: PostgreSQL migration runner (applyPgMigrations)
- Fix pg-migrations.ts: use BIGINT for Unix epoch timestamps, update feedback schema to match @hasna/cloud standard
- Add cloud CLI commands: brains cloud status/push/pull/sync/migrate-pg
- Switch feedback to use sendFeedback/listFeedback from @hasna/cloud; add feedback list CLI command
- Export applyPgMigrations from main index
- Bump version to 0.0.13
Add tests for db/index, all gatherers, providers (mocked), server HTTP routes, and retry edge cases. Coverage: server 100%, db 100%, gatherers 50-100%, providers 95-96%, retry 100%.
Extract models, finetune, data, collections, and cloud command groups into src/cli/commands/. index.ts is now a lean entry point. Bump to 0.0.14.
…astMCP, we use low-level Server)
brains --help was timing out because migrateDotfile() ran at module load time, triggering fs ops on every CLI invocation including --help. Now runs lazily on first getDb()/getRawDb() call only.
The prior repair left http.ts exporting only startHttpServer while mcp/index.ts imported isHttpMode/resolveMcpHttpPort/startMcpHttpServer, breaking the build. Restore the canonical web-standard transport (--http / MCP_HTTP=1, port 8802) and align the index.ts entrypoint and tests with the rest of the @hasna MCP fleet.
`brains-mcp` now starts a shared Streamable HTTP server by default (port 8802); pass `--stdio` (or MCP_STDIO=1) for the legacy per-process stdio transport. This eliminates per-agent process fan-out for clients that connect over HTTP. BREAKING for callers that relied on the bare bin being stdio — update them to pass --stdio or connect to http://127.0.0.1:8802/mcp.
Preserve reviewed non-risky working tree changes before fleet repo redistribution. Risky local-only paths, if any, were left uncommitted.
Resolved conflicts with current main, preserved native storage sync changes, and validated with bun test, bun run typecheck, bun run build, plus adversarial staged review.
Co-authored-by: Codewith <codewith@users.noreply.github.com>
#6) Co-authored-by: Andrei Hasna <andrei@hasna.com>
#7) Co-authored-by: Andrei <andrei@hasna.com>
Agent: agent-ea
Agent: agent-ea
Agent: agent-ea
This was referenced Aug 15, 2026
andrei-hasna
added a commit
that referenced
this pull request
Aug 17, 2026
Delta import from org repo hasna/bridge (freeze 4fef003, 07-30): commits 1c3e5e5 (#14), da2ecae (#16), 1fd3b94 (#15), 558a9d5 (#17, release 0.7.1). Monorepo #182 already ported most of the daemon lifecycle content, but the org main carries two genuine additions the port missed, now imported: - live-owner lock protection: a lock held by a live process is never broken on age alone (with regression test) - config-derived stop grace: --timeout-ms no longer defaults to 5000; unset means derive from config (with derived-grace CLI test) Plus the 0.7.1 release (version + changelog + changeset) and the setsid fixture correction in serve-preflight. Kept member absorption: bun-types/@types/node pins in package.json, bracket-form AWS key literal in codewith-durable.test.ts. Local gates: typecheck 0, 240 tests pass / 0 fail, build 0, secrets scan 0 findings. Agent: aemilianus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Import brains from hasna/brains (history-preserving, merge-commit)
Task: ee9fbb4d (wave 1 batch B). Mechanism:
import-mechanics-codex.md(approved; reviewers A+B GO). Import via disposable mirror →git-filter-repo --to-subdirectory-filter apps/brains --preserve-commit-hashes --preserve-commit-encoding→ same-tree history capsule → one merge-commit PR (merge-commit strategy required — squash/rebase breaks imported-history reachability). No publishes, no repo-settings changes, no deletions.Evidence
PR freeze (checklist 6): 0 open PRs on hasna/brains at import time.
Ref inventory (checklist 1): heads=2, tags=1 (lightweight v0.0.24).
refs/pull/*present in the mirror; pull-only commits dropped per mechanism P3 (accepted, recorded). Peel skipped list: none (all 3 refs resolved viarev-parse ^{commit}; 0 duplicates).Capsule: 6637703, parents=3. PARENT_SET_EQUAL GAPS=0 (checklist 3).
Tree/blob gate (checklist 4): rewritten main tree == mono subtree tree except the documented absorption fix below. 0 gitlink (160000) entries (negative submodule control). Provenance: rewritten main is an ancestor of the import head (DAG_REACHABLE);
git fsck --connectivity-onlyrc=0 (dangling only).In-mono absorption gate (checklist 2): bun install rc=0 ·
bun run checkrc=0 (secrets scan 0 findings / 8,902 added lines) · turbobuild --affectedrc=0 ·test --affectedrc=0 ·lint --affectedrc=0.Absorption fixes (in this PR, smallest per P1b):
apps/brains/package.json— added explicit devDepsbun-types@1.3.14,@types/node@26.1.0:tsconfig.jsontypes["bun-types"]failed in-mono with TS2688 (bun-types unlinked in the workspace store; exact versions match the old repo's resolved tree).Root
bun.lockupdated bybun install(member registration).Hygiene (checklist 5): no
.gitattributesLFS rules, no.gitmodules, staged secrets scan 0 findings,git diff --cached --checkclean.Tag→commit manifest (checklist 8):
/tmp/opencode/wave1b/brains/tag-commit-manifest.md(1 lightweight tag; 3 capsule parents; GAPS=0).Landing requirement
Merge with GitHub's merge-commit strategy only (mechanism doc; squash or rebase breaks reachability of the imported history).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.