karni-cli 0.3.1__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.
- karni_cli-0.3.1/.gitignore +38 -0
- karni_cli-0.3.1/LICENSE +201 -0
- karni_cli-0.3.1/PKG-INFO +191 -0
- karni_cli-0.3.1/README.md +153 -0
- karni_cli-0.3.1/hatch_build.py +77 -0
- karni_cli-0.3.1/karni_cli/__init__.py +3 -0
- karni_cli-0.3.1/karni_cli/_agent/__init__.py +82 -0
- karni_cli-0.3.1/karni_cli/_agent/__main__.py +44 -0
- karni_cli-0.3.1/karni_cli/_agent/check.py +658 -0
- karni_cli-0.3.1/karni_cli/_agent/history.py +328 -0
- karni_cli-0.3.1/karni_cli/_agent/history_chronicle.py +246 -0
- karni_cli-0.3.1/karni_cli/_agent/overrides.py +194 -0
- karni_cli-0.3.1/karni_cli/_agent/rules.py +673 -0
- karni_cli-0.3.1/karni_cli/_changelog/0.2.0.toml +304 -0
- karni_cli-0.3.1/karni_cli/_changelog/0.3.0.toml +25 -0
- karni_cli-0.3.1/karni_cli/_changelog/__init__.py +248 -0
- karni_cli-0.3.1/karni_cli/_errorcodes/__init__.py +1171 -0
- karni_cli-0.3.1/karni_cli/_errorcodes/__main__.py +34 -0
- karni_cli-0.3.1/karni_cli/_errorcodes/links.py +217 -0
- karni_cli-0.3.1/karni_cli/_templates/project/cookiecutter.json +8 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/.dockerignore +7 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/.env.example +85 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/.gitignore +10 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/Caddyfile +22 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/Dockerfile +53 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/Makefile +52 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/README.md +169 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/config/__init__.py +16 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/config/asgi.py +14 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/config/celery.py +17 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/config/settings.py +28 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/config/urls.py +31 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/config/wsgi.py +14 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/docker-compose.yml +126 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/.dockerignore +2 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/.jscpd.json +9 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/.npmrc +7 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/Dockerfile.dev +17 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/eslint.config.js +32 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/index.html +14 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/package.json +43 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/postcss.config.js +6 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/public/favicon.svg +6 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/src/App.tsx +18 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/src/api/health.ts +21 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/src/index.css +11 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/src/layout.tsx +51 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/src/main.tsx +11 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/src/pages/home.tsx +28 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/src/routes.tsx +24 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/src/vite-env.d.ts +1 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/tailwind.config.ts +13 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/tsconfig.json +19 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/frontend/vite.config.ts +18 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/manage.py +23 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/pyproject.toml +31 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/tests/__init__.py +0 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/tests/test_api_schema.py +17 -0
- karni_cli-0.3.1/karni_cli/_templates/project/{{cookiecutter.project_slug}}/tests/test_smoke.py +11 -0
- karni_cli-0.3.1/karni_cli/adapters.py +373 -0
- karni_cli-0.3.1/karni_cli/agent_adapters.toml +160 -0
- karni_cli-0.3.1/karni_cli/agent_data.py +260 -0
- karni_cli-0.3.1/karni_cli/brand.py +55 -0
- karni_cli-0.3.1/karni_cli/clidoc.py +254 -0
- karni_cli-0.3.1/karni_cli/commands/__init__.py +0 -0
- karni_cli-0.3.1/karni_cli/commands/add.py +144 -0
- karni_cli-0.3.1/karni_cli/commands/beat.py +36 -0
- karni_cli-0.3.1/karni_cli/commands/check.py +101 -0
- karni_cli-0.3.1/karni_cli/commands/config.py +81 -0
- karni_cli-0.3.1/karni_cli/commands/context.py +171 -0
- karni_cli-0.3.1/karni_cli/commands/createsuperuser.py +28 -0
- karni_cli-0.3.1/karni_cli/commands/doctor.py +136 -0
- karni_cli-0.3.1/karni_cli/commands/explain.py +60 -0
- karni_cli-0.3.1/karni_cli/commands/make.py +55 -0
- karni_cli-0.3.1/karni_cli/commands/manage_passthrough.py +28 -0
- karni_cli-0.3.1/karni_cli/commands/mcp.py +20 -0
- karni_cli-0.3.1/karni_cli/commands/migrate.py +23 -0
- karni_cli-0.3.1/karni_cli/commands/new.py +106 -0
- karni_cli-0.3.1/karni_cli/commands/routes.py +20 -0
- karni_cli-0.3.1/karni_cli/commands/rules.py +139 -0
- karni_cli-0.3.1/karni_cli/commands/run_tests.py +38 -0
- karni_cli-0.3.1/karni_cli/commands/schedule.py +40 -0
- karni_cli-0.3.1/karni_cli/commands/seed.py +34 -0
- karni_cli-0.3.1/karni_cli/commands/serve.py +50 -0
- karni_cli-0.3.1/karni_cli/commands/shell.py +28 -0
- karni_cli-0.3.1/karni_cli/commands/sync_roles.py +32 -0
- karni_cli-0.3.1/karni_cli/commands/types.py +72 -0
- karni_cli-0.3.1/karni_cli/commands/upgrade.py +231 -0
- karni_cli-0.3.1/karni_cli/commands/worker.py +63 -0
- karni_cli-0.3.1/karni_cli/config.py +142 -0
- karni_cli-0.3.1/karni_cli/environment.py +29 -0
- karni_cli-0.3.1/karni_cli/errorcodes.py +377 -0
- karni_cli-0.3.1/karni_cli/errordoc.py +227 -0
- karni_cli-0.3.1/karni_cli/generators/__init__.py +67 -0
- karni_cli-0.3.1/karni_cli/generators/apitest.py +206 -0
- karni_cli-0.3.1/karni_cli/generators/app.py +103 -0
- karni_cli-0.3.1/karni_cli/generators/command.py +98 -0
- karni_cli-0.3.1/karni_cli/generators/component.py +115 -0
- karni_cli-0.3.1/karni_cli/generators/core.py +319 -0
- karni_cli-0.3.1/karni_cli/generators/event.py +57 -0
- karni_cli-0.3.1/karni_cli/generators/factory.py +88 -0
- karni_cli-0.3.1/karni_cli/generators/fields.py +343 -0
- karni_cli-0.3.1/karni_cli/generators/introspect.py +263 -0
- karni_cli-0.3.1/karni_cli/generators/listener.py +168 -0
- karni_cli-0.3.1/karni_cli/generators/middleware.py +95 -0
- karni_cli-0.3.1/karni_cli/generators/migration.py +82 -0
- karni_cli-0.3.1/karni_cli/generators/model.py +235 -0
- karni_cli-0.3.1/karni_cli/generators/module.py +255 -0
- karni_cli-0.3.1/karni_cli/generators/naming.py +100 -0
- karni_cli-0.3.1/karni_cli/generators/page.py +373 -0
- karni_cli-0.3.1/karni_cli/generators/pysource.py +304 -0
- karni_cli-0.3.1/karni_cli/generators/schedule.py +174 -0
- karni_cli-0.3.1/karni_cli/generators/seeder.py +86 -0
- karni_cli-0.3.1/karni_cli/generators/serializer.py +165 -0
- karni_cli-0.3.1/karni_cli/generators/service.py +68 -0
- karni_cli-0.3.1/karni_cli/generators/task.py +84 -0
- karni_cli-0.3.1/karni_cli/generators/viewset.py +179 -0
- karni_cli-0.3.1/karni_cli/history.py +59 -0
- karni_cli-0.3.1/karni_cli/local_state.py +73 -0
- karni_cli-0.3.1/karni_cli/main.py +104 -0
- karni_cli-0.3.1/karni_cli/mcp_server.py +103 -0
- karni_cli-0.3.1/karni_cli/project.py +248 -0
- karni_cli-0.3.1/karni_cli/rules_render.py +86 -0
- karni_cli-0.3.1/karni_cli/scaffold.py +197 -0
- karni_cli-0.3.1/karni_cli/settings_edit.py +128 -0
- karni_cli-0.3.1/karni_cli/tips.py +53 -0
- karni_cli-0.3.1/karni_cli/typegen.py +101 -0
- karni_cli-0.3.1/karni_cli/upgrades/__init__.py +28 -0
- karni_cli-0.3.1/karni_cli/upgrades/changelog.py +123 -0
- karni_cli-0.3.1/karni_cli/upgrades/codemod.py +125 -0
- karni_cli-0.3.1/karni_cli/upgrades/engine.py +224 -0
- karni_cli-0.3.1/karni_cli/upgrades/legacy_agent_files.py +138 -0
- karni_cli-0.3.1/karni_cli/upgrades/python.py +670 -0
- karni_cli-0.3.1/karni_cli/upgrades/transforms/rename-export.cjs +96 -0
- karni_cli-0.3.1/karni_cli/upgrades/typescript.py +160 -0
- karni_cli-0.3.1/karni_cli/upgrades/v0_2/__init__.py +1 -0
- karni_cli-0.3.1/karni_cli/upgrades/v0_2/agent_guidance.py +269 -0
- karni_cli-0.3.1/karni_cli/upgrades/v1_0/__init__.py +5 -0
- karni_cli-0.3.1/karni_cli/upgrades/v1_0/all_objects_to_without.py +18 -0
- karni_cli-0.3.1/karni_cli/upgrades/v1_0/all_with_deleted_to_without.py +13 -0
- karni_cli-0.3.1/karni_cli/upgrades/v1_0/deleted_only_to_without_dead.py +13 -0
- karni_cli-0.3.1/karni_cli/upgrades/v1_0/object_permission_classes_to_access.py +16 -0
- karni_cli-0.3.1/karni_cli/upgrades/v1_0/related_lookups_to_optimize.py +15 -0
- karni_cli-0.3.1/karni_cli/upgrades/v1_0/scoped_related_lookups_to_optimize.py +15 -0
- karni_cli-0.3.1/karni_cli/upgrades/v1_0/soft_delete_manager_mixin_to_scoped.py +14 -0
- karni_cli-0.3.1/pyproject.toml +104 -0
- karni_cli-0.3.1/tests/__init__.py +0 -0
- karni_cli-0.3.1/tests/conftest.py +151 -0
- karni_cli-0.3.1/tests/fixtures/schema.fixture.json +88 -0
- karni_cli-0.3.1/tests/fixtures/upgrade_changelog/0.9.0.toml +15 -0
- karni_cli-0.3.1/tests/test_adapters.py +502 -0
- karni_cli-0.3.1/tests/test_add.py +201 -0
- karni_cli-0.3.1/tests/test_agent_upgrade.py +171 -0
- karni_cli-0.3.1/tests/test_audit_fixes.py +169 -0
- karni_cli-0.3.1/tests/test_brand.py +41 -0
- karni_cli-0.3.1/tests/test_check.py +78 -0
- karni_cli-0.3.1/tests/test_clidoc.py +22 -0
- karni_cli-0.3.1/tests/test_context.py +134 -0
- karni_cli-0.3.1/tests/test_docs_tutorial.py +32 -0
- karni_cli-0.3.1/tests/test_doctor.py +294 -0
- karni_cli-0.3.1/tests/test_errorcodes_cli.py +130 -0
- karni_cli-0.3.1/tests/test_history.py +358 -0
- karni_cli-0.3.1/tests/test_make.py +541 -0
- karni_cli-0.3.1/tests/test_make_gate.py +404 -0
- karni_cli-0.3.1/tests/test_make_units.py +218 -0
- karni_cli-0.3.1/tests/test_mcp.py +73 -0
- karni_cli-0.3.1/tests/test_new.py +216 -0
- karni_cli-0.3.1/tests/test_project.py +94 -0
- karni_cli-0.3.1/tests/test_rules.py +156 -0
- karni_cli-0.3.1/tests/test_runners.py +333 -0
- karni_cli-0.3.1/tests/test_types.py +48 -0
- karni_cli-0.3.1/tests/test_upgrade.py +393 -0
- karni_cli-0.3.1/tests/test_upgrade_codemods.py +333 -0
- karni_cli-0.3.1/tests/test_upgrade_typescript.py +210 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
.learning/
|
|
2
|
+
|
|
3
|
+
# Python
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.py[cod]
|
|
6
|
+
*.egg-info/
|
|
7
|
+
.venv/
|
|
8
|
+
venv/
|
|
9
|
+
.pytest_cache/
|
|
10
|
+
.mypy_cache/
|
|
11
|
+
.ruff_cache/
|
|
12
|
+
.coverage
|
|
13
|
+
htmlcov/
|
|
14
|
+
|
|
15
|
+
# Build artifacts
|
|
16
|
+
dist/
|
|
17
|
+
build/
|
|
18
|
+
packages/karni-cli/karni_cli/_templates/
|
|
19
|
+
packages/karni-cli/karni_cli/_agent/
|
|
20
|
+
packages/karni-cli/karni_cli/_changelog/
|
|
21
|
+
packages/karni-cli/karni_cli/_errorcodes/
|
|
22
|
+
|
|
23
|
+
# Node
|
|
24
|
+
node_modules/
|
|
25
|
+
storybook-static/
|
|
26
|
+
*.tsbuildinfo
|
|
27
|
+
|
|
28
|
+
# Local env / editor / tooling
|
|
29
|
+
.env
|
|
30
|
+
.env.*
|
|
31
|
+
!.env.example
|
|
32
|
+
.DS_Store
|
|
33
|
+
.idea/
|
|
34
|
+
.claude/scheduled_tasks.lock
|
|
35
|
+
.claude/settings.local.json
|
|
36
|
+
|
|
37
|
+
# MkDocs build output
|
|
38
|
+
site/
|
karni_cli-0.3.1/LICENSE
ADDED
|
@@ -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 [yyyy] [name of copyright owner]
|
|
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.
|
karni_cli-0.3.1/PKG-INFO
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: karni-cli
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: The karni command for the Karni Django + React framework: scaffold a project, generate models, viewsets and pages, run it, upgrade it across releases, and give AI coding agents its context, rules and error explanations.
|
|
5
|
+
Project-URL: Homepage, https://github.com/cbsshekhawat18-lab/karni
|
|
6
|
+
Project-URL: Documentation, https://cbsshekhawat18-lab.github.io/karni/
|
|
7
|
+
Project-URL: Repository, https://github.com/cbsshekhawat18-lab/karni
|
|
8
|
+
Project-URL: Issues, https://github.com/cbsshekhawat18-lab/karni/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/cbsshekhawat18-lab/karni/tree/main/docs/migrations
|
|
10
|
+
Author-email: Chandrabhan Shekhawat <cbsshekhawat18@gmail.com>
|
|
11
|
+
License-Expression: Apache-2.0
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: ai-agents,claude-code,cli,code-generation,cookiecutter,copilot,cursor,django,mcp,project-template,react,scaffolding
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Environment :: Console
|
|
16
|
+
Classifier: Framework :: Django
|
|
17
|
+
Classifier: Framework :: Django :: 5.2
|
|
18
|
+
Classifier: Intended Audience :: Developers
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
25
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
26
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
27
|
+
Classifier: Typing :: Typed
|
|
28
|
+
Requires-Python: >=3.12
|
|
29
|
+
Requires-Dist: cookiecutter>=2.5
|
|
30
|
+
Requires-Dist: libcst>=1.4
|
|
31
|
+
Requires-Dist: packaging>=24.0
|
|
32
|
+
Requires-Dist: pyyaml>=6.0
|
|
33
|
+
Requires-Dist: tomlkit>=0.12
|
|
34
|
+
Requires-Dist: typer>=0.12
|
|
35
|
+
Provides-Extra: mcp
|
|
36
|
+
Requires-Dist: mcp>=1.2; extra == 'mcp'
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
# karni-cli
|
|
40
|
+
|
|
41
|
+
The `karni` command. Orchestrates a Karni project's own `manage.py` via
|
|
42
|
+
subprocess — the CLI itself never imports Django.
|
|
43
|
+
|
|
44
|
+
## Commands
|
|
45
|
+
- `karni new <name>` — scaffold a project from the bundled cookiecutter
|
|
46
|
+
template (monorepo checkouts use the live `templates/project`; override with
|
|
47
|
+
`KARNI_TEMPLATES`).
|
|
48
|
+
- `karni add <module>` — add `karni-<module>` to `[project].dependencies` and
|
|
49
|
+
wire `karni_<module>` into the `# karni:apps` block in config/settings.py.
|
|
50
|
+
Only that marker block is managed; any other layout gets a clear error and
|
|
51
|
+
you edit settings manually.
|
|
52
|
+
Once the module is installed it also records the module's
|
|
53
|
+
`AGENTS.fragment.md` as `.karni/modules/<module>.md` and refreshes the agent
|
|
54
|
+
adapters.
|
|
55
|
+
- `karni types` — dump the OpenAPI schema (`manage.py spectacular`), generate
|
|
56
|
+
`types.ts` (openapi-typescript, project-pinned binary preferred, else
|
|
57
|
+
`npx openapi-typescript@^7`) and typed hooks (`hooks.ts`) over @karni/ui.
|
|
58
|
+
- `karni context` — compact machine-readable inventory (< 200 tokens for a
|
|
59
|
+
typical project): APPS (from the `# karni:apps` block) and PAGES (from
|
|
60
|
+
`frontend/src/pages/`) read statically, MODELS/VIEWSETS from `manage.py karni_context`,
|
|
61
|
+
COMPONENTS/HOOKS from @karni/ui's build-generated `dist/manifest.json`
|
|
62
|
+
(omitted when absent — run `npm i @karni/ui` in `frontend/` on the host to
|
|
63
|
+
enable them; `--manifest PATH` overrides). Nothing is hand-maintained.
|
|
64
|
+
- `karni context --with-history [PATH]` — the same inventory plus a
|
|
65
|
+
`HISTORY:` brief of what was already asked and decided about PATH (without
|
|
66
|
+
PATH: the project's recorded decisions) from any history provider that
|
|
67
|
+
detects a store, e.g. Gigai Chronicle's `.chronicle/`. Capped at ~300
|
|
68
|
+
tokens (characters ÷ 4), cut at line boundaries with a last line naming the
|
|
69
|
+
full-brief command. With no store the output is exactly `karni context`'s.
|
|
70
|
+
See `docs/concepts/history-providers.md`.
|
|
71
|
+
- `karni check [-q]` — Django system checks plus `karni.checks` entry-point hooks
|
|
72
|
+
(the architecture-test extension surface). A clean run outside CI may end
|
|
73
|
+
with one tip on stderr, at most once per project; `-q` suppresses it.
|
|
74
|
+
- `karni doctor [-q]` — human-readable environment report: project,
|
|
75
|
+
interpreter (`.venv` / compose service), Node/npm, the @karni/ui manifest,
|
|
76
|
+
adapter freshness, history providers. May end with the same one-time tip.
|
|
77
|
+
- `karni config get|set|list [--global] KEY [VALUE]` — settings
|
|
78
|
+
(`suggest_tools`): `.karni/config.toml` in the project (committed) or
|
|
79
|
+
`$XDG_CONFIG_HOME/karni/config.toml` with `--global`; the project wins.
|
|
80
|
+
Machine-local state (e.g. "tip shown") lives in the self-ignoring
|
|
81
|
+
`.karni/local/`.
|
|
82
|
+
- `karni rules [--explain CODE | --procedure NAME | --check FILE... | --json]`
|
|
83
|
+
— Karni's conventions from `karni.agent.rules` (no Django needed), and
|
|
84
|
+
static single-file checks (exit 1 on violations).
|
|
85
|
+
- `karni rules sync [--check] [--force]` — regenerate the thin agent adapters
|
|
86
|
+
(AGENTS.md, CLAUDE.md, Cursor, Windsurf, Copilot, Cline, Aider, Junie) and
|
|
87
|
+
slash commands from `karni_cli/agent_adapters.toml`; `--check` is the CI
|
|
88
|
+
staleness gate.
|
|
89
|
+
- `karni mcp` — context, rules and check as MCP tools
|
|
90
|
+
(`pip install 'karni-cli[mcp]'`).
|
|
91
|
+
- `karni upgrade [--to VERSION] [--from VERSION] [--dry-run] [--allow-dirty] [--list]`
|
|
92
|
+
moves the project across Karni versions. It reads the karni installed in
|
|
93
|
+
the project (`--from` overrides), takes every breaking change between that
|
|
94
|
+
and `--to` from Karni's machine-readable changelog
|
|
95
|
+
(`packages/karni/karni/changelog/*.toml`, bundled into karni-cli), and runs
|
|
96
|
+
their codemods in release order. Python codemods use libcst; TypeScript
|
|
97
|
+
codemods use a pinned jscodeshift through `npx` and are skipped, with the
|
|
98
|
+
reason, without Node.js. The codemods run on a scratch copy, and the result
|
|
99
|
+
is written back all at once, or not at all if one fails. `--dry-run` prints
|
|
100
|
+
a unified diff and writes nothing. Writing needs a clean git tree;
|
|
101
|
+
`--allow-dirty` overrides that, and is also required outside git. The
|
|
102
|
+
report lists what was applied (each file and its rewrite count), what could
|
|
103
|
+
not be fixed automatically (the sites found, with each migration-note link)
|
|
104
|
+
and what was skipped. Run it before you raise the karni pin. See
|
|
105
|
+
`docs/migrations/`.
|
|
106
|
+
|
|
107
|
+
See `docs/agents.md` for the agent surface in full.
|
|
108
|
+
|
|
109
|
+
## Runners
|
|
110
|
+
Artisan-style shortcuts. Each runner runs one project command through the
|
|
111
|
+
project interpreter (see *Execution environment* below), streams its output
|
|
112
|
+
and exits with its exit code. `--help` on each names the command it wraps.
|
|
113
|
+
Extra arguments pass straight through; put `--` before any that clash with
|
|
114
|
+
karni's own options (`--docker`, `--service`, `--help`).
|
|
115
|
+
|
|
116
|
+
| Command | Runs |
|
|
117
|
+
|---|---|
|
|
118
|
+
| `karni serve` | `docker compose up` (`--build`, `-d`) |
|
|
119
|
+
| `karni serve --local [--host H] [--port P]` | `manage.py runserver 127.0.0.1:8000` via `.venv` |
|
|
120
|
+
| `karni migrate [ARGS]` | `manage.py migrate [ARGS]` |
|
|
121
|
+
| `karni test [ARGS]` | `python -m pytest [ARGS]` |
|
|
122
|
+
| `karni shell [ARGS]` | `manage.py shell [ARGS]` |
|
|
123
|
+
| `karni routes [--json]` | `manage.py karni_routes`: every URL with methods, name, view, model, access |
|
|
124
|
+
| `karni worker [-A APP] [-l LEVEL] [ARGS]` | `python -m celery -A config worker -l info [ARGS]` |
|
|
125
|
+
| `karni beat [-A APP] [-l LEVEL] [ARGS]` | `python -m celery -A config beat -l info [ARGS]` |
|
|
126
|
+
| `karni schedule list [--json]` | `manage.py karni_schedules`: every merged beat schedule |
|
|
127
|
+
| `karni schedule run NAME` | `manage.py karni_schedules --run NAME`: runs the task once, synchronously |
|
|
128
|
+
| `karni createsuperuser [ARGS]` | `manage.py createsuperuser [ARGS]` |
|
|
129
|
+
| `karni manage ARGS` | `manage.py ARGS`: the raw passthrough for everything else |
|
|
130
|
+
|
|
131
|
+
In docker mode, `shell`, `test`, `worker`, `beat`, `createsuperuser` and
|
|
132
|
+
`manage` get a TTY (`docker compose exec` without `-T`) when karni runs in a
|
|
133
|
+
terminal, so prompts and Ctrl-C work. Scripted and agent runs keep `-T`.
|
|
134
|
+
With the compose stack up, `worker` and `beat` already run as services, so
|
|
135
|
+
`karni worker` and `karni beat` are for `.venv` development. See
|
|
136
|
+
`docs/events.md` and `docs/scheduling.md`.
|
|
137
|
+
|
|
138
|
+
## Generators
|
|
139
|
+
`karni make <type>` writes the project code a task needs, so neither a person
|
|
140
|
+
nor an AI agent hand-creates a file a generator makes. `karni make --list`
|
|
141
|
+
prints them all; every one is also a hidden Laravel-style alias
|
|
142
|
+
`karni make:<type>`. The full reference (every option, the field DSL) is
|
|
143
|
+
[docs/cli.md](https://cbsshekhawat18-lab.github.io/karni/cli/), generated from this CLI.
|
|
144
|
+
|
|
145
|
+
| Command | Writes |
|
|
146
|
+
|---|---|
|
|
147
|
+
| `karni make app NAME` | `NAME/{__init__,apps,models,viewsets}.py`, `migrations/`, `tests/`; wires `# karni:apps` |
|
|
148
|
+
| `karni make model NAME [FIELD...]` | `class NAME(BaseModel)` in `<app>/models.py`; `--with viewset,page` / `-a` chains; `--migrate` |
|
|
149
|
+
| `karni make viewset MODEL` | `<Model>ViewSet` with its `access` (`--access authenticated\|public-read\|owned:<field>\|staff\|role:<name>`), `--search` |
|
|
150
|
+
| `karni make serializer MODEL --reason ...` | `<app>/serializers.py` + `serializer_class` on the viewset |
|
|
151
|
+
| `karni make migration [NAME]` | runs `manage.py makemigrations [--app] [--name] [--empty]` through the project interpreter |
|
|
152
|
+
| `karni make task NAME` | `@shared_task` in `<app>/tasks.py` (`--retry N`) |
|
|
153
|
+
| `karni make schedule NAME` | `every(...)`/`cron(...)` in `<app>/schedules.py` (`--every 15m` / `--cron "0 3 * * *"`, `--task`) |
|
|
154
|
+
| `karni make event NAME` | a `Signal` in `<app>/events.py` |
|
|
155
|
+
| `karni make listener NAME --on ...` | `<app>/listeners.py`: `Model.created\|updated\|deleted` or a custom event; `--queued` |
|
|
156
|
+
| `karni make command NAME` | `<app>/management/commands/NAME.py` |
|
|
157
|
+
| `karni make service NAME` | `<app>/services/NAME.py` (where HTTP clients are allowed) |
|
|
158
|
+
| `karni make middleware NAME` | `<app>/middleware.py`, wired through `# karni:middleware` |
|
|
159
|
+
| `karni make page NAME` | `frontend/src/pages/NAME.tsx` (≤ 50 lines; `--resource R --kind list\|detail\|form`), route in `frontend/src/routes.tsx` |
|
|
160
|
+
| `karni make component NAME` | `frontend/src/components/NAME.tsx` claiming a role (`--role`) |
|
|
161
|
+
| `karni make module NAME` | `modules/karni-NAME/` per docs/modules.md |
|
|
162
|
+
|
|
163
|
+
```sh
|
|
164
|
+
karni make app events
|
|
165
|
+
karni make model Event title:str:200 starts_at:datetime "status:choice:draft|live" \
|
|
166
|
+
organizer:fk:User 'venue:fk:Venue?' -a --access owned:organizer --search title
|
|
167
|
+
karni make migration && karni migrate
|
|
168
|
+
karni make listener notify_organizer --on Event.created --queued
|
|
169
|
+
karni make schedule nightly-report --cron "0 3 * * *"
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Every generator: never overwrites without `--force`; `--dry-run` prints the
|
|
173
|
+
files and diff and writes nothing; prints each created/modified file plus
|
|
174
|
+
notes (the chosen `access`, the route, the next command); resolves the app
|
|
175
|
+
from `--app` or the project's only local app; edits existing files only
|
|
176
|
+
through marker comments or AST-located appends (an unfamiliar layout is an
|
|
177
|
+
error naming the manual step); never imports Django. Generated Python is
|
|
178
|
+
clean under ruff (lint and format) and `karni rules --check`, and generated
|
|
179
|
+
pages parse and stay within 50 lines — `tests/test_make_gate.py` generates
|
|
180
|
+
every type into a fresh scaffold and asserts it (plus `tsc` and the
|
|
181
|
+
frontend's ESLint config when `KARNI_TEST_NODE_MODULES` points at an
|
|
182
|
+
installed `frontend/node_modules`), then runs the generated backend for real
|
|
183
|
+
(makemigrations, migrate, check, requests through the Django test client).
|
|
184
|
+
|
|
185
|
+
Quote fields that end in `?` in zsh (`'venue:fk:Venue?'`) and choice values
|
|
186
|
+
joined by `|`.
|
|
187
|
+
|
|
188
|
+
## Execution environment
|
|
189
|
+
Commands that run the project resolve, in order: `--docker/--no-docker` flag →
|
|
190
|
+
`<project>/.venv` → a running compose service (default `django`; change with
|
|
191
|
+
`--service` or `KARNI_COMPOSE_SERVICE`) → an error naming both remedies.
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# karni-cli
|
|
2
|
+
|
|
3
|
+
The `karni` command. Orchestrates a Karni project's own `manage.py` via
|
|
4
|
+
subprocess — the CLI itself never imports Django.
|
|
5
|
+
|
|
6
|
+
## Commands
|
|
7
|
+
- `karni new <name>` — scaffold a project from the bundled cookiecutter
|
|
8
|
+
template (monorepo checkouts use the live `templates/project`; override with
|
|
9
|
+
`KARNI_TEMPLATES`).
|
|
10
|
+
- `karni add <module>` — add `karni-<module>` to `[project].dependencies` and
|
|
11
|
+
wire `karni_<module>` into the `# karni:apps` block in config/settings.py.
|
|
12
|
+
Only that marker block is managed; any other layout gets a clear error and
|
|
13
|
+
you edit settings manually.
|
|
14
|
+
Once the module is installed it also records the module's
|
|
15
|
+
`AGENTS.fragment.md` as `.karni/modules/<module>.md` and refreshes the agent
|
|
16
|
+
adapters.
|
|
17
|
+
- `karni types` — dump the OpenAPI schema (`manage.py spectacular`), generate
|
|
18
|
+
`types.ts` (openapi-typescript, project-pinned binary preferred, else
|
|
19
|
+
`npx openapi-typescript@^7`) and typed hooks (`hooks.ts`) over @karni/ui.
|
|
20
|
+
- `karni context` — compact machine-readable inventory (< 200 tokens for a
|
|
21
|
+
typical project): APPS (from the `# karni:apps` block) and PAGES (from
|
|
22
|
+
`frontend/src/pages/`) read statically, MODELS/VIEWSETS from `manage.py karni_context`,
|
|
23
|
+
COMPONENTS/HOOKS from @karni/ui's build-generated `dist/manifest.json`
|
|
24
|
+
(omitted when absent — run `npm i @karni/ui` in `frontend/` on the host to
|
|
25
|
+
enable them; `--manifest PATH` overrides). Nothing is hand-maintained.
|
|
26
|
+
- `karni context --with-history [PATH]` — the same inventory plus a
|
|
27
|
+
`HISTORY:` brief of what was already asked and decided about PATH (without
|
|
28
|
+
PATH: the project's recorded decisions) from any history provider that
|
|
29
|
+
detects a store, e.g. Gigai Chronicle's `.chronicle/`. Capped at ~300
|
|
30
|
+
tokens (characters ÷ 4), cut at line boundaries with a last line naming the
|
|
31
|
+
full-brief command. With no store the output is exactly `karni context`'s.
|
|
32
|
+
See `docs/concepts/history-providers.md`.
|
|
33
|
+
- `karni check [-q]` — Django system checks plus `karni.checks` entry-point hooks
|
|
34
|
+
(the architecture-test extension surface). A clean run outside CI may end
|
|
35
|
+
with one tip on stderr, at most once per project; `-q` suppresses it.
|
|
36
|
+
- `karni doctor [-q]` — human-readable environment report: project,
|
|
37
|
+
interpreter (`.venv` / compose service), Node/npm, the @karni/ui manifest,
|
|
38
|
+
adapter freshness, history providers. May end with the same one-time tip.
|
|
39
|
+
- `karni config get|set|list [--global] KEY [VALUE]` — settings
|
|
40
|
+
(`suggest_tools`): `.karni/config.toml` in the project (committed) or
|
|
41
|
+
`$XDG_CONFIG_HOME/karni/config.toml` with `--global`; the project wins.
|
|
42
|
+
Machine-local state (e.g. "tip shown") lives in the self-ignoring
|
|
43
|
+
`.karni/local/`.
|
|
44
|
+
- `karni rules [--explain CODE | --procedure NAME | --check FILE... | --json]`
|
|
45
|
+
— Karni's conventions from `karni.agent.rules` (no Django needed), and
|
|
46
|
+
static single-file checks (exit 1 on violations).
|
|
47
|
+
- `karni rules sync [--check] [--force]` — regenerate the thin agent adapters
|
|
48
|
+
(AGENTS.md, CLAUDE.md, Cursor, Windsurf, Copilot, Cline, Aider, Junie) and
|
|
49
|
+
slash commands from `karni_cli/agent_adapters.toml`; `--check` is the CI
|
|
50
|
+
staleness gate.
|
|
51
|
+
- `karni mcp` — context, rules and check as MCP tools
|
|
52
|
+
(`pip install 'karni-cli[mcp]'`).
|
|
53
|
+
- `karni upgrade [--to VERSION] [--from VERSION] [--dry-run] [--allow-dirty] [--list]`
|
|
54
|
+
moves the project across Karni versions. It reads the karni installed in
|
|
55
|
+
the project (`--from` overrides), takes every breaking change between that
|
|
56
|
+
and `--to` from Karni's machine-readable changelog
|
|
57
|
+
(`packages/karni/karni/changelog/*.toml`, bundled into karni-cli), and runs
|
|
58
|
+
their codemods in release order. Python codemods use libcst; TypeScript
|
|
59
|
+
codemods use a pinned jscodeshift through `npx` and are skipped, with the
|
|
60
|
+
reason, without Node.js. The codemods run on a scratch copy, and the result
|
|
61
|
+
is written back all at once, or not at all if one fails. `--dry-run` prints
|
|
62
|
+
a unified diff and writes nothing. Writing needs a clean git tree;
|
|
63
|
+
`--allow-dirty` overrides that, and is also required outside git. The
|
|
64
|
+
report lists what was applied (each file and its rewrite count), what could
|
|
65
|
+
not be fixed automatically (the sites found, with each migration-note link)
|
|
66
|
+
and what was skipped. Run it before you raise the karni pin. See
|
|
67
|
+
`docs/migrations/`.
|
|
68
|
+
|
|
69
|
+
See `docs/agents.md` for the agent surface in full.
|
|
70
|
+
|
|
71
|
+
## Runners
|
|
72
|
+
Artisan-style shortcuts. Each runner runs one project command through the
|
|
73
|
+
project interpreter (see *Execution environment* below), streams its output
|
|
74
|
+
and exits with its exit code. `--help` on each names the command it wraps.
|
|
75
|
+
Extra arguments pass straight through; put `--` before any that clash with
|
|
76
|
+
karni's own options (`--docker`, `--service`, `--help`).
|
|
77
|
+
|
|
78
|
+
| Command | Runs |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `karni serve` | `docker compose up` (`--build`, `-d`) |
|
|
81
|
+
| `karni serve --local [--host H] [--port P]` | `manage.py runserver 127.0.0.1:8000` via `.venv` |
|
|
82
|
+
| `karni migrate [ARGS]` | `manage.py migrate [ARGS]` |
|
|
83
|
+
| `karni test [ARGS]` | `python -m pytest [ARGS]` |
|
|
84
|
+
| `karni shell [ARGS]` | `manage.py shell [ARGS]` |
|
|
85
|
+
| `karni routes [--json]` | `manage.py karni_routes`: every URL with methods, name, view, model, access |
|
|
86
|
+
| `karni worker [-A APP] [-l LEVEL] [ARGS]` | `python -m celery -A config worker -l info [ARGS]` |
|
|
87
|
+
| `karni beat [-A APP] [-l LEVEL] [ARGS]` | `python -m celery -A config beat -l info [ARGS]` |
|
|
88
|
+
| `karni schedule list [--json]` | `manage.py karni_schedules`: every merged beat schedule |
|
|
89
|
+
| `karni schedule run NAME` | `manage.py karni_schedules --run NAME`: runs the task once, synchronously |
|
|
90
|
+
| `karni createsuperuser [ARGS]` | `manage.py createsuperuser [ARGS]` |
|
|
91
|
+
| `karni manage ARGS` | `manage.py ARGS`: the raw passthrough for everything else |
|
|
92
|
+
|
|
93
|
+
In docker mode, `shell`, `test`, `worker`, `beat`, `createsuperuser` and
|
|
94
|
+
`manage` get a TTY (`docker compose exec` without `-T`) when karni runs in a
|
|
95
|
+
terminal, so prompts and Ctrl-C work. Scripted and agent runs keep `-T`.
|
|
96
|
+
With the compose stack up, `worker` and `beat` already run as services, so
|
|
97
|
+
`karni worker` and `karni beat` are for `.venv` development. See
|
|
98
|
+
`docs/events.md` and `docs/scheduling.md`.
|
|
99
|
+
|
|
100
|
+
## Generators
|
|
101
|
+
`karni make <type>` writes the project code a task needs, so neither a person
|
|
102
|
+
nor an AI agent hand-creates a file a generator makes. `karni make --list`
|
|
103
|
+
prints them all; every one is also a hidden Laravel-style alias
|
|
104
|
+
`karni make:<type>`. The full reference (every option, the field DSL) is
|
|
105
|
+
[docs/cli.md](https://cbsshekhawat18-lab.github.io/karni/cli/), generated from this CLI.
|
|
106
|
+
|
|
107
|
+
| Command | Writes |
|
|
108
|
+
|---|---|
|
|
109
|
+
| `karni make app NAME` | `NAME/{__init__,apps,models,viewsets}.py`, `migrations/`, `tests/`; wires `# karni:apps` |
|
|
110
|
+
| `karni make model NAME [FIELD...]` | `class NAME(BaseModel)` in `<app>/models.py`; `--with viewset,page` / `-a` chains; `--migrate` |
|
|
111
|
+
| `karni make viewset MODEL` | `<Model>ViewSet` with its `access` (`--access authenticated\|public-read\|owned:<field>\|staff\|role:<name>`), `--search` |
|
|
112
|
+
| `karni make serializer MODEL --reason ...` | `<app>/serializers.py` + `serializer_class` on the viewset |
|
|
113
|
+
| `karni make migration [NAME]` | runs `manage.py makemigrations [--app] [--name] [--empty]` through the project interpreter |
|
|
114
|
+
| `karni make task NAME` | `@shared_task` in `<app>/tasks.py` (`--retry N`) |
|
|
115
|
+
| `karni make schedule NAME` | `every(...)`/`cron(...)` in `<app>/schedules.py` (`--every 15m` / `--cron "0 3 * * *"`, `--task`) |
|
|
116
|
+
| `karni make event NAME` | a `Signal` in `<app>/events.py` |
|
|
117
|
+
| `karni make listener NAME --on ...` | `<app>/listeners.py`: `Model.created\|updated\|deleted` or a custom event; `--queued` |
|
|
118
|
+
| `karni make command NAME` | `<app>/management/commands/NAME.py` |
|
|
119
|
+
| `karni make service NAME` | `<app>/services/NAME.py` (where HTTP clients are allowed) |
|
|
120
|
+
| `karni make middleware NAME` | `<app>/middleware.py`, wired through `# karni:middleware` |
|
|
121
|
+
| `karni make page NAME` | `frontend/src/pages/NAME.tsx` (≤ 50 lines; `--resource R --kind list\|detail\|form`), route in `frontend/src/routes.tsx` |
|
|
122
|
+
| `karni make component NAME` | `frontend/src/components/NAME.tsx` claiming a role (`--role`) |
|
|
123
|
+
| `karni make module NAME` | `modules/karni-NAME/` per docs/modules.md |
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
karni make app events
|
|
127
|
+
karni make model Event title:str:200 starts_at:datetime "status:choice:draft|live" \
|
|
128
|
+
organizer:fk:User 'venue:fk:Venue?' -a --access owned:organizer --search title
|
|
129
|
+
karni make migration && karni migrate
|
|
130
|
+
karni make listener notify_organizer --on Event.created --queued
|
|
131
|
+
karni make schedule nightly-report --cron "0 3 * * *"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Every generator: never overwrites without `--force`; `--dry-run` prints the
|
|
135
|
+
files and diff and writes nothing; prints each created/modified file plus
|
|
136
|
+
notes (the chosen `access`, the route, the next command); resolves the app
|
|
137
|
+
from `--app` or the project's only local app; edits existing files only
|
|
138
|
+
through marker comments or AST-located appends (an unfamiliar layout is an
|
|
139
|
+
error naming the manual step); never imports Django. Generated Python is
|
|
140
|
+
clean under ruff (lint and format) and `karni rules --check`, and generated
|
|
141
|
+
pages parse and stay within 50 lines — `tests/test_make_gate.py` generates
|
|
142
|
+
every type into a fresh scaffold and asserts it (plus `tsc` and the
|
|
143
|
+
frontend's ESLint config when `KARNI_TEST_NODE_MODULES` points at an
|
|
144
|
+
installed `frontend/node_modules`), then runs the generated backend for real
|
|
145
|
+
(makemigrations, migrate, check, requests through the Django test client).
|
|
146
|
+
|
|
147
|
+
Quote fields that end in `?` in zsh (`'venue:fk:Venue?'`) and choice values
|
|
148
|
+
joined by `|`.
|
|
149
|
+
|
|
150
|
+
## Execution environment
|
|
151
|
+
Commands that run the project resolve, in order: `--docker/--no-docker` flag →
|
|
152
|
+
`<project>/.venv` → a running compose service (default `django`; change with
|
|
153
|
+
`--service` or `KARNI_COMPOSE_SERVICE`) → an error naming both remedies.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""Hatch build hook: bundle templates/project into the wheel (contract E7).
|
|
2
|
+
|
|
3
|
+
From the monorepo, ../../templates/project is copied to karni_cli/_templates/
|
|
4
|
+
project so sdists are self-contained. Building a wheel FROM an sdist finds the
|
|
5
|
+
copy already in-tree and no-ops — never a missing-source error.
|
|
6
|
+
|
|
7
|
+
The same applies to Karni's stdlib-only agent rules (packages/karni/karni/
|
|
8
|
+
agent -> karni_cli/_agent): the fallback `karni rules` / `karni new` use when
|
|
9
|
+
karni itself is not importable and no project interpreter is reachable. And
|
|
10
|
+
to Karni's machine-readable changelog (packages/karni/karni/changelog ->
|
|
11
|
+
karni_cli/_changelog), which `karni upgrade` reads: the CLI must know every
|
|
12
|
+
change up to its own release, whatever karni the project has installed.
|
|
13
|
+
Likewise Karni's error code registry (packages/karni/karni/errorcodes ->
|
|
14
|
+
karni_cli/_errorcodes), which `karni explain` and error messages read.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import shutil
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
from typing import Any
|
|
22
|
+
|
|
23
|
+
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class TemplateBundleHook(BuildHookInterface):
|
|
27
|
+
PLUGIN_NAME = "custom"
|
|
28
|
+
|
|
29
|
+
def initialize(self, version: str, build_data: dict[str, Any]) -> None:
|
|
30
|
+
pkg_root = Path(self.root)
|
|
31
|
+
bundled = pkg_root / "karni_cli" / "_templates" / "project"
|
|
32
|
+
repo_source = pkg_root.parent.parent / "templates" / "project"
|
|
33
|
+
|
|
34
|
+
if repo_source.is_dir():
|
|
35
|
+
if bundled.exists():
|
|
36
|
+
shutil.rmtree(bundled)
|
|
37
|
+
shutil.copytree(
|
|
38
|
+
repo_source,
|
|
39
|
+
bundled,
|
|
40
|
+
ignore=shutil.ignore_patterns("__pycache__", "node_modules", ".DS_Store"),
|
|
41
|
+
)
|
|
42
|
+
elif not bundled.is_dir():
|
|
43
|
+
raise RuntimeError(
|
|
44
|
+
"No project template available: neither the monorepo templates/ "
|
|
45
|
+
"nor a bundled karni_cli/_templates copy exists."
|
|
46
|
+
)
|
|
47
|
+
build_data.setdefault("artifacts", []).append("karni_cli/_templates/")
|
|
48
|
+
|
|
49
|
+
self._bundle_karni(pkg_root, "agent", "_agent", "agent rules", build_data)
|
|
50
|
+
self._bundle_karni(pkg_root, "changelog", "_changelog", "changelog", build_data)
|
|
51
|
+
self._bundle_karni(pkg_root, "errorcodes", "_errorcodes", "error codes", build_data)
|
|
52
|
+
# karni.links (every published URL, stdlib only) rides inside the
|
|
53
|
+
# errorcodes bundle: the registry loads it by path when karni is absent.
|
|
54
|
+
links = pkg_root.parent / "karni" / "karni" / "links.py"
|
|
55
|
+
bundled_links = pkg_root / "karni_cli" / "_errorcodes" / "links.py"
|
|
56
|
+
if links.is_file():
|
|
57
|
+
shutil.copy2(links, bundled_links)
|
|
58
|
+
elif not bundled_links.is_file():
|
|
59
|
+
raise RuntimeError("No karni/links.py to bundle into karni_cli/_errorcodes.")
|
|
60
|
+
|
|
61
|
+
@staticmethod
|
|
62
|
+
def _bundle_karni(
|
|
63
|
+
pkg_root: Path, package: str, bundle: str, what: str, build_data: dict[str, Any]
|
|
64
|
+
) -> None:
|
|
65
|
+
"""Copy the stdlib-only ``karni/<package>`` into ``karni_cli/<bundle>``."""
|
|
66
|
+
bundled = pkg_root / "karni_cli" / bundle
|
|
67
|
+
source = pkg_root.parent / "karni" / "karni" / package
|
|
68
|
+
if source.is_dir():
|
|
69
|
+
if bundled.exists():
|
|
70
|
+
shutil.rmtree(bundled)
|
|
71
|
+
shutil.copytree(source, bundled, ignore=shutil.ignore_patterns("__pycache__"))
|
|
72
|
+
elif not bundled.is_dir():
|
|
73
|
+
raise RuntimeError(
|
|
74
|
+
f"No {what} available: neither the monorepo packages/karni/karni/{package} "
|
|
75
|
+
f"nor a bundled karni_cli/{bundle} copy exists."
|
|
76
|
+
)
|
|
77
|
+
build_data["artifacts"].append(f"karni_cli/{bundle}/")
|