Skip to content

Commit a62bcea

Browse files
committed
feat(scaffold): add install.sh script and implementation plan
1 parent c220abd commit a62bcea

4 files changed

Lines changed: 234 additions & 1 deletion

File tree

TASKS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Put done tasks into the Archive.
1919
---
2020

2121
## Archive
22+
- [x] Implement the `install.sh` scaffolding script for new projects. (2026-03-03) (See plan: plans/install-script-scaffolding.md)
2223
- [x] Refactor the `/research` command to follow a more extensible, executive-style reporting workflow with iterative updates and asset linking. (2026-03-02)
2324
- [x] Implement drafting (`/draft`) and editing (`/revise`) capabilities using specialized subagents. (2026-03-02) (See plan: plans/drafting-and-editing-capabilities.md)
2425
- [x] Implement a custom `/plan` command workflow and a `planner` sub-agent for repository analysis and plan generation in `plans/`. (2026-03-02)

install.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# --- Configuration ---
5+
REPO_URL="https://github.com/apiad/starter.git"
6+
7+
# --- Functions ---
8+
error() {
9+
echo -e "\033[0;31m❌ Error: $1\033[0m" >&2
10+
exit 1
11+
}
12+
13+
# --- Check Prerequisites ---
14+
for cmd in git node; do
15+
if ! command -v "$cmd" >/dev/null 2>&1; then
16+
error "$cmd is not installed. Please install it and try again."
17+
fi
18+
done
19+
20+
# --- Inputs ---
21+
# We use /dev/tty for input because curl | bash takes over stdin
22+
echo -n "Enter project name: "
23+
read PROJECT_NAME < /dev/tty
24+
25+
if [[ -z "$PROJECT_NAME" ]]; then
26+
error "Project name cannot be empty."
27+
fi
28+
29+
# Sanitize project name for default target directory
30+
DEFAULT_TARGET=$(echo "$PROJECT_NAME" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g')
31+
echo -n "Enter target directory [$DEFAULT_TARGET]: "
32+
read TARGET_DIR < /dev/tty
33+
34+
TARGET_DIR=${TARGET_DIR:-$DEFAULT_TARGET}
35+
36+
if [[ -d "$TARGET_DIR" ]]; then
37+
error "Directory '$TARGET_DIR' already exists. Choose a different directory or delete the existing one."
38+
fi
39+
40+
# --- Execution ---
41+
echo "🚀 Scaffolding new project: $PROJECT_NAME in $TARGET_DIR..."
42+
43+
# Clone the template
44+
git clone --depth 1 "$REPO_URL" "$TARGET_DIR" || error "Failed to clone template repository."
45+
46+
cd "$TARGET_DIR"
47+
48+
# Reset Git History
49+
rm -rf .git
50+
git init -q
51+
52+
# Reset Core Markdown Files
53+
cat <<EOF > README.md
54+
# $PROJECT_NAME
55+
56+
This project was bootstrapped from [apiad/starter](https://github.com/apiad/starter).
57+
EOF
58+
59+
cat <<EOF > CHANGELOG.md
60+
# Changelog
61+
62+
All notable changes to this project will be documented in this file.
63+
64+
## [Unreleased]
65+
- Initial project scaffold.
66+
EOF
67+
68+
# Clear content directories but preserve .gitkeep
69+
for dir in journal plans drafts; do
70+
if [[ -d "$dir" ]]; then
71+
find "$dir" -maxdepth 1 -type f ! -name ".gitkeep" -delete
72+
touch "$dir/.gitkeep"
73+
fi
74+
done
75+
76+
# Create first journal entry
77+
TODAY=$(date +%Y-%m-%d)
78+
cat <<EOF > "journal/$TODAY.md"
79+
# $TODAY - Initial Kickoff
80+
81+
Started the project "$PROJECT_NAME" using the Gemini CLI framework.
82+
EOF
83+
84+
# --- Post-Install ---
85+
git add .
86+
git commit -m "Initial commit" -q
87+
88+
echo "✅ Project $PROJECT_NAME scaffolded successfully!"
89+
echo "🚀 Starting Gemini CLI..."
90+
91+
# Run the gemini CLI
92+
if command -v gemini >/dev/null 2>&1; then
93+
exec gemini
94+
else
95+
echo "⚠️ 'gemini' command not found. Please ensure the Gemini CLI is installed and in your PATH."
96+
fi

journal/2026-03-03.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
- Released v0.9.0 with the new `/debug` command and forensic `debugger` subagent for root-cause analysis (RCA).
44
- Refined `scaffold` and `revise` command instructions for better clarity and consistency.
5-
- Updated project metadata and documentation.
5+
- Implemented the `install.sh` scaffolding script to automate project bootstrapping from the `apiad/starter` template.
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Objective: Implementation of `install.sh` Scaffolding Script
2+
3+
The objective is to provide a robust, interactive shell script at the root of the repository that allows users to quickly bootstrap new projects based on this opinionated Gemini CLI framework. The script is designed to be run via `curl` and piped to `bash`.
4+
5+
## Architectural Impact
6+
- **Developer Experience:** Simplifies the onboarding process for new projects.
7+
- **Project Structure:** Adds a new utility script (`install.sh`) to the repository root.
8+
- **Framework Integrity:** Ensures that all necessary configuration files (specifically the `.gemini/` directory) are preserved while user-specific content is reset.
9+
10+
## File Operations
11+
- **Created File:** `install.sh` at the repository root.
12+
13+
## Step-by-Step Execution
14+
15+
### 1. Script Drafting
16+
Create `install.sh` with the following logic:
17+
- **Environment Checks:** Verify that `git` and `node` are installed.
18+
- **Interactive Prompts:**
19+
- Use `/dev/tty` for `read` commands to ensure compatibility with `curl | bash` execution.
20+
- Ask for the `Project Name`.
21+
- Ask for the `Target Directory` (defaulting to a kebab-case version of the project name).
22+
- **Core Scaffolding:**
23+
- Clone the `apiad/starter` repository using `--depth 1` for a fast, shallow clone.
24+
- Remove the `.git` directory and run `git init` to establish a new history.
25+
- **Content Reset:**
26+
- Overwrite `README.md` with a minimal title and template reference.
27+
- Overwrite `CHANGELOG.md` with a clean header.
28+
- Clear all markdown files from `journal/`, `plans/`, and `drafts/` while preserving `.gitkeep` files.
29+
- Generate a first journal entry for the current date (`journal/YYYY-MM-DD.md`).
30+
- **Finalization:**
31+
- Perform an initial `git add .` and `git commit -m "Initial commit"`.
32+
- Attempt to launch the `gemini` CLI command.
33+
34+
### 2. Permissions (Informational)
35+
While the user will likely run this via `bash`, the script itself should be marked as executable in the repository for local use.
36+
37+
## Proposed `install.sh` Content
38+
39+
```bash
40+
#!/bin/bash
41+
set -e
42+
43+
# --- Configuration ---
44+
REPO_URL="https://github.com/apiad/starter.git"
45+
46+
# --- Functions ---
47+
error() {
48+
echo -e "\033[0;31m❌ Error: \$1\033[0m" >&2
49+
exit 1
50+
}
51+
52+
# --- Check Prerequisites ---
53+
for cmd in git node; do
54+
if ! command -v "\$cmd" >/dev/null 2>&1; then
55+
error "\$cmd is not installed. Please install it and try again."
56+
fi
57+
done
58+
59+
# --- Inputs ---
60+
# We use /dev/tty for input because curl | bash takes over stdin
61+
echo -n "Enter project name: "
62+
read PROJECT_NAME < /dev/tty
63+
64+
if [[ -z "\$PROJECT_NAME" ]]; then
65+
error "Project name cannot be empty."
66+
fi
67+
68+
# Sanitize project name for default target directory
69+
DEFAULT_TARGET=\$(echo "\$PROJECT_NAME" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g')
70+
echo -n "Enter target directory [\$DEFAULT_TARGET]: "
71+
read TARGET_DIR < /dev/tty
72+
73+
TARGET_DIR=\${TARGET_DIR:-\$DEFAULT_TARGET}
74+
75+
if [[ -d "\$TARGET_DIR" ]]; then
76+
error "Directory '\$TARGET_DIR' already exists. Choose a different directory or delete the existing one."
77+
fi
78+
79+
# --- Execution ---
80+
echo "🚀 Scaffolding new project: \$PROJECT_NAME in \$TARGET_DIR..."
81+
82+
# Clone the template
83+
git clone --depth 1 "\$REPO_URL" "\$TARGET_DIR" || error "Failed to clone template repository."
84+
85+
cd "\$TARGET_DIR"
86+
87+
# Reset Git History
88+
rm -rf .git
89+
git init -q
90+
91+
# Reset Core Markdown Files
92+
cat <<EOF > README.md
93+
# \$PROJECT_NAME
94+
95+
This project was bootstrapped from [apiad/starter](https://github.com/apiad/starter).
96+
EOF
97+
98+
cat <<EOF > CHANGELOG.md
99+
# Changelog
100+
101+
All notable changes to this project will be documented in this file.
102+
103+
## [Unreleased]
104+
- Initial project scaffold.
105+
EOF
106+
107+
# Clear content directories but preserve .gitkeep
108+
for dir in journal plans drafts; do
109+
if [[ -d "\$dir" ]]; then
110+
find "\$dir" -maxdepth 1 -type f ! -name ".gitkeep" -delete
111+
touch "\$dir/.gitkeep"
112+
fi
113+
done
114+
115+
# Create first journal entry
116+
TODAY=\$(date +%Y-%m-%d)
117+
cat <<EOF > "journal/\$TODAY.md"
118+
# \$TODAY - Initial Kickoff
119+
120+
Started the project "\$PROJECT_NAME" using the Gemini CLI framework.
121+
EOF
122+
123+
# --- Post-Install ---
124+
git add .
125+
git commit -m "Initial commit" -q
126+
127+
echo "✅ Project \$PROJECT_NAME scaffolded successfully!"
128+
echo "🚀 Starting Gemini CLI..."
129+
130+
# Run the gemini CLI
131+
if command -v gemini >/dev/null 2>&1; then
132+
exec gemini
133+
else
134+
echo "⚠️ 'gemini' command not found. Please ensure the Gemini CLI is installed and in your PATH."
135+
fi
136+
```

0 commit comments

Comments
 (0)