Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
cb4f021
docs: create backlog items from 2026-04-11 audit findings
flyingrobots Apr 12, 2026
053dd2e
docs: add session discoveries to backlog
flyingrobots Apr 12, 2026
c6618e3
docs: log code smells and cool ideas from session code review
flyingrobots Apr 12, 2026
efb48ff
docs: triage inbox — reflect MCP to asap, mind docs to up-next
flyingrobots Apr 12, 2026
fce4ac8
docs: clarify reflect is CLI-only, update agent isolation advice
flyingrobots Apr 12, 2026
66631c4
docs: close cycle 0009-clarify-reflect-mcp-status — hill met
flyingrobots Apr 12, 2026
cd0fb4d
test: RED — assert MIND_ORCHESTRATION.md exists and is linked
flyingrobots Apr 12, 2026
e2d4aef
docs: GREEN — create MIND_ORCHESTRATION.md and link from GUIDE
flyingrobots Apr 12, 2026
8d4f957
docs: close cycle 0010-document-mind-orchestration — hill met
flyingrobots Apr 12, 2026
74430fb
refactor: remove unused browseStartMs from windowed model
flyingrobots Apr 12, 2026
f462325
docs: close cycle 0011-unused-browseStartMs-field — hill met
flyingrobots Apr 12, 2026
b0050e8
fix: validate shaderCount > 0 in shaderForMind
flyingrobots Apr 12, 2026
1dc6923
docs: close cycle 0011-shaderForMind-no-input-validation — hill met
flyingrobots Apr 12, 2026
55e361c
fix: standardize doctor skip logic for upstream without checker
flyingrobots Apr 12, 2026
709b55e
docs: close cycle 0011-doctor-inconsistent-skip-logic — hill met
flyingrobots Apr 12, 2026
970dc4d
refactor: DRY sparkline — formatStats calls buildStatsSparkline
flyingrobots Apr 12, 2026
91e0fa9
docs: close cycle 0012-buildStatsSparkline-duplication — hill met
flyingrobots Apr 12, 2026
08a7e3a
docs: add dependency frontmatter to bad-code backlog items
flyingrobots Apr 12, 2026
85714cd
test: RED — assert Entry and ReflectSession are class instances
flyingrobots Apr 12, 2026
18696cd
refactor: GREEN — promote Entry and ReflectSession to frozen classes
flyingrobots Apr 12, 2026
30167a1
docs: close cycle 0012-audit-plain-object-model — hill met
flyingrobots Apr 12, 2026
4a3a21c
refactor: add ENTRY_KINDS and BUCKET_PERIODS validated constants
flyingrobots Apr 12, 2026
76ce596
docs: close cycle 0013-ssjr-src-store-model-js — hill met
flyingrobots Apr 12, 2026
d2eaf39
fix: restrict provenance URLs to http/https schemes
flyingrobots Apr 12, 2026
d21f48c
docs: close cycle 0014-audit-provenance-url-schemes — hill met
flyingrobots Apr 12, 2026
c28a686
refactor: move ambient context resolution out of store layer
flyingrobots Apr 12, 2026
c736bbd
docs: close cycle 0015-audit-capture-path-sync-git — hill met
flyingrobots Apr 12, 2026
4ae35b4
refactor: promote CaptureProvenance to a frozen class
flyingrobots Apr 12, 2026
920ba2d
docs: close cycle 0016-ssjr-src-capture-provenance-js — hill met
flyingrobots Apr 12, 2026
0314347
docs: document ambient context and recall pipeline
flyingrobots Apr 13, 2026
6b6d493
docs: close cycle 0017-audit-undocumented-ambient-context-and-recall …
flyingrobots Apr 13, 2026
f6fb393
docs: remove stale project-context blocker from store-capture SSJR
flyingrobots Apr 13, 2026
8499d70
refactor: clean up capture.js — remove pointless alias, tighten SSJR
flyingrobots Apr 13, 2026
b03d154
docs: close cycle 0018-ssjr-src-store-capture-js — hill met
flyingrobots Apr 13, 2026
f35ecee
refactor: promote getStoredEntry result to frozen StoredEntry class
flyingrobots Apr 13, 2026
98e5547
docs: close cycle 0019-audit-unvalidated-read-models — hill met
flyingrobots Apr 13, 2026
a2ddf00
feat: introduce Think error taxonomy
flyingrobots Apr 13, 2026
0f82b85
docs: close cycle 0020-audit-no-error-taxonomy — hill met
flyingrobots Apr 13, 2026
cc5aac5
fix: resolve git binary path once instead of trusting PATH
flyingrobots Apr 13, 2026
5118c11
docs: close cycle 0021-audit-git-binary-path-trust — hill met
flyingrobots Apr 13, 2026
60f3932
refactor: freeze query result shapes (inspect, browse window)
flyingrobots Apr 13, 2026
b00834d
docs: close cycle 0022-audit-query-reshape-pipeline — hill met
flyingrobots Apr 13, 2026
5cc00f1
perf: cache openWarpApp handles by repoDir
flyingrobots Apr 13, 2026
1dd348a
docs: close cycle 0023-audit-warp-handle-reuse — hill met
flyingrobots Apr 13, 2026
8164635
refactor: add SESSION_KINDS constant, use in runtime.js
flyingrobots Apr 13, 2026
fb121a6
docs: close cycle 0024-ssjr-src-store-runtime-js — hill met
flyingrobots Apr 13, 2026
31ec6ad
refactor: promote VerboseReporter to a class
flyingrobots Apr 13, 2026
22556ba
docs: close cycle 0025-ssjr-src-verbose-js — hill met
flyingrobots Apr 13, 2026
44088c1
refactor: DRY MCP entry helpers, freeze results
flyingrobots Apr 13, 2026
e1ae6ab
docs: close cycle 0026-audit-mcp-service-shape-soup — hill met
flyingrobots Apr 13, 2026
be45e1f
fix: replace all z.any() holes in MCP server with typed schemas
flyingrobots Apr 13, 2026
7decc6e
docs: close cycle 0027-audit-mcp-contract-holes — hill met
flyingrobots Apr 13, 2026
d02b404
refactor: freeze parsed CLI options and positionals
flyingrobots Apr 13, 2026
24f0251
docs: close cycle 0028-audit-cli-options-bag — hill met
flyingrobots Apr 13, 2026
5103763
refactor: add COMMANDS constants to CLI options
flyingrobots Apr 13, 2026
7327556
docs: close cycle 0029-ssjr-src-cli-options-js — hill met
flyingrobots Apr 13, 2026
dbec874
refactor: freeze query results (remember, stats, buckets)
flyingrobots Apr 13, 2026
9d6343a
docs: close cycle 0030-ssjr-src-store-queries-js — hill met
flyingrobots Apr 13, 2026
30d5f3c
docs: design doc for SSJR src/mcp/service.js
flyingrobots Apr 13, 2026
05df51a
docs: close cycle 0031-ssjr-src-mcp-service-js — hill met
flyingrobots Apr 13, 2026
7e585f8
feat: add remediation field to graph migration errors
flyingrobots Apr 13, 2026
38e9fa9
docs: close cycle 0032-HT-007-remediation-payloads-in-json-errors — h…
flyingrobots Apr 13, 2026
3577fe8
refactor: freeze migration result objects
flyingrobots Apr 13, 2026
6436d8f
docs: close cycle 0032-ssjr-src-store-migrations-js — hill met
flyingrobots Apr 13, 2026
5f20a81
refactor: replace CLI dispatch if/else ladder with command map
flyingrobots Apr 13, 2026
1b9ef77
docs: close cycle 0033-audit-cli-dispatch-chain — hill met
flyingrobots Apr 13, 2026
2b48496
refactor: promote CliOutput to class, extract STDERR_EVENTS constant
flyingrobots Apr 13, 2026
390f9f7
docs: close cycle 0034-ssjr-src-cli-output-js — hill met
flyingrobots Apr 13, 2026
afb9dec
refactor: freeze MCP tool result objects
flyingrobots Apr 13, 2026
b8c8164
docs: close cycle 0035-ssjr-src-mcp-result-js — hill met
flyingrobots Apr 13, 2026
29bb718
refactor: use ThinkError for git command failures
flyingrobots Apr 13, 2026
3ce2245
docs: close cycle 0036-ssjr-src-git-js — hill met
flyingrobots Apr 13, 2026
ab1eb69
refactor: validate and freeze prompt metrics records on parse
flyingrobots Apr 13, 2026
ff2a146
docs: close cycle 0037-audit-prompt-metrics-raw-parse — hill met
flyingrobots Apr 13, 2026
990263e
docs: design doc for SSJR src/cli.js
flyingrobots Apr 13, 2026
822874d
docs: close cycle 0038-ssjr-src-cli-js — hill met
flyingrobots Apr 13, 2026
8473075
refactor: freeze ambient project context objects and tokens
flyingrobots Apr 13, 2026
706baa4
docs: close cycle 0039-ssjr-src-project-context-js — hill met
flyingrobots Apr 13, 2026
9c7374a
refactor: accept optional reader in readPromptMetricsRecords
flyingrobots Apr 13, 2026
af7d407
docs: close cycle 0040-audit-prompt-metrics-io-port — hill met
flyingrobots Apr 13, 2026
e9543e9
docs: design doc for SSJR src/mcp/server.js
flyingrobots Apr 13, 2026
9bc971e
docs: close cycle 0041-ssjr-src-mcp-server-js — hill met
flyingrobots Apr 13, 2026
542290e
docs: design doc for SSJR src/cli/graph-gate.js
flyingrobots Apr 13, 2026
9d9db3d
docs: close cycle 0042-ssjr-src-cli-graph-gate-js — hill met
flyingrobots Apr 13, 2026
08eb312
docs: design doc for SSJR bin/think-mcp.js — 9 lines, already clean
flyingrobots Apr 13, 2026
88c7ba6
docs: close cycle 0043 — hill met
flyingrobots Apr 13, 2026
9746cc0
refactor: DRY interactive shell checks via shared helper
flyingrobots Apr 13, 2026
49299b0
docs: close cycle 0044 — hill met
flyingrobots Apr 13, 2026
451edf2
refactor: freeze HELP_TEXT and renderHelp result
flyingrobots Apr 13, 2026
9050252
docs: close cycle 0045 — hill met
flyingrobots Apr 13, 2026
84d0441
docs: design doc for SSJR src/cli/commands/capture.js
flyingrobots Apr 13, 2026
d0df7c2
docs: close cycle 0046 — hill met
flyingrobots Apr 13, 2026
8b43b0a
docs: design doc for SSJR src/cli/commands/read.js
flyingrobots Apr 13, 2026
1cf9bd5
docs: close cycle 0047 — hill met
flyingrobots Apr 13, 2026
eb62b3e
docs: pull cycle 0048 for bin/think.js SSJR review
flyingrobots Apr 13, 2026
06785fd
docs: close cycle 0048 — bin/think.js already clean
flyingrobots Apr 13, 2026
1a43c03
refactor: use typed errors, constants, and frozen returns in browse-b…
flyingrobots Apr 13, 2026
4e24826
docs: close cycle 0049 — browse-benchmark SSJR cleanup
flyingrobots Apr 13, 2026
6b5e737
refactor: DRY capitalize by exporting from interactive.js
flyingrobots Apr 13, 2026
2396149
docs: close cycle 0050 — interactive.js DRY capitalize
flyingrobots Apr 13, 2026
17736db
docs: pull cycle 0051 for src/store.js SSJR review
flyingrobots Apr 13, 2026
cfb7c96
docs: close cycle 0051 — src/store.js barrel already clean
flyingrobots Apr 13, 2026
def0b40
refactor: freeze return objects in prompt-metrics summarizers
flyingrobots Apr 13, 2026
ff9004e
docs: close cycle 0052 — prompt-metrics frozen returns
flyingrobots Apr 13, 2026
3b55f30
refactor: freeze scope and match return objects in remember.js
flyingrobots Apr 13, 2026
2ef42ef
docs: close cycle 0053 — remember.js frozen returns
flyingrobots Apr 13, 2026
56e6601
docs: pull cycle 0054 for reflect.js command SSJR review
flyingrobots Apr 13, 2026
71b4285
docs: close cycle 0054 — reflect.js command cleaned by prior cycle
flyingrobots Apr 13, 2026
f8fbe1b
refactor: freeze return objects in derivation.js
flyingrobots Apr 13, 2026
e91dcba
docs: close cycle 0055 — derivation.js frozen returns
flyingrobots Apr 13, 2026
a19d055
refactor: freeze return objects in reflect.js
flyingrobots Apr 13, 2026
664fc9b
docs: close cycle 0056 — reflect.js frozen returns
flyingrobots Apr 13, 2026
afdc7cb
fix: surface typed error messages instead of generic 'Something went …
flyingrobots Apr 13, 2026
35f5755
docs: close cycle 0057 — CLI generic error reporting fixed
flyingrobots Apr 13, 2026
b0cd65f
docs: add PR and issue templates
flyingrobots Apr 13, 2026
75a2137
docs: batch clear 6 audit items
flyingrobots Apr 13, 2026
338ab3f
docs: restore dropped mind ideas + add LLM chorus triage
flyingrobots Apr 13, 2026
3ca188a
docs: log session-discovered bad code and cool ideas
flyingrobots Apr 13, 2026
48c966e
docs: add enrichment and automation backlog items
flyingrobots Apr 14, 2026
5a0bd2a
docs: write enrichment pipeline design document
flyingrobots Apr 14, 2026
aa58f07
docs: add semantic object nodes to enrichment pipeline design
flyingrobots Apr 14, 2026
02f268d
docs: refine enrichment pipeline design
flyingrobots Apr 14, 2026
7823085
docs: link 7 cool-ideas items to enrichment pipeline design
flyingrobots Apr 14, 2026
1b32ad6
docs: link deterministic analysis and future-self to enrichment design
flyingrobots Apr 14, 2026
1e84408
feat: graph v4 — enrichment schema extension
flyingrobots Apr 14, 2026
84b554e
docs: close cycle 0060-graph-v4-enrichment-schema — hill met
flyingrobots Apr 14, 2026
e83d5d2
test: RED — failing tests for think --annotate
flyingrobots Apr 14, 2026
1e1da09
feat: GREEN — think --annotate attaches notes to captures
flyingrobots Apr 14, 2026
ae7cbe1
docs: close cycle 0061-annotate-command — hill met
flyingrobots Apr 14, 2026
8074581
docs: write design doc for 0062-auto-tags-stage
flyingrobots Apr 14, 2026
521bbda
test: RED — failing tests for auto_tags enrichment stage
flyingrobots Apr 14, 2026
b4e3dbe
feat: GREEN — auto_tags enrichment stage with topic graph nodes
flyingrobots Apr 14, 2026
7703d04
docs: close cycle 0062-auto-tags-stage — hill met
flyingrobots Apr 14, 2026
a87b6e1
docs: write design doc for 0063-semantic-parse-stage
flyingrobots Apr 14, 2026
20bf748
test: RED — failing tests for classifyThought
flyingrobots Apr 14, 2026
bf73823
feat: GREEN — semantic_parse stage with classified_as edges
flyingrobots Apr 14, 2026
ecf6acd
docs: close cycle 0063-semantic-parse-stage — hill met
flyingrobots Apr 14, 2026
fd4a64c
docs: design doc for 0064-recent-default-limit
flyingrobots Apr 14, 2026
1700cdc
test: RED — tests for --recent default limit and total count
flyingrobots Apr 14, 2026
26fd7c0
docs: design doc for 0065-eliminate-full-graph-materialization
flyingrobots Apr 14, 2026
71e5f3e
test: RED — assert zero getNodes()/getEdges() calls in src/
flyingrobots Apr 14, 2026
7248e3f
refactor: GREEN — eliminate full graph materialization anti-pattern
flyingrobots Apr 14, 2026
4a11bc2
docs: close cycle 0065 — partial (v2 migration test needs fix)
flyingrobots Apr 14, 2026
4e2230c
fix: restore think reads and writes
flyingrobots May 3, 2026
56c45f7
docs: Add git-warp v17 mind repair card
flyingrobots May 5, 2026
6e0b32a
perf: optimize session attribution with O(1) graph traversal
flyingrobots May 9, 2026
0fc4234
perf: broad O(N) elimination and incremental enrichment
flyingrobots May 9, 2026
4abd793
perf: implement graph-native inverted index for O(1) search
flyingrobots May 9, 2026
285ca6a
perf: implement hybrid in-memory Trie for instant prefix search
flyingrobots May 9, 2026
31b1875
perf: implement fuzzy matching with Levenshtein ranking
flyingrobots May 9, 2026
8e4da36
refactor: DRY consolidation of high-performance traversal API
flyingrobots May 9, 2026
5e31cfd
docs: codify Infrastructure Doctrine
flyingrobots May 9, 2026
1b245db
docs: link to Infrastructure Doctrine in meta-docs
flyingrobots May 9, 2026
f55dd0b
feat: implement Bijou notifications and performance stream toggle
flyingrobots May 9, 2026
de615fc
feat: implement theme notifications and F10 perf stream toggle
flyingrobots May 9, 2026
919e83b
fix(reads): keep product reads on observer basis
flyingrobots May 11, 2026
a5570fd
fix(tui): adapt browse shell themes to bijou
flyingrobots May 11, 2026
f3ec8a6
fix(read): open product reads from checkpoint state
flyingrobots May 11, 2026
9cfccd8
fix(read): keep checkpoint fast path read-only
flyingrobots May 11, 2026
94ceb1f
fix(tui): keep browse splash handoff in alt screen
flyingrobots May 11, 2026
64327c4
fix: harden graph read and write contracts
flyingrobots May 11, 2026
8bc60d5
docs(backlog): record git-warp dependency truth debt
flyingrobots May 11, 2026
e9f1d98
docs(backlog): add Think Echo proof phases
flyingrobots May 12, 2026
d043cb0
docs(backlog): add Think Echo follow-up notes
flyingrobots May 12, 2026
880c4f1
fix(read): guard git-warp blob storage reads
flyingrobots May 12, 2026
4ee68c4
fix(migrate): infer reflect session edges
flyingrobots May 12, 2026
b54b1ee
fix(migrate): backfill reflect edges by session
flyingrobots May 12, 2026
5883b9e
fix(migrate): write repaired edges with migration writer
flyingrobots May 12, 2026
60035b1
ci: run official actions on node 24
flyingrobots May 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Bug report
about: Report a bug
---

