Add development-scripts agent skill
Ports generic-scripts-module-v1 into a routed skill: module anatomy, shared loggers/base modules, Taskfile integration, workflows, and pattern decisions. Fixes a latent defect in the loggers example that silenced all logging in the module scaffold: loggers/lib/--index-api.sh now sources --env-vars-reader.sh, and the reader preserves already-exported values so caller overrides still win. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
# `module-example-v1` Generic Scaffold
|
||||
|
||||
This is a generic reference scaffold for a new Cognitive Architect script module.
|
||||
|
||||
To adapt it:
|
||||
|
||||
1. Copy `module-example-v1/` into `.scripts/<new-module>/`.
|
||||
2. Replace paths containing `module-example-v1`.
|
||||
3. Replace environment prefix `MODULE_EXAMPLE_V1_`.
|
||||
4. Replace function prefix `_moduleExampleV1_`.
|
||||
5. Add public API wrappers and implementation files as needed.
|
||||
6. Add a root `Taskfile.yml` include only if the module should be task-runner public.
|
||||
7. Run `bash -n` against all generated `.sh` files.
|
||||
@@ -0,0 +1,10 @@
|
||||
# https://taskfile.dev
|
||||
|
||||
version: "3"
|
||||
|
||||
tasks:
|
||||
initialize-one:
|
||||
cmds:
|
||||
- |
|
||||
./.scripts/module-example-v1/api/initialize-one.sh {{.CLI_ARGS}}
|
||||
silent: true
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ./.scripts/module-example-v1/lib/--index.sh
|
||||
|
||||
_moduleExampleV1_initializeOne
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
export MODULE_EXAMPLE_V1_NAME="${MODULE_EXAMPLE_V1_NAME:-default-name}"
|
||||
export MODULE_EXAMPLE_V1_OUTPUT_DIR="${MODULE_EXAMPLE_V1_OUTPUT_DIR:-.tmp/module-example-v1}"
|
||||
export MODULE_EXAMPLE_V1_DRY_RUN="${MODULE_EXAMPLE_V1_DRY_RUN:-false}"
|
||||
|
||||
ALL_ARGS=("$@")
|
||||
while [[ "$#" -gt 0 ]]; do
|
||||
case $1 in
|
||||
--name)
|
||||
export MODULE_EXAMPLE_V1_NAME="$2"
|
||||
shift
|
||||
;;
|
||||
--output-dir)
|
||||
export MODULE_EXAMPLE_V1_OUTPUT_DIR="$2"
|
||||
shift
|
||||
;;
|
||||
--dry-run)
|
||||
export MODULE_EXAMPLE_V1_DRY_RUN="true"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
set -- "${ALL_ARGS[@]}"
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ./.scripts/loggers/lib/--index-api.sh
|
||||
|
||||
if [ -z "${MODULE_EXAMPLE_V1_NAME}" ]; then
|
||||
_loggers_error "module-example-v1" "Missing required --name / MODULE_EXAMPLE_V1_NAME"
|
||||
exit 1
|
||||
fi
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ./.scripts/loggers/lib/--index-api.sh
|
||||
. ./.scripts/base/lib/--index-api.sh
|
||||
|
||||
. ./.scripts/module-example-v1/lib/-initialize-one.sh
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# --> passed parameters are read & exported environment variables
|
||||
#
|
||||
. ./.scripts/module-example-v1/lib/--env-vars-reader.sh
|
||||
#
|
||||
# --> required environment variables are validated for existence
|
||||
#
|
||||
. ./.scripts/module-example-v1/lib/--env-vars-validator.sh
|
||||
#
|
||||
# --> available functions are imported/exported
|
||||
#
|
||||
. ./.scripts/module-example-v1/lib/--index-api.sh
|
||||
# -------------------------------------------------------------------------------------
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ./.scripts/loggers/lib/--index-api.sh
|
||||
|
||||
_moduleExampleV1_initializeOne() {
|
||||
local FUNCTION_NAME="_moduleExampleV1_initializeOne"
|
||||
|
||||
_loggers_info "${FUNCTION_NAME}" "Initializing module-example-v1"
|
||||
_loggers_debug "${FUNCTION_NAME}" "Name: ${MODULE_EXAMPLE_V1_NAME}"
|
||||
_loggers_debug "${FUNCTION_NAME}" "Output directory: ${MODULE_EXAMPLE_V1_OUTPUT_DIR}"
|
||||
|
||||
if [ "${MODULE_EXAMPLE_V1_DRY_RUN}" = "true" ]; then
|
||||
_loggers_info "${FUNCTION_NAME}" "Dry run enabled; no files will be changed."
|
||||
return 0
|
||||
fi
|
||||
|
||||
mkdir -p "${MODULE_EXAMPLE_V1_OUTPUT_DIR}"
|
||||
_loggers_info "${FUNCTION_NAME}" "Initialization complete."
|
||||
}
|
||||
Reference in New Issue
Block a user