Skip to content

Commit a79d66a

Browse files
committed
feat:global and project level config file and fix mode documentation
1 parent 1200898 commit a79d66a

File tree

17 files changed

+263
-52
lines changed

17 files changed

+263
-52
lines changed

docs/quickstart.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,26 @@ Specify supports two workflow modes that control development complexity, plus co
2929
/mode
3030

3131
# Switch to lightweight mode for prototyping
32-
/mode build
32+
/speckit.mode build
3333

3434
# Switch to comprehensive mode for production features
35-
/mode spec
35+
/speckit.mode spec
3636

3737
# Customize framework opinions
38-
/mode --no-contracts # Disable API contracts
39-
/mode --tdd # Enable TDD
40-
/mode --risk-tests # Enable risk-based testing
41-
/mode --reset-opinions # Reset to mode defaults
38+
/speckit.mode --no-contracts # Disable API contracts
39+
/speckit.mode --tdd # Enable TDD
40+
/speckit.mode --risk-tests # Enable risk-based testing
41+
/speckit.mode --reset-opinions # Reset to mode defaults
4242

4343
# Learn more about modes and opinions
44-
/mode --info
44+
/speckit.mode --info
4545
```
4646

4747
**Recommendation:**
4848

4949
- Use **`build` mode** for: Individual development, rapid prototyping, quick wins, senior engineer autonomy
5050
- Use **`spec` mode** for: Team collaboration, complex systems, comprehensive documentation, rigorous validation
51-
- Switch between modes as needed: `/mode build` for fast iteration, `/mode spec` for thorough planning
51+
- Switch between modes as needed: `/speckit.mode build` for fast iteration, `/speckit.mode spec` for thorough planning
5252

5353
1. **Project Initialization (`/init`)**
5454
**Action:** From the project root, run the Agentic SDLC Spec Kit `init` command (e.g., `specify init <project> --team-ai-directives https://github.com/your-org/team-ai-directives.git`) to configure local settings and clone the shared `team-ai-directives` modules.
@@ -304,7 +304,7 @@ Your development needs may change as features evolve:
304304
### When to Switch from Build to Spec Mode
305305
306306
```bash
307-
/mode spec
307+
/speckit.mode spec
308308
```
309309
310310
**Indicators:**
@@ -317,7 +317,7 @@ Your development needs may change as features evolve:
317317
### When to Switch from Spec to Build Mode
318318
319319
```bash
320-
/mode build
320+
/speckit.mode build
321321
```
322322
323323
**Indicators:**

roadmap.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525

2626
### **Workflow Modes Feature** - **COMPLETED**
2727

28-
-**Mode Switching Command**: `/mode` command to set build/spec workflow modes and framework options (spec mode is default)
28+
-**Mode Switching Command**: `/speckit.mode` command to set build/spec workflow modes and framework options (spec mode is default)
2929
-**Consolidated Configuration**: Unified `.specify/config/mode.json` with `options` section replacing separate `opinions.json`
30-
-**Framework Options**: Configurable TDD, contracts, data models, and risk-based testing via `/mode` command
30+
-**Framework Options**: Configurable TDD, contracts, data models, and risk-based testing via `/speckit.mode` command
3131
-**Mode State Persistence**: Store current mode, options, and history in single config file
3232
-**Mode-Aware Commands**: `/specify`, `/clarify`, `/plan`, `/implement`, `/analyze` commands adapted for mode-aware behavior
3333
-**Mode Validation**: Commands validate mode compatibility and provide guidance
@@ -64,7 +64,7 @@
6464

6565
-**Risk Extraction**: Standardized severity levels (Critical/High/Medium/Low) in `check-prerequisites.sh`
6666
-**Automated Test Generation**: `generate-risk-tests.sh` creates targeted test tasks
67-
-**Mode Integration**: Risk-based testing configurable via `/mode --risk-tests` command
67+
-**Mode Integration**: Risk-based testing configurable via `/speckit.mode --risk-tests` command
6868
-**Test Evidence Capture**: `/implement` preserves risk mitigation validation
6969

7070
#### **Dual Execution Loop Infrastructure**
@@ -114,7 +114,7 @@
114114

115115
#### **Configurable Framework Options** *(100% Complete)* - **MEDIUM PRIORITY** - Addresses over-opinionated critique
116116

117-
-**Opt-in Architecture Patterns**: TDD, contracts, data models, risk-based testing become user-configurable via `/mode` command
117+
-**Opt-in Architecture Patterns**: TDD, contracts, data models, risk-based testing become user-configurable via `/speckit.mode` command
118118
-**Consolidated Configuration**: Unified `config.json` with `options` section
119119
-**Mode-Based Preferences**: Different defaults for build vs spec modes
120120
-**Reduced Mandatory Options**: Core workflow preserved, options made optional

