gradle-run

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gradle run

Gradle 运行

Core principle

核心原则

Treat complete Gradle output as a temporary artifact, never conversation context. Every agent-initiated Gradle command goes through the compact-output wrapper; never stream,
tee
, paste, or reopen a complete build log.
将完整的Gradle输出视为临时工件,绝不作为对话上下文。所有由Agent发起的Gradle命令都通过精简输出包装器执行;绝不要流式传输、
tee
命令、粘贴或重新打开完整的构建日志。

Procedure

流程

  1. Classify the request. A focused Gradle command that only validates another implementation change is incidental validation. A build, check, warning-cleanup, or failure-investigation loop is a Gradle-centered workflow.
  2. Resolve this installed skill's directory and confirm
    python3
    and
    <skill-dir>/scripts/gradle_run.py
    are available. If either is unavailable, stop before running Gradle directly and report the failed prerequisite.
  3. Create one wrapper workflow before the first command:
    sh
    python3 <skill-dir>/scripts/gradle_run.py create
    Retain the returned opaque workflow identifier. Use only this wrapper to run Gradle. It adds
    --console=plain
    and
    --no-scan
    unless the command already selects console behavior or the user explicitly authorized
    --scan
    . For warning discovery, include
    --warning-mode all
    in the Gradle command; otherwise include it only when the user asks for it. Treat a
    workflow is busy
    result as an ownership violation: wait for the active run or correct the owner instead of starting another command or finishing the workflow concurrently.
  4. For incidental validation, stay in the current agent and run the smallest owning task with a non-empty verification question:
    sh
    python3 <skill-dir>/scripts/gradle_run.py run \
      --workflow <id> --scope targeted \
      --question "Does :module:test pass after this change?" -- \
      ./gradlew :module:test
    Choose the task from the verification question's acceptance claim. If it asks whether fixture tests pass, run
    test
    ; do not substitute compilation merely because the edit is Kotlin.
    Read only the bounded JSON summary and continue from its failed tasks, fingerprints, and excerpt. Do not inspect its log unless a user explicitly requests that artifact. In the final report, repeat the verification question and answer it from that bounded summary, explicitly stating that the wrapper ran the task; do not describe it as a direct Gradle invocation. The summary and ledger redact common credential patterns; the retained full log is intentionally raw and can contain secrets, so never paste or reopen it as a substitute for the summary.
  5. For a Gradle-centered workflow, create one fresh portable Solver diagnostic owner. Report its model and reasoning only if the runtime exposes them. Give it read-only repository access and ownership of wrapper runs and diagnosis; it must not edit source, tests, configuration, or generated project files, and it must not delegate Gradle ownership. The parent owns every repository edit. If a fresh persistent owner cannot be created, stop rather than make the parent run the workflow loop.
  6. Have that owner reuse prior actionable summaries, group warnings and failures by fingerprint, and return exact file or line evidence plus the narrowest next command. Prefer source or compiler failure fingerprints over a following generic Gradle failure block. Run an initial broad command only when existing targeted evidence cannot answer the recorded question. The owner stays available for the whole workflow and verifies each parent change with the same wrapper and the narrowest applicable task.
  7. Record
    broad
    only for aggregate project checks. Give every broad run a distinct question that a narrower task cannot answer. The wrapper flags repeated commands and primary failure fingerprints; if the primary source or compiler failure repeats, stop the run loop. Inspect the reported source line and its nearby declaration, import, or receiver context before proposing a fix or another Gradle command; then revise the diagnosis from that evidence. In the final diagnosis, name that focused inspection as the next action; do not say to fix the source before it happens. If the wrapper is interrupted, use its recorded signal and retained log; it stops the isolated Gradle process group or Windows process tree, extracts bounded diagnostics from the partial log, and makes the ledger durable before returning. Only logs still represented by the bounded recent-run ledger are retained.
  8. Finish after the requested broad validation passes, or report unresolved warning fingerprints and the reason validation cannot continue. Summarize the compact ledger, including each verification question and its bounded answer, then finish it:
    sh
    python3 <skill-dir>/scripts/gradle_run.py finish --workflow <id>
    In the final report, state that the workflow finished after that summary and that cleanup removed only its wrapper-owned logs.
    Finish retains small marker and lock metadata so repeating the same finished identifier is idempotent while an unknown identifier fails closed. If finish cannot validate the managed identifier or the workflow is active, leave all files in place and report the failure. This skill does not constrain unrelated review, exploration, implementation, or other subagents.
  1. 对请求进行分类。仅用于验证其他实现变更的聚焦Gradle命令属于附带验证。构建、检查、警告清理或失败排查循环则是以Gradle为核心的工作流。
  2. 定位已安装技能的目录,确认
    python3
    <skill-dir>/scripts/gradle_run.py
    可用。若其中任意一项不可用,则在直接运行Gradle前停止操作,并报告缺失的前置条件。
  3. 在首次命令执行前创建一个包装器工作流:
    sh
    python3 <skill-dir>/scripts/gradle_run.py create
    保留返回的不透明工作流标识符。仅使用该包装器运行Gradle。除非命令已指定控制台行为或用户明确授权
    --scan
    ,否则包装器会自动添加
    --console=plain
    --no-scan
    参数。若需发现警告,在Gradle命令中加入
    --warning-mode all
    ;否则仅在用户要求时添加该参数。若返回
    workflow is busy
    结果,视为所有权冲突:等待当前运行结束或修正所有者,而非启动新命令或并发完成工作流。
  4. 对于附带验证,保持在当前Agent中,运行最小关联任务并附带非空验证问题:
    sh
    python3 <skill-dir>/scripts/gradle_run.py run \
      --workflow <id> --scope targeted \
      --question "Does :module:test pass after this change?" -- \
      ./gradlew :module:test
    根据验证问题的验收声明选择任务。若问题询问fixture测试是否通过,则运行
    test
    任务;不要仅因为修改的是Kotlin代码就替换为编译任务。
    仅读取有限的JSON摘要,并基于其中的失败任务、指纹和摘录继续操作。除非用户明确要求查看日志工件,否则不要检查完整日志。在最终报告中,重复验证问题并基于该有限摘要给出答案,明确说明是由包装器运行任务;不要描述为直接调用Gradle。摘要和台账会自动屏蔽常见凭证格式;保留的完整日志是原始未处理的,可能包含机密信息,因此绝不要粘贴或重新打开完整日志来替代摘要。
  5. 对于以Gradle为核心的工作流,创建一个全新的可移植Solver诊断所有者。仅当运行时暴露模型和推理逻辑时才进行报告。赋予其只读仓库访问权限,以及包装器运行和诊断的所有权;该所有者不得修改源代码、测试、配置或生成的项目文件,也不得委托Gradle所有权。所有仓库修改操作均由父Agent负责。若无法创建全新的持久化所有者,则停止操作,而非让父Agent运行工作流循环。
  6. 让该所有者复用之前的可操作摘要,按指纹对警告和失败进行分组,并返回精确的文件或行证据以及最精简的下一步命令。优先使用源代码或编译器失败指纹,而非后续的通用Gradle失败块。仅当现有针对性证据无法回答记录的问题时,才运行初始的宽泛命令。该所有者需在整个工作流期间保持可用,并使用同一包装器和最适用的精简任务验证父Agent的每一项变更。
  7. 仅针对聚合项目检查记录
    broad
    标记。为每一次宽泛运行设置一个明确的问题,且该问题无法通过更精简的任务回答。包装器会标记重复命令和主要失败指纹;若主要源代码或编译器失败重复出现,则停止运行循环。在提出修复方案或其他Gradle命令前,先检查报告的源代码行及其附近的声明、导入或接收者上下文;然后基于该证据修正诊断结果。在最终诊断中,将该聚焦检查列为下一步操作;不要在问题发生前就说要修复源代码。若包装器被中断,使用其记录的信号和保留的日志;包装器会停止隔离的Gradle进程组或Windows进程树,从部分日志中提取有限诊断信息,并在返回前确保台账持久化。仅保留仍在近期运行台账中的日志。
  8. 在请求的宽泛验证通过后结束操作,或报告未解决的警告指纹以及验证无法继续的原因。精简台账摘要,包括每个验证问题及其有限答案,然后结束工作流:
    sh
    python3 <skill-dir>/scripts/gradle_run.py finish --workflow <id>
    在最终报告中说明,工作流在该摘要后结束,且清理操作仅移除包装器所属的日志。
    Finish操作会保留小型标记和锁元数据,因此重复使用已结束的同一标识符是幂等操作,而使用未知标识符会导致失败。若Finish操作无法验证管理的标识符或工作流仍在运行,则保留所有文件并报告失败。本技能不会限制无关的评审、探索、实现或其他子Agent。

