Skip to content

Commit 7d458a7

Browse files
committed
fix: resolve team-ai-directives path and fix fragile script sourcing
- Add load_team_directives_config() function to common.sh for runtime path resolution - Fix bash scripts: validate-directives.sh, setup-levelup.sh, analyze-context.sh (levelup), setup-product.sh, setup-architect.sh - Fix PowerShell scripts: setup-levelup.ps1, analyze-context.ps1, validate-trace.ps1, generate-trace.ps1 (levelup), setup-product.ps1 - Bump versions: CLI 0.8.3+adlc2 -> 0.8.3+adlc3, levelup 1.1.7 -> 1.1.8, product 1.1.10 -> 1.1.11, architect 2.0.3 -> 2.0.4
1 parent a281ffb commit 7d458a7

20 files changed

Lines changed: 278 additions & 59 deletions

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ All notable changes to the Specify CLI and templates are documented here.
44

55
# [Unreleased]
66

7+
# [0.8.3+adlc3] - 2026-04-30
8+
9+
### Fixed
10+
11+
- **team-ai-directives resolution**: Added `load_team_directives_config()` function to `scripts/bash/common.sh` to properly resolve team-ai-directives path from init-options.json at runtime (not just during init).
12+
- **Fragile path sourcing in scripts**: Fixed bash and PowerShell scripts in levelup, product, and architect extensions that used fragile relative paths (`../../../../`) to source common.sh. Now uses robust project-root-finding pattern that works regardless of script location.
13+
14+
### Changed
15+
16+
- **levelup**: v1.1.7 → v1.1.8
17+
- **product**: v1.1.10 → v1.1.11
18+
- **architect**: v2.0.3 → v2.0.4
19+
720
# [0.8.3+adlc2] - 2026-04-29
821

922
### Fixed

extensions/architect/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to the Architect extension will be documented in this file.
44

5+
## [2.0.4] - 2026-04-30
6+
7+
### Fixed
8+
9+
- **Fragile path sourcing**: Fixed bash script using fragile relative paths to source common.sh.
10+
511
## [2.0.3] - 2026-04-23
612

713
### Changed

extensions/architect/extension.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ schema_version: "1.0"
33
extension:
44
id: "architect"
55
name: "Architect - ADR & Architecture Description"
6-
version: "2.0.3"
6+
version: "2.0.4"
77
description: "Create and manage Architecture Decision Records (ADRs) and Architecture Descriptions (AD.md) using Rozanski & Woods Viewpoints and Perspectives methodology"
88
author: "Agentic SDLC Team"
99
repository: "https://github.com/tikalk/agentic-sdlc-spec-kit"

extensions/architect/scripts/bash/setup-architect.sh

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,29 @@ DECOMPOSE=true
1212
# Get script directory FIRST (needed for common.sh sourcing)
1313
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1414

15-
# Load common functions from the main scripts directory
16-
# Extension scripts are in .specify/extensions/architect/scripts/bash/
17-
# Common.sh is in .specify/scripts/bash/
18-
if [[ -f "$SCRIPT_DIR/common.sh" ]]; then
15+
# Find project root by walking up from script location
16+
_find_project_root() {
17+
local dir="$SCRIPT_DIR"
18+
while [ "$dir" != "/" ]; do
19+
if [ -d "$dir/.specify" ] || [ -d "$dir/.git" ]; then
20+
echo "$dir"
21+
return 0
22+
fi
23+
dir="$(dirname "$dir")"
24+
done
25+
return 1
26+
}
27+
28+
PROJECT_ROOT="$(_find_project_root)" || PROJECT_ROOT="$SCRIPT_DIR"
29+
30+
# Load common functions - use absolute path from project root
31+
if [[ -n "$PROJECT_ROOT" && -f "$PROJECT_ROOT/.specify/scripts/bash/common.sh" ]]; then
32+
source "$PROJECT_ROOT/.specify/scripts/bash/common.sh"
33+
elif [[ -f "$SCRIPT_DIR/common.sh" ]]; then
1934
source "$SCRIPT_DIR/common.sh"
20-
elif [[ -f "$SCRIPT_DIR/../../../../scripts/bash/common.sh" ]]; then
21-
# Extension path: .specify/extensions/architect/scripts/bash/ -> .specify/scripts/bash/
22-
source "$SCRIPT_DIR/../../../../scripts/bash/common.sh"
2335
else
24-
# Fallback: search for common.sh relative to git root
25-
# This handles both extension and non-extension scenarios
26-
fallback_root=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
27-
if [[ -f "$fallback_root/.specify/scripts/bash/common.sh" ]]; then
28-
source "$fallback_root/.specify/scripts/bash/common.sh"
29-
else
30-
echo "Error: Could not find common.sh" >&2
31-
exit 1
32-
fi
36+
echo "Error: Could not find common.sh" >&2
37+
exit 1
3338
fi
3439