scripts/bash/check-prerequisites.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ PY
150150
# Extract mode configuration
151151
get_mode_config() {
152152
local config_file
153-
config_file=$(get_global_config_path)
153+
config_file=$(get_config_path)
154154

155155
# Extract current mode and options from consolidated config
156156
python3 - "$config_file" <<'PY'
@@ -228,7 +228,7 @@ fi
228228
if [[ ! -f "$IMPL_PLAN" ]]; then
229229
# Get current mode to determine if plan.md is required
230230
current_mode="spec"
231-
global_config=$(get_global_config_path)
231+
global_config=$(get_config_path)
232232
if [[ -f "$global_config" ]]; then
233233
current_mode=$(python3 -c "
234234
import json

scripts/bash/common.sh

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,33 @@ get_global_config_path() {
1313
echo "$config_home/specify/config.json"
1414
}
1515

16-
# Get current workflow mode from global config (build or spec)
16+
# Get project-level config path (.specify/config.json)
17+
get_project_config_path() {
18+
local repo_root=$(get_repo_root)
19+
echo "$repo_root/.specify/config.json"
20+
}
21+
22+
# Get config path with hierarchical resolution
23+
# Priority: 1) Project config 2) User config 3) Default to project
24+
get_config_path() {
25+
local project_config=$(get_project_config_path)
26+
local user_config=$(get_global_config_path)
27+
28+
if [[ -f "$project_config" ]]; then
29+
echo "$project_config"
30+
elif [[ -f "$user_config" ]]; then
31+
echo "$user_config"
32+
else
33+
# Default to project-level config
34+
echo "$project_config"
35+
fi
36+
}
37+
38+
# Get current workflow mode from config (build or spec)
1739
# Defaults to "spec" if config doesn't exist or mode is invalid
1840
get_current_mode() {
1941
local config_file
20-
config_file=$(get_global_config_path)
42+
config_file=$(get_config_path)
2143

2244
# Default to spec mode if no config exists
2345
if [[ ! -f "$config_file" ]] || ! command -v jq >/dev/null 2>&1; then
@@ -43,7 +65,7 @@ get_current_mode() {
4365
get_mode_config() {
4466
local key="$1"
4567
local config_file
46-
config_file=$(get_global_config_path)
68+
config_file=$(get_config_path)
4769

4870
# Default to false if no config exists or jq not available
4971
if [[ ! -f "$config_file" ]] || ! command -v jq >/dev/null 2>&1; then
@@ -62,11 +84,11 @@ get_mode_config() {
6284
echo "$value"
6385
}
6486

65-
# Get architecture diagram format from global config (mermaid or ascii)
87+
# Get architecture diagram format from config (mermaid or ascii)
6688
# Defaults to "mermaid" if config doesn't exist or format is invalid
6789
get_architecture_diagram_format() {
6890
local config_file
69-
config_file=$(get_global_config_path)
91+
config_file=$(get_config_path)
7092

7193
# Default to mermaid if no config exists or jq not available
7294
if [[ ! -f "$config_file" ]] || ! command -v jq >/dev/null 2>&1; then

scripts/bash/create-new-feature.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,25 @@ get_global_config_path() {
180180
echo "$config_home/specify/config.json"
181181
}
182182

183+
# Get project-level config path (.specify/config.json)
184+
get_project_config_path() {
185+
echo "$REPO_ROOT/.specify/config.json"
186+
}
187+
188+
# Get config path with hierarchical resolution
189+
get_config_path() {
190+
local project_config=$(get_project_config_path)
191+
local user_config=$(get_global_config_path)
192+
193+
if [[ -f "$project_config" ]]; then
194+
echo "$project_config"
195+
elif [[ -f "$user_config" ]]; then
196+
echo "$user_config"
197+
else
198+
echo "$project_config"
199+
fi
200+
}
201+
183202
SPECS_DIR="$REPO_ROOT/specs"
184203
mkdir -p "$SPECS_DIR"
185204

@@ -304,7 +323,7 @@ replace_date_placeholders() {
304323
}
305324

306325
# Mode-aware template selection
307-
MODE_FILE=$(get_global_config_path)
326+
MODE_FILE=$(get_config_path)
308327
CURRENT_MODE="spec"
309328
if [ -f "$MODE_FILE" ]; then
310329
CURRENT_MODE=$(python3 -c "

scripts/bash/implement.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ load_implementation_context() {
122122
# Get current workflow mode
123123
local workflow_mode="spec" # Default
124124
local global_config
125-
global_config=$(get_global_config_path)
125+
global_config=$(get_config_path)
126126
if [[ -f "$global_config" ]]; then
127127
workflow_mode=$(jq -r '.workflow.current_mode // "spec"' "$global_config" 2>/dev/null || echo "spec")
128128
fi
@@ -444,7 +444,7 @@ handle_task_failure() {
444444
# Get workflow mode for mode-aware rollback
445445
local mode="spec" # Default
446446
local global_config
447-
global_config=$(get_global_config_path)
447+
global_config=$(get_config_path)
448448
if [[ -f "$global_config" ]]; then
449449
mode=$(jq -r '.workflow.current_mode // "spec"' "$global_config" 2>/dev/null || echo "spec")
450450
fi

scripts/bash/spec-hooks-install.sh

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,39 @@ set -euo pipefail
7777
SCRIPT_DIR="\$(cd "\$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
7878
PROJECT_ROOT="\$(cd "\$SCRIPT_DIR/../.." && pwd)"
7979
80-
# Get the global config path using XDG Base Directory spec
81-
GLOBAL_CONFIG="\${XDG_CONFIG_HOME:-\$HOME/.config}/specify/config.json"
80+
# Get config path with hierarchical resolution (project-level preferred)
81+
get_repo_root() {
82+
if git rev-parse --show-toplevel >/dev/null 2>&1; then
83+
git rev-parse --show-toplevel
84+
else
85+
pwd
86+
fi
87+
}
88+
89+
get_project_config_path() {
90+
local repo_root=$(get_repo_root)
91+
echo "$repo_root/.specify/config.json"
92+
}
93+
94+
get_global_config_path() {
95+
local config_home="\${XDG_CONFIG_HOME:-\$HOME/.config}"
96+
echo "$config_home/specify/config.json"
97+
}
98+
99+
get_config_path() {
100+
local project_config=$(get_project_config_path)
101+
local user_config=$(get_global_config_path)
102+
103+
if [[ -f "$project_config" ]]; then
104+
echo "$project_config"
105+
elif [[ -f "$user_config" ]]; then
106+
echo "$user_config"
107+
else
108+
echo "$project_config"
109+
fi
110+
}
111+
112+
GLOBAL_CONFIG=$(get_config_path)
82113
83114
# Check if spec sync is enabled for this project
84115
if [[ ! -f "\$GLOBAL_CONFIG" ]]; then

scripts/bash/spec-sync-post-commit.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,22 @@ log_error() {
3232
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3333
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
3434

35-
# Check if spec sync is enabled (global config)
36-
CONFIG_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/specify/config.json"
35+
# Get config path with hierarchical resolution
36+
get_config_path() {
37+
local project_config="$PROJECT_ROOT/.specify/config.json"
38+
local user_config="${XDG_CONFIG_HOME:-$HOME/.config}/specify/config.json"
39+
40+
if [[ -f "$project_config" ]]; then
41+
echo "$project_config"
42+
elif [[ -f "$user_config" ]]; then
43+
echo "$user_config"
44+
else
45+
echo "$project_config"
46+
fi
47+
}
48+
49+
# Check if spec sync is enabled
50+
CONFIG_FILE=$(get_config_path)
3751
if [[ ! -f "$CONFIG_FILE" ]]; then
3852
exit 0
3953
fi

scripts/bash/spec-sync-pre-commit.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,22 @@ log_error() {
3232
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3333
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
3434

35-
# Check if spec sync is enabled (global config)
36-
CONFIG_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/specify/config.json"
35+
# Get config path with hierarchical resolution
36+
get_config_path() {
37+
local project_config="$PROJECT_ROOT/.specify/config.json"
38+
local user_config="${XDG_CONFIG_HOME:-$HOME/.config}/specify/config.json"
39+
40+
if [[ -f "$project_config" ]]; then
41+
echo "$project_config"
42+
elif [[ -f "$user_config" ]]; then
43+
echo "$user_config"
44+
else
45+
echo "$project_config"
46+
fi
47+
}
48+
49+
# Check if spec sync is enabled
50+
CONFIG_FILE=$(get_config_path)
3751
if [[ ! -f "$CONFIG_FILE" ]]; then
3852
exit 0
3953
fi

scripts/bash/spec-sync-pre-push.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,22 @@ log_error() {
3232
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3333
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
3434

35-
# Check if spec sync is enabled (global config)
36-
CONFIG_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/specify/config.json"
35+
# Get config path with hierarchical resolution
36+
get_config_path() {
37+
local project_config="$PROJECT_ROOT/.specify/config.json"
38+
local user_config="${XDG_CONFIG_HOME:-$HOME/.config}/specify/config.json"
39+
40+
if [[ -f "$project_config" ]]; then
41+
echo "$project_config"
42+
elif [[ -f "$user_config" ]]; then
43+
echo "$user_config"
44+
else
45+
echo "$project_config"
46+
fi
47+
}
48+
49+
# Check if spec sync is enabled
50+
CONFIG_FILE=$(get_config_path)
3751
if [[ ! -f "$CONFIG_FILE" ]]; then
3852
exit 0
3953
fi

0 commit comments

Comments
 (0)