## Description

<!-- What happened? -->

## Steps to reproduce

1.
2.

## Expected behavior

<!-- What should have happened? -->

## Environment

- OS:
- Node version:
- Think version:
10 changes: 10 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Summary

<!-- What changed and why -->

## Test plan

- [ ] `npm run lint` passes
- [ ] `npm run test:ports` passes
- [ ] `npm run test:m1` passes
- [ ] Docs updated if user-facing
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
matrix:
node-version: [22]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node-version }}
cache: npm
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
sanity:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 22
cache: npm
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
needs: sanity
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0

Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Do not audit the repository by recursively walking the filesystem. Follow the au

### 2. The Bedrock
- **`ARCHITECTURE.md`**: The authoritative structural reference (Git, WARP, Minds).
- **`docs/INFRASTRUCTURE_DOCTRINE.md`**: The runtime-first engineering standards (MANDATORY).
- **`docs/VISION.md`**: Core tenets and the capture doctrine.
- **`docs/method/process.md`**: Repo work doctrine (Backlog lanes, Cycle loop).

Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ Release discipline:
- `package.json` version is bumped on the release commit
- a Git tag is created on the commit that lands on `main` for that release

## Unreleased

- fixed MCP tool result envelopes so structured content matches each registered output schema again
- fixed checkpoint-backed reads to use public `@git-stunts/git-warp` package exports instead of private `node_modules` internals
- fixed cached writer retries across raw capture follow-through, annotations, reflect writes, migrations, and enrichment patches
- fixed enrichment search-index invalidation and per-repo cache scoping, and counted semantic-parse receipts in enrichment results
- documented `--annotate`, `--enrich`, and `--topics` in CLI help and validated stray positional text for enrichment/topic commands
- cleaned whitespace in the infrastructure doctrine and reflect command source so diff checks pass

