Commit graph

22 commits

Author SHA1 Message Date
ad1ad4f999
feat: SARIF 2.1.0 and Checkstyle XML reports for check/fix
Some checks are pending
CI / lint (push) Waiting to run
CI / test (ubuntu-latest) (push) Waiting to run
CI / test (windows-latest) (push) Waiting to run
--report FILE on check and fix writes the findings a run already
computed into CI-consumable formats chosen by extension: .sarif
(single run, %SRCROOT%-relative URIs, properties.autoFixable, rule
registry with descriptions) and .xml (Checkstyle, source=jmove.<rule>).
Unknown suffixes fail fast with INVALID_ARGUMENT; stdout and exit codes
are untouched, and clean runs write valid empty documents.

The check handler moved into cli::report (its format siblings); fix
emits the candidate list in dry-run and apply modes. Marketing angle
from the plan: auto-fix for what Checkstyle only reports.
2026-09-15 20:23:20 +02:00
47395069cb
fix: actually apply the warning pluralization fix
The previous commit shipped a no-op: cargo fmt had reflowed the match
into multiline form, so the scripted replacement never matched and the
failing e2e it introduced caught exactly that. Verified with a full
cargo test this time (not a grep-masked pipeline).
2026-09-15 19:51:43 +02:00
98e1f4a3d3
fix: correct pluralization in the non-import reference warning
Live smoke printed 'reference s to moved files' (the plural 's' was
separated from the noun by the format placeholder). The e2e now pins
the exact warning text.
2026-09-15 19:50:54 +02:00
1ddf79b508
feat: warn about non-import references to moved files
The import graph only rewrites import/export-from/require. Files are
also named from markdown links, package.json fields, jest.mock strings
and tsconfig file lists, and a move that dangles those must not pass
silently. mv now scans text formats plus source strings for the moved
paths, module names and old specifier forms (word-boundary matched,
lockfiles/hidden dirs skipped) and reports each occurrence once per
line on stderr and as non_import_refs[] in --json (dry-run included).
References are never edited; exit codes are unchanged.

Also moves normalize_scope into Index (its only consumer) and the
Change/ChangedFile JSON structs into output where they are built, to
stay inside the 250-line-per-file budget.
2026-09-15 19:48:18 +02:00
b1af375763
feat: tsconfig compilerOptions.paths — aliased bare specifiers join the graph and follow moves
- index/tsconfig: JSONC sanitize (comments, trailing commas), baseUrl +
  star/exact path keys, first candidate only, longest-prefix wins; invalid
  or missing tsconfig silently means no aliases
- resolution pass: '.'-prefixed specifiers resolve relatively as before,
  bare ones go through the alias table and join the importer graph
- planner: remap keeps the alias shape while the moved file stays inside
  the mapped tree (morphological, since destinations do not exist yet),
  exact keys keep meaning only while still resolving to the target;
  otherwise the previous relative rewrite applies unchanged
- resolve_base extracted from resolve_module (shared extension/index
  guessing); MODULE_EXTS is the exact inverse for remapping
- e2e: @utils/str.ts -> @utils/text.ts inside alias, -> ./core/text.ts
  when leaving it, @cfg falls back to ./settings; check passes on aliases
2026-09-15 19:17:06 +02:00
f8004e669b
feat(check): java public-class ⇄ file-name mismatch — layout finding with a ready jmove mv repair
- parser::java::class_name: exactly-one-public-top-level-type rule
  (package-info/module-info and 0-or-2-public files skipped)
- check gains name_mismatches[] (JSON, omitted when clean) + human lines;
  exit 2 covers both kinds; fix engine untouched by design — a file rename
  is not a byte edit, and mv keeps the FQN so no imports change
- output split into output/{mod,check} to stay under the 250-line rule
- e2e: reports Bad.java, stays quiet on Good.java, suggested rename makes
  check pass and preserves the file bytes
2026-09-15 19:05:54 +02:00
c0b06efe57
fix(test): make dir-plan assertions type-comparable string tuples (missed in previous commit) 2026-09-15 18:35:56 +02:00
4e78a1c2b8
test(dir): compare planned paths via rel_str so Windows backslash display cannot leak into assertions 2026-09-15 18:33:24 +02:00
6f7a2190e6
feat: directory moves — mirrored batch relocation of every indexed file under a dir
- MovePlan gains moves[] (file move = 1 relocation), left_behind[] for
  unindexable files that deliberately stay, prune_dirs[] applied after the
  batch (remove_dir only succeeds when empty, leftovers keep their home)
- plan::dir: nesting/target-exists guards, merged per-file rewrites
- apply: atomic N-rename batch (per-file git mv), rollback restores every
  move, rewrite and created dir newest-first
- mv_reject accepts dirs; --json adds moved_files/would_move_files only for
  real dir moves (single-file contract byte-identical); summary shows
  (N files) and left-behind count
