Skip to content

feat(plugin): add plugin init command and developer kit (F111)#381

Merged
pocky merged 1 commit into
mainfrom
feature/F111-plugin-developer-kit-and-onboarding
Jun 25, 2026
Merged

feat(plugin): add plugin init command and developer kit (F111)#381
pocky merged 1 commit into
mainfrom
feature/F111-plugin-developer-kit-and-onboarding

Conversation

@pocky

@pocky pocky commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Introduce awf plugin init <name> to scaffold a complete, production-ready operation plugin repository from a single CLI command, eliminating the manual copy-and-adapt workflow previously required to create new plugins
  • Distinguish distribution name (awf-plugin-example) from runtime plugin id (example) consistently across the CLI, docs, example plugin, and generated scaffold so authors understand the two-name model before writing any code
  • Fix awf plugin enable to accept distribution names (e.g. awf-plugin-example) by auto-resolving to the runtime manifest id, so the first-run sequence works without requiring users to know the internal name
  • Align the awf-plugin-echo reference example to match the generated operation template exactly so authors can read the example as the canonical scaffold contract

Changes

Plugin Init Command

  • internal/interfaces/cli/plugin_init_cmd.go: New awf plugin init <name> Cobra command with --kind, --output, and --force flags
  • internal/interfaces/cli/plugin_init_options.go: Flag and argument parsing, distribution name validation (awf-plugin- prefix, lowercase ASCII pattern), runtime id derivation, kind validation (operation only, single-kind enforcement), output path normalization
  • internal/interfaces/cli/plugin_init_generate.go: Repository generation pipeline: render templates, pre-flight conflict detection (including symlink traversal rejection), atomic file writes with 0644/0755 permissions, next-steps output
  • internal/interfaces/cli/plugin_init_template.go: Template rendering infrastructure; resolves AWF module version and optional local replace directive for the generated go.mod
  • internal/interfaces/cli/plugin_init_templates.go: Embedded Go text templates for all generated files (main.go, main_test.go, plugin.yaml, Makefile, examples/demo.yaml, README.md, AGENTS.md, .github/workflows/release.yml, go.mod)
  • internal/interfaces/cli/plugin_cmd.go: Register newPluginInitCommand() in the plugin subcommand tree; fix plugin enable to normalize distribution names to runtime ids

Pack Resolver

  • internal/interfaces/cli/pack_resolver.go: Add isExistingWorkflowFile helper; treat paths that resolve to existing files as local workflows even when they contain slashes (enables awf run examples/demo.yaml)
  • internal/interfaces/cli/config.go: Add newWorkflowRepositoryForIdentifier to build a repository scoped to the parent directory of a local file path

Reference Example Plugin

  • examples/plugins/awf-plugin-echo/main.go: Align implementation to the generated operation template contract: sdk.NewErrorResult for unknown operations and missing text, sdk.GetString for both inputs, structured output map including output key
  • examples/plugins/awf-plugin-echo/main_test.go: Rewrite tests to match the generated template test style: source-reading assertions, manifest validation via pluginmgr.NewManifestParser(), Makefile target and content checks, demo workflow YAML parsing
  • examples/plugins/awf-plugin-echo/Makefile: Add test, lint, install-local, uninstall-local, package, checksums targets; use dist/ build output; adopt awf-plugin-<name>_<version>_<os>_<arch>.tar.gz archive naming
  • examples/plugins/awf-plugin-echo/examples/demo.yaml: Add demo workflow calling echo.echo (runtime id, not distribution name)

Tests

  • internal/interfaces/cli/plugin_cmd_test.go: Add acceptance tests for plugin init full file set, --kind validation, --output, --force, invalid names, help output, and plugin enable distribution-name normalization
  • internal/interfaces/cli/plugin_init_generate_test.go: Generation pipeline tests covering missing directory creation, existing directory coexistence, conflict detection ordering, symlink rejection, --force overwrite, file mode enforcement, and next-steps output format
  • internal/interfaces/cli/plugin_init_options_test.go: Unit tests for parsePluginInitOptions, derivePluginRuntimeID, validatePluginInitKind, normalizePluginInitOutput, and all validation error shapes
  • internal/interfaces/cli/plugin_init_template_internal_test.go: Internal template rendering unit tests
  • internal/interfaces/cli/plugin_init_template_test.go: External template rendering tests covering generated file content contracts
  • internal/interfaces/cli/plugin_init_docs_test.go: Generated README.md content contract tests covering first-run sequence, manifest field documentation, SDK API coverage, Makefile target documentation, and future-kind exclusion
  • internal/interfaces/cli/pack_resolver_test.go: Add test for existing file path treated as local workflow despite containing slashes
  • tests/integration/cli/plugin_init_test.go: Integration tests exercising the full plugin initplugin enableplugin list --operations flow
  • tests/integration/cli/plugin_init_release_test.go: Integration tests for release asset naming convention compatibility between generated make package/make checksums output and awf plugin install expectations

Documentation

  • docs/getting-started/first-plugin.md: New end-to-end tutorial: scaffold → test → install → enable → run demo
  • docs/user-guide/commands.md: Add awf plugin init reference section with arguments, flags, description, examples, first-run sequence, and error table; sort plugin subcommands alphabetically; fix release asset naming convention to include <version> component
  • docs/user-guide/plugins.md: Add "Create a Plugin" section with awf plugin init quick start; replace hand-written minimal plugin example with scaffold-first guidance; replace GoReleaser YAML block with generated release workflow instructions; add sdk.OperationSchemaProvider to SDK helpers table; fix awf-plugin-echo.echoecho.echo operation reference
  • docs/README.md: Add "Build Your First Plugin" to getting-started index; update plugins page description
  • README.md: Add awf plugin init to command reference table; sort plugin subcommands alphabetically; mention awf plugin init in Plugin System feature bullet

Infrastructure

  • go.mod: Promote github.com/rivo/uniseg from indirect to direct dependency
  • .specify/implementation/F107/tasks/index.json: Remove completed F107 task index (superseded)
  • .zpm/kb/pr_feature_f111_plugin_developer_kit_and_onboarding/journal.lock, .../journal.wal, .../knowledge.pl: ZPM knowledge base segment for this PR
  • .zpm/mounts.json: Register new PR knowledge base mount

Test plan

  • Run awf plugin init awf-plugin-example --kind operation, confirm all 9 files are created (main.go, main_test.go, plugin.yaml, Makefile, go.mod, README.md, AGENTS.md, examples/demo.yaml, .github/workflows/release.yml), and output shows the exact cdmake testawf run examples/demo.yaml next-step sequence
  • Run awf plugin init example and confirm exit code 1 with required-prefix validation error and no directory created; run awf plugin init awf-plugin-example --kind validator and confirm unsupported-kind error
  • In the scaffolded directory: make build && make install-local && awf plugin enable awf-plugin-example && awf plugin list --operations — confirm example.echo appears; run awf run examples/demo.yaml and confirm it completes with success status
  • Run unit tests: go test ./internal/interfaces/cli/... and confirm all plugin_init_* test files pass
  • Run integration tests: go test -tags integration ./tests/integration/cli/... and confirm plugin_init_test.go and plugin_init_release_test.go pass

Closes #380


Generated with awf commit workflow

- `.specify/implementation/F107/tasks/index.json`: Remove completed F107 task index
- `.zpm/kb/pr_feature_f111_plugin_developer_kit_and_onboarding/journal.lock`: Add ZPM knowledge base journal lock
- `.zpm/kb/pr_feature_f111_plugin_developer_kit_and_onboarding/journal.wal`: Add ZPM knowledge base WAL
- `.zpm/kb/pr_feature_f111_plugin_developer_kit_and_onboarding/knowledge.pl`: Add ZPM Prolog knowledge facts for F111
- `.zpm/mounts.json`: Register F111 knowledge base mount
- `README.md`: Update with plugin init command reference
- `docs/README.md`: Link to new first-plugin guide
- `docs/getting-started/first-plugin.md`: Add step-by-step first plugin tutorial
- `docs/user-guide/commands.md`: Document plugin init command and flags
- `docs/user-guide/plugins.md`: Revise plugin authoring and onboarding guidance
- `examples/plugins/awf-plugin-echo/Makefile`: Update build targets for echo plugin
- `examples/plugins/awf-plugin-echo/examples/demo.yaml`: Add demo workflow for echo plugin
- `examples/plugins/awf-plugin-echo/main.go`: Update echo plugin implementation
- `examples/plugins/awf-plugin-echo/main_test.go`: Revise echo plugin test suite
- `go.mod`: Update module dependencies
- `internal/interfaces/cli/config.go`: Wire plugin init command into CLI
- `internal/interfaces/cli/pack_resolver.go`: Support local plugin path resolution
- `internal/interfaces/cli/pack_resolver_test.go`: Add local path resolver tests
- `internal/interfaces/cli/plugin_cmd.go`: Add init subcommand to plugin command group
- `internal/interfaces/cli/plugin_cmd_test.go`: Expand plugin command test coverage
- `internal/interfaces/cli/plugin_init_cmd.go`: Implement plugin init cobra command
- `internal/interfaces/cli/plugin_init_docs_test.go`: Add docs generation tests for plugin init
- `internal/interfaces/cli/plugin_init_generate.go`: Implement scaffold file generation logic
- `internal/interfaces/cli/plugin_init_generate_test.go`: Add generation unit tests
- `internal/interfaces/cli/plugin_init_options.go`: Define and validate plugin init options
- `internal/interfaces/cli/plugin_init_options_test.go`: Add options validation tests
- `internal/interfaces/cli/plugin_init_template.go`: Implement template rendering engine
- `internal/interfaces/cli/plugin_init_template_internal_test.go`: Add internal template tests
- `internal/interfaces/cli/plugin_init_template_test.go`: Add template rendering tests
- `internal/interfaces/cli/plugin_init_templates.go`: Define Go, Python, and shell plugin templates
- `internal/interfaces/cli/run.go`: Register plugin init in command runner
- `tests/integration/cli/plugin_init_release_test.go`: Add release artifact integration tests
- `tests/integration/cli/plugin_init_test.go`: Add end-to-end plugin init integration tests

Closes #380
@pocky pocky marked this pull request as ready for review June 25, 2026 17:41
@pocky pocky merged commit 9971294 into main Jun 25, 2026
5 checks passed
@pocky pocky deleted the feature/F111-plugin-developer-kit-and-onboarding branch June 25, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

F111: Plugin Developer Kit and Onboarding

1 participant