Problem/Motivation
Today DTK compresses output for everyone the moment the module is enabled, and the only escape is remembering to type --no-ai-compress. That is backwards for both audiences:
- Humans did not ask for this. A developer who runs
drush pmlin a project that happens to have DTK enabled suddenly gets terse CSV instead of the readable ASCII table Drush has always printed. They now have to learn a flag to get their own tool back. The module is invisible until it surprises them. - Agents are the ones who actually benefit, and they are also the ones we can reliably configure. An agent never forgets a flag it was told to pass — that is the whole point of an agent.
We are defaulting the burden onto the party that cannot be configured, and giving the free ride to the party that can.
Proposed resolution
1. Flip the default. Compression is off unless explicitly requested. drush pml with DTK enabled prints exactly what drush pml printed before DTK existed. Enabling the module becomes a no-op for a human at a terminal, which is what "no commands are added for everyday use" should have meant all along.
The opt-in surface, roughly in order of preference:
- An
--ai-compressflag, mirroring today's--no-ai-compress. - An environment variable (e.g.
DTK_COMPRESS=1), so it can be set once for a whole agent session rather than threaded through every command invocation. - Possibly a Drupal config setting for projects that genuinely want it on for all callers. This is the escape hatch for anyone relying on current behaviour.
The environment variable matters more than it looks: agents shell out to drush through wrappers, ddev drush, and their own tool definitions. A flag has to be injected at every call site; an env var is set once.
2. Install agent hooks that opt in. The module ships hooks for the coding agents that support them, and those hooks turn compression on for agent-issued Drush calls — by exporting the env var, or by appending the flag. The user does nothing. The agent gets compact output. The human, in the same project, at the same terminal, gets the native output they have always had.
This is the core of the proposal: the audience that benefits is the audience that gets configured. The flag stops being something a human has to remember and becomes something an agent already carries.
Hook mechanisms differ per agent, and some agents have none. Where there is no hook, degrade to documenting the env var — the agent still benefits if the user exports it, and nothing regresses for anyone else.
3. Keep --no-ai-compress working. Once compression is opt-in, the opt-out flag is redundant, but it should remain as an accepted no-op (or an override that beats the env var) so existing scripts, agent configs, and muscle memory do not break. Removing it buys nothing and breaks callers.
Remaining tasks
- Decide the opt-in surfaces (flag, env var, config setting, or all three) and define precedence between them — flag beats env var beats config seems obvious, but it should be written down.
- Implement the inverted default in
DrushDtkCommands::skip()and the per-commandINITIALIZEhooks. - Decide which agents get a hook in the first pass, and whether the hook ships inside this module or alongside it. A Drupal module writing into an agent's config directory is unusual, and it is worth asking whether that belongs here or in an installer.
- Rule out (deliberately) any "am I being run by an agent" heuristic such as non-TTY stdout. Any such guess, when wrong, silently changes a human's output — the exact failure this issue exists to eliminate.
- Rewrite the README section "Opting out" as "Opting in", and reframe the module from "this changes your Drush" to "this gives agents a compact mode".
- Update
AGENTS.mdto tell agents to opt in, since agents that read it are exactly the ones that should. - Write a change record / migration note for anyone relying on always-on compression. The config setting is what they switch to.
User interface changes
None in the Drupal UI. The command-line experience changes for humans: enabling DTK no longer alters drush output unless compression is opted into. The automatic skip when the user passes --fields or --format stays as-is — an explicit output choice still wins over compression.
API changes
A new --ai-compress flag and a DTK_COMPRESS environment variable. --no-ai-compress is retained as an accepted option so existing callers do not break.
Data model changes
None, unless the optional "compress for all callers" config setting is accepted — in which case a single boolean in module config.
This was auto generated using AI agents
Issue fork dtk-3609463
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
marcus_johansson commentedComment #3
gxleano commentedComment #5
gxleano commentedComment #6
gxleano commentedComment #8
gxleano commented