@camunda/linting-autofix

中文文档
0.3.0发布于 2026/10/21MITTypeScriptESM + CJS近 30 天下载 1.3万

Autofix and autofill affordances for Camunda linting, shared by Camunda Desktop and Web Modeler

原始使用文档
文档目录8 节
  1. Usage
  2. Peer dependencies
  3. Affordances
  4. The seeded fromAi() type is a guess, not a fact
  5. Eligibility
  6. Build and Run
  7. Local development against a host modeler
  8. License

@camunda/linting-autofix

Autofix and autofill affordances for linting, shared by Camunda Desktop and Web Modeler.

The module decorates the properties panel of elements inside an agentic ad-hoc sub-process with one-click affordances that wire up both sides of an AI Agent tool contract: the fromAi() inputs the agent supplies, and the toolCallResult output it reads back. One rule governs every affordance: seed a blank field, never overwrite a value.

Both modelers register the same module, so the two stay in lockstep by construction rather than by builders remembering to change both.

Usage

Register the module:

import { agentConfigAutofillModule } from '@camunda/linting-autofix';

const modeler = new BpmnModeler({
  additionalModules: [
    agentConfigAutofillModule
  ]
});

The module is editor-only (it mutates the model) and needs the properties panel to be registered too. Host integration is a single line.

Breaking change: @camunda/linting-autofix/assets/linting-autofix.css no longer exists — drop any import '@camunda/linting-autofix/assets/linting-autofix.css'; line. The module now publishes plain diagnostics through the properties panel's own propertiesPanel.setDiagnostics API, which renders and styles everything (text colors, action buttons, group dots, list badges) natively; there is no styling of this package's own left to ship.

Peer dependencies

bpmn-js, diagram-js, bpmn-js-properties-panel and @bpmn-io/properties-panel (>= 3.57.1) are peer dependencies, so the module always works with the host's own instances and stays in sync with however the panel styles a diagnostic.

bpmn-js-element-templates (>= 2.38.0) and @camunda/linting (>= 4.1.0) are optional peers. The module adds its actions to the diagnostics linting publishes through propertiesPanel.setDiagnostics. Where linting has flagged a field, the action rides that diagnostic; everywhere else it is a bare action with its explanation in the tooltip.

Affordances

  1. Input autofill (fromAi()), on the tool flow's entry element only — blank io-mapping inputs and blank FEEL-capable element-template fields bound to zeebe:input get an Input from agent action, seeding =fromAi(toolCall.<key>, "<description>", "<type>"). No offer when the derived key collides with a fromAi() key already declared on the element.

  2. Result autofill (toolCallResult), an Output to agent action on any tool-flow element that does not already produce a contract-readable result upstream on its own execution path, writing into the element's native result field — a templated connector's result expression, a FEEL script task's result variable, a multi-instance output collection, or an output parameter's process variable name on a plain task.

    On an output mapping row this action sits on the process variable name and writes that and nothing else, so the row's variable assignment value never affects it.

    Withdrawn where clicking could not help: on an output row already targeting toolCallResult, the click would write the value already there; on a row targeting a sub-path such as toolCallResult.statusCode, it would collapse a deliberate partial contribution back to the root.

  3. Autofix actions, offered on populated fields: malformed fromAi() keys (wrong prefix, bracket notation, quoted, over-long path, wrong casing, missing entirely) and near-miss result-channel names are detected by re-parsing the element's own fields. A well-formed fromAi() call sitting on a non-entry element is offered as Move to "<entry element>", which declares it on the actual entry element and rewrites only the fromAi(...) span, leaving the rest of that field's expression intact.

    Every action is part of the field's own diagnostic: a correction rides the validation message it resolves, and an offer on a field that nothing flags is a bare action with its explanation in the tooltip. Its visible label describes the builder's goal independently of whether the implementation classifies the mutation as a fix or autofill:

    What the field holdsWhat accepting gives youLabel
    A description or type you wroteYour text kept exactly; only the key is corrected, and anything you left out is filled inFix
    Nothing but a broken key (fromAi(), fromAi(42))A complete call: key, description, typeInput from agent
    A call that will not parse at allA reset to a working default; what you wrote is replaced, and the adjacent validation text and accessible tooltip say soInput from agent

    Three rules govern this, stated canonically in agent-tool-corrections.ts: keep every decision you made that is still readable; reset only when nothing can be salvaged; and say which of the two just happened, because the button previews nothing. A type is written from a template's declared property but never from a keyword guess into a call you already had.

Fixes are span-scoped, never whole-field replacement, so an expression like =concat("prefix-", fromAi(), "-suffix") is never discarded. Every applied fix, including a multi-element move, is a single undo unit.

The seeded fromAi() type is a guess, not a fact

Every seeded call carries a type argument computed by inferFromAiType in from-ai-autofill.ts. Only propertyType === 'Boolean' on an element-template field is a confident fact; everything else is a keyword heuristic over the field's own description/label text, defaulting to 'string'.

If you hit a runtime type mismatch on a tool call, check this before assuming the connector or the model is at fault: the third argument of a seeded call is exactly what inferFromAiType returned, never hand-authored. The fix is a one-word edit to the seeded "<type>" argument in the field itself, not a change to that function.

Eligibility

An ad-hoc sub-process counts as agentic once it carries the io.camunda.agenticai.toolContainer zeebe:Properties boolean, or the io.camunda.connectors.agenticai.aiagent.jobworker.v1 element template id — matching isAgenticAdHocSubProcess in bpmnlint-plugin-camunda-compat. A bare zeebe:AdHoc extension is deliberately not treated as a fallback: plain ad-hoc sub-processes using output collection carry it too.

The shared predicates (isAgenticAdHocSubProcess, isToolFlowElement, isToolEntryElement) are exported so every host surface agrees on where the affordances belong.

Build and Run

# install/setup
npm install

## spin up visual playground
npm start

# lint + build + test, the same as CI
npm run all

Local development against a host modeler

Build the library and link it into the host:

npm run build && npm link
cd ../camunda-modeler/client && npm link @camunda/linting-autofix

Re-run npm run build after each change; the host picks up dist/ directly.

License

MIT

版本与发布记录

@camunda/linting-autofix 共发布 4 个版本,首次发布于 2026/08/19;过去 12 个月发布了 4 个版本。

版本发布日期距今
0.3.0latest2026/10/2119 天前
0.2.02026/08/272 个月前
0.1.12026/08/242 个月前
0.1.02026/08/192 个月前

关于 @camunda/linting-autofix 的常见问题

@camunda/linting-autofix 是什么?

Autofix and autofill affordances for Camunda linting, shared by Camunda Desktop and Web Modeler

如何安装 @camunda/linting-autofix?

在项目目录运行 npm install @camunda/linting-autofix,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:bpmn-js(>= 18.0.0)、diagram-js(>= 15.0.0)、bpmn-js-properties-panel(>= 5.63.0)、@bpmn-io/properties-panel(>= 3.57.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@camunda/linting-autofix 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@camunda/linting-autofix 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@camunda/linting-autofix 可以商用吗?

@camunda/linting-autofix 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@camunda/linting-autofix 的下载量有多少?

根据 npm 官方下载统计,@camunda/linting-autofix 在 2026/10/09 – 2026/11/07 这 30 天内被下载 13,283 次,日均约 443 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@camunda/linting-autofix 还在维护吗?

最新版本 0.3.0 发布于 2026/10/21(19 天前);至今共发布 4 个版本,其中过去 12 个月发布了 4 个;首次发布于 2026/08/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。