@codebehind/agent-workflow 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +94 -0
  2. package/bin/agent-workflow.mjs +96 -0
  3. package/package.json +28 -0
  4. package/templates/.agent-workflow/README.md +160 -0
  5. package/templates/.agent-workflow/acceptance-verification.md +192 -0
  6. package/templates/.agent-workflow/artifacts/.gitkeep +0 -0
  7. package/templates/.agent-workflow/docs/README.md +45 -0
  8. package/templates/.agent-workflow/docs/_template.md +35 -0
  9. package/templates/.agent-workflow/notion-spec-mapping.md +54 -0
  10. package/templates/.agent-workflow/plans/.gitkeep +0 -0
  11. package/templates/.agent-workflow/plans/README.md +19 -0
  12. package/templates/.agent-workflow/playwright-acceptance.md +169 -0
  13. package/templates/.agent-workflow/specs/README.md +46 -0
  14. package/templates/.agent-workflow/specs/_template.md +60 -0
  15. package/templates/.agent-workflow/specs/assets/.gitkeep +0 -0
  16. package/templates/.agent-workflow/specs/assets/README.md +15 -0
  17. package/templates/.claude/hooks/.gitkeep +0 -0
  18. package/templates/.claude/rules/agentic-workflow.md +138 -0
  19. package/templates/.claude/settings.json +76 -0
  20. package/templates/.claude/skills/acceptance-proof/SKILL.md +68 -0
  21. package/templates/.claude/skills/create-mr-summary/SKILL.md +29 -0
  22. package/templates/.claude/skills/implement-spec/SKILL.md +97 -0
  23. package/templates/.claude/skills/prepare-spec/SKILL.md +77 -0
  24. package/templates/AGENTS.md +43 -0
  25. package/templates/agents-workflow-dev-process.md +212 -0
  26. package/templates/agents-workflow-env-setup.md +136 -0
  27. package/templates/scripts/agent/LOCAL_GITLAB_WORKFLOW.md +83 -0
  28. package/templates/scripts/agent/cleanup-worktree.sh +23 -0
  29. package/templates/scripts/agent/ensure-codebase.sh +43 -0
  30. package/templates/scripts/agent/git-detect-default-branch.sh +32 -0
  31. package/templates/scripts/agent/git-find-open-mr.sh +6 -0
  32. package/templates/scripts/agent/git-open-mr.sh +24 -0
  33. package/templates/scripts/agent/git-prepare-worktree.sh +54 -0
  34. package/templates/scripts/agent/git-push-branch.sh +12 -0
  35. package/templates/scripts/agent/git-update-mr.sh +28 -0
  36. package/templates/scripts/agent/implement-task.sh +19 -0
  37. package/templates/scripts/agent/mr-template.sh +33 -0
  38. package/templates/scripts/agent/post-run-summary.sh +24 -0
  39. package/templates/scripts/agent/prepare-spec.sh +19 -0
  40. package/templates/scripts/agent/start-worktree.sh +36 -0
  41. package/templates/scripts/agent/verify-acceptance.sh +12 -0
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ REPO_ROOT="${1:-.}"
5
+ REPO_ROOT="$(cd "$REPO_ROOT" && pwd)"
6
+ CODEBASE_FILE="$REPO_ROOT/.agent-workflow/codebase.md"
7
+
8
+ if [[ -f "$CODEBASE_FILE" && -s "$CODEBASE_FILE" ]]; then
9
+ echo "$CODEBASE_FILE already exists"
10
+ exit 0
11
+ fi
12
+
13
+ mkdir -p "$(dirname "$CODEBASE_FILE")"
14
+ cat > "$CODEBASE_FILE" <<'EOF'
15
+ # Codebase overview
16
+
17
+ ## Purpose
18
+ Briefly describe what this application does.
19
+
20
+ ## Main areas
21
+ - Backend:
22
+ - Frontend:
23
+ - Persistence:
24
+ - External services:
25
+
26
+ ## Key commands
27
+ - Install:
28
+ - Backend dev:
29
+ - Frontend dev:
30
+ - Tests:
31
+
32
+ ## Important conventions
33
+ - Branching:
34
+ - API patterns:
35
+ - DB / migration patterns:
36
+ - Documentation expectations:
37
+
38
+ ## Notes for future agents
39
+ - Keep this file concise.
40
+ - Update it when architecture or commands materially change.
41
+ EOF
42
+
43
+ echo "$CODEBASE_FILE created"
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ REMOTE="${1:-origin}"
5
+
6
+ if ! git rev-parse --git-dir >/dev/null 2>&1; then
7
+ echo "Not inside a git repository" >&2
8
+ exit 1
9
+ fi
10
+
11
+ if git symbolic-ref -q --short "refs/remotes/${REMOTE}/HEAD" >/dev/null 2>&1; then
12
+ git symbolic-ref -q --short "refs/remotes/${REMOTE}/HEAD" | sed "s#^${REMOTE}/##"
13
+ exit 0
14
+ fi
15
+
16
+ if git remote show "$REMOTE" >/dev/null 2>&1; then
17
+ branch="$(git remote show "$REMOTE" | sed -n '/HEAD branch/s/.*: //p' | head -n1)"
18
+ if [[ -n "$branch" ]]; then
19
+ echo "$branch"
20
+ exit 0
21
+ fi
22
+ fi
23
+
24
+ for candidate in main master test develop; do
25
+ if git show-ref --verify --quiet "refs/remotes/${REMOTE}/${candidate}"; then
26
+ echo "$candidate"
27
+ exit 0
28
+ fi
29
+ done
30
+
31
+ echo "Could not determine default branch for remote ${REMOTE}" >&2
32
+ exit 1
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ BRANCH="${1:-$(git rev-parse --abbrev-ref HEAD)}"
5
+
6
+ glab mr list --source-branch "$BRANCH" --state opened --json iid,web_url,title | jq '.[0] // empty'
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if [[ $# -lt 2 ]]; then
5
+ echo "Usage: $0 <title> <description-file> [target-branch]" >&2
6
+ exit 1
7
+ fi
8
+
9
+ TITLE="$1"
10
+ DESCRIPTION_FILE="$2"
11
+ TARGET_BRANCH="${3:-$(scripts/agent/git-detect-default-branch.sh origin)}"
12
+ SOURCE_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
13
+
14
+ if existing="$(scripts/agent/git-find-open-mr.sh "$SOURCE_BRANCH")" && [[ -n "$existing" ]]; then
15
+ IID="$(echo "$existing" | jq -r '.iid')"
16
+ scripts/agent/git-update-mr.sh "$IID" "$DESCRIPTION_FILE" "$TITLE"
17
+ exit 0
18
+ fi
19
+
20
+ glab mr create \
21
+ --source-branch "$SOURCE_BRANCH" \
22
+ --target-branch "$TARGET_BRANCH" \
23
+ --title "$TITLE" \
24
+ --description-file "$DESCRIPTION_FILE"
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if [[ $# -lt 2 ]]; then
5
+ echo "Usage: $0 <spec|task> <slug> [repo_root]" >&2
6
+ exit 1
7
+ fi
8
+
9
+ STAGE="$1"
10
+ SLUG="$2"
11
+ REPO_ROOT="${3:-$(pwd)}"
12
+
13
+ case "$STAGE" in
14
+ spec) BRANCH="agent/spec/${SLUG}"; WT_NAME="spec-${SLUG}" ;;
15
+ task) BRANCH="agent/task/${SLUG}"; WT_NAME="task-${SLUG}" ;;
16
+ *) echo "Stage must be 'spec' or 'task'" >&2; exit 1 ;;
17
+ esac
18
+
19
+ REPO_ROOT="$(cd "$REPO_ROOT" && pwd)"
20
+ cd "$REPO_ROOT"
21
+
22
+ REPO_NAME="$(basename "$REPO_ROOT")"
23
+ RUN_ROOT="${HOME}/agent-runs/${REPO_NAME}"
24
+ WORKTREE_DIR="${RUN_ROOT}/worktrees/${WT_NAME}"
25
+ DEFAULT_BRANCH="$(${REPO_ROOT}/scripts/agent/git-detect-default-branch.sh origin)"
26
+
27
+ mkdir -p "${RUN_ROOT}/worktrees"
28
+
29
+ git fetch origin --prune
30
+
31
+ if git worktree list --porcelain | awk '/^worktree /{print $2}' | grep -Fxq "$WORKTREE_DIR"; then
32
+ if [[ -d "$WORKTREE_DIR" ]]; then
33
+ echo "Syncing existing worktree with origin/${DEFAULT_BRANCH}..." >&2
34
+ git -C "$WORKTREE_DIR" rebase "origin/${DEFAULT_BRANCH}"
35
+ echo "WORKTREE_DIR=${WORKTREE_DIR}"
36
+ exit 0
37
+ else
38
+ git worktree prune
39
+ fi
40
+ fi
41
+
42
+ if git show-ref --verify --quiet "refs/heads/${BRANCH}"; then
43
+ git branch -D "$BRANCH"
44
+ fi
45
+
46
+ rm -rf "$WORKTREE_DIR"
47
+ git worktree add "$WORKTREE_DIR" -b "$BRANCH" "origin/${DEFAULT_BRANCH}"
48
+
49
+ cat <<OUT
50
+ WORKTREE_DIR=${WORKTREE_DIR}
51
+ BRANCH=${BRANCH}
52
+ DEFAULT_BRANCH=${DEFAULT_BRANCH}
53
+
54
+ OUT
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ REMOTE="${1:-origin}"
5
+ BRANCH="$(git rev-parse --abbrev-ref HEAD)"
6
+
7
+ if [[ "$BRANCH" == "HEAD" ]]; then
8
+ echo "Detached HEAD; cannot push" >&2
9
+ exit 1
10
+ fi
11
+
12
+ git push -u "$REMOTE" "$BRANCH"
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ IID="${1:-}"
5
+ DESCRIPTION_FILE="${2:-}"
6
+ TITLE="${3:-}"
7
+
8
+ if [[ -z "$IID" ]]; then
9
+ existing="$(scripts/agent/git-find-open-mr.sh)"
10
+ IID="$(echo "$existing" | jq -r '.iid // empty')"
11
+ fi
12
+
13
+ if [[ -z "$IID" ]]; then
14
+ echo "No open MR found for current branch" >&2
15
+ exit 1
16
+ fi
17
+
18
+ args=(mr update "$IID")
19
+
20
+ if [[ -n "$TITLE" ]]; then
21
+ args+=(--title "$TITLE")
22
+ fi
23
+
24
+ if [[ -n "$DESCRIPTION_FILE" && "$DESCRIPTION_FILE" != "-" ]]; then
25
+ args+=(--description-file "$DESCRIPTION_FILE")
26
+ fi
27
+
28
+ glab "${args[@]}"
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if [[ $# -lt 2 ]]; then
5
+ echo "Usage: $0 <slug> <spec_name>" >&2
6
+ exit 1
7
+ fi
8
+
9
+ SLUG="$1"
10
+ SPEC_NAME="$2"
11
+ REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
12
+
13
+ echo "Preparing task worktree for '${SLUG}'..." >&2
14
+ OUTPUT=$(bash "${REPO_ROOT}/scripts/agent/git-prepare-worktree.sh" task "${SLUG}" "${REPO_ROOT}")
15
+ WORKTREE_DIR=$(echo "${OUTPUT}" | grep '^WORKTREE_DIR=' | cut -d= -f2-)
16
+
17
+ echo "Worktree: ${WORKTREE_DIR}" >&2
18
+ cd "${WORKTREE_DIR}"
19
+ exec claude --dangerously-skip-permissions -p "use implement-spec skill from ${SPEC_NAME}"
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if [[ $# -lt 5 ]]; then
5
+ echo "Usage: $0 <spec|task> <spec-path|-> <plan-path|-> <doc-path|-> <artifacts-path|->" >&2
6
+ exit 1
7
+ fi
8
+
9
+ MODE="$1"
10
+ SPEC_PATH="$2"
11
+ PLAN_PATH="$3"
12
+ DOC_PATH="$4"
13
+ ARTIFACTS_PATH="$5"
14
+ BRANCH="$(git rev-parse --abbrev-ref HEAD)"
15
+ COMMIT_SHA="$(git rev-parse --short HEAD)"
16
+
17
+ cat <<EOF2
18
+ ## Summary
19
+ - Workflow mode: ${MODE}
20
+ - Branch: ${BRANCH}
21
+ - Commit: ${COMMIT_SHA}
22
+
23
+ ## Paths
24
+ - Spec: ${SPEC_PATH}
25
+ - Plan: ${PLAN_PATH}
26
+ - Docs: ${DOC_PATH}
27
+ - Artifacts: ${ARTIFACTS_PATH}
28
+
29
+ ## Notes for review
30
+ - Review only the files relevant to this workflow stage.
31
+ - Spec branches should normally contain spec/assets/docs-only changes.
32
+ - Task branches may contain plan, implementation, verification artifacts, and related docs updates.
33
+ EOF2
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if [[ $# -lt 4 ]]; then
5
+ echo "Usage: $0 <spec_path> <plan_path> <docs_path> <artifacts_path>" >&2
6
+ exit 1
7
+ fi
8
+
9
+ SPEC_PATH="$1"
10
+ PLAN_PATH="$2"
11
+ DOCS_PATH="$3"
12
+ ARTIFACTS_PATH="$4"
13
+
14
+ cat <<EOF
15
+ ## Agent run summary
16
+ - Spec: \
17
+ $SPEC_PATH
18
+ - Plan: \
19
+ $PLAN_PATH
20
+ - Docs: \
21
+ $DOCS_PATH
22
+ - Artifacts: \
23
+ $ARTIFACTS_PATH
24
+ EOF
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if [[ $# -lt 2 ]]; then
5
+ echo "Usage: $0 <slug> <notion_url>" >&2
6
+ exit 1
7
+ fi
8
+
9
+ SLUG="$1"
10
+ NOTION_URL="$2"
11
+ REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
12
+
13
+ echo "Preparing spec worktree for '${SLUG}'..." >&2
14
+ OUTPUT=$(bash "${REPO_ROOT}/scripts/agent/git-prepare-worktree.sh" spec "${SLUG}" "${REPO_ROOT}")
15
+ WORKTREE_DIR=$(echo "${OUTPUT}" | grep '^WORKTREE_DIR=' | cut -d= -f2-)
16
+
17
+ echo "Worktree: ${WORKTREE_DIR}" >&2
18
+ cd "${WORKTREE_DIR}"
19
+ exec claude --dangerously-skip-permissions -p "use prepare-spec skill from ${NOTION_URL}"
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if [[ $# -lt 3 ]]; then
5
+ echo "Usage: $0 <repo_root> <base_branch> <spec_slug> [feature_prefix]" >&2
6
+ exit 1
7
+ fi
8
+
9
+ REPO_ROOT="$1"
10
+ BASE_BRANCH="$2"
11
+ SPEC_SLUG="$3"
12
+ FEATURE_PREFIX="${4:-feature/agent}"
13
+
14
+ REPO_ROOT="$(cd "$REPO_ROOT" && pwd)"
15
+ WORKTREE_BASE="$REPO_ROOT/.worktrees"
16
+ BRANCH_NAME="${FEATURE_PREFIX}/${SPEC_SLUG}"
17
+ WORKTREE_PATH="$WORKTREE_BASE/$SPEC_SLUG"
18
+
19
+ mkdir -p "$WORKTREE_BASE"
20
+ cd "$REPO_ROOT"
21
+
22
+ git fetch origin "$BASE_BRANCH" --prune
23
+ if git show-ref --verify --quiet "refs/heads/$BRANCH_NAME"; then
24
+ :
25
+ else
26
+ git branch "$BRANCH_NAME" "origin/$BASE_BRANCH"
27
+ fi
28
+
29
+ if [[ -d "$WORKTREE_PATH" ]]; then
30
+ echo "$WORKTREE_PATH"
31
+ exit 0
32
+ fi
33
+
34
+ git worktree add "$WORKTREE_PATH" "$BRANCH_NAME" >/dev/null
35
+
36
+ echo "$WORKTREE_PATH"
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if [[ $# -lt 1 ]]; then
5
+ echo "Usage: $0 <spec_path>" >&2
6
+ exit 1
7
+ fi
8
+
9
+ SPEC_PATH="$1"
10
+ REPO_ROOT="$(pwd)"
11
+
12
+ node "$REPO_ROOT/scripts/agent/prepare-acceptance.mjs" "$SPEC_PATH"