3540
# Get all paths and variables from common functions

extensions/levelup/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to the LevelUp extension will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.1.8] - 2026-04-30
9+
10+
### Fixed
11+
12+
- **Fragile path sourcing**: Fixed bash and PowerShell scripts using fragile relative paths to source common.sh. Now uses robust project-root-finding pattern that works regardless of script location.
13+
814
## [1.1.7] - 2026-04-19
915

1016
### Fixed

extensions/levelup/extension.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ schema_version: "1.0"
33
extension:
44
id: "levelup"
55
name: "LevelUp - Team AI Directives Contributor"
6-
version: "1.1.7"
6+
version: "1.1.8"
77
description: "Discover and contribute context modules (rules, personas, examples, skills) to team-ai-directives using Context Directive Records (CDRs)"
88
author: "Agentic SDLC Team"
99
repository: "https://github.com/tikalk/agentic-sdlc-spec-kit"

extensions/levelup/scripts/bash/analyze-context.sh

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,26 @@ HEURISTIC="surprising"
1212
# Get script directory for common.sh sourcing
1313
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1414

15-
# Load common functions
16-
if [[ -f "$SCRIPT_DIR/common.sh" ]]; then
15+
# Find project root by walking up from script location
16+
_find_project_root() {
17+
local dir="$SCRIPT_DIR"
18+
while [ "$dir" != "/" ]; do
19+
if [ -d "$dir/.specify" ] || [ -d "$dir/.git" ]; then
20+
echo "$dir"
21+
return 0
22+
fi
23+
dir="$(dirname "$dir")"
24+
done
25+
return 1
26+
}
27+
28+
PROJECT_ROOT="$(_find_project_root)" || PROJECT_ROOT="$SCRIPT_DIR"
29+
30+
# Load common functions - use absolute path from project root
31+
if [[ -n "$PROJECT_ROOT" && -f "$PROJECT_ROOT/.specify/scripts/bash/common.sh" ]]; then
32+
source "$PROJECT_ROOT/.specify/scripts/bash/common.sh"
33+
elif [[ -f "$SCRIPT_DIR/common.sh" ]]; then
1734
source "$SCRIPT_DIR/common.sh"
18-
elif [[ -f "$SCRIPT_DIR/../../../../scripts/bash/common.sh" ]]; then
19-
source "$SCRIPT_DIR/../../../../scripts/bash/common.sh"
2035
fi
2136

2237
# Get repository root using common.sh function (searches upward for .specify first)

extensions/levelup/scripts/bash/setup-levelup.sh

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,26 @@ ARGS=()
1212
# Get script directory for common.sh sourcing
1313
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1414

15-
# Load common functions
16-
if [[ -f "$SCRIPT_DIR/common.sh" ]]; then
15+
# Find project root by walking up from script location
16+
_find_project_root() {
17+
local dir="$SCRIPT_DIR"
18+
while [ "$dir" != "/" ]; do
19+
if [ -d "$dir/.specify" ] || [ -d "$dir/.git" ]; then
20+
echo "$dir"
21+
return 0
22+
fi
23+
dir="$(dirname "$dir")"
24+
done
25+
return 1
26+
}
27+
28+
PROJECT_ROOT="$(_find_project_root)" || PROJECT_ROOT="$SCRIPT_DIR"
29+
30+
# Load common functions - use absolute path from project root
31+
if [[ -n "$PROJECT_ROOT" && -f "$PROJECT_ROOT/.specify/scripts/bash/common.sh" ]]; then
32+
source "$PROJECT_ROOT/.specify/scripts/bash/common.sh"
33+
elif [[ -f "$SCRIPT_DIR/common.sh" ]]; then
1734
source "$SCRIPT_DIR/common.sh"
18-
elif [[ -f "$SCRIPT_DIR/../../../../scripts/bash/common.sh" ]]; then
19-
source "$SCRIPT_DIR/../../../../scripts/bash/common.sh"
2035
fi
2136