## [0.7.0] - 2026-04-11

- added `think --doctor` health check command — reports think directory, local repo, graph model version, entry count, and upstream reachability (with `git ls-remote` connectivity test)
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ npm run benchmark:browse

## Coding standard

New JavaScript should follow [System-Style JavaScript](./docs/SYSTEMS_STYLE_JAVASCRIPT.md): runtime-backed domain concepts, boundary validation, explicit ownership of behavior, and narrow seams instead of object-shape soup.
New JavaScript should follow **[Infrastructure Doctrine](./docs/INFRASTRUCTURE_DOCTRINE.md)** and [System-Style JavaScript](./docs/SYSTEMS_STYLE_JAVASCRIPT.md): runtime-backed domain concepts, boundary validation, explicit ownership of behavior, and narrow seams instead of object-shape soup.

Read [`ARCHITECTURE.md`](./ARCHITECTURE.md) before making structural changes. Do not let storage concerns leak into normal UX, and do not let surface-specific concerns infect the capture core.

Expand Down
4 changes: 2 additions & 2 deletions GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Return to your archive through high-fidelity browse or context-aware recall.

### 4. Pressure-Testing (Reflect)
Move beyond simple capture by challenging your ideas through structured prompt families.
- **Run**: `think --reflect`
- **Run**: `think --reflect` (CLI-only; MCP reflect is not yet available)
- **Modes**: `challenge`, `constraint`, `sharpen`

