lv24-brain 0.12.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.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 LevapVeeskela
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.4
2
+ Name: lv24-brain
3
+ Version: 0.12.0
4
+ Summary: Python launcher for the lv24-brain CLI
5
+ Author: LevapVeeskela
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://brain.lv24.by
8
+ Project-URL: Repository, https://github.com/LevapVeeskela/lv24-brain
9
+ Project-URL: Issues, https://github.com/LevapVeeskela/lv24-brain/issues
10
+ Project-URL: Documentation, https://github.com/LevapVeeskela/lv24-brain/blob/main/docs/pypi.md
11
+ Keywords: brain,cli,memory,knowledge,agents
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Environment :: Console
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Dynamic: license-file
19
+
20
+ # lv24-brain (Python launcher)
21
+
22
+ A thin Python launcher for **LV24 Brain**, the curated project memory CLI for
23
+ coding agents and people. LV24 Brain itself is a Go binary published on npm as
24
+ [`lv24-brain`](https://www.npmjs.com/package/lv24-brain) and through signed
25
+ GitHub release installers. This package does not reimplement the CLI, bundle
26
+ Node.js, or download the binary: the `lv24-brain` command delegates to the npm
27
+ package through `npx`.
28
+
29
+ The npm package, the signed installers, and GitHub Releases remain the
30
+ canonical distribution. The PyPI package only contains this launcher.
31
+
32
+ ## The `brain` name
33
+
34
+ This package intentionally installs **only** the `lv24-brain` console script.
35
+ It does not install `brain`, because the native Go binary, the signed
36
+ installers, and the npm package already own that name. A pip-installed `brain`
37
+ script would silently shadow the real binary depending on `PATH` order. Use
38
+ `lv24-brain` for the launcher, or install the native binary for `brain`:
39
+
40
+ ```bash
41
+ npm i -g lv24-brain
42
+ # or the installers in docs/install.md
43
+ brain version
44
+ ```
45
+
46
+ ## Prerequisites
47
+
48
+ - **Node.js 18 or newer**, including npm and npx
49
+ ([nodejs.org](https://nodejs.org/)).
50
+ - Network access on first run, or an npm cache that already contains the
51
+ requested package, because `npx` may download it.
52
+ - Python 3.9 or newer.
53
+
54
+ The CLI itself does not need a Go toolchain or a checkout of the repository.
55
+
56
+ ## Installation
57
+
58
+ Once the first PyPI release is published:
59
+
60
+ ```bash
61
+ pip install lv24-brain
62
+ ```
63
+
64
+ This installs one console script, `lv24-brain`. The launcher also runs as a
65
+ module:
66
+
67
+ ```bash
68
+ python -m lv24_brain --help
69
+ ```
70
+
71
+ ## Usage
72
+
73
+ ```bash
74
+ lv24-brain open .
75
+ lv24-brain search "auth"
76
+ lv24-brain handoff "done: login page" --next "wire the logout button"
77
+ ```
78
+
79
+ All arguments are forwarded unchanged to the npm CLI. The child process
80
+ inherits the terminal, environment, and exit code.
81
+
82
+ If `npx` cannot be found, the launcher exits with code `127` and prints an
83
+ installation hint. An interrupted run exits with code `130`.
84
+
85
+ ## Version pinning
86
+
87
+ By default the launcher runs the npm package version matching its own version
88
+ (currently `0.12.0`). Override it with `BRAIN_NPM_VERSION` to use any npm
89
+ version or tag:
90
+
91
+ ```bash
92
+ BRAIN_NPM_VERSION=latest lv24-brain --help
93
+ BRAIN_NPM_VERSION=0.12.0 lv24-brain --help
94
+ ```
95
+
96
+ PowerShell:
97
+
98
+ ```powershell
99
+ $env:BRAIN_NPM_VERSION = "latest"; lv24-brain --help
100
+ ```
101
+
102
+ Keep the launcher and the npm CLI on the same version unless you have a reason
103
+ not to; the Python package is released for the same tag.
104
+
105
+ ## Links
106
+
107
+ - Documentation: <https://brain.lv24.by>
108
+ - Repository and issues:
109
+ <https://github.com/LevapVeeskela/lv24-brain>
110
+ - Publishing runbook:
111
+ [docs/pypi.md](https://github.com/LevapVeeskela/lv24-brain/blob/main/docs/pypi.md)
112
+ - npm package: <https://www.npmjs.com/package/lv24-brain>
113
+
114
+ ## License
115
+
116
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,97 @@
1
+ # lv24-brain (Python launcher)
2
+
3
+ A thin Python launcher for **LV24 Brain**, the curated project memory CLI for
4
+ coding agents and people. LV24 Brain itself is a Go binary published on npm as
5
+ [`lv24-brain`](https://www.npmjs.com/package/lv24-brain) and through signed
6
+ GitHub release installers. This package does not reimplement the CLI, bundle
7
+ Node.js, or download the binary: the `lv24-brain` command delegates to the npm
8
+ package through `npx`.
9
+
10
+ The npm package, the signed installers, and GitHub Releases remain the
11
+ canonical distribution. The PyPI package only contains this launcher.
12
+
13
+ ## The `brain` name
14
+
15
+ This package intentionally installs **only** the `lv24-brain` console script.
16
+ It does not install `brain`, because the native Go binary, the signed
17
+ installers, and the npm package already own that name. A pip-installed `brain`
18
+ script would silently shadow the real binary depending on `PATH` order. Use
19
+ `lv24-brain` for the launcher, or install the native binary for `brain`:
20
+
21
+ ```bash
22
+ npm i -g lv24-brain
23
+ # or the installers in docs/install.md
24
+ brain version
25
+ ```
26
+
27
+ ## Prerequisites
28
+
29
+ - **Node.js 18 or newer**, including npm and npx
30
+ ([nodejs.org](https://nodejs.org/)).
31
+ - Network access on first run, or an npm cache that already contains the
32
+ requested package, because `npx` may download it.
33
+ - Python 3.9 or newer.
34
+
35
+ The CLI itself does not need a Go toolchain or a checkout of the repository.
36
+
37
+ ## Installation
38
+
39
+ Once the first PyPI release is published:
40
+
41
+ ```bash
42
+ pip install lv24-brain
43
+ ```
44
+
45
+ This installs one console script, `lv24-brain`. The launcher also runs as a
46
+ module:
47
+
48
+ ```bash
49
+ python -m lv24_brain --help
50
+ ```
51
+
52
+ ## Usage
53
+
54
+ ```bash
55
+ lv24-brain open .
56
+ lv24-brain search "auth"
57
+ lv24-brain handoff "done: login page" --next "wire the logout button"
58
+ ```
59
+
60
+ All arguments are forwarded unchanged to the npm CLI. The child process
61
+ inherits the terminal, environment, and exit code.
62
+
63
+ If `npx` cannot be found, the launcher exits with code `127` and prints an
64
+ installation hint. An interrupted run exits with code `130`.
65
+
66
+ ## Version pinning
67
+
68
+ By default the launcher runs the npm package version matching its own version
69
+ (currently `0.12.0`). Override it with `BRAIN_NPM_VERSION` to use any npm
70
+ version or tag:
71
+
72
+ ```bash
73
+ BRAIN_NPM_VERSION=latest lv24-brain --help
74
+ BRAIN_NPM_VERSION=0.12.0 lv24-brain --help
75
+ ```
76
+
77
+ PowerShell:
78
+
79
+ ```powershell
80
+ $env:BRAIN_NPM_VERSION = "latest"; lv24-brain --help
81
+ ```
82
+
83
+ Keep the launcher and the npm CLI on the same version unless you have a reason
84
+ not to; the Python package is released for the same tag.
85
+
86
+ ## Links
87
+
88
+ - Documentation: <https://brain.lv24.by>
89
+ - Repository and issues:
90
+ <https://github.com/LevapVeeskela/lv24-brain>
91
+ - Publishing runbook:
92
+ [docs/pypi.md](https://github.com/LevapVeeskela/lv24-brain/blob/main/docs/pypi.md)
93
+ - npm package: <https://www.npmjs.com/package/lv24-brain>
94
+
95
+ ## License
96
+
97
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,35 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "lv24-brain"
7
+ version = "0.12.0"
8
+ description = "Python launcher for the lv24-brain CLI"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
13
+ authors = [
14
+ { name = "LevapVeeskela" },
15
+ ]
16
+ keywords = ["brain", "cli", "memory", "knowledge", "agents"]
17
+ classifiers = [
18
+ "Programming Language :: Python :: 3",
19
+ "Environment :: Console",
20
+ "Operating System :: OS Independent",
21
+ ]
22
+
23
+ [project.urls]
24
+ Homepage = "https://brain.lv24.by"
25
+ Repository = "https://github.com/LevapVeeskela/lv24-brain"
26
+ Issues = "https://github.com/LevapVeeskela/lv24-brain/issues"
27
+ Documentation = "https://github.com/LevapVeeskela/lv24-brain/blob/main/docs/pypi.md"
28
+
29
+ [project.scripts]
30
+ # No `brain` script on purpose: the native Go binary and the npm package
31
+ # already own that name, and pip would silently shadow one of them on PATH.
32
+ lv24-brain = "lv24_brain.cli:main"
33
+
34
+ [tool.setuptools.packages.find]
35
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ """Python launcher for the lv24-brain CLI."""
2
+
3
+ __version__ = "0.12.0"
4
+
5
+ __all__ = ["__version__"]
@@ -0,0 +1,6 @@
1
+ """Allow running the launcher with ``python -m lv24_brain``."""
2
+
3
+ from .cli import main
4
+
5
+ if __name__ == "__main__":
6
+ raise SystemExit(main())
@@ -0,0 +1,55 @@
1
+ """Command-line entry point that delegates to the npm lv24-brain CLI."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import shutil
7
+ import subprocess
8
+ import sys
9
+ from typing import Optional, Sequence
10
+
11
+ from . import __version__
12
+
13
+ NPM_PACKAGE = "lv24-brain"
14
+ NPM_VERSION_ENV = "BRAIN_NPM_VERSION"
15
+
16
+ _NPX_MISSING_MESSAGE = """\
17
+ lv24-brain: npx was not found on PATH.
18
+
19
+ This package is a thin Python launcher for the lv24-brain CLI distributed
20
+ through npm; it does not bundle Node.js or the CLI itself. Install Node.js 18
21
+ or newer (npm and npx are included) from https://nodejs.org/, or install the
22
+ native binary with the signed installers:
23
+ https://github.com/LevapVeeskela/lv24-brain/blob/main/docs/install.md
24
+ """
25
+
26
+
27
+ def npm_spec() -> str:
28
+ """Return the npm package spec, honoring BRAIN_NPM_VERSION."""
29
+ version = os.environ.get(NPM_VERSION_ENV, "").strip() or __version__
30
+ return "{0}@{1}".format(NPM_PACKAGE, version)
31
+
32
+
33
+ def main(argv: Optional[Sequence[str]] = None) -> int:
34
+ """Run the npm CLI through npx and return its exit code."""
35
+ args = list(sys.argv[1:] if argv is None else argv)
36
+
37
+ npx = shutil.which("npx")
38
+ if npx is None:
39
+ sys.stderr.write(_NPX_MISSING_MESSAGE)
40
+ return 127
41
+
42
+ # No shell: the version and every user argument stay a single argv entry,
43
+ # so nothing in them can be interpreted by a command interpreter.
44
+ command = [npx, "--yes", npm_spec(), *args]
45
+
46
+ try:
47
+ completed = subprocess.run(command, check=False)
48
+ return completed.returncode
49
+ except KeyboardInterrupt:
50
+ return 130
51
+ except OSError as exc:
52
+ sys.stderr.write(
53
+ "lv24-brain: failed to start {0}: {1}\n".format(npx, exc)
54
+ )
55
+ return 127
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.4
2
+ Name: lv24-brain
3
+ Version: 0.12.0
4
+ Summary: Python launcher for the lv24-brain CLI
5
+ Author: LevapVeeskela
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://brain.lv24.by
8
+ Project-URL: Repository, https://github.com/LevapVeeskela/lv24-brain
9
+ Project-URL: Issues, https://github.com/LevapVeeskela/lv24-brain/issues
10
+ Project-URL: Documentation, https://github.com/LevapVeeskela/lv24-brain/blob/main/docs/pypi.md
11
+ Keywords: brain,cli,memory,knowledge,agents
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Environment :: Console
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Dynamic: license-file
19
+
20
+ # lv24-brain (Python launcher)
21
+
22
+ A thin Python launcher for **LV24 Brain**, the curated project memory CLI for
23
+ coding agents and people. LV24 Brain itself is a Go binary published on npm as
24
+ [`lv24-brain`](https://www.npmjs.com/package/lv24-brain) and through signed
25
+ GitHub release installers. This package does not reimplement the CLI, bundle
26
+ Node.js, or download the binary: the `lv24-brain` command delegates to the npm
27
+ package through `npx`.
28
+
29
+ The npm package, the signed installers, and GitHub Releases remain the
30
+ canonical distribution. The PyPI package only contains this launcher.
31
+
32
+ ## The `brain` name
33
+
34
+ This package intentionally installs **only** the `lv24-brain` console script.
35
+ It does not install `brain`, because the native Go binary, the signed
36
+ installers, and the npm package already own that name. A pip-installed `brain`
37
+ script would silently shadow the real binary depending on `PATH` order. Use
38
+ `lv24-brain` for the launcher, or install the native binary for `brain`:
39
+
40
+ ```bash
41
+ npm i -g lv24-brain
42
+ # or the installers in docs/install.md
43
+ brain version
44
+ ```
45
+
46
+ ## Prerequisites
47
+
48
+ - **Node.js 18 or newer**, including npm and npx
49
+ ([nodejs.org](https://nodejs.org/)).
50
+ - Network access on first run, or an npm cache that already contains the
51
+ requested package, because `npx` may download it.
52
+ - Python 3.9 or newer.
53
+
54
+ The CLI itself does not need a Go toolchain or a checkout of the repository.
55
+
56
+ ## Installation
57
+
58
+ Once the first PyPI release is published:
59
+
60
+ ```bash
61
+ pip install lv24-brain
62
+ ```
63
+
64
+ This installs one console script, `lv24-brain`. The launcher also runs as a
65
+ module:
66
+
67
+ ```bash
68
+ python -m lv24_brain --help
69
+ ```
70
+
71
+ ## Usage
72
+
73
+ ```bash
74
+ lv24-brain open .
75
+ lv24-brain search "auth"
76
+ lv24-brain handoff "done: login page" --next "wire the logout button"
77
+ ```
78
+
79
+ All arguments are forwarded unchanged to the npm CLI. The child process
80
+ inherits the terminal, environment, and exit code.
81
+
82
+ If `npx` cannot be found, the launcher exits with code `127` and prints an
83
+ installation hint. An interrupted run exits with code `130`.
84
+
85
+ ## Version pinning
86
+
87
+ By default the launcher runs the npm package version matching its own version
88
+ (currently `0.12.0`). Override it with `BRAIN_NPM_VERSION` to use any npm
89
+ version or tag:
90
+
91
+ ```bash
92
+ BRAIN_NPM_VERSION=latest lv24-brain --help
93
+ BRAIN_NPM_VERSION=0.12.0 lv24-brain --help
94
+ ```
95
+
96
+ PowerShell:
97
+
98
+ ```powershell
99
+ $env:BRAIN_NPM_VERSION = "latest"; lv24-brain --help
100
+ ```
101
+
102
+ Keep the launcher and the npm CLI on the same version unless you have a reason
103
+ not to; the Python package is released for the same tag.
104
+
105
+ ## Links
106
+
107
+ - Documentation: <https://brain.lv24.by>
108
+ - Repository and issues:
109
+ <https://github.com/LevapVeeskela/lv24-brain>
110
+ - Publishing runbook:
111
+ [docs/pypi.md](https://github.com/LevapVeeskela/lv24-brain/blob/main/docs/pypi.md)
112
+ - npm package: <https://www.npmjs.com/package/lv24-brain>
113
+
114
+ ## License
115
+
116
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/lv24_brain/__init__.py
5
+ src/lv24_brain/__main__.py
6
+ src/lv24_brain/cli.py
7
+ src/lv24_brain.egg-info/PKG-INFO
8
+ src/lv24_brain.egg-info/SOURCES.txt
9
+ src/lv24_brain.egg-info/dependency_links.txt
10
+ src/lv24_brain.egg-info/entry_points.txt
11
+ src/lv24_brain.egg-info/top_level.txt
12
+ tests/test_cli.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ lv24-brain = lv24_brain.cli:main
@@ -0,0 +1 @@
1
+ lv24_brain
@@ -0,0 +1,205 @@
1
+ """Tests for the Python launcher that delegates to the npm lv24-brain CLI."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import contextlib
6
+ import io
7
+ import json
8
+ import os
9
+ import stat
10
+ import sys
11
+ import tempfile
12
+ import unittest
13
+ from pathlib import Path
14
+ from unittest import mock
15
+
16
+ SRC_DIR = Path(__file__).resolve().parents[1] / "src"
17
+ if str(SRC_DIR) not in sys.path:
18
+ sys.path.insert(0, str(SRC_DIR))
19
+
20
+ from lv24_brain import __version__
21
+ from lv24_brain.cli import NPM_PACKAGE, NPM_VERSION_ENV, main
22
+
23
+ _FAKE_NPX = '''\
24
+ import json
25
+ import os
26
+ import sys
27
+
28
+ record = {
29
+ "argv": sys.argv[1:],
30
+ "env": {
31
+ key: value
32
+ for key, value in os.environ.items()
33
+ if key.startswith("BRAIN_") or key == "PATH"
34
+ },
35
+ }
36
+ with open(os.environ["BRAIN_TEST_LOG"], "a", encoding="utf-8") as handle:
37
+ handle.write(json.dumps(record, sort_keys=True) + "\\n")
38
+ raise SystemExit(3)
39
+ '''
40
+
41
+
42
+ class MainTests(unittest.TestCase):
43
+ def setUp(self):
44
+ self._tempdir = tempfile.TemporaryDirectory()
45
+ self.addCleanup(self._tempdir.cleanup)
46
+ self.root = Path(self._tempdir.name)
47
+ self.bin_dir = self.root / "bin"
48
+ self.bin_dir.mkdir()
49
+ self.empty_dir = self.root / "empty"
50
+ self.empty_dir.mkdir()
51
+ self.log_path = self.root / "calls.jsonl"
52
+
53
+ self._saved_env = {
54
+ key: os.environ.get(key)
55
+ for key in ("BRAIN_NPM_VERSION", "BRAIN_TEST_LOG")
56
+ }
57
+ self.addCleanup(self._restore_env)
58
+ os.environ.pop("BRAIN_NPM_VERSION", None)
59
+ os.environ["BRAIN_TEST_LOG"] = str(self.log_path)
60
+
61
+ self._write_fake_npx()
62
+
63
+ def _restore_env(self):
64
+ for key, value in self._saved_env.items():
65
+ if value is None:
66
+ os.environ.pop(key, None)
67
+ else:
68
+ os.environ[key] = value
69
+
70
+ def _write_fake_npx(self):
71
+ script = self.bin_dir / "fake_npx.py"
72
+ script.write_text(_FAKE_NPX, encoding="utf-8")
73
+
74
+ if os.name == "nt":
75
+ launcher = self.bin_dir / "npx.cmd"
76
+ content = '@echo off\r\n"{0}" "%~dp0fake_npx.py" %*\r\n'.format(
77
+ sys.executable
78
+ )
79
+ with launcher.open("w", encoding="utf-8", newline="") as handle:
80
+ handle.write(content)
81
+ else:
82
+ launcher = self.bin_dir / "npx"
83
+ content = '#!/bin/sh\nexec "{0}" "${{0%/*}}/fake_npx.py" "$@"\n'.format(
84
+ sys.executable
85
+ )
86
+ launcher.write_text(content, encoding="utf-8")
87
+ launcher.chmod(
88
+ launcher.stat().st_mode
89
+ | stat.S_IXUSR
90
+ | stat.S_IXGRP
91
+ | stat.S_IXOTH
92
+ )
93
+
94
+ def _invoke(self, args, *, env=None, path=None, cwd=None):
95
+ call_env = {
96
+ "PATH": str(self.bin_dir if path is None else path),
97
+ "BRAIN_TEST_LOG": str(self.log_path),
98
+ }
99
+ if os.name == "nt":
100
+ call_env["PATHEXT"] = ".COM;.EXE;.BAT;.CMD"
101
+ if env:
102
+ call_env.update(env)
103
+
104
+ stderr = io.StringIO()
105
+ previous_cwd = os.getcwd()
106
+ if cwd is not None:
107
+ os.chdir(cwd)
108
+ try:
109
+ with mock.patch.dict(os.environ, call_env, clear=False):
110
+ with contextlib.redirect_stderr(stderr):
111
+ code = main(list(args))
112
+ finally:
113
+ if cwd is not None:
114
+ os.chdir(previous_cwd)
115
+ return code, stderr.getvalue()
116
+
117
+ def _calls(self):
118
+ if not self.log_path.exists():
119
+ return []
120
+ return [
121
+ json.loads(line)
122
+ for line in self.log_path.read_text(encoding="utf-8").splitlines()
123
+ if line
124
+ ]
125
+
126
+ def test_forwards_arguments_and_returns_child_exit_code(self):
127
+ code, stderr = self._invoke(["open", ".", "--json"])
128
+
129
+ self.assertEqual(code, 3)
130
+ self.assertEqual(stderr, "")
131
+ calls = self._calls()
132
+ self.assertEqual(len(calls), 1)
133
+ self.assertEqual(
134
+ calls[0]["argv"],
135
+ [
136
+ "--yes",
137
+ "{0}@{1}".format(NPM_PACKAGE, __version__),
138
+ "open",
139
+ ".",
140
+ "--json",
141
+ ],
142
+ )
143
+
144
+ def test_version_matches_expected_release(self):
145
+ self.assertEqual(__version__, "0.12.0")
146
+
147
+ def test_uses_env_override_and_inherits_it(self):
148
+ code, stderr = self._invoke(
149
+ ["--help"], env={NPM_VERSION_ENV: "latest"}
150
+ )
151
+
152
+ self.assertEqual(code, 3)
153
+ self.assertEqual(stderr, "")
154
+ call = self._calls()[0]
155
+ self.assertEqual(
156
+ call["argv"],
157
+ ["--yes", "{0}@latest".format(NPM_PACKAGE), "--help"],
158
+ )
159
+ self.assertEqual(call["env"][NPM_VERSION_ENV], "latest")
160
+
161
+ def test_blank_env_override_falls_back_to_package_version(self):
162
+ code, _ = self._invoke([], env={NPM_VERSION_ENV: " "})
163
+
164
+ self.assertEqual(code, 3)
165
+ self.assertEqual(
166
+ self._calls()[0]["argv"],
167
+ ["--yes", "{0}@{1}".format(NPM_PACKAGE, __version__)],
168
+ )
169
+
170
+ def test_missing_npx_returns_127_with_install_hint(self):
171
+ code, stderr = self._invoke(
172
+ [], path=self.empty_dir, cwd=self.empty_dir
173
+ )
174
+
175
+ self.assertEqual(code, 127)
176
+ self.assertIn("npx", stderr)
177
+ self.assertIn("Node.js", stderr)
178
+ self.assertIn("npm", stderr)
179
+ self.assertIn("installers", stderr)
180
+ self.assertEqual(self._calls(), [])
181
+
182
+ def test_keyboard_interrupt_returns_130(self):
183
+ with mock.patch(
184
+ "lv24_brain.cli.subprocess.run",
185
+ side_effect=KeyboardInterrupt,
186
+ ):
187
+ code, stderr = self._invoke([])
188
+
189
+ self.assertEqual(code, 130)
190
+ self.assertEqual(stderr, "")
191
+
192
+ def test_oserror_returns_127(self):
193
+ with mock.patch(
194
+ "lv24_brain.cli.subprocess.run",
195
+ side_effect=OSError("not executable"),
196
+ ):
197
+ code, stderr = self._invoke([])
198
+
199
+ self.assertEqual(code, 127)
200
+ self.assertIn("failed to start", stderr)
201
+ self.assertIn("not executable", stderr)
202
+
203
+
204
+ if __name__ == "__main__":
205
+ unittest.main()