divan-cli 0.2.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.
- divan_cli-0.2.0/.agents/plugins/marketplace.json +12 -0
- divan_cli-0.2.0/.antigravity-plugin/plugin.json +10 -0
- divan_cli-0.2.0/.claude-plugin/marketplace.json +13 -0
- divan_cli-0.2.0/.claude-plugin/plugin.json +10 -0
- divan_cli-0.2.0/.codex-plugin/plugin.json +11 -0
- divan_cli-0.2.0/.github/workflows/ci.yml +20 -0
- divan_cli-0.2.0/.github/workflows/package.yml +202 -0
- divan_cli-0.2.0/.gitignore +6 -0
- divan_cli-0.2.0/AGENTS.md +38 -0
- divan_cli-0.2.0/CHANGELOG.md +70 -0
- divan_cli-0.2.0/CODE_OF_CONDUCT.md +124 -0
- divan_cli-0.2.0/CONTRIBUTING.md +39 -0
- divan_cli-0.2.0/LICENSE +202 -0
- divan_cli-0.2.0/PKG-INFO +202 -0
- divan_cli-0.2.0/README.md +177 -0
- divan_cli-0.2.0/SECURITY.md +76 -0
- divan_cli-0.2.0/examples/ci-divan-check.yml +13 -0
- divan_cli-0.2.0/hooks/claude.json +61 -0
- divan_cli-0.2.0/hooks/codex.json +59 -0
- divan_cli-0.2.0/hooks.json +18 -0
- divan_cli-0.2.0/install.sh +105 -0
- divan_cli-0.2.0/packaging/homebrew/divan.rb.tmpl +25 -0
- divan_cli-0.2.0/packaging/homebrew/render.py +40 -0
- divan_cli-0.2.0/packaging/homebrew/tap-readme.md +9 -0
- divan_cli-0.2.0/packaging/smoke.sh +52 -0
- divan_cli-0.2.0/pyproject.toml +45 -0
- divan_cli-0.2.0/skills/divan/SKILL.md +12 -0
- divan_cli-0.2.0/src/divan/SKILL.md +1 -0
- divan_cli-0.2.0/src/divan/__init__.py +1 -0
- divan_cli-0.2.0/src/divan/__main__.py +3 -0
- divan_cli-0.2.0/src/divan/agent.py +281 -0
- divan_cli-0.2.0/src/divan/check.py +182 -0
- divan_cli-0.2.0/src/divan/cli.py +415 -0
- divan_cli-0.2.0/src/divan/config.py +278 -0
- divan_cli-0.2.0/src/divan/doc.py +90 -0
- divan_cli-0.2.0/src/divan/hooks.py +475 -0
- divan_cli-0.2.0/src/divan/index.py +229 -0
- divan_cli-0.2.0/src/divan/join.py +213 -0
- divan_cli-0.2.0/src/divan/land.py +271 -0
- divan_cli-0.2.0/src/divan/privdir.py +53 -0
- divan_cli-0.2.0/src/divan/safe.py +27 -0
- divan_cli-0.2.0/src/divan/settings.py +123 -0
- divan_cli-0.2.0/src/divan/tomledit.py +97 -0
- divan_cli-0.2.0/src/divan/write.py +72 -0
- divan_cli-0.2.0/tests/conftest.py +72 -0
- divan_cli-0.2.0/tests/test_agent.py +314 -0
- divan_cli-0.2.0/tests/test_check.py +165 -0
- divan_cli-0.2.0/tests/test_confinement.py +464 -0
- divan_cli-0.2.0/tests/test_exclude.py +44 -0
- divan_cli-0.2.0/tests/test_find_new.py +164 -0
- divan_cli-0.2.0/tests/test_guide_since.py +62 -0
- divan_cli-0.2.0/tests/test_hooks.py +476 -0
- divan_cli-0.2.0/tests/test_isolation.py +61 -0
- divan_cli-0.2.0/tests/test_join.py +183 -0
- divan_cli-0.2.0/tests/test_land.py +212 -0
- divan_cli-0.2.0/tests/test_packaging.py +269 -0
- divan_cli-0.2.0/tests/test_plugin.py +73 -0
- divan_cli-0.2.0/tests/test_settings.py +310 -0
- divan_cli-0.2.0/tests/test_topics.py +17 -0
- divan_cli-0.2.0/uv.lock +156 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "divan",
|
|
3
|
+
"interface": { "displayName": "divan" },
|
|
4
|
+
"plugins": [
|
|
5
|
+
{
|
|
6
|
+
"name": "divan",
|
|
7
|
+
"source": { "source": "local", "path": "./" },
|
|
8
|
+
"policy": { "installation": "AVAILABLE", "authentication": "ON_INSTALL" },
|
|
9
|
+
"category": "Productivity"
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "divan",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Search your knowledge base before researching, save findings after, and never lose research at the end of a session.",
|
|
5
|
+
"author": { "name": "Tim Nunamaker" },
|
|
6
|
+
"homepage": "https://github.com/tnunamak/divan",
|
|
7
|
+
"repository": "https://github.com/tnunamak/divan",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"skills": "./skills/"
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "divan",
|
|
3
|
+
"owner": { "name": "Tim Nunamaker" },
|
|
4
|
+
"metadata": { "description": "divan: search and write your markdown knowledge bases from your coding agent" },
|
|
5
|
+
"plugins": [
|
|
6
|
+
{
|
|
7
|
+
"name": "divan",
|
|
8
|
+
"source": "./",
|
|
9
|
+
"description": "Search your knowledge base before researching, save findings after, and never lose research at the end of a session.",
|
|
10
|
+
"category": "productivity"
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "divan",
|
|
3
|
+
"description": "Search your knowledge base before researching, save findings after, and never lose research at the end of a session.",
|
|
4
|
+
"author": { "name": "Tim Nunamaker" },
|
|
5
|
+
"homepage": "https://github.com/tnunamak/divan",
|
|
6
|
+
"repository": "https://github.com/tnunamak/divan",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"skills": "./skills/",
|
|
9
|
+
"hooks": "./hooks/claude.json"
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "divan",
|
|
3
|
+
"description": "Search your knowledge base before researching, save findings after, and never lose research at the end of a session.",
|
|
4
|
+
"author": { "name": "Tim Nunamaker" },
|
|
5
|
+
"homepage": "https://github.com/tnunamak/divan",
|
|
6
|
+
"repository": "https://github.com/tnunamak/divan",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"skills": "./skills/",
|
|
9
|
+
"hooks": "./hooks/codex.json",
|
|
10
|
+
"interface": { "displayName": "divan", "shortDescription": "Search first, save findings, never lose research", "category": "Productivity" }
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
strategy:
|
|
11
|
+
fail-fast: false
|
|
12
|
+
matrix:
|
|
13
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: astral-sh/setup-uv@v6
|
|
17
|
+
with:
|
|
18
|
+
enable-cache: true
|
|
19
|
+
- name: Test
|
|
20
|
+
run: uv run --python ${{ matrix.python-version }} python -m pytest -q
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
name: Package
|
|
2
|
+
|
|
3
|
+
# Publishing a GitHub release (tag vX.Y.Z) builds divan-cli, publishes it to PyPI
|
|
4
|
+
# (trusted publishing, environment "pypi"), attaches the files to the release and
|
|
5
|
+
# updates the Homebrew tap. The tag must be vX.Y.Z and match the version in pyproject.toml.
|
|
6
|
+
# The test job tests and builds one checkout; later jobs publish only those verified files.
|
|
7
|
+
# To release: bump the version in pyproject.toml and src/divan/__init__.py, move the
|
|
8
|
+
# CHANGELOG "Unreleased" notes under the new version, push, then
|
|
9
|
+
# gh release create vX.Y.Z --title vX.Y.Z --notes-file <notes>
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
release:
|
|
13
|
+
types: [published]
|
|
14
|
+
|
|
15
|
+
concurrency:
|
|
16
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
17
|
+
cancel-in-progress: false
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
test:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
permissions:
|
|
23
|
+
contents: read
|
|
24
|
+
outputs:
|
|
25
|
+
sha: ${{ steps.sha.outputs.sha }}
|
|
26
|
+
version: ${{ steps.version.outputs.version }}
|
|
27
|
+
sdist_sha256: ${{ steps.digests.outputs.sdist }}
|
|
28
|
+
wheel_sha256: ${{ steps.digests.outputs.wheel }}
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v4
|
|
31
|
+
with:
|
|
32
|
+
persist-credentials: false
|
|
33
|
+
- name: Record the tested commit
|
|
34
|
+
id: sha
|
|
35
|
+
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
|
36
|
+
- uses: astral-sh/setup-uv@v6
|
|
37
|
+
with:
|
|
38
|
+
enable-cache: true
|
|
39
|
+
- name: Check the tag is vX.Y.Z and matches the package version
|
|
40
|
+
id: version
|
|
41
|
+
env:
|
|
42
|
+
TAG: ${{ github.ref_name }}
|
|
43
|
+
run: |
|
|
44
|
+
set -eu
|
|
45
|
+
if ! printf '%s' "$TAG" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
|
|
46
|
+
echo "::error::tag is not of the form vX.Y.Z"; exit 1
|
|
47
|
+
fi
|
|
48
|
+
v=$(python3 -c 'import tomllib;print(tomllib.load(open("pyproject.toml","rb"))["project"]["version"])')
|
|
49
|
+
i=$(python3 -c 'import re;print(re.search(r"__version__ = \"([^\"]+)\"", open("src/divan/__init__.py").read()).group(1))')
|
|
50
|
+
want="${TAG#v}"
|
|
51
|
+
if [ "$v" != "$want" ] || [ "$i" != "$want" ]; then
|
|
52
|
+
echo "::error::tag $TAG does not match pyproject $v / __version__ $i"; exit 1
|
|
53
|
+
fi
|
|
54
|
+
echo "version=$v" >> "$GITHUB_OUTPUT"
|
|
55
|
+
- run: uv run python -m pytest -q
|
|
56
|
+
- name: Build sdist and wheel from this checkout
|
|
57
|
+
run: uv build --out-dir dist
|
|
58
|
+
- name: Smoke-test the built wheel and sdist in fresh venvs
|
|
59
|
+
env:
|
|
60
|
+
VERSION: ${{ steps.version.outputs.version }}
|
|
61
|
+
run: sh packaging/smoke.sh dist "$VERSION"
|
|
62
|
+
- name: Record digests
|
|
63
|
+
id: digests
|
|
64
|
+
run: |
|
|
65
|
+
set -eu
|
|
66
|
+
set -- dist/*.tar.gz; [ "$#" = 1 ] && [ -f "$1" ] || exit 1
|
|
67
|
+
echo "sdist=$(sha256sum "$1" | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
|
|
68
|
+
set -- dist/*.whl; [ "$#" = 1 ] && [ -f "$1" ] || exit 1
|
|
69
|
+
echo "wheel=$(sha256sum "$1" | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
|
|
70
|
+
- uses: actions/upload-artifact@v4
|
|
71
|
+
with:
|
|
72
|
+
name: dist
|
|
73
|
+
path: dist/
|
|
74
|
+
if-no-files-found: error
|
|
75
|
+
|
|
76
|
+
publish:
|
|
77
|
+
needs: test
|
|
78
|
+
runs-on: ubuntu-latest
|
|
79
|
+
environment:
|
|
80
|
+
name: pypi
|
|
81
|
+
url: https://pypi.org/p/divan-cli
|
|
82
|
+
permissions:
|
|
83
|
+
id-token: write
|
|
84
|
+
contents: write
|
|
85
|
+
steps:
|
|
86
|
+
- uses: actions/download-artifact@v4
|
|
87
|
+
with:
|
|
88
|
+
name: dist
|
|
89
|
+
path: dist
|
|
90
|
+
- name: Verify the files are the ones that were tested
|
|
91
|
+
env:
|
|
92
|
+
SDIST_SHA256: ${{ needs.test.outputs.sdist_sha256 }}
|
|
93
|
+
WHEEL_SHA256: ${{ needs.test.outputs.wheel_sha256 }}
|
|
94
|
+
run: |
|
|
95
|
+
set -eu
|
|
96
|
+
set -- dist/*.tar.gz; [ "$#" = 1 ] && [ -f "$1" ] || exit 1
|
|
97
|
+
echo "$SDIST_SHA256 $1" | sha256sum -c -
|
|
98
|
+
set -- dist/*.whl; [ "$#" = 1 ] && [ -f "$1" ] || exit 1
|
|
99
|
+
echo "$WHEEL_SHA256 $1" | sha256sum -c -
|
|
100
|
+
[ "$(ls dist | wc -l)" = 2 ]
|
|
101
|
+
- name: Check the tag still points at the tested commit
|
|
102
|
+
env:
|
|
103
|
+
TAG: ${{ github.ref_name }}
|
|
104
|
+
REPO: ${{ github.repository }}
|
|
105
|
+
TESTED_SHA: ${{ needs.test.outputs.sha }}
|
|
106
|
+
run: |
|
|
107
|
+
set -eu
|
|
108
|
+
printf '%s' "$TAG" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'
|
|
109
|
+
refs=$(git ls-remote "https://github.com/${REPO}.git" "refs/tags/${TAG}" "refs/tags/${TAG}^{}")
|
|
110
|
+
now=$(printf '%s\n' "$refs" | awk '/\^\{\}$/ {p=$1} !/\^\{\}$/ {d=$1} END {print (p != "" ? p : d)}')
|
|
111
|
+
if [ "$now" != "$TESTED_SHA" ]; then
|
|
112
|
+
echo "::error::tag $TAG moved after the tests ran"; exit 1
|
|
113
|
+
fi
|
|
114
|
+
- name: Publish to PyPI
|
|
115
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
116
|
+
with:
|
|
117
|
+
packages-dir: dist
|
|
118
|
+
- name: Attach the files to the GitHub release
|
|
119
|
+
env:
|
|
120
|
+
GH_TOKEN: ${{ github.token }}
|
|
121
|
+
TAG: ${{ github.ref_name }}
|
|
122
|
+
REPO: ${{ github.repository }}
|
|
123
|
+
run: gh release upload "$TAG" dist/* --repo "$REPO" --clobber
|
|
124
|
+
|
|
125
|
+
render-formula:
|
|
126
|
+
# Has this repository's code but no secrets.
|
|
127
|
+
needs: [test, publish]
|
|
128
|
+
runs-on: ubuntu-latest
|
|
129
|
+
permissions:
|
|
130
|
+
contents: read
|
|
131
|
+
steps:
|
|
132
|
+
- uses: actions/checkout@v4
|
|
133
|
+
with:
|
|
134
|
+
ref: ${{ needs.test.outputs.sha }}
|
|
135
|
+
persist-credentials: false
|
|
136
|
+
- name: Render the formula from the verified sdist
|
|
137
|
+
env:
|
|
138
|
+
VERSION: ${{ needs.test.outputs.version }}
|
|
139
|
+
SDIST_SHA256: ${{ needs.test.outputs.sdist_sha256 }}
|
|
140
|
+
run: |
|
|
141
|
+
set -eu
|
|
142
|
+
for i in $(seq 1 30); do
|
|
143
|
+
if curl -fsS "https://pypi.org/pypi/divan-cli/$VERSION/json" -o divan.json; then break; fi
|
|
144
|
+
echo "waiting for divan-cli $VERSION on PyPI ($i)"; sleep 10
|
|
145
|
+
done
|
|
146
|
+
test -s divan.json
|
|
147
|
+
curl -fsS https://pypi.org/pypi/pyyaml/json -o pyyaml.json
|
|
148
|
+
mkdir -p out
|
|
149
|
+
python3 packaging/homebrew/render.py divan.json pyyaml.json "$VERSION" "$SDIST_SHA256" > out/divan.rb
|
|
150
|
+
cp packaging/homebrew/tap-readme.md out/tap-readme.md
|
|
151
|
+
- uses: actions/upload-artifact@v4
|
|
152
|
+
with:
|
|
153
|
+
name: formula
|
|
154
|
+
path: out/
|
|
155
|
+
if-no-files-found: error
|
|
156
|
+
|
|
157
|
+
push-tap:
|
|
158
|
+
# Has the deploy key but none of this repository's code: it only downloads the rendered
|
|
159
|
+
# files and runs git. No checkout of this repo, no uv, no python.
|
|
160
|
+
needs: [test, render-formula]
|
|
161
|
+
runs-on: ubuntu-latest
|
|
162
|
+
permissions:
|
|
163
|
+
contents: read
|
|
164
|
+
steps:
|
|
165
|
+
- name: Check for the tap deploy key
|
|
166
|
+
id: key
|
|
167
|
+
env:
|
|
168
|
+
DEPLOY_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }}
|
|
169
|
+
run: |
|
|
170
|
+
if [ -z "$DEPLOY_KEY" ]; then
|
|
171
|
+
echo "::notice::HOMEBREW_TAP_DEPLOY_KEY is not set; skipping the Homebrew tap update."
|
|
172
|
+
echo "present=false" >> "$GITHUB_OUTPUT"
|
|
173
|
+
else
|
|
174
|
+
echo "present=true" >> "$GITHUB_OUTPUT"
|
|
175
|
+
fi
|
|
176
|
+
- uses: actions/download-artifact@v4
|
|
177
|
+
if: steps.key.outputs.present == 'true'
|
|
178
|
+
with:
|
|
179
|
+
name: formula
|
|
180
|
+
path: out
|
|
181
|
+
- uses: webfactory/ssh-agent@v0.9.0
|
|
182
|
+
if: steps.key.outputs.present == 'true'
|
|
183
|
+
with:
|
|
184
|
+
ssh-private-key: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }}
|
|
185
|
+
- name: Push the formula to the tap (git and cp only)
|
|
186
|
+
if: steps.key.outputs.present == 'true'
|
|
187
|
+
env:
|
|
188
|
+
VERSION: ${{ needs.test.outputs.version }}
|
|
189
|
+
run: |
|
|
190
|
+
set -eu
|
|
191
|
+
mkdir -p ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
|
|
192
|
+
git -c core.hooksPath=/dev/null clone git@github.com:tnunamak/homebrew-divan.git tap
|
|
193
|
+
mkdir -p tap/Formula
|
|
194
|
+
cp out/divan.rb tap/Formula/divan.rb
|
|
195
|
+
if [ ! -f tap/README.md ]; then cp out/tap-readme.md tap/README.md; fi
|
|
196
|
+
cd tap
|
|
197
|
+
git config user.name "divan release"
|
|
198
|
+
git config user.email "noreply@github.com"
|
|
199
|
+
git add -A
|
|
200
|
+
if git diff --cached --quiet; then echo "tap already up to date"; exit 0; fi
|
|
201
|
+
git -c core.hooksPath=/dev/null commit -m "divan $VERSION"
|
|
202
|
+
git -c core.hooksPath=/dev/null push origin HEAD
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Agent instructions for divan
|
|
2
|
+
|
|
3
|
+
divan is a small Python CLI (`src/divan/`) that searches and writes markdown
|
|
4
|
+
knowledge-base repos. Read `README.md` first.
|
|
5
|
+
|
|
6
|
+
## Run the tests
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
uv sync
|
|
10
|
+
uv run python -m pytest -q
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Use `uv run python -m pytest`, not `uv run pytest`. Tests use temporary repos and
|
|
14
|
+
caches (`tests/conftest.py`). Never point a test at a real config or corpus.
|
|
15
|
+
|
|
16
|
+
## Invariants the tests protect
|
|
17
|
+
|
|
18
|
+
Do not weaken these. Each has tests in `tests/`.
|
|
19
|
+
|
|
20
|
+
- **A profile is confinement.** `--path` and `--profile`/`DIVAN_PROFILE` are mutually exclusive. Only the profile's own corpus roots are resolved or opened (`test_isolation.py`, `test_confinement.py`).
|
|
21
|
+
- **Paths stay inside the corpus.** Every read and write goes through `safe.py`. Symlinks leaving the root are skipped, templates and `new` output cannot escape, and `check` rejects outside paths.
|
|
22
|
+
- **One cache per profile and root.** The cache file name is a hash of profile and root, the root is verified on open, refresh and query share one lock, and a cache folder inside a corpus is refused.
|
|
23
|
+
- **`land` publishes exactly the named files.**
|
|
24
|
+
- Literal paths to existing regular files only; no globs, directories or symlinks.
|
|
25
|
+
- The bytes `check` inspected are the bytes committed.
|
|
26
|
+
- The commit is built on the fetched destination tip, so it is exactly one commit on top of it, and only the named paths differ.
|
|
27
|
+
- The push sends that SHA (never `HEAD`) with `--force-with-lease` on the fetched tip; a lost lease retries from a fresh fetch.
|
|
28
|
+
- A named path that changed on the destination since the local copy's merge base is a conflict. Equal bytes are not.
|
|
29
|
+
- A remote must have one push URL, equal to its fetch URL, and equal to the corpus's configured `remote` when one is set (on github.com, gitlab.com, bitbucket.org and codeberg.org ssh and https forms match; on any other host the addresses must be equal as text after lower-casing the host and dropping a trailing slash and an explicit default port; a trailing `.git` is kept there). Once validated, land uses that literal URL for ls-remote, fetch and every push attempt. Messages never print URLs.
|
|
30
|
+
- The destination branch is the corpus config's `branch`, else the remote's default branch (`git ls-remote --symref`). The local upstream setting never picks it; if it cannot be determined, land refuses.
|
|
31
|
+
- After a push, land does not touch the working tree, index or local branch.
|
|
32
|
+
- It builds commits directly, so repo hooks do not run.
|
|
33
|
+
- **Threat model:** divan defends against content from corpora and clones, hook payloads, other local users, a remote that differs from the configured one, and races between its own processes; it does not defend against a process running as the same user (see `SECURITY.md`).
|
|
34
|
+
- **`check` is quiet on documentation.** Generic paths and private IPs are warnings by default, secrets need key shapes or long high-entropy values, and denylist hits are errors.
|
|
35
|
+
|
|
36
|
+
## Style
|
|
37
|
+
|
|
38
|
+
Few dependencies. Keep functions small and honest; do not add abstractions without a test that needs them.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to divan are recorded here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
|
+
|
|
6
|
+
## Unreleased
|
|
7
|
+
|
|
8
|
+
## 0.2.0 - 2026-12-02
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- `divan find` also searches each entry's frontmatter `summary` (or `description`), so a one-line summary is enough to find an entry.
|
|
13
|
+
- Indexing no longer hard-codes which file names to skip. By default divan skips only a corpus's own docs at its root (`README.md`, `AGENTS.md`, `CLAUDE.md`, `CONTRIBUTING.md`) and the files named as collection `template`s. Nested `README.md` files, `INDEX.md` and `INDEX-*.md` are indexed like any other file. A corpus adds exclusions with `[corpus] exclude = ["glob", ...]`.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- `divan agent setup` and `--remove` stop with exit 2 and change nothing if they cannot lock their state folder, instead of running without the lock.
|
|
18
|
+
- `divan agent setup` and `--remove` hold one lock from reading the ownership record through every agent CLI call to the last write, so a second concurrent run waits (up to 120 s, then stops with a clear message) instead of acting on stale state.
|
|
19
|
+
- `divan agent setup` updates its ownership record under a file lock, so two setups cannot lose each other's entries, and warns on stderr (without failing the install) if it cannot write the record.
|
|
20
|
+
- The remote check treats ssh and https as the same repository only on github.com, gitlab.com, bitbucket.org and codeberg.org. On any other host the two addresses must be equal as text after lower-casing the host, dropping a trailing slash and an explicit default port (a trailing `.git` is kept there): scp-style and `ssh://` forms differ, and so do different login users.
|
|
21
|
+
- `divan land` runs every git command with hooks off, so a `pre-push` hook cannot run.
|
|
22
|
+
- Hook state and the hook log folder are opened once with `O_DIRECTORY|O_NOFOLLOW` and used by descriptor: a symlinked, foreign or group/other-writable state folder is refused (the hook allows silently), and pruning deletes only old regular files with divan's own marker names. An existing `DIVAN_HOOK_LOG` folder must be private (yours, no group or other bits).
|
|
23
|
+
- A closed stdout pipe makes a hook exit 0 quietly.
|
|
24
|
+
- The remote check keeps a non-default port in a repository's identity (`ssh://host:2222/o/r` is not `git@host:o/r`).
|
|
25
|
+
- `install.sh` is one brace group, so a download cut at any byte fails to parse and runs nothing; the README now says to download the file, then run it.
|
|
26
|
+
- The release's Homebrew step is two jobs: one renders the formula with the repository's code and no secrets; the other holds the tap deploy key, runs no repository code and only pushes the rendered file with git.
|
|
27
|
+
- `divan land` checks the remote's URLs against the corpus config before any network contact.
|
|
28
|
+
- `divan join` checks files out with no global or system git config, so a repository's `.gitattributes` cannot trigger your own filter drivers.
|
|
29
|
+
- The hook deadline now stays armed through the last byte of output (and the log writes), and exits 0 at once if a blocked write overruns it.
|
|
30
|
+
- `DIVAN_HOOK_LOG` folders are created `0700` and files `0600`; a folder others can write to is not used.
|
|
31
|
+
- Release: tests and build run on one checkout; the publish job verifies the tested files' digests and that the tag still names the tested commit, with no repo code in it; the Homebrew job renders from the tested commit and sdist digest and loads the tap key only after rendering. Tags must be exactly `vX.Y.Z`.
|
|
32
|
+
- `install.sh` runs everything inside `main()`, so a truncated download does nothing, and saves the uv installer to a temporary file instead of piping it into a shell.
|
|
33
|
+
- Every hook run has a hard 3 s deadline (no output, exit 0), covering a stdin that never closes and slow transcript reads.
|
|
34
|
+
- Hook flags are one marker file each, so overlapping hooks cannot erase each other's `found`, `researched` or `landed`.
|
|
35
|
+
- `divan agent setup --remove` removes only what setup added (plugin included); a plugin you installed yourself is left alone. An "already" reply is recognised per agent and never recorded as divan's.
|
|
36
|
+
- `divan land` pushes to the corpus's `branch` (new optional setting) or the remote's default branch, never the local upstream's; it stops if the default cannot be read.
|
|
37
|
+
- Hooks say "once" only once: a deny or block needs a durable per-session marker won atomically; with no session id, an unwritable state folder or a lost race the hook allows silently. Web search in a helper agent is no longer denied. Hook input is capped at 1 MB and the Codex rollout scan is bounded (tail, 4 MB, 1 s).
|
|
38
|
+
- `divan join` accepts only https and ssh addresses unless `--allow-local` is given, and clones without system or global git hooks.
|
|
39
|
+
- Concurrent config edits (`divan agent set`, `divan join`) take turns and refuse to overwrite a file that changed underneath them.
|
|
40
|
+
- `divan agent setup --remove` removes only what setup added; a marketplace that was already there is left alone, and one left by a failed install is cleaned up.
|
|
41
|
+
- `divan land` refuses to push when the push remote's URL differs from the corpus's configured `remote`.
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
|
|
45
|
+
- `divan --version`.
|
|
46
|
+
- The release tests also install the built wheel and sdist into fresh virtual environments and run `divan --version`, `--help`, `skill` and a hook call, check the version equals the tag, and check the packaged skill, hook and plugin files are present (`packaging/smoke.sh`).
|
|
47
|
+
- `[agent] gate_headless` (default false): the Stop gate no longer blocks or reminds in headless Claude runs (`CLAUDE_CODE_ENTRYPOINT` starting with `sdk`, such as `claude -p`), so a parent process keeps the result it reads. Set it true to gate them too. Codex and Antigravity are treated as interactive until a real headless payload is captured with `DIVAN_HOOK_LOG`.
|
|
48
|
+
- `DIVAN_HOOK_LOG=<dir>` records every hook call's raw stdin and output (for capturing real payloads).
|
|
49
|
+
- Plugin for Claude Code and Codex (`.claude-plugin/`, `.codex-plugin/`, `.agents/plugins/`): the skill plus five hooks. The skill now lives only at `skills/divan/SKILL.md`; `divan skill` prints the packaged symlink of it.
|
|
50
|
+
- `divan hook <agent> <event>`: session-start reminder, a one-time deny of the first web search until `divan find` has run, a save reminder after web research, and a one-time block at stop (and a reminder before compaction) when research happened and nothing was landed. No network; per-session state under the XDG state dir, pruned after 14 days; always exits 0. Codex's built-in web search skips hooks, so for Codex it is detected at stop from the rollout file.
|
|
51
|
+
- `divan agent setup` (`--status`, `--json`, `--client`, `-y`, `--remove`): installs the plugin through each agent's own CLI (Claude Code, Codex, Antigravity); never edits agent settings.
|
|
52
|
+
- Antigravity plugin (`.antigravity-plugin/`, root `hooks.json`): the skill plus SessionStart, PreToolUse (`search_web`, `read_url_content`), PostToolUse and Stop hooks.
|
|
53
|
+
- `[agent]` settings in the user config (`enabled`, `session_note`, `search_first`, `capture_reminder`, `compact_reminder`, `stop_gate`, `note_extra`), `divan agent config`, `divan agent set KEY VALUE` (edits the file in place and keeps the rest of it), and `DIVAN_AGENT=off`. Deny and block messages say how to soften them.
|
|
54
|
+
- `divan join <git-url> [--path] [--name] [--author]`: clone and register a corpus, preserving the config's formatting.
|
|
55
|
+
- `divan guide [corpus]` and `[corpus] guide` in `divan.toml`; `divan new` points at the guide.
|
|
56
|
+
- `divan list --since 7d`, and `divan list --topics` (one line per top-level folder: entry count and top 3 tags, else title words).
|
|
57
|
+
- Packaging: the PyPI name is `divan-cli` (the command stays `divan`); `install.sh` (installs uv if missing, then `uv tool install divan-cli`; `--agents` also runs `divan agent setup -y`); a Homebrew formula template and a release workflow (publishing a GitHub release `vX.Y.Z` checks the tag matches the package version, publishes to PyPI by trusted publishing and updates the tap by deploy key). Release notes stay in this file by hand.
|
|
58
|
+
- `divan agent setup` and `--status` say plainly that Codex keeps the divan hooks inactive until you approve them in `/hooks`.
|
|
59
|
+
- A collection can say what `divan new` creates: `filename` (default `{slug}.md`) and a `dir` folder pattern, with `{slug}`, `{date}`, `{title}` and your own placeholders from `--var key=value` or a `[vars]` table in the user config. Templates use the same names as `{{name}}`. This covers folder-per-item corpora such as `<person>/<date>-<topic>/TAKEAWAYS.md`.
|
|
60
|
+
|
|
61
|
+
## 0.1.0
|
|
62
|
+
|
|
63
|
+
### Added
|
|
64
|
+
|
|
65
|
+
- `divan find`: ranked full-text search (SQLite FTS5, Porter stemming), grouped per corpus, with `--corpus`, `--collection`, `--all`, `-n` and `--json`.
|
|
66
|
+
- `divan new`, `divan list`, `divan corpora`, `divan check` and `divan skill`.
|
|
67
|
+
- `divan land`: publishes exactly the files you name. It builds the commit on the fetched remote branch, pushes that exact commit with a lease, stops with a conflict if someone changed the same note, and never touches your working files.
|
|
68
|
+
- User config with named corpora and profiles. A profile opens only its own corpora and index files.
|
|
69
|
+
- Optional `divan.toml` per corpus: collections, templates, required fields, weights, and strict leak checks for shared corpora with per-rule severity.
|
|
70
|
+
- Zero-config use on one repo with `--path DIR`, for CI.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
+
identity and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
- Demonstrating empathy and kindness toward other people.
|
|
21
|
+
- Being respectful of differing opinions, viewpoints, and experiences.
|
|
22
|
+
- Giving and gracefully accepting constructive feedback.
|
|
23
|
+
- Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience.
|
|
25
|
+
- Focusing on what is best not just for us as individuals, but for the overall
|
|
26
|
+
community.
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
- The use of sexualized language or imagery, and sexual attention or advances of
|
|
31
|
+
any kind.
|
|
32
|
+
- Trolling, insulting or derogatory comments, and personal or political attacks.
|
|
33
|
+
- Public or private harassment.
|
|
34
|
+
- Publishing others' private information, such as a physical or email address,
|
|
35
|
+
without their explicit permission.
|
|
36
|
+
- Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting.
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive, or
|
|
44
|
+
harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official email address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement through the same
|
|
63
|
+
private route described in `SECURITY.md`. If GitHub private vulnerability
|
|
64
|
+
reporting is not enabled for the repository, use the maintainer's private
|
|
65
|
+
contact channel from the project profile or ask for a private channel without
|
|
66
|
+
including sensitive details in a public issue. All complaints will be reviewed
|
|
67
|
+
and investigated promptly and fairly.
|
|
68
|
+
|
|
69
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
70
|
+
reporter of any incident.
|
|
71
|
+
|
|
72
|
+
## Enforcement Guidelines
|
|
73
|
+
|
|
74
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
75
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
76
|
+
|
|
77
|
+
### 1. Correction
|
|
78
|
+
|
|
79
|
+
**Community Impact:** Use of inappropriate language or other behavior deemed
|
|
80
|
+
unprofessional or unwelcome in the community.
|
|
81
|
+
|
|
82
|
+
**Consequence:** A private, written warning from community leaders, providing
|
|
83
|
+
clarity around the nature of the violation and an explanation of why the
|
|
84
|
+
behavior was inappropriate. A public apology may be requested.
|
|
85
|
+
|
|
86
|
+
### 2. Warning
|
|
87
|
+
|
|
88
|
+
**Community Impact:** A violation through a single incident or series of
|
|
89
|
+
actions.
|
|
90
|
+
|
|
91
|
+
**Consequence:** A warning with consequences for continued behavior. No
|
|
92
|
+
interaction with the people involved, including unsolicited interaction with
|
|
93
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
94
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
95
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
|
96
|
+
ban.
|
|
97
|
+
|
|
98
|
+
### 3. Temporary Ban
|
|
99
|
+
|
|
100
|
+
**Community Impact:** A serious violation of community standards, including
|
|
101
|
+
sustained inappropriate behavior.
|
|
102
|
+
|
|
103
|
+
**Consequence:** A temporary ban from any sort of interaction or public
|
|
104
|
+
communication with the community for a specified period of time. No public or
|
|
105
|
+
private interaction with the people involved, including unsolicited interaction
|
|
106
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
107
|
+
Violating these terms may lead to a permanent ban.
|
|
108
|
+
|
|
109
|
+
### 4. Permanent Ban
|
|
110
|
+
|
|
111
|
+
**Community Impact:** Demonstrating a pattern of violation of community
|
|
112
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
113
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
114
|
+
|
|
115
|
+
**Consequence:** A permanent ban from any sort of public interaction within the
|
|
116
|
+
community.
|
|
117
|
+
|
|
118
|
+
## Attribution
|
|
119
|
+
|
|
120
|
+
This Code of Conduct is adapted from the Contributor Covenant, version 2.1,
|
|
121
|
+
available at https://www.contributor-covenant.org/version/2/1/code_of_conduct/.
|
|
122
|
+
|
|
123
|
+
Community Impact Guidelines were inspired by Mozilla's code of conduct
|
|
124
|
+
enforcement ladder.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for helping improve divan, a small CLI that searches and writes
|
|
4
|
+
markdown knowledge-base repos.
|
|
5
|
+
|
|
6
|
+
## Development setup
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
git clone https://github.com/tnunamak/divan
|
|
10
|
+
cd divan
|
|
11
|
+
uv sync
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Tests
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
uv run python -m pytest -q
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Use `uv run python -m pytest`, not `uv run pytest`: the second form can pick up a
|
|
21
|
+
pytest from outside the project environment. Tests build their own temporary
|
|
22
|
+
repos and caches; they never touch your real config or notes. Add a test for
|
|
23
|
+
every behavior change, and for a bug fix write the test first and watch it fail.
|
|
24
|
+
|
|
25
|
+
Keep dependencies few: the standard library plus a YAML parser.
|
|
26
|
+
|
|
27
|
+
## Commit style
|
|
28
|
+
|
|
29
|
+
Keep commits small and reviewable. Open the message body with a short paragraph
|
|
30
|
+
in plain words about what a person using divan now sees or can do. Name internal
|
|
31
|
+
parts after it.
|
|
32
|
+
|
|
33
|
+
## Pull requests
|
|
34
|
+
|
|
35
|
+
Every pull request should say what changed, why, and how you tested it. Do not
|
|
36
|
+
commit real notes, tokens, local paths or hostnames; fixtures use `alice`,
|
|
37
|
+
`example.com` and `192.168.1.x`.
|
|
38
|
+
|
|
39
|
+
By contributing you agree to license your work under Apache-2.0.
|