- engine rollback/prune tests moved to tests/apply.rs (public API; a
  mid-batch failure cannot be forced through the CLI), java-rule e2e split
  into its own binary to keep every file under the 250-line budget
2026-09-15 18:30:33 +02:00
b96deeaf2f
docs: guava real-world re-run green — mv+git-mv+fix+compile SUCCESS with --source-root 2026-09-15 18:02:45 +02:00
7c8498bc2a
feat(ts): ts/unused-import rule — whole-statement delete of dead TS/JS imports
- binds names via tree-sitter (default, namespace, named + alias, type-only),
  keeps a statement when ANY bound name occurs outside it (word scan over
  comments/strings included): under-delete is the safe direction, mirroring
  the Java rule's asymmetry
- ESM caveat encoded in the policy: mixed live/dead statements are not
  touched — removing a specifier would still drop the module's side effects
- side-effect imports and 'export .. from' re-exports are never candidates
- parser/ts became a folder (mod/extract/unused_imports) to keep the
  4-entries-per-module rule; word_occurs shared via crate::parser
- java/rules/unused_imports now reuses the shared word scanner (DRY)
2026-09-15 17:07:46 +02:00
d5d34afb00
feat: global --source-root — index/mv/check/fix one subtree; deterministic Java FQN resolution in monorepos with duplicate packages (guava vs android/guava); move mv_reject to output.rs 2026-09-15 16:48:57 +02:00
7f568fd0c9
ci: set core.autocrlf=false before checkout; windows images ship autocrlf=true in system gitconfig, which rewrote LF fixtures to CRLF and broke byte-span assertions 2026-09-15 16:18:23 +02:00
4f91cf4387
test: force-track the node_modules fixture file the fixture .gitignore hid from git; run all test binaries with --no-fail-fast 2026-09-15 16:14:42 +02:00
8a9a384365
chore: crates.io publish metadata + CI matrix (fmt/clippy on linux, cargo test on linux+windows) 2026-09-15 16:10:17 +02:00
81d442b5b1
docs: fix rules, git-aware mv, install-as-library; agent workflow for mv+fix+check loop 2026-09-15 16:10:17 +02:00
9dda5f4562
feat: fix engine (Phase 1.6) + git-aware mv + windows-safe path output
- Edit engine: generic span edits (replace/insert/delete) with stale-index
  guard; mv and fix share one atomic apply/rollback/diff/--json pipeline
- jmove mv|check|fix commands; java rules: unused-import, missing-import
  (unique-FQN insert, ambiguous -> candidates for agents), import-order
  (google style; cross-rule byte conflicts prune by severity and converge)
- mv of tracked files goes through git mv (staged rename, --no-git opt-out,
  moved_via/would_move_via in --json, GIT_ERROR code)
- fix java extract_package losing single-segment packages (bare identifier,
  not scoped_identifier) — broke the FQN index for 'package p;' projects
- core::rel_str: project-relative paths rendered with '/' on every platform
  (human/JSON/diff headers/git pathspecs), Path::display() no longer used
  for output; e2e fixtures: java/fix, java/fix_missing, java/order
2026-09-15 16:10:04 +02:00
0216fd6523
docs: Phase 1.6 fix-engine plan + guava real-world Java smoke test results 2026-09-13 17:55:55 +02:00
603f916ee9
feat(java): Phase 1.5 — tree-sitter Java frontend, package-aware mv, e2e fixtures 2026-09-13 17:29:07 +02:00
55670030c3
feat: MVP — move files, rewrite imports, atomically
- core: gitignore-aware index (ignore crate), forward/reverse import graph,
  relative-specifier math, pure-data move plans
- apply: rewrite-first + rename-last with fsync, temp+rename, full rollback
  (incl. stale-plan detection before any write); unified diff for dry-run
- cli: mv + check commands, human output, --json envelope with stable error
  codes (SOURCE_NOT_FOUND, TARGET_EXISTS, ...) and hints; exit codes 0/1/2
- parser/core split into submodules to keep files <=250 lines
- tests: 37 unit + 10 e2e + 2 doctests; fixtures tests/typescript/{basic,normal,complex}
- docs: SKILL.md synced (no --force in Phase 1), EXAMPLES.md
- plan: AI/agent support done; Phase 1.5 = Java niche
2026-09-10 11:41:03 +02:00
9d8f1e0bba
feat(parser): tree-sitter TS/JS import extraction + module specifier resolver
- 6 import forms: static/type/side-effect export-from, require, dynamic import()
- specifier-only rewrites: byte spans exclude quotes, statements never reformatted
- resolver: exact path > extension guessing (.ts/.tsx/.js/.jsx/.mjs/.cjs) > .d.ts > index.*
- 22 unit tests (11 parser + 11 resolver)
2026-09-09 22:02:09 +02:00
a33ed2eb30
chore: project skeleton — module contracts, docs plan, GPLv3 2026-09-09 21:43:42 +02:00