brain-framework 22.0.0__tar.gz → 23.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {brain_framework-22.0.0 → brain_framework-23.0.0}/PKG-INFO +19 -17
- {brain_framework-22.0.0 → brain_framework-23.0.0}/README.md +18 -16
- {brain_framework-22.0.0 → brain_framework-23.0.0}/pyproject.toml +17 -3
- {brain_framework-22.0.0 → brain_framework-23.0.0}/pyproject.toml.orig +18 -3
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/__init__.py +1 -1
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/cli.py +90 -137
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/collect.py +43 -29
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/config.py +145 -147
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/evaluate.py +6 -11
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/graph.py +50 -86
- brain_framework-23.0.0/src/bf/guide.py +75 -0
- brain_framework-23.0.0/src/bf/guides/authoring.md +58 -0
- brain_framework-23.0.0/src/bf/guides/events.md +60 -0
- brain_framework-23.0.0/src/bf/guides/getting-started.md +73 -0
- brain_framework-23.0.0/src/bf/guides/index.md +37 -0
- brain_framework-23.0.0/src/bf/guides/jobs.md +61 -0
- brain_framework-23.0.0/src/bf/guides/operations.md +64 -0
- brain_framework-23.0.0/src/bf/guides/reference.md +68 -0
- brain_framework-23.0.0/src/bf/guides/retrieval.md +60 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/health.py +65 -96
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/history.py +18 -10
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/index.py +40 -78
- brain_framework-23.0.0/src/bf/install.py +314 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/links.py +36 -28
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/markdown.py +6 -1
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/mcp.py +11 -12
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/models.py +161 -201
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/ontology.py +40 -126
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/pages.py +238 -542
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/replies.py +67 -115
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/retrieve.py +177 -327
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/runtime.py +3 -2
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/schemas.py +9 -4
- brain_framework-23.0.0/src/bf/skills/bf/SKILL.md +35 -0
- brain_framework-23.0.0/src/bf/starter/AGENTS.md +21 -0
- brain_framework-23.0.0/src/bf/starter/gitignore +7 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/storage.py +50 -153
- brain_framework-23.0.0/src/bf/usage.py +326 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/validate.py +42 -5
- brain_framework-22.0.0/src/bf/install.py +0 -229
- brain_framework-22.0.0/src/bf/skills/README.md +0 -37
- brain_framework-22.0.0/src/bf/skills/bf-action/SKILL.md +0 -52
- brain_framework-22.0.0/src/bf/skills/bf-action/references/actions.md +0 -29
- brain_framework-22.0.0/src/bf/skills/bf-action/references/context.md +0 -21
- brain_framework-22.0.0/src/bf/skills/bf-action/references/handoff.md +0 -36
- brain_framework-22.0.0/src/bf/skills/bf-action/scripts/check-handoff.py +0 -133
- brain_framework-22.0.0/src/bf/skills/bf-action/templates/action.md +0 -37
- brain_framework-22.0.0/src/bf/skills/bf-maintain/SKILL.md +0 -46
- brain_framework-22.0.0/src/bf/skills/bf-maintain/references/conflicts.md +0 -10
- brain_framework-22.0.0/src/bf/skills/bf-maintain/references/integrations.md +0 -94
- brain_framework-22.0.0/src/bf/skills/bf-maintain/references/operations.md +0 -42
- brain_framework-22.0.0/src/bf/skills/bf-setup/SKILL.md +0 -55
- brain_framework-22.0.0/src/bf/skills/bf-setup/references/discovery.md +0 -15
- brain_framework-22.0.0/src/bf/skills/bf-setup/references/import.md +0 -20
- brain_framework-22.0.0/src/bf/skills/bf-setup/references/scan.md +0 -19
- brain_framework-22.0.0/src/bf/skills/bf-setup/scripts/inventory.py +0 -182
- brain_framework-22.0.0/src/bf/skills/bf-use/SKILL.md +0 -53
- brain_framework-22.0.0/src/bf/skills/bf-use/references/evidence.md +0 -32
- brain_framework-22.0.0/src/bf/skills/bf-use/references/learn.md +0 -43
- brain_framework-22.0.0/src/bf/skills/bf-use/references/links.md +0 -28
- brain_framework-22.0.0/src/bf/skills/bf-use/references/retrieval.md +0 -26
- brain_framework-22.0.0/src/bf/skills/bf-use/scripts/evidence.py +0 -348
- brain_framework-22.0.0/src/bf/skills/bf-use/scripts/guarded-write.py +0 -359
- brain_framework-22.0.0/src/bf/skills/bf-use/templates/concept.md +0 -16
- brain_framework-22.0.0/src/bf/skills/bf-use/templates/project.md +0 -29
- brain_framework-22.0.0/src/bf/starter/AGENTS.md +0 -23
- brain_framework-22.0.0/src/bf/starter/gitignore +0 -8
- brain_framework-22.0.0/src/bf/usage.py +0 -346
- {brain_framework-22.0.0 → brain_framework-23.0.0}/LICENSE +0 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/THIRD_PARTY_NOTICES.md +0 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/__main__.py +0 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/assistants.py +0 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/channels.py +0 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/messages.py +0 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/py.typed +0 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/records.py +0 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/starter/concepts/index.md +0 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/starter/concepts/welcome.md +0 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/starter/evals/retrieval.yaml +0 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/update.py +0 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/watch.py +0 -0
- {brain_framework-22.0.0 → brain_framework-23.0.0}/src/bf/watch_settings.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: brain-framework
|
|
3
|
-
Version:
|
|
3
|
+
Version: 23.0.0
|
|
4
4
|
Summary: Brain Framework is a local-first brain for you and your AI agents. It collects evidence from your tools into plain files you own, connects them through an ontology you declare, lets any agent harness search and read offline, and wakes your harness when declarative when: rules or reviewed gates spot new evidence.
|
|
5
5
|
Keywords: ai,ai-agents,agent-memory,agent-skills,agents-md,context-engineering,knowledge-graph,knowledge-management,local-first,mcp,model-context-protocol,ontology,personal-knowledge-management,python,second-brain
|
|
6
6
|
Author: Médéric Hurier
|
|
@@ -107,30 +107,32 @@ Continue with [Getting started](https://fmind.github.io/brain-framework/docs/get
|
|
|
107
107
|
|
|
108
108
|
Five steps run in one loop: **gather → normalize → organize and connect → act → learn.**
|
|
109
109
|
|
|
110
|
-
| Folder | Role
|
|
111
|
-
| ----------- |
|
|
112
|
-
| `memories/` | Collected JSON records keyed by SHA-256 of `id`, with provenance and `
|
|
113
|
-
| `projects/` | Project state (`Now`), decisions (`Decision`) and open tasks (`Next actions`)
|
|
114
|
-
| `concepts/` | Durable reusable patterns and reference syntheses
|
|
115
|
-
| `actions/` | Tracked work sessions (`draft` open, `stable` settled, `deprecated` retired)
|
|
116
|
-
| `sensors/` | Stdlib scripts (built on `_sensor.py`) printing JSON or JSONL from your tools
|
|
117
|
-
| `routines/` | Deterministic scripts (built on `_bf.py`) run on intervals, `at` or Git hooks
|
|
110
|
+
| Folder | Role |
|
|
111
|
+
| ----------- | ------------------------------------------------------------------------------------------------------- |
|
|
112
|
+
| `memories/` | Collected JSON records keyed by SHA-256 of `id`, with provenance, `@type`, `relations` and `attributes` |
|
|
113
|
+
| `projects/` | Project state (`Now`), decisions (`Decision`) and open tasks (`Next actions`) |
|
|
114
|
+
| `concepts/` | Durable reusable patterns and reference syntheses |
|
|
115
|
+
| `actions/` | Tracked work sessions (`draft` open, `stable` settled, `deprecated` retired) |
|
|
116
|
+
| `sensors/` | Stdlib scripts (built on `_sensor.py`) printing JSON or JSONL from your tools |
|
|
117
|
+
| `routines/` | Deterministic scripts (built on `_bf.py`) run on intervals, `at` or Git hooks |
|
|
118
118
|
|
|
119
119
|
`bf.yaml` declares shared [fields and mappings](https://fmind.github.io/brain-framework/docs/schema/#shared-fields-and-sensor-mappings), [sensors](https://fmind.github.io/brain-framework/docs/sensors/), [routines](https://fmind.github.io/brain-framework/docs/routines/) and [assistants](https://fmind.github.io/brain-framework/docs/prompts/). A disposable SQLite cache in `.bf/` powers offline BM25 search, graph backlinks (`bf read project:new-website`), triage (`bf read review`) and JSONL exports (`bf export --kind items`). See the [directory reference](https://fmind.github.io/brain-framework/docs/brain/#directory-reference).
|
|
120
120
|
|
|
121
121
|
## Open your agent in your brain
|
|
122
122
|
|
|
123
|
-
Install the packaged
|
|
123
|
+
Install the packaged `/bf` skill for [Claude Code](https://code.claude.com/docs/en/overview), [Codex](https://openai.com/codex/), [GitHub Copilot](https://github.com/features/copilot) or any [Agent Skills](https://agentskills.io/specification) host:
|
|
124
124
|
|
|
125
125
|
```bash
|
|
126
|
-
bf
|
|
127
|
-
bf
|
|
126
|
+
bf skill install --global # ~/.agents/skills/bf (and links ~/.claude/skills/bf if present)
|
|
127
|
+
bf skill install # inside a brain: skills/bf, linked to .agents/skills/bf and .claude/skills/bf
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
- **`bf
|
|
133
|
-
- **`bf
|
|
130
|
+
The `/bf` router connects your harness to built-in offline documentation via `bf guide`:
|
|
131
|
+
|
|
132
|
+
- **`bf guide retrieval`**: orient with `bf read review`, verify and cite `SOURCE:ID` refs and export graph claims.
|
|
133
|
+
- **`bf guide authoring`**: update owning `projects/` and `concepts/`, manage tracked `actions/` (`bf action new`, `bf action status`) and connect entities.
|
|
134
|
+
- **`bf guide getting-started` / `bf guide operations`**: initialize or register brains, run [MCP](https://fmind.github.io/brain-framework/docs/mcp/), validate, evaluate and troubleshoot.
|
|
135
|
+
- **`bf guide jobs` / `bf guide events`**: configure sensors, routines, assistants and `bf watch`, recover queues and use Git hooks.
|
|
134
136
|
|
|
135
137
|
See [agent workflows](https://fmind.github.io/brain-framework/docs/agents/) and optional repository [hooks](https://github.com/fmind/brain-framework/tree/main/examples/hooks).
|
|
136
138
|
|
|
@@ -182,6 +184,6 @@ assistants:
|
|
|
182
184
|
|
|
183
185
|
1. **Local-first and private.** No BF server, account or telemetry; retrieval is 100% offline ([privacy and security](https://fmind.github.io/brain-framework/docs/privacy/)).
|
|
184
186
|
1. **Harnesses reason; BF verifies.** BF runs no LLM and ships no provider SDKs or embeddings (`bf export --kind items` feeds external retrievers; [what BF does not do](https://fmind.github.io/brain-framework/docs/concepts/#what-bf-does-not-do)).
|
|
185
|
-
1. **Git-native collaboration.** Version notes
|
|
187
|
+
1. **Git-native collaboration.** Version notes, ontology, programs and evals in Git while keeping local memories and `.bf/` caches out of shared history; major releases batch breaking changes cleanly ([versioning](https://fmind.github.io/brain-framework/docs/upgrades/#versioning-and-stability)).
|
|
186
188
|
|
|
187
189
|
[Commands](https://fmind.github.io/brain-framework/docs/commands/) · [Issues](https://github.com/fmind/brain-framework/issues) · [Contribute](https://github.com/fmind/brain-framework/blob/main/CONTRIBUTING.md) · [Governance](https://github.com/fmind/brain-framework/blob/main/GOVERNANCE.md) · [MIT License](https://github.com/fmind/brain-framework/blob/main/LICENSE) · [Third-party notices](https://github.com/fmind/brain-framework/blob/main/THIRD_PARTY_NOTICES.md)
|
|
@@ -73,30 +73,32 @@ Continue with [Getting started](https://fmind.github.io/brain-framework/docs/get
|
|
|
73
73
|
|
|
74
74
|
Five steps run in one loop: **gather → normalize → organize and connect → act → learn.**
|
|
75
75
|
|
|
76
|
-
| Folder | Role
|
|
77
|
-
| ----------- |
|
|
78
|
-
| `memories/` | Collected JSON records keyed by SHA-256 of `id`, with provenance and `
|
|
79
|
-
| `projects/` | Project state (`Now`), decisions (`Decision`) and open tasks (`Next actions`)
|
|
80
|
-
| `concepts/` | Durable reusable patterns and reference syntheses
|
|
81
|
-
| `actions/` | Tracked work sessions (`draft` open, `stable` settled, `deprecated` retired)
|
|
82
|
-
| `sensors/` | Stdlib scripts (built on `_sensor.py`) printing JSON or JSONL from your tools
|
|
83
|
-
| `routines/` | Deterministic scripts (built on `_bf.py`) run on intervals, `at` or Git hooks
|
|
76
|
+
| Folder | Role |
|
|
77
|
+
| ----------- | ------------------------------------------------------------------------------------------------------- |
|
|
78
|
+
| `memories/` | Collected JSON records keyed by SHA-256 of `id`, with provenance, `@type`, `relations` and `attributes` |
|
|
79
|
+
| `projects/` | Project state (`Now`), decisions (`Decision`) and open tasks (`Next actions`) |
|
|
80
|
+
| `concepts/` | Durable reusable patterns and reference syntheses |
|
|
81
|
+
| `actions/` | Tracked work sessions (`draft` open, `stable` settled, `deprecated` retired) |
|
|
82
|
+
| `sensors/` | Stdlib scripts (built on `_sensor.py`) printing JSON or JSONL from your tools |
|
|
83
|
+
| `routines/` | Deterministic scripts (built on `_bf.py`) run on intervals, `at` or Git hooks |
|
|
84
84
|
|
|
85
85
|
`bf.yaml` declares shared [fields and mappings](https://fmind.github.io/brain-framework/docs/schema/#shared-fields-and-sensor-mappings), [sensors](https://fmind.github.io/brain-framework/docs/sensors/), [routines](https://fmind.github.io/brain-framework/docs/routines/) and [assistants](https://fmind.github.io/brain-framework/docs/prompts/). A disposable SQLite cache in `.bf/` powers offline BM25 search, graph backlinks (`bf read project:new-website`), triage (`bf read review`) and JSONL exports (`bf export --kind items`). See the [directory reference](https://fmind.github.io/brain-framework/docs/brain/#directory-reference).
|
|
86
86
|
|
|
87
87
|
## Open your agent in your brain
|
|
88
88
|
|
|
89
|
-
Install the packaged
|
|
89
|
+
Install the packaged `/bf` skill for [Claude Code](https://code.claude.com/docs/en/overview), [Codex](https://openai.com/codex/), [GitHub Copilot](https://github.com/features/copilot) or any [Agent Skills](https://agentskills.io/specification) host:
|
|
90
90
|
|
|
91
91
|
```bash
|
|
92
|
-
bf
|
|
93
|
-
bf
|
|
92
|
+
bf skill install --global # ~/.agents/skills/bf (and links ~/.claude/skills/bf if present)
|
|
93
|
+
bf skill install # inside a brain: skills/bf, linked to .agents/skills/bf and .claude/skills/bf
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
- **`bf
|
|
99
|
-
- **`bf
|
|
96
|
+
The `/bf` router connects your harness to built-in offline documentation via `bf guide`:
|
|
97
|
+
|
|
98
|
+
- **`bf guide retrieval`**: orient with `bf read review`, verify and cite `SOURCE:ID` refs and export graph claims.
|
|
99
|
+
- **`bf guide authoring`**: update owning `projects/` and `concepts/`, manage tracked `actions/` (`bf action new`, `bf action status`) and connect entities.
|
|
100
|
+
- **`bf guide getting-started` / `bf guide operations`**: initialize or register brains, run [MCP](https://fmind.github.io/brain-framework/docs/mcp/), validate, evaluate and troubleshoot.
|
|
101
|
+
- **`bf guide jobs` / `bf guide events`**: configure sensors, routines, assistants and `bf watch`, recover queues and use Git hooks.
|
|
100
102
|
|
|
101
103
|
See [agent workflows](https://fmind.github.io/brain-framework/docs/agents/) and optional repository [hooks](https://github.com/fmind/brain-framework/tree/main/examples/hooks).
|
|
102
104
|
|
|
@@ -148,6 +150,6 @@ assistants:
|
|
|
148
150
|
|
|
149
151
|
1. **Local-first and private.** No BF server, account or telemetry; retrieval is 100% offline ([privacy and security](https://fmind.github.io/brain-framework/docs/privacy/)).
|
|
150
152
|
1. **Harnesses reason; BF verifies.** BF runs no LLM and ships no provider SDKs or embeddings (`bf export --kind items` feeds external retrievers; [what BF does not do](https://fmind.github.io/brain-framework/docs/concepts/#what-bf-does-not-do)).
|
|
151
|
-
1. **Git-native collaboration.** Version notes
|
|
153
|
+
1. **Git-native collaboration.** Version notes, ontology, programs and evals in Git while keeping local memories and `.bf/` caches out of shared history; major releases batch breaking changes cleanly ([versioning](https://fmind.github.io/brain-framework/docs/upgrades/#versioning-and-stability)).
|
|
152
154
|
|
|
153
155
|
[Commands](https://fmind.github.io/brain-framework/docs/commands/) · [Issues](https://github.com/fmind/brain-framework/issues) · [Contribute](https://github.com/fmind/brain-framework/blob/main/CONTRIBUTING.md) · [Governance](https://github.com/fmind/brain-framework/blob/main/GOVERNANCE.md) · [MIT License](https://github.com/fmind/brain-framework/blob/main/LICENSE) · [Third-party notices](https://github.com/fmind/brain-framework/blob/main/THIRD_PARTY_NOTICES.md)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "brain-framework"
|
|
3
|
-
version = "
|
|
3
|
+
version = "23.0.0"
|
|
4
4
|
description = "Brain Framework is a local-first brain for you and your AI agents. It collects evidence from your tools into plain files you own, connects them through an ontology you declare, lets any agent harness search and read offline, and wakes your harness when declarative when: rules or reviewed gates spot new evidence."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.14"
|
|
@@ -78,7 +78,6 @@ src = [
|
|
|
78
78
|
extend-exclude = ["*.md"]
|
|
79
79
|
|
|
80
80
|
[tool.ruff.per-file-target-version]
|
|
81
|
-
"src/bf/skills/*/scripts/*.py" = "py311"
|
|
82
81
|
"examples/**/*.py" = "py311"
|
|
83
82
|
|
|
84
83
|
[tool.ruff.format]
|
|
@@ -131,12 +130,26 @@ ignore = [
|
|
|
131
130
|
]
|
|
132
131
|
|
|
133
132
|
[tool.ruff.lint.per-file-ignores]
|
|
134
|
-
"examples
|
|
133
|
+
"examples/**/_bf.py" = [
|
|
134
|
+
"A002",
|
|
135
|
+
"S603",
|
|
136
|
+
"S607",
|
|
137
|
+
]
|
|
138
|
+
"examples/channels/**" = ["S603"]
|
|
139
|
+
"examples/hooks/**" = [
|
|
140
|
+
"BLE001",
|
|
141
|
+
"S607",
|
|
142
|
+
]
|
|
135
143
|
"examples/sensors/**" = [
|
|
136
144
|
"S603",
|
|
137
145
|
"S607",
|
|
138
146
|
"T201",
|
|
139
147
|
]
|
|
148
|
+
"examples/sensors/_sensor.py" = [
|
|
149
|
+
"A002",
|
|
150
|
+
"BLE001",
|
|
151
|
+
"S310",
|
|
152
|
+
]
|
|
140
153
|
"tests/**" = [
|
|
141
154
|
"BLE001",
|
|
142
155
|
"S101",
|
|
@@ -162,6 +175,7 @@ patch = ["subprocess"]
|
|
|
162
175
|
|
|
163
176
|
[tool.coverage.report]
|
|
164
177
|
fail_under = 95
|
|
178
|
+
precision = 2
|
|
165
179
|
show_missing = true
|
|
166
180
|
skip_covered = true
|
|
167
181
|
skip_empty = true
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# https://packaging.python.org/en/latest/specifications/pyproject-toml/
|
|
2
2
|
[project]
|
|
3
3
|
name = "brain-framework"
|
|
4
|
-
version = "
|
|
4
|
+
version = "23.0.0"
|
|
5
5
|
description = "Brain Framework is a local-first brain for you and your AI agents. It collects evidence from your tools into plain files you own, connects them through an ontology you declare, lets any agent harness search and read offline, and wakes your harness when declarative when: rules or reviewed gates spot new evidence."
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
requires-python = ">=3.14"
|
|
@@ -90,8 +90,8 @@ dev = [
|
|
|
90
90
|
line-length = 120
|
|
91
91
|
src = ["src", "tests"]
|
|
92
92
|
extend-exclude = ["*.md"] # dprint owns Markdown, including its Python code blocks.
|
|
93
|
-
#
|
|
94
|
-
per-file-target-version = { "
|
|
93
|
+
# Copied examples run with the host's python3, not the package interpreter.
|
|
94
|
+
per-file-target-version = { "examples/**/*.py" = "py311" }
|
|
95
95
|
|
|
96
96
|
[tool.ruff.format]
|
|
97
97
|
docstring-code-format = true
|
|
@@ -143,14 +143,28 @@ ignore = [
|
|
|
143
143
|
]
|
|
144
144
|
|
|
145
145
|
[tool.ruff.lint.per-file-ignores]
|
|
146
|
+
"examples/**/_bf.py" = [
|
|
147
|
+
"A002", # `emit_receipt(id=...)` matches BF's channel receipt field name.
|
|
148
|
+
"S603", # Helpers invoke `bf` with literal argv lists and no shell.
|
|
149
|
+
"S607", # `bf` is resolved on the PATH Brain Framework or the host provides.
|
|
150
|
+
]
|
|
151
|
+
"examples/channels/**" = [
|
|
152
|
+
"S603", # Channel adapters invoke notifier CLIs with literal argv lists and no shell.
|
|
153
|
+
]
|
|
146
154
|
"examples/hooks/**" = [
|
|
147
155
|
"BLE001", # Silent hooks must exit 0 with no output on any unexpected error.
|
|
156
|
+
"S607", # Hooks resolve `git` by bare name on PATH with literal arguments.
|
|
148
157
|
]
|
|
149
158
|
"examples/sensors/**" = [
|
|
150
159
|
"S603", # Adapters invoke provider CLIs with literal argv lists; no shell is involved.
|
|
151
160
|
"S607", # Provider CLIs are resolved by bare name on the PATH Brain Framework sanitizes.
|
|
152
161
|
"T201", # Adapters print exactly one JSON array to stdout.
|
|
153
162
|
]
|
|
163
|
+
"examples/sensors/_sensor.py" = [
|
|
164
|
+
"A002", # `record(id=...)` matches BF's record field name.
|
|
165
|
+
"BLE001", # `main()` and `cli()` catch unexpected exceptions so tracebacks never quote provider data.
|
|
166
|
+
"S310", # `fetch()` rejects non-HTTPS schemes, credentials and cross-host redirects before opening.
|
|
167
|
+
]
|
|
154
168
|
"tests/**" = [
|
|
155
169
|
"BLE001", # Worker-thread test helpers record any exception so the test thread can assert on it.
|
|
156
170
|
"S101", # pytest assertions are the test contract.
|
|
@@ -181,6 +195,7 @@ patch = ["subprocess"]
|
|
|
181
195
|
|
|
182
196
|
[tool.coverage.report]
|
|
183
197
|
fail_under = 95
|
|
198
|
+
precision = 2
|
|
184
199
|
show_missing = true
|
|
185
200
|
skip_covered = true
|
|
186
201
|
skip_empty = true
|
|
@@ -56,7 +56,6 @@ from bf.models import (
|
|
|
56
56
|
)
|
|
57
57
|
|
|
58
58
|
if TYPE_CHECKING:
|
|
59
|
-
from bf.models import SchemaField
|
|
60
59
|
from bf.storage import Store
|
|
61
60
|
|
|
62
61
|
|
|
@@ -145,24 +144,17 @@ app = typer.Typer(
|
|
|
145
144
|
BrainOption = Annotated[
|
|
146
145
|
str,
|
|
147
146
|
typer.Option(
|
|
148
|
-
"--brain", help="Brain name or path; otherwise BF_BRAIN, the enclosing brain, or
|
|
149
|
-
),
|
|
150
|
-
]
|
|
151
|
-
# build, eval and validate check one root: several registered brains need a choice.
|
|
152
|
-
OneBrainOption = Annotated[
|
|
153
|
-
str,
|
|
154
|
-
typer.Option(
|
|
155
|
-
"--brain",
|
|
156
|
-
help="Brain name or path; otherwise BF_BRAIN, the enclosing brain, or the only registered brain present.",
|
|
147
|
+
"--brain", help="Brain name or path; otherwise BF_BRAIN, the enclosing brain, or the default registered brain."
|
|
157
148
|
),
|
|
158
149
|
]
|
|
150
|
+
OneBrainOption = BrainOption
|
|
159
151
|
# Registration selects brains for retrieval only: programs run in one explicitly or enclosingly selected brain.
|
|
160
152
|
RunOption = Annotated[
|
|
161
153
|
str,
|
|
162
154
|
typer.Option(
|
|
163
155
|
"--brain",
|
|
164
156
|
help="Registered or enclosing brain name, or a path; otherwise BF_BRAIN or the enclosing brain, "
|
|
165
|
-
"never
|
|
157
|
+
"never the default registered brain.",
|
|
166
158
|
),
|
|
167
159
|
]
|
|
168
160
|
SensorOption = Annotated[
|
|
@@ -181,7 +173,7 @@ AssistantOption = Annotated[
|
|
|
181
173
|
FOLDERS = ("projects", "actions")
|
|
182
174
|
OPTIONAL = ("memories", "assets", "sensors", "routines", "skills")
|
|
183
175
|
# The files every new brain starts with, packaged as plain files: AGENTS.md, loaded by every agent session, stays
|
|
184
|
-
# short, since procedures live in the
|
|
176
|
+
# short, since procedures live in `bf guide` and the packaged `bf` skill. The ignore file is stored without its dot.
|
|
185
177
|
STARTER = {
|
|
186
178
|
"AGENTS.md": "AGENTS.md",
|
|
187
179
|
".gitignore": "gitignore",
|
|
@@ -232,7 +224,14 @@ def _option[T](name: str, parse: Callable[[str], T], value: str) -> T:
|
|
|
232
224
|
|
|
233
225
|
|
|
234
226
|
# Service argument names as the commands spell them, for invalid input a service rejects.
|
|
235
|
-
_ARGUMENTS = {
|
|
227
|
+
_ARGUMENTS = {
|
|
228
|
+
"query": "QUERY",
|
|
229
|
+
"ref": "REF",
|
|
230
|
+
"rel": "--rel",
|
|
231
|
+
"scope": "--scope",
|
|
232
|
+
"offset": "--offset",
|
|
233
|
+
"topic": "TOPIC",
|
|
234
|
+
}
|
|
236
235
|
|
|
237
236
|
|
|
238
237
|
def _finite(value: float | None) -> float | None:
|
|
@@ -278,103 +277,16 @@ def _derived(directory: str) -> str:
|
|
|
278
277
|
return name
|
|
279
278
|
|
|
280
279
|
|
|
281
|
-
def _vacant(directory: Path) -> None:
|
|
282
|
-
"""Refuse a directory holding anything
|
|
283
|
-
|
|
280
|
+
def _vacant(directory: Path, *, locked: bool = False) -> None:
|
|
281
|
+
"""Refuse a directory holding anything besides Git metadata (and `.bf` created by `writer(store)` when locked)."""
|
|
282
|
+
allowed = {".git", ".bf"} if locked else {".git"}
|
|
283
|
+
if any(entry.name not in allowed for entry in directory.iterdir()):
|
|
284
284
|
raise Error("initialization requires a new, empty or freshly cloned directory")
|
|
285
285
|
|
|
286
286
|
|
|
287
287
|
# This release's published schemas, for editor modelines: the strict schema on main may already belong to the next
|
|
288
288
|
# major, which can reject keys this release accepts. Editors fetch them; BF itself stays offline.
|
|
289
289
|
SCHEMAS = f"https://raw.githubusercontent.com/fmind/brain-framework/v{__version__}/docs/"
|
|
290
|
-
# The standard vocabulary (docs/docs/schema.md#standard-vocabulary): sensors that print these attributes plug into a
|
|
291
|
-
# new brain without mappings, and notes link with the relations at the end.
|
|
292
|
-
_PEOPLE = {
|
|
293
|
-
"author": "Account explicitly credited as author; authorship is not ownership.",
|
|
294
|
-
"owner": "Account or organization the provider declares responsible for the item.",
|
|
295
|
-
"assignee": "Account assigned responsibility for the item.",
|
|
296
|
-
"participant": "Any account in a message, event or meeting; its narrower relations, such as sender, list here too.",
|
|
297
|
-
}
|
|
298
|
-
_ROLES = {
|
|
299
|
-
"sender": "Account that sent the message.",
|
|
300
|
-
"recipient": "Direct recipients; excludes copy recipients.",
|
|
301
|
-
"cc": "Accounts explicitly copied on a message.",
|
|
302
|
-
"organizer": "Organizer declared by the calendar provider.",
|
|
303
|
-
"attendee": "Accounts listed as attendees; not proof of attendance.",
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
def _standard_fields() -> dict[str, SchemaField]:
|
|
308
|
-
from bf.models import SchemaField
|
|
309
|
-
|
|
310
|
-
return {
|
|
311
|
-
**{
|
|
312
|
-
name: SchemaField(
|
|
313
|
-
description=description,
|
|
314
|
-
type="identity",
|
|
315
|
-
cardinality="many",
|
|
316
|
-
relation=True,
|
|
317
|
-
path=f"/attributes/{name}_refs",
|
|
318
|
-
)
|
|
319
|
-
for name, description in _PEOPLE.items()
|
|
320
|
-
},
|
|
321
|
-
**{
|
|
322
|
-
name: SchemaField(
|
|
323
|
-
description=description,
|
|
324
|
-
type="identity",
|
|
325
|
-
cardinality="many",
|
|
326
|
-
relation=True,
|
|
327
|
-
broader="participant",
|
|
328
|
-
path=f"/attributes/{name}_refs",
|
|
329
|
-
)
|
|
330
|
-
for name, description in _ROLES.items()
|
|
331
|
-
},
|
|
332
|
-
"repository": SchemaField(
|
|
333
|
-
description="Repository the item belongs to.",
|
|
334
|
-
type="identity",
|
|
335
|
-
cardinality="many",
|
|
336
|
-
relation=True,
|
|
337
|
-
path="/attributes/repository_refs",
|
|
338
|
-
),
|
|
339
|
-
"project": SchemaField(
|
|
340
|
-
description="Project the source names for the item.",
|
|
341
|
-
type="identity",
|
|
342
|
-
cardinality="many",
|
|
343
|
-
relation=True,
|
|
344
|
-
path="/attributes/project_refs",
|
|
345
|
-
),
|
|
346
|
-
"part-of": SchemaField(
|
|
347
|
-
description="Containing thread, folder, list, epic, project or other parent item.",
|
|
348
|
-
type="identity",
|
|
349
|
-
cardinality="many",
|
|
350
|
-
relation=True,
|
|
351
|
-
path="/attributes/parent_refs",
|
|
352
|
-
),
|
|
353
|
-
"label": SchemaField(
|
|
354
|
-
description="Label the provider attaches to the item.",
|
|
355
|
-
type="identity",
|
|
356
|
-
cardinality="many",
|
|
357
|
-
relation=True,
|
|
358
|
-
path="/attributes/label_refs",
|
|
359
|
-
),
|
|
360
|
-
"kind": SchemaField(
|
|
361
|
-
description="Provider-declared kind of item within a source that mixes several kinds.",
|
|
362
|
-
type="string",
|
|
363
|
-
cardinality="one",
|
|
364
|
-
path="/attributes/kind",
|
|
365
|
-
),
|
|
366
|
-
"status": SchemaField(
|
|
367
|
-
description="The item's state in its own tool.", type="string", cardinality="one", path="/attributes/status"
|
|
368
|
-
),
|
|
369
|
-
**{
|
|
370
|
-
name: SchemaField(description=description, type="identity", cardinality="many", relation=True)
|
|
371
|
-
for name, description in {
|
|
372
|
-
"depends-on": "The subject requires the target to operate or remain valid.",
|
|
373
|
-
"related-to": "An explicit association without a more specific known relation.",
|
|
374
|
-
"supersedes": "The subject replaces the target, which remains historical evidence.",
|
|
375
|
-
}.items()
|
|
376
|
-
},
|
|
377
|
-
}
|
|
378
290
|
|
|
379
291
|
|
|
380
292
|
@app.command("init", rich_help_panel="Set up")
|
|
@@ -397,20 +309,21 @@ def initialize(
|
|
|
397
309
|
"""Create a brain at PATH (recommended: ~/brain); no global registration is needed."""
|
|
398
310
|
import yaml
|
|
399
311
|
|
|
400
|
-
from bf.models import
|
|
312
|
+
from bf.models import starter_config
|
|
401
313
|
from bf.storage import Store, expand, writer
|
|
402
314
|
|
|
403
315
|
path = expand(path)
|
|
404
316
|
# Only an omitted --name derives one: an empty or blank value is invalid, never the directory's name.
|
|
405
317
|
name = _derived(path.resolve().name) if name is None else _name(name)
|
|
406
|
-
config =
|
|
318
|
+
config = starter_config(name)
|
|
407
319
|
if path.exists():
|
|
408
320
|
_vacant(path)
|
|
409
321
|
path.mkdir(mode=0o700, parents=True, exist_ok=True)
|
|
410
322
|
store = Store(path)
|
|
411
323
|
with writer(store):
|
|
412
|
-
# Again under the lock: of two runs on one empty directory, the second never replaces the first's files
|
|
413
|
-
|
|
324
|
+
# Again under the lock: of two runs on one empty directory, the second never replaces the first's files;
|
|
325
|
+
# `writer(store)` creates `.bf/locks` on first entry, while the pre-lock check already rejected pre-existing `.bf`.
|
|
326
|
+
_vacant(store.root, locked=True)
|
|
414
327
|
store.write(
|
|
415
328
|
"bf.yaml",
|
|
416
329
|
(
|
|
@@ -437,17 +350,39 @@ def enroll(
|
|
|
437
350
|
metavar="PATH", show_default=False, help="Existing brain directory; defaults to the current directory."
|
|
438
351
|
),
|
|
439
352
|
] = Path(),
|
|
353
|
+
name: Annotated[
|
|
354
|
+
str | None,
|
|
355
|
+
typer.Option("--name", help="Registry alias; defaults to bf.yaml's brain name."),
|
|
356
|
+
] = None,
|
|
357
|
+
default: Annotated[
|
|
358
|
+
bool,
|
|
359
|
+
typer.Option("--default", help="Select this brain by default outside any brain directory."),
|
|
360
|
+
] = False,
|
|
440
361
|
) -> None:
|
|
441
362
|
"""Register an existing brain to select it by name outside its folder; never runs its programs."""
|
|
442
363
|
from bf.config import register
|
|
443
364
|
from bf.storage import Store, expand
|
|
444
365
|
|
|
366
|
+
alias = "" if name is None else _name(name)
|
|
445
367
|
path = expand(path)
|
|
446
368
|
if not path.is_dir():
|
|
447
369
|
raise Error("PATH is not an existing directory; pass the brain's directory")
|
|
448
370
|
if not (path / "bf.yaml").is_file():
|
|
449
371
|
raise Error("PATH has no bf.yaml; run bf init PATH first, or pass the brain's root directory")
|
|
450
|
-
emit(register(Store(path)))
|
|
372
|
+
emit(register(Store(path), name=alias, default=default))
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
@app.command("unregister", rich_help_panel="Set up")
|
|
376
|
+
def unenroll(
|
|
377
|
+
target: Annotated[
|
|
378
|
+
str,
|
|
379
|
+
typer.Argument(metavar="TARGET", help="Registered brain name or path to remove from ~/.config/bf/config.yaml."),
|
|
380
|
+
],
|
|
381
|
+
) -> None:
|
|
382
|
+
"""Remove a brain registration from the user registry; changes no files inside the brain."""
|
|
383
|
+
from bf.config import unregister
|
|
384
|
+
|
|
385
|
+
emit(unregister(target))
|
|
451
386
|
|
|
452
387
|
|
|
453
388
|
@app.command("mcp", rich_help_panel="Set up")
|
|
@@ -482,42 +417,61 @@ def serve(brain: BrainOption = "") -> None:
|
|
|
482
417
|
tools.run()
|
|
483
418
|
|
|
484
419
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
420
|
+
skill_app = typer.Typer(
|
|
421
|
+
cls=_Group,
|
|
422
|
+
no_args_is_help=True,
|
|
423
|
+
add_completion=False,
|
|
424
|
+
context_settings={"help_option_names": ["-h", "--help"]},
|
|
425
|
+
pretty_exceptions_show_locals=False,
|
|
426
|
+
help="Install and verify the packaged bf skill.",
|
|
427
|
+
)
|
|
428
|
+
app.add_typer(skill_app, name="skill", rich_help_panel="Set up")
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
@skill_app.command("install")
|
|
432
|
+
def skill_install(
|
|
433
|
+
brain: BrainOption = "",
|
|
434
|
+
global_: Annotated[
|
|
435
|
+
bool,
|
|
436
|
+
typer.Option("--global", help="Install into ~/.agents/skills/bf (and link ~/.claude/skills/bf when present)."),
|
|
437
|
+
] = False,
|
|
495
438
|
check: Annotated[
|
|
496
439
|
bool,
|
|
497
440
|
typer.Option(
|
|
498
441
|
"--check",
|
|
499
|
-
help="Report
|
|
442
|
+
help="Report current, installed, outdated, modified, unmanaged, stale or missing; write nothing.",
|
|
500
443
|
),
|
|
501
444
|
] = False,
|
|
502
445
|
force: Annotated[
|
|
503
446
|
bool,
|
|
504
|
-
typer.Option("--force", help="Replace edited, foreign or newer skill
|
|
505
|
-
] = False,
|
|
506
|
-
link: Annotated[
|
|
507
|
-
bool,
|
|
508
|
-
typer.Option(
|
|
509
|
-
"--link",
|
|
510
|
-
help="When DIR sits inside a brain, link <brain>/.agents/skills/bf-* and <brain>/.claude/skills/bf-* to it.",
|
|
511
|
-
),
|
|
447
|
+
typer.Option("--force", help="Replace edited, foreign or newer bf skill files with the packaged copy."),
|
|
512
448
|
] = False,
|
|
513
449
|
) -> None:
|
|
514
|
-
"""Install
|
|
515
|
-
from bf.
|
|
450
|
+
"""Install the packaged bf skill into one brain (and link .agents/.claude) or globally with --global."""
|
|
451
|
+
from bf.config import one
|
|
452
|
+
from bf.install import install as install_skill
|
|
516
453
|
|
|
517
|
-
|
|
454
|
+
if global_ and brain:
|
|
455
|
+
raise typer.BadParameter("cannot be combined with --global", param_hint="--brain")
|
|
456
|
+
store = None if global_ else one(brain)
|
|
457
|
+
result = install_skill(store, global_=global_, check=check, force=force)
|
|
518
458
|
_finish(result, failed=not result["ok"])
|
|
519
459
|
|
|
520
460
|
|
|
461
|
+
@app.command("guide", rich_help_panel="Set up")
|
|
462
|
+
def guide_command(
|
|
463
|
+
topic: Annotated[
|
|
464
|
+
str | None,
|
|
465
|
+
typer.Argument(metavar="[TOPIC]", show_default=False, help="Guide topic to read; omit to list all topics."),
|
|
466
|
+
] = None,
|
|
467
|
+
) -> None:
|
|
468
|
+
"""Print a Brain Framework guide or the guide topic directory as Markdown."""
|
|
469
|
+
from bf.guide import read_guide, render_index
|
|
470
|
+
|
|
471
|
+
text = render_index() if topic is None else read_guide(topic)
|
|
472
|
+
_write(text.encode("utf-8"))
|
|
473
|
+
|
|
474
|
+
|
|
521
475
|
@app.command("schema", rich_help_panel="Set up")
|
|
522
476
|
def schema(
|
|
523
477
|
kind: Annotated[SchemaKind, typer.Option(help="Configuration format or command reply to describe.")] = "brain",
|
|
@@ -583,8 +537,7 @@ def exact(
|
|
|
583
537
|
from bf.config import select
|
|
584
538
|
from bf.retrieve import read
|
|
585
539
|
|
|
586
|
-
# A malformed ref, or a relation page of a page or a section, fails before any brain is read
|
|
587
|
-
# relation fails once the selected brains name the declared ones.
|
|
540
|
+
# A malformed ref, or a relation page of a page or a section, fails before any brain is read.
|
|
588
541
|
pages.readable(ref, rel)
|
|
589
542
|
emit(read(select(brain), ref, rel=rel, offset=offset))
|
|
590
543
|
|
|
@@ -595,7 +548,7 @@ def export(
|
|
|
595
548
|
Literal["edges", "identities", "items"],
|
|
596
549
|
typer.Option(
|
|
597
550
|
help="edges: one claim per line; identities: each note or record that answers to more than its own "
|
|
598
|
-
"address, with every name; items: each note and record with its metadata,
|
|
551
|
+
"address, with every name; items: each note and record with its metadata, relations, attributes and text."
|
|
599
552
|
),
|
|
600
553
|
] = "edges",
|
|
601
554
|
brain: BrainOption = "",
|
|
@@ -615,7 +568,7 @@ def export(
|
|
|
615
568
|
),
|
|
616
569
|
] = "",
|
|
617
570
|
) -> None:
|
|
618
|
-
"""Print the graph of the selected
|
|
571
|
+
"""Print the graph of the selected brain as JSON Lines from its cache; exit 1 when evidence was skipped."""
|
|
619
572
|
from bf import pages
|
|
620
573
|
from bf.config import select
|
|
621
574
|
from bf.retrieve import edges, identities, items
|
|
@@ -1406,8 +1359,8 @@ _GIVEN = {
|
|
|
1406
1359
|
"--since": "give a start time; an empty value names none",
|
|
1407
1360
|
"--summary": "give a summary; an empty value names none",
|
|
1408
1361
|
"--title": "give a title; an empty value names none",
|
|
1409
|
-
"DIR": "give a directory; an empty value would name the working directory",
|
|
1410
1362
|
"PATH": "give a directory; an empty value would name the working directory",
|
|
1363
|
+
"TARGET": "give a registered brain name or path",
|
|
1411
1364
|
"SENSOR": "give a sensor name from bf.yaml",
|
|
1412
1365
|
"SLUG": "give an action slug or path",
|
|
1413
1366
|
"CHANNEL": "give a channel name from bf.yaml",
|
|
@@ -1528,5 +1481,5 @@ def main() -> None:
|
|
|
1528
1481
|
|
|
1529
1482
|
# Last in the module, so every command declared here gets _Command's checks: repeated or empty values, and invalid
|
|
1530
1483
|
# input a service finds.
|
|
1531
|
-
for _command in (*app.registered_commands, *action_app.registered_commands):
|
|
1484
|
+
for _command in (*app.registered_commands, *action_app.registered_commands, *skill_app.registered_commands):
|
|
1532
1485
|
_command.cls = _Command
|