cendor-init 0.1.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.
- cendor_init-0.1.0/.gitignore +27 -0
- cendor_init-0.1.0/LICENSE +201 -0
- cendor_init-0.1.0/NOTICE +7 -0
- cendor_init-0.1.0/PKG-INFO +81 -0
- cendor_init-0.1.0/README.md +54 -0
- cendor_init-0.1.0/pyproject.toml +60 -0
- cendor_init-0.1.0/src/cendor_init/__init__.py +15 -0
- cendor_init-0.1.0/src/cendor_init/__main__.py +8 -0
- cendor_init-0.1.0/src/cendor_init/cli.py +188 -0
- cendor_init-0.1.0/src/cendor_init/detect.py +226 -0
- cendor_init-0.1.0/src/cendor_init/doctor.py +259 -0
- cendor_init-0.1.0/src/cendor_init/initialize.py +239 -0
- cendor_init-0.1.0/src/cendor_init/io.py +39 -0
- cendor_init-0.1.0/src/cendor_init/scan.py +58 -0
- cendor_init-0.1.0/src/cendor_init/semver.py +58 -0
- cendor_init-0.1.0/src/cendor_init/templates.py +131 -0
- cendor_init-0.1.0/src/cendor_init/versions.py +26 -0
- cendor_init-0.1.0/tests/test_doctor.py +90 -0
- cendor_init-0.1.0/tests/test_init.py +87 -0
- cendor_init-0.1.0/tests/test_io.py +34 -0
- cendor_init-0.1.0/tests/test_semver.py +27 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*.egg-info/
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
.venv/
|
|
7
|
+
.uv/
|
|
8
|
+
uv.lock
|
|
9
|
+
.ruff_cache/
|
|
10
|
+
.pytest_cache/
|
|
11
|
+
.mypy_cache/
|
|
12
|
+
.coverage
|
|
13
|
+
coverage.json
|
|
14
|
+
htmlcov/
|
|
15
|
+
.smoke/
|
|
16
|
+
.idea/
|
|
17
|
+
.vscode/
|
|
18
|
+
.DS_Store
|
|
19
|
+
*.log
|
|
20
|
+
|
|
21
|
+
# Local scratch / audit artifacts produced by examples & tests
|
|
22
|
+
audit.jsonl
|
|
23
|
+
*.audit.jsonl
|
|
24
|
+
checkpoints/
|
|
25
|
+
|
|
26
|
+
# Planning docs — kept local, not tracked
|
|
27
|
+
plan/
|
|
@@ -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 Raghav Mishra (PowerAI Labs)
|
|
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.
|
cendor_init-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cendor-init
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Offline CLI to make your project Cendor-ready and Cendor-fluent for your AI assistant (init) and catch wiring mistakes (doctor). Run with `uvx cendor-init`.
|
|
5
|
+
Project-URL: Homepage, https://cendor.ai/docs/for-ai-assistants
|
|
6
|
+
Project-URL: Repository, https://github.com/cendorhq/cendor-sdk
|
|
7
|
+
Project-URL: Issues, https://github.com/cendorhq/cendor-sdk/issues
|
|
8
|
+
Author: Raghav Mishra (PowerAI Labs)
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Keywords: ai-assistant,cendor,claude-code,cli,copilot,cursor,init,llm,mcp,scaffold
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
25
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# cendor-init
|
|
29
|
+
|
|
30
|
+
**One command to make your project Cendor-ready and Cendor-fluent for your AI assistant** — plus a
|
|
31
|
+
`doctor` that catches the wiring mistakes before they bite. Offline: no network, no API key.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
uvx cendor-init # detect + write assistant rules files (idempotent)
|
|
35
|
+
uvx cendor-init doctor # validate the wiring; exit 1 on hard problems (CI-usable)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
> Optional developer tooling — dependency-free stdlib. It writes files and inspects your project; it
|
|
39
|
+
> makes **no network call**, and no Cendor library depends on it at runtime. (Node users:
|
|
40
|
+
> `npx @cendor/init`.) This is the Python twin of `@cendor/init`; both share the same behavior.
|
|
41
|
+
|
|
42
|
+
## What `init` does
|
|
43
|
+
|
|
44
|
+
1. **Detects your project** — Python (`pyproject.toml` / `requirements`) or Node (`package.json`),
|
|
45
|
+
which provider SDKs you have, and which `cendor-*` / `@cendor/*` packages are installed.
|
|
46
|
+
2. **Writes the matching assistant rules file(s)** so your assistant reads the correct Cendor
|
|
47
|
+
call-shapes on every edit. Detected by default; `--all` for every one:
|
|
48
|
+
- `.github/copilot-instructions.md` (GitHub Copilot)
|
|
49
|
+
- `.cursor/rules/cendor.mdc` (Cursor)
|
|
50
|
+
- `AGENTS.md` (the cross-tool default — always written)
|
|
51
|
+
- a marked section in `CLAUDE.md` (Claude Code)
|
|
52
|
+
- `.windsurf/rules` (Windsurf)
|
|
53
|
+
|
|
54
|
+
**Idempotent and safe:** re-running updates a marker-delimited block in place — never duplicates,
|
|
55
|
+
never clobbers your surrounding content. A dedicated file it didn't create is left alone unless
|
|
56
|
+
you pass `--force`.
|
|
57
|
+
3. **Offers MCP setup** (`--mcp`) — drops the connect config for the Cendor MCP server (remote
|
|
58
|
+
`mcp.cendor.ai` or local `uvx cendor-mcp` / `npx @cendor/mcp`) where it's absent.
|
|
59
|
+
4. **Optional starter** (`--scaffold`) — a minimal, correct `instrument()` + budgeted-call example.
|
|
60
|
+
|
|
61
|
+
The rules content is a copy of section 3 of the docs source of truth,
|
|
62
|
+
[`for-ai-assistants`](https://cendor.ai/docs/for-ai-assistants).
|
|
63
|
+
|
|
64
|
+
## What `doctor` checks
|
|
65
|
+
|
|
66
|
+
Static checks only — it **never mutates** your project, and exits non-zero on hard problems so it
|
|
67
|
+
works in CI:
|
|
68
|
+
|
|
69
|
+
- **Namespace** — a stray `cendor/__init__.py` in your tree, or a bare `import cendor` (the namespace
|
|
70
|
+
has no module body — import `from cendor.<tool>`).
|
|
71
|
+
- **Provider deps** — a provider SDK your code imports but hasn't installed/declared (Cendor never
|
|
72
|
+
pulls one for you; they are optional extras). Uses the installed environment when available.
|
|
73
|
+
- **`instrument()` once** — warns if Cendor is imported but the client is never wrapped.
|
|
74
|
+
- **Money** — flags coercing a price/cost to `float` (it should stay `Decimal`).
|
|
75
|
+
- **Versions** — warns when an installed/pinned `cendor-*` version trails the latest release.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
uvx cendor-init --help
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Apache-2.0 · [cendor.ai](https://cendor.ai) · [For AI assistants](https://cendor.ai/docs/for-ai-assistants) · [MCP](https://cendor.ai/mcp)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# cendor-init
|
|
2
|
+
|
|
3
|
+
**One command to make your project Cendor-ready and Cendor-fluent for your AI assistant** — plus a
|
|
4
|
+
`doctor` that catches the wiring mistakes before they bite. Offline: no network, no API key.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
uvx cendor-init # detect + write assistant rules files (idempotent)
|
|
8
|
+
uvx cendor-init doctor # validate the wiring; exit 1 on hard problems (CI-usable)
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> Optional developer tooling — dependency-free stdlib. It writes files and inspects your project; it
|
|
12
|
+
> makes **no network call**, and no Cendor library depends on it at runtime. (Node users:
|
|
13
|
+
> `npx @cendor/init`.) This is the Python twin of `@cendor/init`; both share the same behavior.
|
|
14
|
+
|
|
15
|
+
## What `init` does
|
|
16
|
+
|
|
17
|
+
1. **Detects your project** — Python (`pyproject.toml` / `requirements`) or Node (`package.json`),
|
|
18
|
+
which provider SDKs you have, and which `cendor-*` / `@cendor/*` packages are installed.
|
|
19
|
+
2. **Writes the matching assistant rules file(s)** so your assistant reads the correct Cendor
|
|
20
|
+
call-shapes on every edit. Detected by default; `--all` for every one:
|
|
21
|
+
- `.github/copilot-instructions.md` (GitHub Copilot)
|
|
22
|
+
- `.cursor/rules/cendor.mdc` (Cursor)
|
|
23
|
+
- `AGENTS.md` (the cross-tool default — always written)
|
|
24
|
+
- a marked section in `CLAUDE.md` (Claude Code)
|
|
25
|
+
- `.windsurf/rules` (Windsurf)
|
|
26
|
+
|
|
27
|
+
**Idempotent and safe:** re-running updates a marker-delimited block in place — never duplicates,
|
|
28
|
+
never clobbers your surrounding content. A dedicated file it didn't create is left alone unless
|
|
29
|
+
you pass `--force`.
|
|
30
|
+
3. **Offers MCP setup** (`--mcp`) — drops the connect config for the Cendor MCP server (remote
|
|
31
|
+
`mcp.cendor.ai` or local `uvx cendor-mcp` / `npx @cendor/mcp`) where it's absent.
|
|
32
|
+
4. **Optional starter** (`--scaffold`) — a minimal, correct `instrument()` + budgeted-call example.
|
|
33
|
+
|
|
34
|
+
The rules content is a copy of section 3 of the docs source of truth,
|
|
35
|
+
[`for-ai-assistants`](https://cendor.ai/docs/for-ai-assistants).
|
|
36
|
+
|
|
37
|
+
## What `doctor` checks
|
|
38
|
+
|
|
39
|
+
Static checks only — it **never mutates** your project, and exits non-zero on hard problems so it
|
|
40
|
+
works in CI:
|
|
41
|
+
|
|
42
|
+
- **Namespace** — a stray `cendor/__init__.py` in your tree, or a bare `import cendor` (the namespace
|
|
43
|
+
has no module body — import `from cendor.<tool>`).
|
|
44
|
+
- **Provider deps** — a provider SDK your code imports but hasn't installed/declared (Cendor never
|
|
45
|
+
pulls one for you; they are optional extras). Uses the installed environment when available.
|
|
46
|
+
- **`instrument()` once** — warns if Cendor is imported but the client is never wrapped.
|
|
47
|
+
- **Money** — flags coercing a price/cost to `float` (it should stay `Decimal`).
|
|
48
|
+
- **Versions** — warns when an installed/pinned `cendor-*` version trails the latest release.
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
uvx cendor-init --help
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Apache-2.0 · [cendor.ai](https://cendor.ai) · [For AI assistants](https://cendor.ai/docs/for-ai-assistants) · [MCP](https://cendor.ai/mcp)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "cendor-init"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Offline CLI to make your project Cendor-ready and Cendor-fluent for your AI assistant (init) and catch wiring mistakes (doctor). Run with `uvx cendor-init`."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
authors = [{ name = "Raghav Mishra (PowerAI Labs)" }]
|
|
13
|
+
keywords = ["cendor", "cli", "init", "scaffold", "ai-assistant", "copilot", "cursor", "claude-code", "mcp", "llm"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: Apache Software License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Topic :: Software Development :: Code Generators",
|
|
23
|
+
]
|
|
24
|
+
# Offline + dependency-light by design: stdlib only (argparse, importlib.metadata, pathlib, re, json).
|
|
25
|
+
dependencies = []
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
dev = ["pytest>=8", "ruff>=0.6", "mypy>=1.10"]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://cendor.ai/docs/for-ai-assistants"
|
|
32
|
+
Repository = "https://github.com/cendorhq/cendor-sdk"
|
|
33
|
+
Issues = "https://github.com/cendorhq/cendor-sdk/issues"
|
|
34
|
+
|
|
35
|
+
[project.scripts]
|
|
36
|
+
cendor-init = "cendor_init.cli:main"
|
|
37
|
+
|
|
38
|
+
# This is a SELF-CONTAINED package living inside the cendor-sdk repo (dev tooling, published
|
|
39
|
+
# separately at the launch gate). It ships `cendor_init` — a standalone top-level package, NOT part
|
|
40
|
+
# of the `cendor.*` PEP 420 namespace — so it never collides with cendor-sdk's `cendor/sdk`. It is
|
|
41
|
+
# NOT a uv workspace member: `uv build` it from this directory; the cendor-sdk build/release is
|
|
42
|
+
# untouched (mirrors how cendor-mcp keeps its Python twin standalone).
|
|
43
|
+
[tool.hatch.build.targets.wheel]
|
|
44
|
+
packages = ["src/cendor_init"]
|
|
45
|
+
|
|
46
|
+
[tool.ruff]
|
|
47
|
+
line-length = 100
|
|
48
|
+
target-version = "py310"
|
|
49
|
+
|
|
50
|
+
[tool.ruff.lint]
|
|
51
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
52
|
+
# The rules templates + scaffolds are VERBATIM vendored copy (kept identical to the docs source of
|
|
53
|
+
# truth); their bullet lines legitimately run past 100 cols. This is embedded text, not code width.
|
|
54
|
+
ignore = ["E501"]
|
|
55
|
+
|
|
56
|
+
[tool.pytest.ini_options]
|
|
57
|
+
testpaths = ["tests"]
|
|
58
|
+
|
|
59
|
+
[tool.mypy]
|
|
60
|
+
python_version = "3.10"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""cendor-init — offline CLI to wire Cendor + your AI assistant (``init``) and validate the wiring
|
|
2
|
+
(``doctor``). Optional developer tooling; no Cendor library depends on it, and it makes no network
|
|
3
|
+
call. See https://cendor.ai/docs/for-ai-assistants.
|
|
4
|
+
|
|
5
|
+
This is a standalone top-level package (``cendor_init``) — NOT part of the PEP 420 ``cendor.*``
|
|
6
|
+
namespace — mirroring how ``cendor-mcp`` ships ``cendor_mcp``.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from .doctor import run_doctor
|
|
12
|
+
from .initialize import run_init
|
|
13
|
+
|
|
14
|
+
__all__ = ["run_init", "run_doctor", "__version__"]
|
|
15
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"""``cendor-init`` — one command to make a project Cendor-ready and Cendor-fluent for its AI
|
|
2
|
+
assistant, plus a ``doctor`` that catches wiring mistakes before they bite. Offline: no network, no key.
|
|
3
|
+
|
|
4
|
+
uvx cendor-init # detect + write assistant rules (idempotent)
|
|
5
|
+
uvx cendor-init doctor # validate wiring; non-zero exit on hard problems (CI-usable)
|
|
6
|
+
|
|
7
|
+
See https://cendor.ai/docs/for-ai-assistants and https://cendor.ai/mcp.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import argparse
|
|
13
|
+
import sys
|
|
14
|
+
import textwrap
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
from .doctor import SEVERITY_RANK, Finding, run_doctor
|
|
18
|
+
from .initialize import ALL_ASSISTANTS, InitOptions, run_init
|
|
19
|
+
|
|
20
|
+
__all__ = ["main"]
|
|
21
|
+
|
|
22
|
+
_ICON = {
|
|
23
|
+
"created": "+",
|
|
24
|
+
"updated": "~",
|
|
25
|
+
"appended": "~",
|
|
26
|
+
"skipped": "·",
|
|
27
|
+
"would-create": "+",
|
|
28
|
+
"would-update": "~",
|
|
29
|
+
"would-append": "~",
|
|
30
|
+
"would-skip": "·",
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _version() -> str:
|
|
35
|
+
try:
|
|
36
|
+
from importlib import metadata
|
|
37
|
+
|
|
38
|
+
return metadata.version("cendor-init")
|
|
39
|
+
except Exception:
|
|
40
|
+
return "0.1.0"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _parse_assistants(raw: list[str] | None) -> list[str] | None:
|
|
44
|
+
if not raw:
|
|
45
|
+
return None
|
|
46
|
+
wanted: list[str] = []
|
|
47
|
+
for item in raw:
|
|
48
|
+
for part in item.split(","):
|
|
49
|
+
part = part.strip().lower()
|
|
50
|
+
if part and part not in wanted:
|
|
51
|
+
wanted.append(part)
|
|
52
|
+
bad = [w for w in wanted if w not in ALL_ASSISTANTS]
|
|
53
|
+
if bad:
|
|
54
|
+
sys.stderr.write(f"cendor-init: unknown assistant(s): {', '.join(bad)}\n")
|
|
55
|
+
sys.stderr.write(f" valid: {', '.join(ALL_ASSISTANTS)}\n")
|
|
56
|
+
raise SystemExit(2)
|
|
57
|
+
return wanted
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _cmd_init(args: argparse.Namespace) -> int:
|
|
61
|
+
root = Path.cwd()
|
|
62
|
+
opts = InitOptions(
|
|
63
|
+
root=root,
|
|
64
|
+
assistants=_parse_assistants(args.assistant),
|
|
65
|
+
all=args.all,
|
|
66
|
+
mcp=args.mcp,
|
|
67
|
+
scaffold=args.scaffold,
|
|
68
|
+
force=args.force,
|
|
69
|
+
dry_run=args.dry_run,
|
|
70
|
+
)
|
|
71
|
+
result = run_init(opts)
|
|
72
|
+
dry = opts.dry_run
|
|
73
|
+
eco = result.detected.ecosystem
|
|
74
|
+
|
|
75
|
+
out = sys.stdout.write
|
|
76
|
+
out(
|
|
77
|
+
f"\ncendor-init — {'dry run (no files written)' if dry else 'wiring Cendor for your assistant'}\n"
|
|
78
|
+
)
|
|
79
|
+
line = "no package.json / pyproject found" if eco == "unknown" else f"{eco} project"
|
|
80
|
+
if result.detected.declared_providers:
|
|
81
|
+
line += f" · providers: {', '.join(sorted(result.detected.declared_providers))}"
|
|
82
|
+
out(f"project: {line}\n\n")
|
|
83
|
+
|
|
84
|
+
for a in result.actions:
|
|
85
|
+
icon = _ICON.get(a.status, "·")
|
|
86
|
+
note = f" ({a.note})" if a.note else ""
|
|
87
|
+
out(f" {icon} {a.status:<13} {a.path}{note}\n")
|
|
88
|
+
|
|
89
|
+
out("\nMCP (agent-mode assistants):\n")
|
|
90
|
+
for ln in result.mcp_guidance.split("\n"):
|
|
91
|
+
out(f" {ln}\n")
|
|
92
|
+
|
|
93
|
+
out("\nNext:\n")
|
|
94
|
+
out(" • Trust your editor's hover/completion — every Cendor symbol ships an @example.\n")
|
|
95
|
+
out(" • Full trap sheet: https://cendor.ai/docs/for-ai-assistants\n")
|
|
96
|
+
out(" • Validate wiring: uvx cendor-init doctor\n\n")
|
|
97
|
+
return 0
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _print_finding(f: Finding) -> None:
|
|
101
|
+
tag = {"error": "ERROR", "warn": "WARN ", "ok": "OK "}.get(f.severity, "INFO ")
|
|
102
|
+
out = sys.stdout.write
|
|
103
|
+
out(f" [{tag}] {f.title}\n")
|
|
104
|
+
for ln in textwrap.wrap(f.detail, width=88):
|
|
105
|
+
out(f" {ln}\n")
|
|
106
|
+
if f.fix:
|
|
107
|
+
out(f" fix: {f.fix}\n")
|
|
108
|
+
for loc in f.locations:
|
|
109
|
+
out(f" - {loc}\n")
|
|
110
|
+
out("\n")
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _cmd_doctor(_args: argparse.Namespace) -> int:
|
|
114
|
+
result = run_doctor(Path.cwd())
|
|
115
|
+
sys.stdout.write("\ncendor-init doctor\n\n")
|
|
116
|
+
for f in sorted(result.findings, key=lambda x: SEVERITY_RANK.get(x.severity, 9)):
|
|
117
|
+
_print_finding(f)
|
|
118
|
+
errors = sum(1 for f in result.findings if f.severity == "error")
|
|
119
|
+
warns = sum(1 for f in result.findings if f.severity == "warn")
|
|
120
|
+
tail = "OK." if result.exit_code == 0 else "Fix the errors above."
|
|
121
|
+
sys.stdout.write(f"{errors} error(s), {warns} warning(s). {tail}\n\n")
|
|
122
|
+
return result.exit_code
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _build_parser() -> argparse.ArgumentParser:
|
|
126
|
+
parser = argparse.ArgumentParser(
|
|
127
|
+
prog="cendor-init",
|
|
128
|
+
description="Wire Cendor + your AI assistant, offline.",
|
|
129
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
130
|
+
epilog="Docs: https://cendor.ai/docs/for-ai-assistants MCP: https://cendor.ai/mcp",
|
|
131
|
+
)
|
|
132
|
+
parser.add_argument("-v", "--version", action="version", version=_version())
|
|
133
|
+
sub = parser.add_subparsers(dest="command")
|
|
134
|
+
|
|
135
|
+
p_init = sub.add_parser("init", help="write assistant rules files (default command)")
|
|
136
|
+
_add_init_args(p_init)
|
|
137
|
+
sub.add_parser("doctor", help="validate the wiring (never writes); exit 1 on hard problems")
|
|
138
|
+
return parser
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _add_init_args(p: argparse.ArgumentParser) -> None:
|
|
142
|
+
p.add_argument("--all", action="store_true", help="write every assistant rules file")
|
|
143
|
+
p.add_argument(
|
|
144
|
+
"--assistant",
|
|
145
|
+
action="append",
|
|
146
|
+
metavar="LIST",
|
|
147
|
+
help="comma-separated subset: copilot,cursor,agents,claude,windsurf",
|
|
148
|
+
)
|
|
149
|
+
p.add_argument("--mcp", action="store_true", help="also drop MCP connect config where absent")
|
|
150
|
+
p.add_argument(
|
|
151
|
+
"--scaffold", action="store_true", help="also write a correct instrument()+budget starter"
|
|
152
|
+
)
|
|
153
|
+
p.add_argument(
|
|
154
|
+
"--force", action="store_true", help="overwrite an owned file (.cursor/rules/cendor.mdc)"
|
|
155
|
+
)
|
|
156
|
+
p.add_argument("--dry-run", action="store_true", help="show what would change without writing")
|
|
157
|
+
p.add_argument("-y", "--yes", action="store_true", help=argparse.SUPPRESS)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def _force_utf8() -> None:
|
|
161
|
+
"""Our output uses em-dashes / bullets. A Windows console defaults to a non-UTF-8 code page,
|
|
162
|
+
which would raise UnicodeEncodeError on those — force UTF-8 (with a replace fallback)."""
|
|
163
|
+
for stream in (sys.stdout, sys.stderr):
|
|
164
|
+
reconfigure = getattr(stream, "reconfigure", None)
|
|
165
|
+
if reconfigure is not None:
|
|
166
|
+
try:
|
|
167
|
+
reconfigure(encoding="utf-8", errors="replace")
|
|
168
|
+
except (ValueError, OSError): # pragma: no cover - stream doesn't support it
|
|
169
|
+
pass
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def main(argv: list[str] | None = None) -> int:
|
|
173
|
+
_force_utf8()
|
|
174
|
+
argv = list(sys.argv[1:] if argv is None else argv)
|
|
175
|
+
# Default to `init` when no subcommand is given (mirrors `npx @cendor/init`).
|
|
176
|
+
if not argv or (argv[0].startswith("-") and argv[0] not in ("-h", "--help", "-v", "--version")):
|
|
177
|
+
argv = ["init", *argv]
|
|
178
|
+
|
|
179
|
+
parser = _build_parser()
|
|
180
|
+
args = parser.parse_args(argv)
|
|
181
|
+
command = args.command or "init"
|
|
182
|
+
if command == "doctor":
|
|
183
|
+
return _cmd_doctor(args)
|
|
184
|
+
return _cmd_init(args)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
if __name__ == "__main__": # pragma: no cover
|
|
188
|
+
raise SystemExit(main())
|