codefactory-cli 0.20.1__tar.gz → 0.20.2__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.
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/PKG-INFO +7 -3
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/README.md +6 -2
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/__init__.py +1 -1
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/cli.py +1 -1
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/skill.py +45 -9
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/skill_template/SKILL.md +1 -1
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory_cli.egg-info/PKG-INFO +7 -3
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/pyproject.toml +1 -1
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_skill.py +56 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/LICENSE +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/__main__.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/accept.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/analyzers/__init__.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/analyzers/generic.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/analyzers/parallel.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/analyzers/python.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/analyzers/python_parse.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/analyzers/treewalk.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/analyzers/ts_helper.js +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/analyzers/typescript.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/apple.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/audit.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/baseline.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/brief.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/cache.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/checks.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/config.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/coverage.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/deps.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/diff.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/efficiency.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/flags.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/graph.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/hotspots.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/infra.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/intent.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/layers.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/org.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/owners.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/patch.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/paths.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/plan.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/privacy.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/profile.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/rerank.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/review.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/rules.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/sarif.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/sbom.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/security.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/similar.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/skill_template/__init__.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/sqlgraph.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/suppress.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/taint.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/trace.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/viewer/__init__.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/viewer/dashboard.html +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/viewer/factory.css +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/viewer/factory.js +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory/viewer/template.html +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory_cli.egg-info/SOURCES.txt +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory_cli.egg-info/dependency_links.txt +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory_cli.egg-info/entry_points.txt +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory_cli.egg-info/requires.txt +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory_cli.egg-info/top_level.txt +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/setup.cfg +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_accept.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_agent.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_apple.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_audit.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_bench.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_cache.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_cli_errors.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_coverage.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_diff.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_efficiency.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_findings_review.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_generic.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_golden.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_hotspots.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_intent.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_org.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_parallel.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_patch.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_privacy.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_profile.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_public_repos.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_python_scopes.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_release.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_review.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_rules.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_sarif.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_security.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_shop.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_sql_trace.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_taint.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_typescript.py +0 -0
- {codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/tests/test_workflow.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codefactory-cli
|
|
3
|
-
Version: 0.20.
|
|
3
|
+
Version: 0.20.2
|
|
4
4
|
Summary: See a codebase as a factory floor, find what's wrong with it (copies, N+1 loops, dead code, import loops, security and reliability problems), and turn it into ranked work.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/dominickkubica/codefactory
|
|
@@ -56,7 +56,7 @@ the number of calls it carries. Dashed orange conveyors run backwards, from a lo
|
|
|
56
56
|
## Quick start
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
pip install "codefactory[languages]
|
|
59
|
+
pip install "codefactory-cli[languages]"
|
|
60
60
|
cd path/to/your/repo
|
|
61
61
|
|
|
62
62
|
codefactory review -o review.md # a technical review of the repository (--online: also vulnerable dependencies)
|
|
@@ -66,7 +66,11 @@ codefactory profile # what kind of project it thinks this is (findi
|
|
|
66
66
|
codefactory hotspots # where change happens: complex code that keeps changing
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
+
- **The package is `codefactory-cli`** on PyPI (`codefactory` there is an unrelated project); the command is
|
|
70
|
+
`codefactory`. Installed from GitHub before? `codefactory update` moves you over.
|
|
69
71
|
- **Python 3.11 or newer.** On Windows, run the same commands in PowerShell; use `py -m pip` if `pip` isn't found.
|
|
72
|
+
On a Mac, `brew install pipx` and then `pipx install "codefactory-cli[languages]"` (Homebrew's Python refuses a
|
|
73
|
+
plain `pip install`, and the built-in `python3` is too old).
|
|
70
74
|
- **TypeScript/JavaScript projects:** run `npm install` in the project first, because codefactory uses the project's
|
|
71
75
|
own TypeScript compiler (needs [Node.js](https://nodejs.org)). Without it, those files are still analyzed, less
|
|
72
76
|
precisely.
|
|
@@ -178,7 +182,7 @@ jobs:
|
|
|
178
182
|
steps:
|
|
179
183
|
- uses: actions/checkout@v4
|
|
180
184
|
with: { fetch-depth: 0 }
|
|
181
|
-
- uses: dominickkubica/codefactory@v0 # follows releases; or pin v0.20.
|
|
185
|
+
- uses: dominickkubica/codefactory@v0 # follows releases; or pin v0.20.2 or a commit SHA
|
|
182
186
|
with: { fail-on: high }
|
|
183
187
|
```
|
|
184
188
|
|
|
@@ -22,7 +22,7 @@ the number of calls it carries. Dashed orange conveyors run backwards, from a lo
|
|
|
22
22
|
## Quick start
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
pip install "codefactory[languages]
|
|
25
|
+
pip install "codefactory-cli[languages]"
|
|
26
26
|
cd path/to/your/repo
|
|
27
27
|
|
|
28
28
|
codefactory review -o review.md # a technical review of the repository (--online: also vulnerable dependencies)
|
|
@@ -32,7 +32,11 @@ codefactory profile # what kind of project it thinks this is (findi
|
|
|
32
32
|
codefactory hotspots # where change happens: complex code that keeps changing
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
- **The package is `codefactory-cli`** on PyPI (`codefactory` there is an unrelated project); the command is
|
|
36
|
+
`codefactory`. Installed from GitHub before? `codefactory update` moves you over.
|
|
35
37
|
- **Python 3.11 or newer.** On Windows, run the same commands in PowerShell; use `py -m pip` if `pip` isn't found.
|
|
38
|
+
On a Mac, `brew install pipx` and then `pipx install "codefactory-cli[languages]"` (Homebrew's Python refuses a
|
|
39
|
+
plain `pip install`, and the built-in `python3` is too old).
|
|
36
40
|
- **TypeScript/JavaScript projects:** run `npm install` in the project first, because codefactory uses the project's
|
|
37
41
|
own TypeScript compiler (needs [Node.js](https://nodejs.org)). Without it, those files are still analyzed, less
|
|
38
42
|
precisely.
|
|
@@ -144,7 +148,7 @@ jobs:
|
|
|
144
148
|
steps:
|
|
145
149
|
- uses: actions/checkout@v4
|
|
146
150
|
with: { fetch-depth: 0 }
|
|
147
|
-
- uses: dominickkubica/codefactory@v0 # follows releases; or pin v0.20.
|
|
151
|
+
- uses: dominickkubica/codefactory@v0 # follows releases; or pin v0.20.2 or a commit SHA
|
|
148
152
|
with: { fail-on: high }
|
|
149
153
|
```
|
|
150
154
|
|
|
@@ -692,7 +692,7 @@ Run `codefactory <command> --help` for a command's options.""",
|
|
|
692
692
|
if name == "skill":
|
|
693
693
|
s.add_argument("--hook", action="store_true", help="also add a session-start hook that keeps codefactory current")
|
|
694
694
|
if name == "update":
|
|
695
|
-
s.add_argument("--source", default=SKILL_SOURCE, help="where to install from (default:
|
|
695
|
+
s.add_argument("--source", default=SKILL_SOURCE, help="where to install from (default: codefactory-cli on PyPI)")
|
|
696
696
|
if name == "sbom":
|
|
697
697
|
s.add_argument("-o", "--output", help="output file (default: print it)")
|
|
698
698
|
if name not in ("skill", "update", "sbom"):
|
|
@@ -19,7 +19,8 @@ from pathlib import Path
|
|
|
19
19
|
|
|
20
20
|
from . import __version__
|
|
21
21
|
|
|
22
|
-
SOURCE = "codefactory[languages]
|
|
22
|
+
SOURCE = "codefactory-cli[languages]" # on PyPI as codefactory-cli (`codefactory` there is an unrelated project)
|
|
23
|
+
GIT_URL = "github.com/dominickkubica/codefactory"
|
|
23
24
|
STAMP = re.compile(r"<!-- codefactory skill (\S+) -->")
|
|
24
25
|
HOOK_NAME = "codefactory.sh"
|
|
25
26
|
HOOK_COMMAND = f'"$CLAUDE_PROJECT_DIR"/.claude/hooks/{HOOK_NAME}'
|
|
@@ -83,23 +84,35 @@ set -u
|
|
|
83
84
|
cd "${CLAUDE_PROJECT_DIR:-.}" || exit 0
|
|
84
85
|
|
|
85
86
|
SOURCE="__SOURCE__"
|
|
87
|
+
STAMP="${HOME:-/tmp}/.cache/codefactory/last-update"
|
|
88
|
+
mkdir -p "$(dirname "$STAMP")" 2>/dev/null
|
|
89
|
+
stale() { [ -z "$(find "$STAMP" -mmin -1440 2>/dev/null)" ]; }
|
|
90
|
+
limit() { if command -v timeout >/dev/null 2>&1; then timeout 180 "$@"; else "$@"; fi; }
|
|
91
|
+
|
|
92
|
+
if [ ! -f ../codefactory/pyproject.toml ] && command -v codefactory >/dev/null 2>&1 && codefactory --version >/dev/null 2>&1; then
|
|
93
|
+
# already a command (pipx, uv tool, a virtualenv): upgrade it with its own Python, never touching python3 (on a Mac
|
|
94
|
+
# without developer tools that's a stub that opens an install dialog; Homebrew's refuses pip installs)
|
|
95
|
+
if stale; then limit codefactory update >/dev/null 2>&1 && touch "$STAMP"; fi
|
|
96
|
+
codefactory skill . >/dev/null 2>&1
|
|
97
|
+
echo "codefactory $(codefactory --version 2>/dev/null | cut -d' ' -f2) is installed: see .claude/skills/codefactory/SKILL.md"
|
|
98
|
+
exit 0
|
|
99
|
+
fi
|
|
100
|
+
|
|
86
101
|
PY=""
|
|
87
102
|
for c in python3 python py; do # the first that really runs (Windows has a python3 stub that doesn't)
|
|
88
103
|
if command -v "$c" >/dev/null 2>&1 && "$c" -c "" >/dev/null 2>&1; then PY="$c"; break; fi
|
|
89
104
|
done
|
|
90
105
|
[ -n "$PY" ] || exit 0
|
|
91
|
-
STAMP="${HOME:-/tmp}/.cache/codefactory/last-update"
|
|
92
|
-
mkdir -p "$(dirname "$STAMP")" 2>/dev/null
|
|
93
106
|
|
|
94
107
|
install() { # $1: what to install
|
|
95
|
-
|
|
96
|
-
else "$PY" -m pip install --quiet --upgrade "$1" >/dev/null 2>&1; fi
|
|
108
|
+
limit "$PY" -m pip install --quiet --upgrade "$@" >/dev/null 2>&1
|
|
97
109
|
}
|
|
98
110
|
|
|
99
111
|
if [ -f ../codefactory/pyproject.toml ]; then
|
|
100
112
|
# a checkout of codefactory next to this repository (a cloud session with both attached): use it as is
|
|
101
113
|
"$PY" -c "import codefactory" 2>/dev/null || install -e "../codefactory[languages]"
|
|
102
|
-
elif ! "$PY" -c "import codefactory" 2>/dev/null ||
|
|
114
|
+
elif ! "$PY" -c "import codefactory" 2>/dev/null || stale; then
|
|
115
|
+
"$PY" -c "from codefactory.skill import drop_git_install as d; d()" >/dev/null 2>&1 # an older install from GitHub
|
|
103
116
|
install "$SOURCE" && touch "$STAMP"
|
|
104
117
|
fi
|
|
105
118
|
|
|
@@ -131,12 +144,35 @@ def install_hook(repo: Path) -> tuple[Path, Path]:
|
|
|
131
144
|
return hook, settings_file
|
|
132
145
|
|
|
133
146
|
|
|
147
|
+
def git_install() -> bool:
|
|
148
|
+
"""codefactory installed from its GitHub repository (as the `codefactory` distribution), before it was on PyPI."""
|
|
149
|
+
from importlib.metadata import PackageNotFoundError, distribution
|
|
150
|
+
|
|
151
|
+
try:
|
|
152
|
+
url = distribution("codefactory").read_text("direct_url.json") or ""
|
|
153
|
+
except PackageNotFoundError:
|
|
154
|
+
return False
|
|
155
|
+
return GIT_URL in url and '"vcs_info"' in url # not an editable clone (a file:// URL), not PyPI's other project
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def drop_git_install() -> bool:
|
|
159
|
+
"""Uninstalls a GitHub install, which shares every file with codefactory-cli. codefactory-cli goes too when it's
|
|
160
|
+
also installed: uninstalling either deletes the shared files, and pip would then see codefactory-cli as already
|
|
161
|
+
installed and leave it broken. The caller installs codefactory-cli afresh."""
|
|
162
|
+
if not git_install():
|
|
163
|
+
return False
|
|
164
|
+
return subprocess.run([sys.executable, "-m", "pip", "uninstall", "--yes", "--quiet", "codefactory", "codefactory-cli"],
|
|
165
|
+
capture_output=True).returncode == 0 # fmt: skip
|
|
166
|
+
|
|
167
|
+
|
|
134
168
|
def update(source: str = SOURCE) -> tuple[str, str]:
|
|
135
169
|
"""Upgrades codefactory with this Python's pip. Returns (old version, new version)."""
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
)
|
|
170
|
+
pip = [sys.executable, "-m", "pip", "install", "--quiet", "--upgrade"]
|
|
171
|
+
dropped = drop_git_install()
|
|
172
|
+
proc = subprocess.run([*pip, source], capture_output=True, text=True)
|
|
139
173
|
if proc.returncode != 0:
|
|
174
|
+
if dropped: # put the GitHub install back rather than leave nothing installed
|
|
175
|
+
subprocess.run([*pip, f"codefactory[languages] @ git+https://{GIT_URL}"], capture_output=True)
|
|
140
176
|
raise RuntimeError(f"pip couldn't upgrade codefactory:\n{proc.stderr.strip()[-1500:]}")
|
|
141
177
|
new = subprocess.run(
|
|
142
178
|
[sys.executable, "-c", "import codefactory; print(codefactory.__version__)"], capture_output=True, text=True
|
|
@@ -7,7 +7,7 @@ description: Map this codebase's structure (layers, who calls what) and find cop
|
|
|
7
7
|
|
|
8
8
|
`codefactory` statically analyzes this repo into a call graph and lists issues with `file:line`. The first run takes a few seconds to ~30 s; later runs reuse `.codefactory/graph.json` until a source
|
|
9
9
|
file changes. Run it from the repo root. If the command isn't found, use `python -m codefactory`; if it isn't
|
|
10
|
-
installed at all, `pip install "codefactory[languages]
|
|
10
|
+
installed at all, `pip install "codefactory-cli[languages]"` (on a Mac: `pipx install "codefactory-cli[languages]"`).
|
|
11
11
|
It reads Python and TypeScript/JavaScript precisely; Go, Java, Kotlin, Swift, Rust, C/C++, C#, Ruby, PHP and others
|
|
12
12
|
through tree-sitter, matching calls by name, so for those languages treat call, impact and unused findings as leads
|
|
13
13
|
to confirm in the code. Big repositories are fine: files are parsed in parallel and cached per file. If a command below is missing or
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codefactory-cli
|
|
3
|
-
Version: 0.20.
|
|
3
|
+
Version: 0.20.2
|
|
4
4
|
Summary: See a codebase as a factory floor, find what's wrong with it (copies, N+1 loops, dead code, import loops, security and reliability problems), and turn it into ranked work.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/dominickkubica/codefactory
|
|
@@ -56,7 +56,7 @@ the number of calls it carries. Dashed orange conveyors run backwards, from a lo
|
|
|
56
56
|
## Quick start
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
pip install "codefactory[languages]
|
|
59
|
+
pip install "codefactory-cli[languages]"
|
|
60
60
|
cd path/to/your/repo
|
|
61
61
|
|
|
62
62
|
codefactory review -o review.md # a technical review of the repository (--online: also vulnerable dependencies)
|
|
@@ -66,7 +66,11 @@ codefactory profile # what kind of project it thinks this is (findi
|
|
|
66
66
|
codefactory hotspots # where change happens: complex code that keeps changing
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
+
- **The package is `codefactory-cli`** on PyPI (`codefactory` there is an unrelated project); the command is
|
|
70
|
+
`codefactory`. Installed from GitHub before? `codefactory update` moves you over.
|
|
69
71
|
- **Python 3.11 or newer.** On Windows, run the same commands in PowerShell; use `py -m pip` if `pip` isn't found.
|
|
72
|
+
On a Mac, `brew install pipx` and then `pipx install "codefactory-cli[languages]"` (Homebrew's Python refuses a
|
|
73
|
+
plain `pip install`, and the built-in `python3` is too old).
|
|
70
74
|
- **TypeScript/JavaScript projects:** run `npm install` in the project first, because codefactory uses the project's
|
|
71
75
|
own TypeScript compiler (needs [Node.js](https://nodejs.org)). Without it, those files are still analyzed, less
|
|
72
76
|
precisely.
|
|
@@ -178,7 +182,7 @@ jobs:
|
|
|
178
182
|
steps:
|
|
179
183
|
- uses: actions/checkout@v4
|
|
180
184
|
with: { fetch-depth: 0 }
|
|
181
|
-
- uses: dominickkubica/codefactory@v0 # follows releases; or pin v0.20.
|
|
185
|
+
- uses: dominickkubica/codefactory@v0 # follows releases; or pin v0.20.2 or a commit SHA
|
|
182
186
|
with: { fail-on: high }
|
|
183
187
|
```
|
|
184
188
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "codefactory-cli"
|
|
7
|
-
version = "0.20.
|
|
7
|
+
version = "0.20.2"
|
|
8
8
|
description = "See a codebase as a factory floor, find what's wrong with it (copies, N+1 loops, dead code, import loops, security and reliability problems), and turn it into ranked work."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -77,15 +77,71 @@ class SkillTest(unittest.TestCase):
|
|
|
77
77
|
proc = subprocess.run(["/bin/bash", str(hook)], env=env, capture_output=True, text=True)
|
|
78
78
|
self.assertEqual(proc.returncode, 0) # no Python at all: quietly does nothing
|
|
79
79
|
|
|
80
|
+
@unittest.skipIf(os.name == "nt", "bash script")
|
|
81
|
+
def test_hook_uses_an_installed_command_without_python(self):
|
|
82
|
+
# pipx on a Mac: `codefactory` is a command, python3 can't import it (and may be a stub that opens a dialog)
|
|
83
|
+
hook, _ = skill.install_hook(self.repo)
|
|
84
|
+
bin_dir, log = Path(self.tmp.name) / "bin", Path(self.tmp.name) / "log"
|
|
85
|
+
bin_dir.mkdir()
|
|
86
|
+
for name, body in (("codefactory", f'echo "codefactory $*" >> {log}; echo codefactory 9.9.9'),
|
|
87
|
+
("python3", f"echo python3 >> {log}; exit 1")): # fmt: skip
|
|
88
|
+
(bin_dir / name).write_text(f"#!/bin/sh\n{body}\n", encoding="utf-8")
|
|
89
|
+
(bin_dir / name).chmod(0o755)
|
|
90
|
+
env = {**os.environ, "CLAUDE_PROJECT_DIR": str(self.repo), "HOME": self.tmp.name, "PATH": f"{bin_dir}:/usr/bin:/bin"}
|
|
91
|
+
for _ in range(2):
|
|
92
|
+
proc = subprocess.run(["/bin/bash", str(hook)], env=env, capture_output=True, text=True)
|
|
93
|
+
self.assertEqual(proc.returncode, 0)
|
|
94
|
+
calls = log.read_text(encoding="utf-8").splitlines()
|
|
95
|
+
self.assertNotIn("python3", calls)
|
|
96
|
+
self.assertEqual(calls.count("codefactory update"), 1) # at most once a day
|
|
97
|
+
self.assertEqual(calls.count("codefactory skill ."), 2)
|
|
98
|
+
self.assertIn("9.9.9", proc.stdout)
|
|
99
|
+
|
|
80
100
|
def test_update_reports_versions(self):
|
|
81
101
|
ok = subprocess.CompletedProcess([], 0, stdout="9.9.9\n", stderr="")
|
|
82
102
|
with mock.patch("subprocess.run", return_value=ok) as run:
|
|
83
103
|
self.assertEqual(skill.update(), (__version__, "9.9.9"))
|
|
84
104
|
self.assertIn(skill.SOURCE, run.call_args_list[0].args[0])
|
|
105
|
+
self.assertEqual(skill.SOURCE, "codefactory-cli[languages]")
|
|
85
106
|
bad = subprocess.CompletedProcess([], 1, stdout="", stderr="no network")
|
|
86
107
|
with mock.patch("subprocess.run", return_value=bad), self.assertRaises(RuntimeError):
|
|
87
108
|
skill.update()
|
|
88
109
|
|
|
110
|
+
def _dist(self, direct_url):
|
|
111
|
+
dist = mock.Mock()
|
|
112
|
+
dist.read_text.return_value = direct_url
|
|
113
|
+
return mock.patch("importlib.metadata.distribution", return_value=dist)
|
|
114
|
+
|
|
115
|
+
def test_git_install_is_only_ours_from_github(self):
|
|
116
|
+
git = '{"url": "https://github.com/dominickkubica/codefactory", "vcs_info": {"vcs": "git"}}'
|
|
117
|
+
with self._dist(git):
|
|
118
|
+
self.assertTrue(skill.git_install())
|
|
119
|
+
with self._dist('{"url": "file:///home/me/codefactory", "dir_info": {"editable": true}}'):
|
|
120
|
+
self.assertFalse(skill.git_install()) # a developer's clone stays
|
|
121
|
+
with self._dist(None):
|
|
122
|
+
self.assertFalse(skill.git_install()) # from PyPI (no direct_url.json): the unrelated project
|
|
123
|
+
from importlib.metadata import PackageNotFoundError
|
|
124
|
+
|
|
125
|
+
with mock.patch("importlib.metadata.distribution", side_effect=PackageNotFoundError):
|
|
126
|
+
self.assertFalse(skill.git_install())
|
|
127
|
+
|
|
128
|
+
def test_update_moves_a_git_install_to_pypi(self):
|
|
129
|
+
ok = subprocess.CompletedProcess([], 0, stdout="9.9.9\n", stderr="")
|
|
130
|
+
with mock.patch.object(skill, "git_install", return_value=True), mock.patch("subprocess.run", return_value=ok) as run:
|
|
131
|
+
skill.update()
|
|
132
|
+
cmds = [c.args[0] for c in run.call_args_list]
|
|
133
|
+
self.assertIn("uninstall", cmds[0]) # the GitHub install goes first, then PyPI's
|
|
134
|
+
self.assertIn("codefactory-cli", cmds[0]) # also uninstalled: pip would see it installed, with its files gone
|
|
135
|
+
self.assertIn(skill.SOURCE, cmds[1])
|
|
136
|
+
bad = subprocess.CompletedProcess([], 1, stdout="", stderr="no network")
|
|
137
|
+
with (
|
|
138
|
+
mock.patch.object(skill, "git_install", return_value=True),
|
|
139
|
+
mock.patch("subprocess.run", side_effect=[ok, bad, ok]) as run,
|
|
140
|
+
self.assertRaises(RuntimeError),
|
|
141
|
+
):
|
|
142
|
+
skill.update()
|
|
143
|
+
self.assertIn("git+https://github.com/dominickkubica/codefactory", run.call_args_list[2].args[0][-1]) # put back
|
|
144
|
+
|
|
89
145
|
|
|
90
146
|
if __name__ == "__main__":
|
|
91
147
|
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{codefactory_cli-0.20.1 → codefactory_cli-0.20.2}/codefactory_cli.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|