@anhth2/spec-driven-dev-plugin 0.5.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.
- package/ARCHITECTURE.md +243 -0
- package/bin/build.js +230 -0
- package/bin/index.js +311 -0
- package/commands/debug.md +374 -0
- package/commands/debug.tmpl +77 -0
- package/commands/define-product.md +451 -0
- package/commands/define-product.tmpl +154 -0
- package/commands/fix-bug.md +379 -0
- package/commands/fix-bug.tmpl +82 -0
- package/commands/generate-bdd.md +591 -0
- package/commands/generate-bdd.tmpl +294 -0
- package/commands/generate-code.md +395 -0
- package/commands/generate-code.tmpl +98 -0
- package/commands/generate-prd.md +488 -0
- package/commands/generate-prd.tmpl +191 -0
- package/commands/generate-tech-docs.md +362 -0
- package/commands/generate-tech-docs.tmpl +65 -0
- package/commands/generate-tests.md +377 -0
- package/commands/generate-tests.tmpl +80 -0
- package/commands/refine-prd.md +408 -0
- package/commands/refine-prd.tmpl +111 -0
- package/commands/review-code.md +354 -0
- package/commands/review-code.tmpl +57 -0
- package/commands/review-context.md +646 -0
- package/commands/review-context.tmpl +349 -0
- package/commands/review-tech-docs.md +518 -0
- package/commands/review-tech-docs.tmpl +221 -0
- package/commands/run-tests.md +343 -0
- package/commands/run-tests.tmpl +46 -0
- package/commands/setup-ai-first.md +278 -0
- package/commands/setup-ai-first.tmpl +197 -0
- package/commands/smoke-test.md +366 -0
- package/commands/smoke-test.tmpl +69 -0
- package/commands/validate-traces.md +529 -0
- package/commands/validate-traces.tmpl +232 -0
- package/core/FRAMEWORK_VERSION +1 -0
- package/core/commands/debug.md +374 -0
- package/core/commands/define-product.md +451 -0
- package/core/commands/fix-bug.md +379 -0
- package/core/commands/generate-bdd.md +591 -0
- package/core/commands/generate-code.md +395 -0
- package/core/commands/generate-prd.md +488 -0
- package/core/commands/generate-tech-docs.md +362 -0
- package/core/commands/generate-tests.md +377 -0
- package/core/commands/refine-prd.md +408 -0
- package/core/commands/review-code.md +354 -0
- package/core/commands/review-context.md +646 -0
- package/core/commands/review-tech-docs.md +518 -0
- package/core/commands/run-tests.md +343 -0
- package/core/commands/setup-ai-first.md +278 -0
- package/core/commands/smoke-test.md +366 -0
- package/core/commands/validate-traces.md +529 -0
- package/core/hooks/data-guard.js +141 -0
- package/core/hooks/settings.json +18 -0
- package/core/modules/angular/architecture-snippets/component-patterns.md +187 -0
- package/core/modules/angular/module.yaml +6 -0
- package/core/modules/angular/stack-profile.yaml +38 -0
- package/core/modules/context-engineering/architecture-snippets/context-design.md +119 -0
- package/core/modules/context-engineering/module.yaml +9 -0
- package/core/modules/context-engineering/stack-profile.yaml +61 -0
- package/core/modules/dotnet/architecture-snippets/clean-arch.md +160 -0
- package/core/modules/dotnet/module.yaml +6 -0
- package/core/modules/dotnet/stack-profile.yaml +50 -0
- package/core/modules/golang/architecture-snippets/domain-layout.md +283 -0
- package/core/modules/golang/module.yaml +6 -0
- package/core/modules/golang/stack-profile.yaml +40 -0
- package/core/modules/java-spring/architecture-snippets/layered-arch.md +201 -0
- package/core/modules/java-spring/module.yaml +15 -0
- package/core/modules/java-spring/stack-profile.yaml +28 -0
- package/core/modules/nextjs/architecture-snippets/app-router-patterns.md +269 -0
- package/core/modules/nextjs/module.yaml +14 -0
- package/core/modules/nextjs/stack-profile.yaml +74 -0
- package/core/modules/php-laravel/architecture-snippets/service-repository.md +302 -0
- package/core/modules/php-laravel/module.yaml +15 -0
- package/core/modules/php-laravel/stack-profile.yaml +56 -0
- package/core/modules/react/architecture-snippets/hooks-query-patterns.md +254 -0
- package/core/modules/react/module.yaml +14 -0
- package/core/modules/react/stack-profile.yaml +63 -0
- package/core/rules/data-protection.md +80 -0
- package/core/rules/workflow.md +44 -0
- package/core/skills/code/SKILL.md +526 -0
- package/core/skills/debug/SKILL.md +584 -0
- package/core/skills/discovery/SKILL.md +363 -0
- package/core/skills/prd/SKILL.md +456 -0
- package/core/skills/setup-ai-first/SKILL.md +160 -0
- package/core/skills/spec/SKILL.md +361 -0
- package/core/skills/test/SKILL.md +862 -0
- package/core/steps/context-loader.md +163 -0
- package/core/steps/gate.md +81 -0
- package/core/steps/report-footer.md +53 -0
- package/core/steps/spawn-agent.md +123 -0
- package/core/templates/architecture.template.md +113 -0
- package/core/templates/feature.template +259 -0
- package/core/templates/platform-guide.template.md +145 -0
- package/core/templates/prd.template.md +312 -0
- package/core/templates/product-definition.template.md +168 -0
- package/core/templates/project-context.yaml +78 -0
- package/hooks/data-guard.js +141 -0
- package/hooks/settings.json +18 -0
- package/modules/angular/architecture-snippets/component-patterns.md +187 -0
- package/modules/angular/module.yaml +6 -0
- package/modules/angular/stack-profile.yaml +38 -0
- package/modules/context-engineering/architecture-snippets/context-design.md +119 -0
- package/modules/context-engineering/module.yaml +9 -0
- package/modules/context-engineering/stack-profile.yaml +61 -0
- package/modules/dotnet/architecture-snippets/clean-arch.md +160 -0
- package/modules/dotnet/module.yaml +6 -0
- package/modules/dotnet/stack-profile.yaml +50 -0
- package/modules/golang/architecture-snippets/domain-layout.md +283 -0
- package/modules/golang/module.yaml +6 -0
- package/modules/golang/stack-profile.yaml +40 -0
- package/modules/java-spring/architecture-snippets/layered-arch.md +201 -0
- package/modules/java-spring/module.yaml +15 -0
- package/modules/java-spring/stack-profile.yaml +28 -0
- package/modules/nextjs/architecture-snippets/app-router-patterns.md +269 -0
- package/modules/nextjs/module.yaml +14 -0
- package/modules/nextjs/stack-profile.yaml +74 -0
- package/modules/php-laravel/architecture-snippets/service-repository.md +302 -0
- package/modules/php-laravel/module.yaml +15 -0
- package/modules/php-laravel/stack-profile.yaml +56 -0
- package/modules/react/architecture-snippets/hooks-query-patterns.md +254 -0
- package/modules/react/module.yaml +14 -0
- package/modules/react/stack-profile.yaml +63 -0
- package/package.json +42 -0
- package/rules/data-protection.md +80 -0
- package/rules/workflow.md +44 -0
- package/scripts/init.sh +49 -0
- package/scripts/upgrade.sh +94 -0
- package/skills/code/SKILL.md +526 -0
- package/skills/code/SKILL.tmpl +176 -0
- package/skills/debug/SKILL.md +584 -0
- package/skills/debug/SKILL.tmpl +262 -0
- package/skills/discovery/SKILL.md +363 -0
- package/skills/discovery/SKILL.tmpl +147 -0
- package/skills/prd/SKILL.md +456 -0
- package/skills/prd/SKILL.tmpl +188 -0
- package/skills/setup-ai-first/SKILL.md +160 -0
- package/skills/setup-ai-first/SKILL.tmpl +107 -0
- package/skills/spec/SKILL.md +361 -0
- package/skills/spec/SKILL.tmpl +174 -0
- package/skills/test/SKILL.md +862 -0
- package/skills/test/SKILL.tmpl +296 -0
- package/steps/context-loader.md +163 -0
- package/steps/gate.md +81 -0
- package/steps/report-footer.md +53 -0
- package/steps/spawn-agent.md +123 -0
- package/templates/architecture.template.md +113 -0
- package/templates/feature.template +259 -0
- package/templates/platform-guide.template.md +145 -0
- package/templates/prd.template.md +312 -0
- package/templates/product-definition.template.md +168 -0
- package/templates/project-context.yaml +78 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
build:
|
|
2
|
+
compile: "npm run build"
|
|
3
|
+
test: "npm test"
|
|
4
|
+
run: "npm run dev"
|
|
5
|
+
lint: "npm run lint"
|
|
6
|
+
|
|
7
|
+
architecture:
|
|
8
|
+
style: "Feature-based (components → hooks → queries → store)"
|
|
9
|
+
key_rules:
|
|
10
|
+
- "Business logic lives in custom hooks, not in components"
|
|
11
|
+
- "Server state managed by React Query (useQuery / useMutation)"
|
|
12
|
+
- "Client-only UI state managed by Zustand or useState"
|
|
13
|
+
- "Components must be pure functions — no direct API calls inside JSX"
|
|
14
|
+
- "Shared UI primitives in components/ui/, feature logic in features/{name}/"
|
|
15
|
+
- "Never fetch data directly in a component — use a custom hook"
|
|
16
|
+
folder_structure: |
|
|
17
|
+
src/
|
|
18
|
+
├── api/ ← axios instance, interceptors
|
|
19
|
+
├── components/
|
|
20
|
+
│ └── ui/ ← reusable primitives (Button, Modal, Table...)
|
|
21
|
+
├── features/
|
|
22
|
+
│ └── {domain}/
|
|
23
|
+
│ ├── components/ ← feature-specific UI
|
|
24
|
+
│ ├── hooks/ ← useOrderList, useCreateOrder...
|
|
25
|
+
│ ├── queries/ ← React Query definitions
|
|
26
|
+
│ ├── store/ ← Zustand slice (if needed)
|
|
27
|
+
│ └── types.ts
|
|
28
|
+
├── pages/ ← route-level page components
|
|
29
|
+
└── lib/ ← utilities, formatters, constants
|
|
30
|
+
|
|
31
|
+
coding_standards:
|
|
32
|
+
naming:
|
|
33
|
+
components: "PascalCase (e.g., OrderList, CreateOrderModal)"
|
|
34
|
+
hooks: "camelCase with 'use' prefix (e.g., useOrderList, useCreateOrder)"
|
|
35
|
+
query_keys: "SCREAMING_SNAKE_CASE array (e.g., ['ORDER_LIST', customerId])"
|
|
36
|
+
stores: "camelCase + Store suffix (e.g., useCartStore)"
|
|
37
|
+
files:
|
|
38
|
+
component: "{Feature}.tsx"
|
|
39
|
+
hook: "use{Feature}.ts"
|
|
40
|
+
query: "{feature}.queries.ts"
|
|
41
|
+
store: "{feature}.store.ts"
|
|
42
|
+
types: "{feature}.types.ts"
|
|
43
|
+
patterns:
|
|
44
|
+
data_fetching: "React Query (TanStack Query v5)"
|
|
45
|
+
global_state: "Zustand slices"
|
|
46
|
+
forms: "React Hook Form + Zod validation"
|
|
47
|
+
api_client: "Axios with interceptors for auth + error handling"
|
|
48
|
+
error_boundary: "React ErrorBoundary wraps each feature route"
|
|
49
|
+
|
|
50
|
+
testing:
|
|
51
|
+
unit: "Vitest + React Testing Library"
|
|
52
|
+
e2e: "Playwright or Cypress"
|
|
53
|
+
patterns:
|
|
54
|
+
- "Test behavior, not implementation — query by role/label, not className"
|
|
55
|
+
- "Mock React Query with a QueryClient wrapper in test setup"
|
|
56
|
+
- "Use MSW (Mock Service Worker) to mock API calls in tests"
|
|
57
|
+
- "renderWithProviders() helper wraps component with QueryClient + Router"
|
|
58
|
+
|
|
59
|
+
trace_tags:
|
|
60
|
+
implements: "// @trace.implements={UC-ID}-SC{N}"
|
|
61
|
+
source: "// @trace.source=specs/bdd/{domain}/{UC-ID}.feature"
|
|
62
|
+
verifies: "// @trace.verifies={UC-ID}"
|
|
63
|
+
test_type: "// @trace.test_type=unit|integration"
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@anhth2/spec-driven-dev-plugin",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "AI-First Spec-Driven Development workflow plugin for Claude Code",
|
|
5
|
+
"bin": {
|
|
6
|
+
"spec-driven-dev": "./bin/index.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "node bin/build.js",
|
|
10
|
+
"prepublishOnly": "node bin/build.js",
|
|
11
|
+
"pub": "npm publish --access=public",
|
|
12
|
+
"dev": "node bin/build.js && node bin/index.js --init",
|
|
13
|
+
"prepack": "node -e \"const fs=require('fs'); ['README.md','PUBLISHING.md','SETUP_GUIDE.md'].forEach(f=>{ if(fs.existsSync(f)) fs.renameSync(f,'__'+f); });\"",
|
|
14
|
+
"postpack": "node -e \"const fs=require('fs'); ['README.md','PUBLISHING.md','SETUP_GUIDE.md'].forEach(f=>{ if(fs.existsSync('__'+f)) fs.renameSync('__'+f,f); });\""
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"bin/",
|
|
18
|
+
"commands/",
|
|
19
|
+
"core/",
|
|
20
|
+
"hooks/",
|
|
21
|
+
"modules/",
|
|
22
|
+
"rules/",
|
|
23
|
+
"scripts/",
|
|
24
|
+
"skills/",
|
|
25
|
+
"steps/",
|
|
26
|
+
"templates/",
|
|
27
|
+
"ARCHITECTURE.md"
|
|
28
|
+
],
|
|
29
|
+
"keywords": ["claude-code", "spec-driven", "ai-first", "bdd", "traceability", "workflow"],
|
|
30
|
+
"author": "Edupia Team",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/TranHongAnh2k/spec-driven-dev"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=14"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Data Protection Rules
|
|
2
|
+
|
|
3
|
+
> These rules are loaded by `steps/context-loader.md` at the start of every command.
|
|
4
|
+
> AI agents MUST follow these rules without exception.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## NEVER Read — Sensitive Files
|
|
9
|
+
|
|
10
|
+
The following file patterns contain credentials, secrets, or private keys.
|
|
11
|
+
**Do NOT read, display, log, or reference their contents under any circumstance.**
|
|
12
|
+
|
|
13
|
+
### Environment & Secrets
|
|
14
|
+
- `.env`
|
|
15
|
+
- `.env.*` (e.g., `.env.local`, `.env.production`, `.env.staging`)
|
|
16
|
+
- `*.secret`
|
|
17
|
+
- `secrets/` (entire directory)
|
|
18
|
+
- `.secrets/` (entire directory)
|
|
19
|
+
- `*credentials*`
|
|
20
|
+
|
|
21
|
+
### Cryptographic Keys & Certificates
|
|
22
|
+
- `*.key`
|
|
23
|
+
- `*.pem`
|
|
24
|
+
- `*.p12`
|
|
25
|
+
- `*.pfx`
|
|
26
|
+
- `*.jks`
|
|
27
|
+
- `*.keystore`
|
|
28
|
+
- `*.crt` / `*.cert`
|
|
29
|
+
|
|
30
|
+
### Framework-Specific Config Files (may contain DB passwords, API keys)
|
|
31
|
+
- `application-prod.yml` / `application-prod.properties`
|
|
32
|
+
- `application-production.yml`
|
|
33
|
+
- `appsettings.Production.json`
|
|
34
|
+
- `appsettings.Staging.json`
|
|
35
|
+
- `database.yml` (Rails)
|
|
36
|
+
- `config/master.key` (Rails)
|
|
37
|
+
- `storage/oauth-private.key`
|
|
38
|
+
|
|
39
|
+
### Files Matching Dangerous Keywords
|
|
40
|
+
Any file whose name contains (case-insensitive):
|
|
41
|
+
- `password`
|
|
42
|
+
- `passwd`
|
|
43
|
+
- `secret`
|
|
44
|
+
- `private_key`
|
|
45
|
+
- `api_key`
|
|
46
|
+
- `access_token`
|
|
47
|
+
- `auth_token`
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## NEVER Write or Modify
|
|
52
|
+
|
|
53
|
+
- Any file listed above
|
|
54
|
+
- `*.lock` files that are not package lock files (e.g., `*.lock` outside of `package-lock.json`, `yarn.lock`, `composer.lock`)
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## NEVER Execute via Bash
|
|
59
|
+
|
|
60
|
+
- Commands that print secrets: `printenv`, `env | grep -i secret`, `cat .env`
|
|
61
|
+
- Commands that expose credentials: `docker inspect`, `kubectl get secret -o yaml`
|
|
62
|
+
- Git commands that may expose history of secrets: `git show`, `git log -p` on config files
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Safe Alternatives
|
|
67
|
+
|
|
68
|
+
If context about environment configuration is needed:
|
|
69
|
+
|
|
70
|
+
1. Ask the user to describe the configuration **without sharing actual values**.
|
|
71
|
+
2. Reference the **structure** of config (keys, not values): "I see you use `DATABASE_URL` — I'll generate code that reads from that variable."
|
|
72
|
+
3. Use placeholder values in generated code: `process.env.DATABASE_URL` or `${DATABASE_URL}`.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## If a Sensitive File is Accidentally Accessed
|
|
77
|
+
|
|
78
|
+
1. Do NOT display or repeat any content from the file.
|
|
79
|
+
2. Immediately stop and notify the user: "I've detected a sensitive file. I will not read or use its contents."
|
|
80
|
+
3. Ask the user what they actually need (usually it's the structure, not the values).
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Workflow Rules
|
|
2
|
+
|
|
3
|
+
> General AI behavior rules for all spec-driven-dev commands.
|
|
4
|
+
> Loaded by `steps/context-loader.md` at the start of every command.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Checkpoints
|
|
9
|
+
|
|
10
|
+
- **Always** show a CHECKPOINT before making significant changes.
|
|
11
|
+
- A CHECKPOINT must include: what will be done, which files will be created/modified, estimated scope.
|
|
12
|
+
- Wait for explicit "Y" or user confirmation before proceeding.
|
|
13
|
+
- Exception: read-only analysis commands (`/review-code`, `/validate-traces`, `/debug`) may skip CHECKPOINT.
|
|
14
|
+
|
|
15
|
+
## Scope Control
|
|
16
|
+
|
|
17
|
+
- Work only within the scope explicitly confirmed at CHECKPOINT.
|
|
18
|
+
- Do NOT create files outside the directories specified in `project-context.yaml → paths`.
|
|
19
|
+
- If new scope is discovered mid-command, STOP and ask: "I found additional scope [{description}]. Should I include it? (Y/N)"
|
|
20
|
+
|
|
21
|
+
## Code Generation
|
|
22
|
+
|
|
23
|
+
- Never generate code for files not backed by a `.feature` spec (unless `/fix-bug` or `/debug`).
|
|
24
|
+
- Always add `@trace.implements` tags on controller-level methods.
|
|
25
|
+
- Never overwrite existing business logic without explicit confirmation.
|
|
26
|
+
- Build must pass before committing: run `{conventions.build_command}` and fix errors (max 3 retries).
|
|
27
|
+
|
|
28
|
+
## File Operations
|
|
29
|
+
|
|
30
|
+
- Prefer **editing** existing files over replacing them entirely.
|
|
31
|
+
- When creating new files, check if a similar file already exists first.
|
|
32
|
+
- Never delete files unless explicitly instructed.
|
|
33
|
+
|
|
34
|
+
## Communication
|
|
35
|
+
|
|
36
|
+
- Report in the language the user writes in (Vietnamese if user uses Vietnamese, English otherwise).
|
|
37
|
+
- Keep reports structured: status, artifacts created, next recommended command.
|
|
38
|
+
- If unsure about business intent, ask — do not guess and generate wrong spec.
|
|
39
|
+
|
|
40
|
+
## Error Handling
|
|
41
|
+
|
|
42
|
+
- If a tool call fails (file not found, build error, etc.), report the specific error clearly.
|
|
43
|
+
- Do NOT silently skip errors or pretend success.
|
|
44
|
+
- Suggest a concrete fix, not just "please check the error".
|
package/scripts/init.sh
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# init.sh — First-time setup of Spec-Driven Dev framework in a consumer project.
|
|
3
|
+
#
|
|
4
|
+
# Usage:
|
|
5
|
+
# bash scripts/init.sh
|
|
6
|
+
# bash scripts/init.sh --module java-spring
|
|
7
|
+
# bash scripts/init.sh --module java-spring --hooks
|
|
8
|
+
#
|
|
9
|
+
# What it does:
|
|
10
|
+
# 1. Copies framework files to .agent/ (commands, steps, hooks, rules, templates, modules)
|
|
11
|
+
# 2. Creates lightweight shortcut files in .claude/commands/ that delegate to .agent/
|
|
12
|
+
# 3. Writes .agent/FRAMEWORK_VERSION for upgrade.sh to track installed version
|
|
13
|
+
#
|
|
14
|
+
# After init:
|
|
15
|
+
# - Commit .agent/ to git so the entire team shares the framework
|
|
16
|
+
# - Run /setup-ai-first in Claude Code to complete project setup
|
|
17
|
+
# - To upgrade later: bash scripts/upgrade.sh
|
|
18
|
+
|
|
19
|
+
set -euo pipefail
|
|
20
|
+
|
|
21
|
+
echo ""
|
|
22
|
+
echo "╔══════════════════════════════════════════╗"
|
|
23
|
+
echo "║ Spec-Driven Dev — Project Init ║"
|
|
24
|
+
echo "╚══════════════════════════════════════════╝"
|
|
25
|
+
echo ""
|
|
26
|
+
|
|
27
|
+
# ── Prerequisite check ────────────────────────────────────────────────────────
|
|
28
|
+
|
|
29
|
+
if ! command -v node &> /dev/null; then
|
|
30
|
+
echo "❌ Node.js is required. Install from https://nodejs.org"
|
|
31
|
+
exit 1
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
# ── Run installer via npx ─────────────────────────────────────────────────────
|
|
35
|
+
|
|
36
|
+
echo "Running: npx @anhth2/spec-driven-dev --init $*"
|
|
37
|
+
echo ""
|
|
38
|
+
|
|
39
|
+
npx -y @anhth2/spec-driven-dev --init "$@"
|
|
40
|
+
|
|
41
|
+
echo ""
|
|
42
|
+
echo "✅ Init complete!"
|
|
43
|
+
echo ""
|
|
44
|
+
echo "Recommended next steps:"
|
|
45
|
+
echo " git add .agent/ .claude/commands/"
|
|
46
|
+
echo " git commit -m 'chore: init spec-driven-dev framework'"
|
|
47
|
+
echo ""
|
|
48
|
+
echo "Then open Claude Code and run: /setup-ai-first"
|
|
49
|
+
echo ""
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# upgrade.sh — Upgrade Spec-Driven Dev framework in an existing project.
|
|
3
|
+
#
|
|
4
|
+
# Usage:
|
|
5
|
+
# bash scripts/upgrade.sh
|
|
6
|
+
# bash scripts/upgrade.sh --module java-spring # also upgrade a stack module
|
|
7
|
+
#
|
|
8
|
+
# What it does:
|
|
9
|
+
# 1. Reads current installed version from .agent/FRAMEWORK_VERSION
|
|
10
|
+
# 2. Checks npm registry for the latest published version
|
|
11
|
+
# 3. If newer: runs npx @anhth2/spec-driven-dev@latest --init to update .agent/
|
|
12
|
+
# 4. Reports what changed so you can review before committing
|
|
13
|
+
#
|
|
14
|
+
# Requirements:
|
|
15
|
+
# - Project was set up with init.sh (or npx ... --init)
|
|
16
|
+
# - .agent/FRAMEWORK_VERSION exists
|
|
17
|
+
|
|
18
|
+
set -euo pipefail
|
|
19
|
+
|
|
20
|
+
AGENT_DIR=".agent"
|
|
21
|
+
VERSION_FILE="${AGENT_DIR}/FRAMEWORK_VERSION"
|
|
22
|
+
|
|
23
|
+
echo ""
|
|
24
|
+
echo "╔══════════════════════════════════════════╗"
|
|
25
|
+
echo "║ Spec-Driven Dev — Upgrade ║"
|
|
26
|
+
echo "╚══════════════════════════════════════════╝"
|
|
27
|
+
echo ""
|
|
28
|
+
|
|
29
|
+
# ── Prerequisite checks ───────────────────────────────────────────────────────
|
|
30
|
+
|
|
31
|
+
if ! command -v node &> /dev/null; then
|
|
32
|
+
echo "❌ Node.js is required. Install from https://nodejs.org"
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
if ! command -v npm &> /dev/null; then
|
|
37
|
+
echo "❌ npm is required. Install Node.js from https://nodejs.org"
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
if [ ! -f "$VERSION_FILE" ]; then
|
|
42
|
+
echo "❌ .agent/FRAMEWORK_VERSION not found."
|
|
43
|
+
echo ""
|
|
44
|
+
echo " This project was not set up with --init."
|
|
45
|
+
echo " To set up the new structure:"
|
|
46
|
+
echo ""
|
|
47
|
+
echo " bash scripts/init.sh"
|
|
48
|
+
echo " or:"
|
|
49
|
+
echo " npx @anhth2/spec-driven-dev --init"
|
|
50
|
+
echo ""
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
# ── Version comparison ────────────────────────────────────────────────────────
|
|
55
|
+
|
|
56
|
+
CURRENT=$(cat "$VERSION_FILE" | tr -d '[:space:]')
|
|
57
|
+
echo "Checking npm registry ..."
|
|
58
|
+
|
|
59
|
+
LATEST=$(npm view @anhth2/spec-driven-dev version 2>/dev/null || echo "unknown")
|
|
60
|
+
|
|
61
|
+
echo ""
|
|
62
|
+
echo " Installed : v${CURRENT}"
|
|
63
|
+
echo " Latest : v${LATEST}"
|
|
64
|
+
echo ""
|
|
65
|
+
|
|
66
|
+
if [ "$LATEST" = "unknown" ]; then
|
|
67
|
+
echo "⚠️ Could not reach npm registry. Check your internet connection."
|
|
68
|
+
exit 1
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
if [ "$CURRENT" = "$LATEST" ]; then
|
|
72
|
+
echo "✅ Already up to date (v${CURRENT}). Nothing to do."
|
|
73
|
+
echo ""
|
|
74
|
+
exit 0
|
|
75
|
+
fi
|
|
76
|
+
|
|
77
|
+
# ── Upgrade ───────────────────────────────────────────────────────────────────
|
|
78
|
+
|
|
79
|
+
echo "Upgrading v${CURRENT} → v${LATEST} ..."
|
|
80
|
+
echo ""
|
|
81
|
+
|
|
82
|
+
npx -y @anhth2/spec-driven-dev@latest --init "$@"
|
|
83
|
+
|
|
84
|
+
# ── Post-upgrade guidance ─────────────────────────────────────────────────────
|
|
85
|
+
|
|
86
|
+
echo ""
|
|
87
|
+
echo "✅ Upgraded to v${LATEST}!"
|
|
88
|
+
echo ""
|
|
89
|
+
echo "Review what changed in .agent/ before committing:"
|
|
90
|
+
echo ""
|
|
91
|
+
echo " git diff .agent/"
|
|
92
|
+
echo " git add .agent/"
|
|
93
|
+
echo " git commit -m 'chore: upgrade spec-driven-dev v${CURRENT} → v${LATEST}'"
|
|
94
|
+
echo ""
|