Skip to content

feat(composer): add compact composer command#1539

Open
lamkimphu258 wants to merge 1 commit intortk-ai:developfrom
lamkimphu258:feat/composer-support
Open

feat(composer): add compact composer command#1539
lamkimphu258 wants to merge 1 commit intortk-ai:developfrom
lamkimphu258:feat/composer-support

Conversation

@lamkimphu258
Copy link
Copy Markdown

Summary

  • Add first-class rtk composer support for common Composer dependency workflows.
  • Compact noisy dependency logs for install, update, require, and dump-autoload, while preserving failures, warnings, requested detail flags, and Composer semantics.
  • Add JSON-backed reports for show, licenses, check-platform-reqs, and fund, plus discovery rewrites for supported Composer commands including global flags like -d / --working-dir.

Details

This branch adds a Composer command wrapper under src/cmds/php/ and wires it into the CLI and rewrite discovery path. The wrapper chooses between three modes:

  • Dependency-log mode for install/update/require/autoload workflows.
  • JSON-report mode for structured Composer reports where RTK can safely request --format=json.
  • Passthrough mode for user-requested output shapes or unsupported commands.

Correctness-oriented cases covered in this branch:

  • Non-zero Composer dependency commands fall back to raw Composer output instead of reporting ok (up to date).
  • composer show vendor/package handles Composer's single-package JSON shape without collecting nested license objects as packages.
  • No-op installs still collapse to ok (up to date) even when Composer prints boilerplate verification/autoload lines.
  • Truncated composer show package lists append an omitted count.
  • Discovery rewrites Composer commands with documented global flags before the subcommand.
  • composer show --tree / -t pass through so tree output is preserved.
  • Autoload class warnings are retained.
  • check-platform-reqs treats missing requirements as failures and includes failed requirement context.

Composer Savings Report

Method: representative Composer outputs from the new tests, using RTK's tracking estimator: ceil(chars / 4).

Scenario Raw composer tokens rtk composer tokens Saved Savings
install no-op 73 4 69 94.5%
require package 190 65 125 65.8%
show JSON report 73 20 53 72.6%
check-platform-reqs 56 26 30 53.6%
Total sample 392 115 277 70.7%

Examples of filtered output:

# composer install with nothing to do
ok (up to date)
# composer require monolog/monolog
L=lock I=install U=upgrade D=downgrade R=remove
composer.json has been updated
Lock file operations: 2 installs, 0 updates, 0 removals
Package operations: 2 installs, 0 updates, 0 removals
I psr/log (3.0.2)
I monolog/monolog (3.8.1)
Generating autoload files
# composer check-platform-reqs
S=success F=failed
S php 8.5.0
F ext-xdebug n/a (missing) (vendor/debug-tools requires ext-xdebug ^3.0)

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • Manual testing: representative rtk composer output inspected through focused formatter/parser tests and savings report fixtures

Notes:

  • cargo clippy --all-targets completes successfully but reports existing warnings outside this Composer change.
  • Checked CONTRIBUTING.md: this PR targets develop, keeps a focused Composer scope, uses a conventional commit, and includes tests.

Important: All PRs must target the develop branch (not master).
See CONTRIBUTING.md for details.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 26, 2026

CLA assistant check
All committers have signed the CLA.

@pszymkowiak pszymkowiak added effort-large Plusieurs jours, nouveau module enhancement New feature or request labels Apr 26, 2026
@pszymkowiak
Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

Type feature
🟡 Risk medium

Summary

Adds a first-class rtk composer command that wraps PHP Composer, compacting verbose dependency logs for install/update/require/dump-autoload workflows, providing JSON-backed reports for show/licenses/check-platform-reqs/fund, and passing through unsupported commands. Includes comprehensive tests and discovery rewrite integration.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Analyzed automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort-large Plusieurs jours, nouveau module enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants