feat(plugin): add plugin init command and developer kit (F111)#381
Merged
Conversation
- `.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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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 pluginsawf-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 codeawf plugin enableto 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 nameawf-plugin-echoreference example to match the generated operation template exactly so authors can read the example as the canonical scaffold contractChanges
Plugin Init Command
internal/interfaces/cli/plugin_init_cmd.go: Newawf plugin init <name>Cobra command with--kind,--output, and--forceflagsinternal/interfaces/cli/plugin_init_options.go: Flag and argument parsing, distribution name validation (awf-plugin-prefix, lowercase ASCII pattern), runtime id derivation, kind validation (operationonly, single-kind enforcement), output path normalizationinternal/interfaces/cli/plugin_init_generate.go: Repository generation pipeline: render templates, pre-flight conflict detection (including symlink traversal rejection), atomic file writes with0644/0755permissions, next-steps outputinternal/interfaces/cli/plugin_init_template.go: Template rendering infrastructure; resolves AWF module version and optional local replace directive for the generatedgo.modinternal/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: RegisternewPluginInitCommand()in the plugin subcommand tree; fixplugin enableto normalize distribution names to runtime idsPack Resolver
internal/interfaces/cli/pack_resolver.go: AddisExistingWorkflowFilehelper; treat paths that resolve to existing files as local workflows even when they contain slashes (enablesawf run examples/demo.yaml)internal/interfaces/cli/config.go: AddnewWorkflowRepositoryForIdentifierto build a repository scoped to the parent directory of a local file pathReference Example Plugin
examples/plugins/awf-plugin-echo/main.go: Align implementation to the generated operation template contract:sdk.NewErrorResultfor unknown operations and missing text,sdk.GetStringfor both inputs, structured output map includingoutputkeyexamples/plugins/awf-plugin-echo/main_test.go: Rewrite tests to match the generated template test style: source-reading assertions, manifest validation viapluginmgr.NewManifestParser(), Makefile target and content checks, demo workflow YAML parsingexamples/plugins/awf-plugin-echo/Makefile: Addtest,lint,install-local,uninstall-local,package,checksumstargets; usedist/build output; adoptawf-plugin-<name>_<version>_<os>_<arch>.tar.gzarchive namingexamples/plugins/awf-plugin-echo/examples/demo.yaml: Add demo workflow callingecho.echo(runtime id, not distribution name)Tests
internal/interfaces/cli/plugin_cmd_test.go: Add acceptance tests forplugin initfull file set,--kindvalidation,--output,--force, invalid names, help output, andplugin enabledistribution-name normalizationinternal/interfaces/cli/plugin_init_generate_test.go: Generation pipeline tests covering missing directory creation, existing directory coexistence, conflict detection ordering, symlink rejection,--forceoverwrite, file mode enforcement, and next-steps output formatinternal/interfaces/cli/plugin_init_options_test.go: Unit tests forparsePluginInitOptions,derivePluginRuntimeID,validatePluginInitKind,normalizePluginInitOutput, and all validation error shapesinternal/interfaces/cli/plugin_init_template_internal_test.go: Internal template rendering unit testsinternal/interfaces/cli/plugin_init_template_test.go: External template rendering tests covering generated file content contractsinternal/interfaces/cli/plugin_init_docs_test.go: GeneratedREADME.mdcontent contract tests covering first-run sequence, manifest field documentation, SDK API coverage, Makefile target documentation, and future-kind exclusioninternal/interfaces/cli/pack_resolver_test.go: Add test for existing file path treated as local workflow despite containing slashestests/integration/cli/plugin_init_test.go: Integration tests exercising the fullplugin init→plugin enable→plugin list --operationsflowtests/integration/cli/plugin_init_release_test.go: Integration tests for release asset naming convention compatibility between generatedmake package/make checksumsoutput andawf plugin installexpectationsDocumentation
docs/getting-started/first-plugin.md: New end-to-end tutorial: scaffold → test → install → enable → run demodocs/user-guide/commands.md: Addawf plugin initreference section with arguments, flags, description, examples, first-run sequence, and error table; sort plugin subcommands alphabetically; fix release asset naming convention to include<version>componentdocs/user-guide/plugins.md: Add "Create a Plugin" section withawf plugin initquick start; replace hand-written minimal plugin example with scaffold-first guidance; replace GoReleaser YAML block with generated release workflow instructions; addsdk.OperationSchemaProviderto SDK helpers table; fixawf-plugin-echo.echo→echo.echooperation referencedocs/README.md: Add "Build Your First Plugin" to getting-started index; update plugins page descriptionREADME.md: Addawf plugin initto command reference table; sort plugin subcommands alphabetically; mentionawf plugin initin Plugin System feature bulletInfrastructure
go.mod: Promotegithub.com/rivo/unisegfrom 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 mountTest plan
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 exactcd→make test→awf run examples/demo.yamlnext-step sequenceawf plugin init exampleand confirm exit code 1 withrequired-prefixvalidation error and no directory created; runawf plugin init awf-plugin-example --kind validatorand confirmunsupported-kinderrormake build && make install-local && awf plugin enable awf-plugin-example && awf plugin list --operations— confirmexample.echoappears; runawf run examples/demo.yamland confirm it completes with success statusgo test ./internal/interfaces/cli/...and confirm allplugin_init_*test files passgo test -tags integration ./tests/integration/cli/...and confirmplugin_init_test.goandplugin_init_release_test.gopassCloses #380
Generated with awf commit workflow