## Big Picture: System Orchestration
Expand All @@ -40,7 +40,7 @@ Think is a tiered engine designed to keep capture cheap while enabling rich re-e
## Orientation Checklist

- [ ] **I am setting up a new machine**: Start with `README.md` Quick Start.
- [ ] **I want to separate my agent's thoughts**: Use `THINK_REPO_DIR` in an agent wrapper script.
- [ ] **I want to separate my agent's thoughts**: See [Mind Orchestration](./docs/MIND_ORCHESTRATION.md) for the multi-mind pattern.
- [ ] **I need to backup my archive**: Configure `THINK_UPSTREAM_URL`.
- [ ] **I am debugging the TUI**: Start with `ADVANCED_GUIDE.md`.
- [ ] **I am contributing to Think**: Read `docs/method/process.md` and `docs/BEARING.md`.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Unlike traditional note-taking apps that prioritize organization over ingestion,
## Quick Start

### 1. Local Setup
Clone, install dependencies, and capture your first thought.
Requires **Node.js >= 22** and **Git**. Clone, install, capture.
```bash
npm install
node ./bin/think.js "first captured thought"
Expand Down
121 changes: 121 additions & 0 deletions docs/AMBIENT_CONTEXT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Ambient Context and Recall

How Think collects, persists, and uses project context for capture
provenance and recall matching.

## Overview

When a thought is captured, Think records the ambient project context
— the working directory, git remote, branch, and derived project
tokens — alongside the raw text. This context powers `--remember`,
which matches prior thoughts by project affinity rather than requiring
explicit search terms.

## Collection

Two levels of context are collected at different points in the capture
flow:

### Capture ambient context (`getCaptureAmbientContext`)

Collected synchronously during `saveRawCapture`. Cheap — no git
probes.

| Field | Source | Notes |
|-------|--------|-------|
| `cwd` | `path.resolve(cwd)` | Resolved working directory |
| `projectName` | Derived from cwd basename | Fallback when no git |
| `projectTokens` | Derived from projectName | Lowercased, split on non-alphanumeric |

### Full ambient context (`getAmbientProjectContext`)

Collected during `finalizeCapturedThought` follow-through. Runs three
`git` probes via `spawnSync`:

| Field | Git command | Notes |
|-------|-------------|-------|
| `gitRoot` | `rev-parse --show-toplevel` | Absolute path to repo root |
| `gitRemote` | `config --get remote.origin.url` | Origin remote URL |
| `gitBranch` | `branch --show-current` | Current branch name |
| `projectName` | Derived from gitRemote → gitRoot → cwd | Priority order |
| `projectTokens` | All candidates, lowercased, split | Used for recall matching |

### Resolution priority

The `projectName` is derived in priority order:
1. Last segment of `gitRemote` URL (sans `.git`)
2. Basename of `gitRoot`
3. Basename of `cwd`

### Where resolution happens

The CLI and MCP layers resolve ambient context at the boundary
(`process.cwd()`) and pass it into the store functions. The store
layer does not read `process.cwd()` or shell out to git directly.

## Persistence

Context fields are stored as WARP node properties on the entry:

| Property | Source |
|----------|--------|
| `ambientCwd` | `cwd` |
| `ambientGitRoot` | `gitRoot` (follow-through only) |
| `ambientGitRemote` | `gitRemote` (follow-through only) |
| `ambientGitBranch` | `gitBranch` (follow-through only) |

The two-phase write means `ambientCwd` is available immediately after
capture, while git fields are backfilled during follow-through. This
preserves capture latency.

## Recall matching (`--remember`)

### Ambient recall (no query)

`buildAmbientRememberScope(cwd)` resolves the current project context
and matches stored entries by affinity:

| Match kind | Condition | Score | Tier |
|------------|-----------|-------|------|
| `ambient_git_remote` | Entry's `ambientGitRemote` matches current | 100 | 3 |
| `ambient_git_root` | Entry's `ambientGitRoot` matches current | 50 | 3 |
| `ambient_cwd` | Entry's `ambientCwd` matches current | 25 | 3 |
| `ambient_git_branch` | Entry's `ambientGitBranch` matches current | 15 | 3 |
| `project_tokens_text` | Entry text contains any current project token | 5 per token | 3 |

Results are sorted by score (highest first), then by recency.

### Explicit recall (with query)

`buildExplicitRememberScope(query)` splits the query into terms and
matches against entry text. Terms are lowercased and split on
non-alphanumeric boundaries.

| Match kind | Condition | Score |
|------------|-----------|-------|
| `query_terms` | Entry text contains query terms | 1 per term |

### Provenance

Capture provenance (`CaptureProvenance`) is separate from ambient
context. It records how the thought entered the system:

| Field | Source | Values |
|-------|--------|--------|
| `ingress` | Capture surface | `url`, `shortcut`, `selected_text`, `share` |
| `sourceApp` | Originating application | Free text (trimmed) |
| `sourceURL` | Source URL | `http:` or `https:` only |

Provenance is normalized at the boundary via
`normalizeCaptureProvenance` and persisted as entry properties
(`captureIngress`, `captureSourceApp`, `captureSourceURL`).

## Files

| File | Role |
|------|------|
| `src/project-context.js` | Collection and token generation |
| `src/capture-provenance.js` | Provenance normalization |
| `src/store/capture.js` | Persistence (saveRawCapture, finalize) |
| `src/store/remember.js` | Recall scope and matching |
| `src/store/queries.js` | Query execution (rememberThoughts) |
Loading