feat(kyberforge): add prompt-author skill for .apm/prompts files

Add prompt-author, shaped like instructions-author: dispatch to create or
improve, a scaffold script that also creates .apm/prompts/, a minimal
template, and references on schema, per-target field survival, content and
verification. Verification is a throwaway apm install because apm compile
never reads prompts.

Forge gains a Prompt file row and a prompt-file-or-hand-invoked-skill
discriminator, and apm-workflow points at prompt-author from compile.md.
Bump kyberforge to 2.2.0 and the root pin, version and marketplace.

Refs #149

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012CqgnwEGtmfsjcoG9QwByN
This commit is contained in:
Defame1297andClaude Sonnet 5.5 committed 2026-10-15 16:04:33 +00:00
1 parent 59e0f3a3b8
commit 6a3fd48fbd
24 files changed
+719 -19

No files matched your search

@@ -0,0 +1,13 @@
# tests/
- **`new-prompt.bats`** — covers `scripts/new-prompt.sh`: name validation, package walk-up, no-package refusal, creating `.apm/prompts/`, no-op on an existing file and template placeholders. It does not assert apm's behaviour; the skill's gotchas are checked by hand with `references/verify.md`.
## Dependencies
The test file loads `bats-support` and `bats-assert` from the repo root's `tests/test_helper/`, and runs on the repo's bats submodule at `tests/bats/`. The first `bash tests/run-bats.sh` initialises the submodules.
From the repo root:
```bash
tests/bats/bin/bats plugins/kyberforge/.apm/skills/prompt-author/tests/new-prompt.bats
```
@@ -0,0 +1,175 @@
#!/usr/bin/env bats
setup() {
REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../../../../../../" && pwd)"
load "$REPO_ROOT/tests/test_helper/bats-support/load"
load "$REPO_ROOT/tests/test_helper/bats-assert/load"
SCRIPT="$(cd "$BATS_TEST_DIRNAME/../scripts" && pwd)/new-prompt.sh"
ROOT="$(mktemp -d)"
}
teardown() {
rm -rf "$ROOT"
}
make_package() {
printf 'name: my-package\nversion: 0.1.0\ntype: prompts\ntargets:\n - claude\n' > "$ROOT/apm.yml"
}
# ---------------------------------------------------------------------------
# Help and arguments
# ---------------------------------------------------------------------------
@test "--help exits 0" {
run bash "$SCRIPT" --help
assert_success
assert_output --partial "Usage:"
}
@test "missing arguments exits 1" {
run bash "$SCRIPT"
assert_failure
assert_output --partial "name and root are required"
}
@test "nonexistent root exits 1" {
run bash "$SCRIPT" my-prompt "$ROOT/missing"
assert_failure
assert_output --partial "does not exist"
}
@test "rejects names that are not kebab-case" {
make_package
for bad in My-Rule my_rule -leading trailing- double--hyphen; do
run bash "$SCRIPT" "$bad" "$ROOT"
assert_failure
assert_output --partial "lowercase letters"
done
assert [ ! -d "$ROOT/.apm" ]
}
@test "rejects a name containing a newline" {
make_package
run bash "$SCRIPT" $'my-prompt\nextra' "$ROOT"
assert_failure
assert_output --partial "lowercase letters"
assert [ ! -d "$ROOT/.apm" ]
}
# ---------------------------------------------------------------------------
# Package resolution
# ---------------------------------------------------------------------------
@test "creates <name>.prompt.md under .apm/prompts/, which apm init does not create" {
make_package
run bash "$SCRIPT" my-prompt "$ROOT"
assert_success
assert [ -f "$ROOT/.apm/prompts/my-prompt.prompt.md" ]
}
@test "walks up from a subdirectory to the package root" {
make_package
mkdir -p "$ROOT/deep/er"
run bash "$SCRIPT" my-prompt "$ROOT/deep/er"
assert_success
assert [ -f "$ROOT/.apm/prompts/my-prompt.prompt.md" ]
assert [ ! -d "$ROOT/deep/er/.apm" ]
}
@test "skips a type-less apm.yml and keeps walking up" {
make_package
mkdir -p "$ROOT/marketplace"
printf 'name: catalog\nmarketplace:\n packages: []\n' > "$ROOT/marketplace/apm.yml"
run bash "$SCRIPT" my-prompt "$ROOT/marketplace"
assert_success
assert [ -f "$ROOT/.apm/prompts/my-prompt.prompt.md" ]
assert [ ! -d "$ROOT/marketplace/.apm" ]
}
@test "accepts a quoted type value" {
printf 'name: p\ntype: "hybrid"\n' > "$ROOT/apm.yml"
run bash "$SCRIPT" my-prompt "$ROOT"
assert_success
assert [ -f "$ROOT/.apm/prompts/my-prompt.prompt.md" ]
}
@test "no package: exits 1, points at apm-workflow configure, writes nothing" {
mkdir -p "$ROOT/.git"
run bash "$SCRIPT" my-prompt "$ROOT"
assert_failure
assert_output --partial "apm-workflow configure"
assert [ ! -d "$ROOT/.apm" ]
}
@test "does not walk above a .git boundary" {
make_package
mkdir -p "$ROOT/repo/.git"
run bash "$SCRIPT" my-prompt "$ROOT/repo"
assert_failure
assert [ ! -d "$ROOT/.apm" ]
}
@test "a mismatched-quote type value is not a package marker" {
mkdir -p "$ROOT/.git"
printf 'name: p\ntype: "hybrid'"'"'\n' > "$ROOT/apm.yml"
run bash "$SCRIPT" my-prompt "$ROOT"
assert_failure
assert [ ! -d "$ROOT/.apm" ]
}
@test "a type value that only starts with a package type is not a package marker" {
mkdir -p "$ROOT/.git"
printf 'name: p\ntype: prompts-only\n' > "$ROOT/apm.yml"
run bash "$SCRIPT" my-prompt "$ROOT"
assert_failure
assert [ ! -d "$ROOT/.apm" ]
}
@test "expands a leading ~ in the root to HOME" {
make_package
run env HOME="$ROOT" bash "$SCRIPT" my-prompt '~'
assert_success
assert [ -f "$ROOT/.apm/prompts/my-prompt.prompt.md" ]
}
@test "no-op when the file already exists" {
make_package
mkdir -p "$ROOT/.apm/prompts"
echo "existing" > "$ROOT/.apm/prompts/my-prompt.prompt.md"
run bash "$SCRIPT" my-prompt "$ROOT"
assert_success
run cat "$ROOT/.apm/prompts/my-prompt.prompt.md"
assert_output "existing"
}
# ---------------------------------------------------------------------------
# Template contents
# ---------------------------------------------------------------------------
@test "scaffold carries FILL IN placeholders and one input name" {
make_package
bash "$SCRIPT" my-prompt "$ROOT"
file="$ROOT/.apm/prompts/my-prompt.prompt.md"
run grep -c 'FILL IN' "$file"
assert_success
run grep -E '^input:' "$file"
assert_success
run grep -F '${input:target}' "$file"
assert_success
}
@test "scaffold has no source_keys and no Copilot App workflow keys" {
make_package
bash "$SCRIPT" my-prompt "$ROOT"
file="$ROOT/.apm/prompts/my-prompt.prompt.md"
run grep -E '^(source_keys|interval|schedule_hour|schedule_day):' "$file"
assert_failure
}
@test "scaffold frontmatter is closed" {
make_package
bash "$SCRIPT" my-prompt "$ROOT"
run grep -c '^---$' "$ROOT/.apm/prompts/my-prompt.prompt.md"
assert_output "2"
}