galaxy-tool-refactor-cli 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ # Machine-local scratch, never committed: the cloned corpus (.local/corpus,
2
+ # seeded from corpus_sources.json) and external source clones for inspection
3
+ # (e.g. .local/galaxy-src = a clone of galaxyproject/galaxy used to verify
4
+ # Galaxy-internal behaviour locally).
5
+ # No trailing slash: `.local/` matches only a directory, so an accidental
6
+ # symlink at this path was committable (it happened once; removed in this branch).
7
+ .local
8
+ .venv/
9
+ __pycache__/
10
+ *.pyc
11
+ *.pyo
12
+ .pytest_cache/
13
+ .mypy_cache/
14
+ .ruff_cache/
15
+ dist/
16
+ *.egg-info/
17
+
18
+ # Local-only draft of the GCC poster abstract.
19
+ gcc2026-abstract.txt
20
+
21
+ # Claude Code session scratch (the tracked .claude/ settings + skills stay; this
22
+ # runtime lock for scheduled wakeups is machine-local).
23
+ .claude/scheduled_tasks.lock
24
+ .claude/worktrees/
@@ -0,0 +1,121 @@
1
+ # CLAUDE.md
2
+
3
+ Guidance for Claude Code working in this repository.
4
+
5
+ ## Project
6
+
7
+ `galaxy-tool-refactor-cli` is the **app tier** (tier 4) of the Galaxy tool
8
+ refactoring framework: the user-facing CLI front-end over the rule-registry
9
+ facade.
10
+
11
+ | Tier | Layer | Package |
12
+ |---|---|---|
13
+ | 0.5 | rule metadata | `galaxy-tool-refactor-rules` |
14
+ | 1 | parsing & validation | `galaxy-tool-source` |
15
+ | 2 | structure | `galaxy-tool-codemod` |
16
+ | 3 | formatting | `galaxy-tool-fmt` |
17
+ | 3.5 | advisory checks | `galaxy-tool-lint` |
18
+ | 3.6 | rule registry / rulesets | `galaxy-tool-refactor-registry` |
19
+ | 4 | **app / CLI** | `galaxy-tool-refactor-cli` *(this repo)* |
20
+
21
+ Rule orchestration lives in the tier-3.6 **registry facade**
22
+ (`galaxy-tool-refactor-registry`); this package depends on it (plus fmt's
23
+ `cli_support` engine and tier-1 parsing) and does CLI plumbing only — it no
24
+ longer imports the codemod / check tiers directly. It exposes the
25
+ `galaxy-tool-refactor` CLI with nine subcommands:
26
+
27
+ - `format` — apply a ruleset's fixable rules then cosmetic formatting. The default
28
+ ruleset = `canonical_codemods()` (repair + attribute / element order + the
29
+ CDATA wraps + GTR020 command-var single-quoting) + cosmetic. Safe, idempotent,
30
+ never changes `profile=`. (GTR020 shifts default-`format` bytes vs the pre-GTR020
31
+ historical output — behaviour-preserving; codemod `docs/decisions.md` §30.)
32
+ Advisory rules in a selection are reported as notes, never applied. Also
33
+ cosmetically formats macro-library files (`<macros>` root) — kind-applicable
34
+ rules only (no codemods); selection governs tools (cli §D5).
35
+ - `upgrade` — repair, then iterative profile upgrade, then cosmetic formatting.
36
+ Opt-in and semantic. No `--ruleset`; `--select`/`--ignore` adjust its rule set.
37
+ Also bumps an imported `@PROFILE@` token in place when every profile-using
38
+ importer in the run agrees on the target, else reports+skips (cli §D6); the
39
+ inline-token case is GTR007's job.
40
+ - `check` — report-only linter (mutates nothing) over the selected rules' detect
41
+ phases: `file:line CODE message` per finding. The default ruleset reports only
42
+ *fixable* GTR findings; `--ruleset strict` adds the *advisory* checks (marked
43
+ `(advisory)`). Fixable findings exit non-zero; advisory are informational unless
44
+ `--strict`. Macro files are checked for cosmetic (fixable) drift too.
45
+ - `find-references` — read-only query (mutates nothing, not a rule): print every
46
+ Cheetah `$NAME` reference site (`file:line [section] $ref`) across a tool **and its
47
+ imported macro files** (`galaxy_tool_source.cheetah_refs` + the bundle); see
48
+ `docs/decisions.md` §D8, §D10.
49
+ - `rename-param` — the mutating sibling of `find-references` (not a rule): rename a
50
+ parameter OLD→NEW across every Cheetah section, by-name cross-ref attribute, and
51
+ `<tests>` mirror, plus the definition — across the tool **and its imported macros**
52
+ (the bundle), atomically. `--repo-root` proves a touched macro is sole-owned (a
53
+ shared macro is skipped + reported, or — with `--across-importers` — renamed across
54
+ every importer in lockstep when they all agree); `--check` previews; `--backup` keeps
55
+ `.bak`s. First Cheetah mutator (M5.3) over `cheetah_rename` / `bundle_rename`; see
56
+ `docs/decisions.md` §D9, §D10, §D11.
57
+ - `rulesets` / `rules` — introspection of the baked-in rulesets and rules.
58
+ - `convert-help` — opt-in: convert an RST `<help>` body to Markdown
59
+ (`format="markdown"`, GTR092) when provable — profile ≥ 24.2 (XSD gate; the skip
60
+ says "run `upgrade` first") + the tier-1 render-equivalence gate (needs the
61
+ `galaxy-tool-source[markdown]` extra). Behaviour-changing by construction (swaps the
62
+ rendering engine), so a deliberate, separate command — never part of
63
+ `format`/`upgrade` (cli §D12; codemod §38).
64
+ - `normalize-macros` — opt-in, repo-scoped pass that lowercases literal
65
+ `format`/`ftype` in `<macros>`-root files (the macro-library analog of 24.2
66
+ normalization the per-tool `upgrade` cannot reach). Rewrites files other than the
67
+ one named (a shared macro file affects every importer), so it is a deliberate,
68
+ separate command — never part of `format`/`upgrade` (cli §D7;
69
+ `galaxy-tool-codemod/docs/macro-aware-normalization.md`).
70
+
71
+ Macro handling is **cosmetic-only and bundle-free for `format`/`check`** (macro
72
+ files are formatted/checked standalone as encountered — cosmetic formatting is safe
73
+ regardless of sharing; cli §D5). But `rename-param` / `find-references` **are
74
+ bundle-aware** (cli §D10): they operate over a tool *and its imported macro files*,
75
+ with a sole-owned `--repo-root` gate for the macro edits a rename makes (registry D12;
76
+ `galaxy-tool-source/docs/decisions.md` §21). All five mutating commands accept `--backup`
77
+ (`<file>.bak` before overwrite).
78
+
79
+ Selection (`--ruleset` / `--select` / `--ignore`) is shared by
80
+ `format`/`upgrade`/`check` (upgrade takes no `--ruleset`); precedence is ruff-style
81
+ (`--ignore` ▸ `--select` ▸ `--ruleset`, where `--select` replaces the ruleset set;
82
+ `--ruleset` is repeatable / comma-separated and takes the union of the named sets).
83
+ `format`/`upgrade` reuse fmt's `cli_support` engine (file walking,
84
+ `--check`/`--diff`/`--quiet`, drift detection, summary), wrapping `facade.run` /
85
+ `facade.upgrade` in the per-file transform; `check` runs its own report-only loop
86
+ (`cli_support.iter_targets`/`is_tool_root` + `facade.detect`). The facade — not
87
+ this package — composes the lower tiers, which is *why* the orchestration sits
88
+ below the CLI (so the MCP server reuses it). See `docs/decisions.md` §D1
89
+ (app tier), §D2 (`check`), §D3 (advisory findings), §D4 (registry facade +
90
+ selection); `galaxy-tool-refactor-registry/docs/decisions.md` D1–D4;
91
+ `galaxy-tool-fmt/docs/decisions.md` §D12.
92
+
93
+ ## Coding standards
94
+
95
+ Hand-written code follows **dignified-python** (vendored at the workspace root
96
+ `.claude/skills/dignified-python/`): LBYL over try/except; exceptions only at
97
+ the CLI error boundary; `pathlib.Path` with explicit `encoding="utf-8"`;
98
+ keyword-only args after the first; absolute imports, no re-exports, no
99
+ `__all__`; no import-time side effects. `optimized-python` is a secondary
100
+ reference; **dignified-python governs on conflict**.
101
+
102
+ ## Commands
103
+
104
+ Run from the **workspace root** (`galaxy-tool-refactor/`):
105
+
106
+ - `uv sync` — install dependencies
107
+ - `uv run --package galaxy-tool-refactor-cli pytest galaxy-tool-refactor-cli/tests/` — run tests
108
+ - `uv run ruff check galaxy-tool-refactor-cli/src galaxy-tool-refactor-cli/tests` — lint
109
+ - `uv run mypy --config-file galaxy-tool-refactor-cli/pyproject.toml galaxy-tool-refactor-cli/src` — type-check (strict)
110
+ - `uv run galaxy-tool-refactor format <file>` / `uv run galaxy-tool-refactor upgrade <file>` — run the CLI
111
+
112
+ ## Useful workspace references
113
+
114
+ - `galaxy-tool-refactor-registry/src/galaxy_tool_refactor_registry/facade.py` —
115
+ the `run` / `upgrade` / `detect` / `list_rulesets` / `list_rules` entry points
116
+ this CLI wraps; `resolve.py` for `resolve_codes` / `resolve_upgrade_codes`.
117
+ - `galaxy-tool-fmt/src/galaxy_tool_fmt/cli_support.py` — the shared
118
+ file-processing engine (`run`, `iter_targets`, `is_tool_root`,
119
+ `TransformOutcome`).
120
+ - `galaxy-tool-codemod/src/galaxy_tool_codemod/canonical.py` — the
121
+ `canonical_codemods()` / `AUTO_UPGRADE_CODEMODS` contracts the facade consumes.
@@ -0,0 +1,90 @@
1
+ Metadata-Version: 2.4
2
+ Name: galaxy-tool-refactor-cli
3
+ Version: 0.2.0
4
+ Summary: Top-level CLI app that composes the Galaxy tool refactoring tiers (format + upgrade).
5
+ Author: Richard Burhans
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.10
8
+ Requires-Dist: click>=8
9
+ Requires-Dist: galaxy-tool-fmt==0.2.0
10
+ Requires-Dist: galaxy-tool-refactor-registry==0.2.0
11
+ Requires-Dist: galaxy-tool-source==0.2.0
12
+ Description-Content-Type: text/markdown
13
+
14
+ # galaxy-tool-refactor-cli
15
+
16
+ The **app tier** of the Galaxy tool refactoring framework — the user-facing
17
+ `galaxy-tool-refactor` CLI, a thin front-end over the tier-3.6 rule-registry
18
+ facade (`galaxy-tool-refactor-registry`).
19
+
20
+ | Tier | Layer | Package |
21
+ |---|---|---|
22
+ | 0.5 | rule metadata | `galaxy-tool-refactor-rules` |
23
+ | 1 | parsing & validation | `galaxy-tool-source` |
24
+ | 2 | structure | `galaxy-tool-codemod` |
25
+ | 3 | formatting | `galaxy-tool-fmt` |
26
+ | 3.5 | advisory checks | `galaxy-tool-lint` |
27
+ | 3.6 | rule registry / rulesets | `galaxy-tool-refactor-registry` |
28
+ | 4 | **app / CLI** | `galaxy-tool-refactor-cli` *(this package)* |
29
+
30
+ Rule orchestration lives in the registry facade; this package depends on it
31
+ (plus fmt's `cli_support` engine and tier-1 parsing) and exposes ten commands
32
+ (`format`, `upgrade`, `check`, `find-references`, `rename-param`, `rulesets`, `rules`,
33
+ `normalize-macros`):
34
+
35
+ ```bash
36
+ # Safe, idempotent: apply a ruleset's fixable rules + cosmetic formatting.
37
+ # Default ruleset = structural canonicalisation + cosmetic; never profile=.
38
+ galaxy-tool-refactor format tool.xml
39
+ galaxy-tool-refactor format --ruleset cosmetic tool.xml # whitespace only
40
+ galaxy-tool-refactor format --ignore GTR002 tool.xml # all but param-reorder
41
+ galaxy-tool-refactor format tools/ # also formats <macros> files
42
+
43
+ # Opt-in, semantic: repair typos, then upgrade profile= to the latest reachable
44
+ # version (applying each step's structural migration), then format. Reports the
45
+ # steps applied and warns if a tool stalls. No --ruleset; --select/--ignore tune it.
46
+ galaxy-tool-refactor upgrade tool.xml
47
+
48
+ # Report-only linter: one `file:line CODE message` per finding, mutating
49
+ # nothing. The default ruleset reports the fixable GTR rules; `--ruleset strict` adds
50
+ # the advisory checks (marked `(advisory)`). Exits non-zero on any fixable
51
+ # finding; advisory findings are informational unless --strict.
52
+ galaxy-tool-refactor check tool.xml
53
+ galaxy-tool-refactor check --ruleset strict tool.xml
54
+
55
+ # Introspection.
56
+ galaxy-tool-refactor rulesets
57
+ galaxy-tool-refactor rules
58
+
59
+ # Opt-in, repo-scoped: lowercase literal format/ftype in <macros>-root files (the
60
+ # macro-library fix the per-tool `upgrade` can't reach). Rewrites files other than
61
+ # the one named, so it is a separate command — never part of format/upgrade.
62
+ galaxy-tool-refactor normalize-macros macros/ # --check to preview
63
+ ```
64
+
65
+ `format`/`upgrade`/`check` share rule selection — `--ruleset NAME`
66
+ (repeatable / comma-separated — the union of the named sets),
67
+ `--select CODE…`, `--ignore CODE…` (ruff-style precedence: `--ignore` ▸
68
+ `--select` ▸ `--ruleset`; `--select` replaces the rulesets' set; `upgrade` takes no
69
+ `--ruleset`). `format`/`upgrade` also honour `--check` (detect drift, exit
70
+ non-zero, don't write — distinct from the `check` *command*), `--diff`, and
71
+ `--quiet`; `check` honours `--quiet` and `--strict`. The typical modernization
72
+ flow is `upgrade` then `format`.
73
+
74
+ ## Why a separate tier
75
+
76
+ Profile upgrade is semantic, fallible, and reports outcomes; canonicalisation +
77
+ formatting is safe and idempotent. Keeping them in separate, explicit commands
78
+ (rather than auto-upgrading inside "format my tool") lets users opt into
79
+ modernization deliberately. Rule orchestration sits *below* the CLI in the
80
+ registry facade — both because output is written via fmt's serializer (so the
81
+ orchestrator must sit above fmt) and so the MCP server reuses the same
82
+ core. See `docs/decisions.md` §D1 (the app tier), §D2 (`check`), §D3 (advisory
83
+ findings), §D4 (the registry facade + rule selection).
84
+
85
+ ## Install / test
86
+
87
+ ```bash
88
+ uv sync # from the workspace root
89
+ uv run --package galaxy-tool-refactor-cli pytest galaxy-tool-refactor-cli/tests/
90
+ ```
@@ -0,0 +1,77 @@
1
+ # galaxy-tool-refactor-cli
2
+
3
+ The **app tier** of the Galaxy tool refactoring framework — the user-facing
4
+ `galaxy-tool-refactor` CLI, a thin front-end over the tier-3.6 rule-registry
5
+ facade (`galaxy-tool-refactor-registry`).
6
+
7
+ | Tier | Layer | Package |
8
+ |---|---|---|
9
+ | 0.5 | rule metadata | `galaxy-tool-refactor-rules` |
10
+ | 1 | parsing & validation | `galaxy-tool-source` |
11
+ | 2 | structure | `galaxy-tool-codemod` |
12
+ | 3 | formatting | `galaxy-tool-fmt` |
13
+ | 3.5 | advisory checks | `galaxy-tool-lint` |
14
+ | 3.6 | rule registry / rulesets | `galaxy-tool-refactor-registry` |
15
+ | 4 | **app / CLI** | `galaxy-tool-refactor-cli` *(this package)* |
16
+
17
+ Rule orchestration lives in the registry facade; this package depends on it
18
+ (plus fmt's `cli_support` engine and tier-1 parsing) and exposes ten commands
19
+ (`format`, `upgrade`, `check`, `find-references`, `rename-param`, `rulesets`, `rules`,
20
+ `normalize-macros`):
21
+
22
+ ```bash
23
+ # Safe, idempotent: apply a ruleset's fixable rules + cosmetic formatting.
24
+ # Default ruleset = structural canonicalisation + cosmetic; never profile=.
25
+ galaxy-tool-refactor format tool.xml
26
+ galaxy-tool-refactor format --ruleset cosmetic tool.xml # whitespace only
27
+ galaxy-tool-refactor format --ignore GTR002 tool.xml # all but param-reorder
28
+ galaxy-tool-refactor format tools/ # also formats <macros> files
29
+
30
+ # Opt-in, semantic: repair typos, then upgrade profile= to the latest reachable
31
+ # version (applying each step's structural migration), then format. Reports the
32
+ # steps applied and warns if a tool stalls. No --ruleset; --select/--ignore tune it.
33
+ galaxy-tool-refactor upgrade tool.xml
34
+
35
+ # Report-only linter: one `file:line CODE message` per finding, mutating
36
+ # nothing. The default ruleset reports the fixable GTR rules; `--ruleset strict` adds
37
+ # the advisory checks (marked `(advisory)`). Exits non-zero on any fixable
38
+ # finding; advisory findings are informational unless --strict.
39
+ galaxy-tool-refactor check tool.xml
40
+ galaxy-tool-refactor check --ruleset strict tool.xml
41
+
42
+ # Introspection.
43
+ galaxy-tool-refactor rulesets
44
+ galaxy-tool-refactor rules
45
+
46
+ # Opt-in, repo-scoped: lowercase literal format/ftype in <macros>-root files (the
47
+ # macro-library fix the per-tool `upgrade` can't reach). Rewrites files other than
48
+ # the one named, so it is a separate command — never part of format/upgrade.
49
+ galaxy-tool-refactor normalize-macros macros/ # --check to preview
50
+ ```
51
+
52
+ `format`/`upgrade`/`check` share rule selection — `--ruleset NAME`
53
+ (repeatable / comma-separated — the union of the named sets),
54
+ `--select CODE…`, `--ignore CODE…` (ruff-style precedence: `--ignore` ▸
55
+ `--select` ▸ `--ruleset`; `--select` replaces the rulesets' set; `upgrade` takes no
56
+ `--ruleset`). `format`/`upgrade` also honour `--check` (detect drift, exit
57
+ non-zero, don't write — distinct from the `check` *command*), `--diff`, and
58
+ `--quiet`; `check` honours `--quiet` and `--strict`. The typical modernization
59
+ flow is `upgrade` then `format`.
60
+
61
+ ## Why a separate tier
62
+
63
+ Profile upgrade is semantic, fallible, and reports outcomes; canonicalisation +
64
+ formatting is safe and idempotent. Keeping them in separate, explicit commands
65
+ (rather than auto-upgrading inside "format my tool") lets users opt into
66
+ modernization deliberately. Rule orchestration sits *below* the CLI in the
67
+ registry facade — both because output is written via fmt's serializer (so the
68
+ orchestrator must sit above fmt) and so the MCP server reuses the same
69
+ core. See `docs/decisions.md` §D1 (the app tier), §D2 (`check`), §D3 (advisory
70
+ findings), §D4 (the registry facade + rule selection).
71
+
72
+ ## Install / test
73
+
74
+ ```bash
75
+ uv sync # from the workspace root
76
+ uv run --package galaxy-tool-refactor-cli pytest galaxy-tool-refactor-cli/tests/
77
+ ```