2237
# Get repository root using common.sh function (searches upward for .specify first)
@@ -197,18 +212,13 @@ detect_subsystems() {
197212

198213
# Resolve team-ai-directives path
199214
# Priority:
200-
# 1. SPECIFY_TEAM_DIRECTIVES environment variable
201-
# 2. .specify/init-options.json team_ai_directives (from specify init)
202-
# 3. .specify/config.json team_directives.path (legacy)
203-
# 4. .specify/team-ai-directives (submodule - recommended)
204-
# 5. .specify/memory/team-ai-directives (clone - legacy)
215+
# 1. SPECIFY_TEAM_DIRECTIVES environment variable (manual override)
216+
# 2. .specify/init-options.json team_ai_directives (from specify init)
217+
# 3. .specify/extensions/team-ai-directives (installed extension)
205218

206-
# Resolve team directives using centralized function
219+
# Load team directives using centralized function from common.sh
207220
load_team_directives_config "$REPO_ROOT"
208221
TEAM_DIRECTIVES="${SPECIFY_TEAM_DIRECTIVES:-}"
209-
if [[ -z "$TEAM_DIRECTIVES" ]] && [[ -d "$REPO_ROOT/.specify/team-ai-directives" ]]; then
210-
TEAM_DIRECTIVES="$REPO_ROOT/.specify/team-ai-directives"
211-
fi
212222

213223
# Skills drafts location
214224
SKILLS_DRAFTS="$REPO_ROOT/.specify/drafts/skills"

extensions/levelup/scripts/bash/validate-directives.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,30 @@
33
set -euo pipefail
44

55
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6-
TEAM_DIRECTIVES="${SPECIFY_TEAM_DIRECTIVES:-}"
7-
REPO_ROOT="${REPO_ROOT:-$(pwd)}"
6+
7+
# Find project root by walking up from script location
8+
_find_project_root() {
9+
local dir="$SCRIPT_DIR"
10+
while [ "$dir" != "/" ]; do
11+
if [ -d "$dir/.specify" ] || [ -d "$dir/.git" ]; then
12+
echo "$dir"
13+
return 0
14+
fi
15+
dir="$(dirname "$dir")"
16+
done
17+
return 1
18+
}
19+
20+
PROJECT_ROOT="$(_find_project_root)" || PROJECT_ROOT="$SCRIPT_DIR"
21+
22+
# Load common functions - use absolute path from project root
23+
if [[ -n "$PROJECT_ROOT" && -f "$PROJECT_ROOT/.specify/scripts/bash/common.sh" ]]; then
24+
source "$PROJECT_ROOT/.specify/scripts/bash/common.sh"
25+
elif [[ -f "$SCRIPT_DIR/common.sh" ]]; then
26+
source "$SCRIPT_DIR/common.sh"
27+
fi
28+
29+
REPO_ROOT="${REPO_ROOT:-$PROJECT_ROOT}"
830
OUTPUT_FORMAT="json"
931
SEVERITY_FILTER="info"
1032

@@ -55,11 +77,7 @@ done
5577
validate_environment() {
5678
# Use centralized function to load team directives
5779
load_team_directives_config "$REPO_ROOT"
58-
TEAM_DIRECTIVES="$SPECIFY_TEAM_DIRECTIVES"
59-
60-
if [[ -z "$TEAM_DIRECTIVES" ]] && [[ -d "$REPO_ROOT/.specify/team-ai-directives" ]]; then
61-
TEAM_DIRECTIVES="$REPO_ROOT/.specify/team-ai-directives"
62-
fi
80+
TEAM_DIRECTIVES="${SPECIFY_TEAM_DIRECTIVES:-}"
6381

6482
if [[ -z "$TEAM_DIRECTIVES" ]] || [[ ! -d "$TEAM_DIRECTIVES" ]]; then
6583
echo "Error: team-ai-directives not found. Run 'specify init --team-ai-directives <path>' to configure." >&2

extensions/levelup/scripts/powershell/analyze-context.ps1

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,27 @@ if ($Help) {
2222
# Get script directory for common.ps1 sourcing
2323
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
2424

25-
# Load common functions
26-
$commonPath = "$scriptDir\..\..\..\..\scripts\powershell\common.ps1"
25+
# Find project root by walking up from script location
26+
function Get-ProjectRoot {
27+
param([string]$StartPath)
28+
$dir = $StartPath
29+
while ($dir -ne "") {
30+
if ((Test-Path "$dir\.specify") -or (Test-Path "$dir\.git")) {
31+
return $dir
32+
}
33+
$dir = Split-Path $dir -Parent
34+
}
35+
return $StartPath
36+
}
37+
38+
$projectRoot = Get-ProjectRoot $scriptDir
39+
40+
# Load common functions - use absolute path from project root
41+
$commonPath = "$projectRoot\.specify\scripts\powershell\common.ps1"
2742
if (Test-Path $commonPath) {
2843
. $commonPath
44+
} elseif (Test-Path "$scriptDir\common.ps1") {
45+
. "$scriptDir\common.ps1"
2946
}
3047

3148
# Get repository root using common.ps1 function (searches upward for .specify first)

0 commit comments

Comments
 (0)