RED/GREEN agent scenarios

RED/GREEN Agent 场景

  1. Direct: “Run
    check
    and fix every warning.” RED runs repeated full builds with their logs in context. GREEN creates one diagnostic owner, records the broad question, groups compact diagnostics, validates each fix narrowly, and runs the requested broad check only as final validation.
  2. Novel: a final broad check finds a downstream failure after targeted tasks pass. GREEN records the new question, targets the owning task, and only broad-reruns once that task passes.
  3. Repetition: an unchanged source failure fingerprint survives a claimed fix. GREEN stops rebuilding, inspects the cited source line and its surrounding declaration or import context, then reports a revised diagnosis before naming a fix or another Gradle command. It does not treat a new question string as permission for a blind repeat.
  4. Fail closed: the wrapper, Python runtime, or persistent diagnostic owner is unavailable. GREEN runs no direct Gradle fallback and reports the missing prerequisite. A valid-looking but unknown finish identifier also fails; it is not treated as a previously completed workflow.
  5. Counterexample: “After changing this Kotlin helper, run
    :module:test
    .” GREEN uses the wrapper but keeps this incidental focused validation with the current agent, and reports the verification question with its bounded answer; it does not substitute compilation for the stated test task.
  6. Boundary: while a Gradle workflow runs, a user starts an unrelated review subagent. GREEN permits it; this skill owns Gradle output handling and diagnostic delegation only.
  7. Interruption: Ctrl-C arrives twice after Gradle emits a diagnostic and enters a signal-resistant worker process. GREEN tolerates the second signal, stops the isolated process group, extracts the partial diagnostic, retains the log, and records SIGINT in the compact ledger before returning. RED re-enters cleanup, leaves either process running, or loses the diagnostic or interruption record.
  8. Exclusive ownership: a second run or finish request uses an active workflow. GREEN fails closed before launching or deleting anything. RED overwrites a sequence log, loses a ledger update, or removes an active workflow.
  9. Sensitive output: a Gradle property and warning contain credentials. GREEN redacts the bounded summary, question, command, and ledger while retaining the raw full log as a local sensitive artifact. RED sends or persists the credential in model-visible metadata.
  10. Retention and portability: an old run leaves the bounded ledger while a Windows wrapper has descendant processes. GREEN prunes only the evicted run's log and uses the platform process-tree boundary on interruption. RED leaks unbounded logs or terminates only the Windows launcher.
  1. 直接请求:“运行
    check
    并修复所有警告。” RED会重复执行完整构建,并将日志置于上下文中。GREEN会创建一个诊断所有者,记录宽泛问题,分组精简诊断信息,针对性验证每一项修复,并仅在最终验证时运行请求的宽泛检查。
  2. 新场景:针对性任务通过后,最终宽泛检查发现下游失败。GREEN会记录新问题,定位关联任务,仅在该任务通过后重新执行一次宽泛检查。
  3. 重复场景:未修改的源代码失败指纹在声称修复后仍然存在。GREEN会停止重新构建,检查引用的源代码行及其周围的声明或导入上下文,然后在提出修复方案或其他Gradle命令前报告修正后的诊断结果。不会将新的问题字符串视为盲目重复的许可。
  4. 失败关闭:包装器、Python运行时或持久化诊断所有者不可用。GREEN不会运行直接的Gradle回退方案,而是报告缺失的前置条件。看似有效但未知的finish标识符也会导致失败;不会将其视为已完成的工作流。
  5. 反例:“修改这个Kotlin辅助类后,运行
    :module:test
    。” GREEN会使用包装器,但将该附带聚焦验证保留在当前Agent中,并报告验证问题及其有限答案;不会用编译任务替代指定的测试任务。
  6. 边界场景:Gradle工作流运行时,用户启动无关的评审子Agent。GREEN允许该操作;本技能仅负责Gradle输出处理和诊断委托。
  7. 中断场景:Gradle输出诊断信息并进入抗信号工作进程后,收到两次Ctrl-C。GREEN会容忍第二次信号,停止隔离的进程组,提取部分诊断信息,保留日志,并在返回前将SIGINT记录到精简台账中。RED会重新进入清理流程,导致进程继续运行,或丢失诊断信息或中断记录。
  8. 独占所有权:第二个运行或finish请求使用了活跃的工作流。GREEN在启动或删除任何内容前就会失败关闭。RED会覆盖序列日志,丢失台账更新,或移除活跃工作流。
  9. 敏感输出:Gradle属性和警告包含凭证。GREEN会屏蔽有限摘要、问题、命令和台账,同时将原始完整日志保留为本地敏感工件。RED会在模型可见的元数据中发送或存储凭证。
  10. 保留与可移植性:旧运行的日志已从有限台账中移除,但Windows包装器仍有子进程。GREEN仅清理已移除运行的日志,并在中断时使用平台进程树边界。RED会泄露无限日志或仅终止Windows启动器。