ai-workflow-init 1.2.3 → 1.3.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/.cursor/commands/check-implementation.md +4 -0
- package/.cursor/commands/code-review.md +13 -0
- package/.cursor/commands/create-plan.md +38 -13
- package/.cursor/commands/execute-plan.md +67 -30
- package/.cursor/commands/generate-standards.md +63 -27
- package/.cursor/commands/init-chat.md +10 -7
- package/.cursor/commands/writing-test.md +15 -7
- package/cli.js +76 -26
- package/docs/ai/implementation/feature-template.md +12 -2
- package/package.json +1 -1
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
Compare current implementation against planning and implementation notes.
|
|
2
2
|
|
|
3
|
+
## Workflow Alignment
|
|
4
|
+
- Provide brief status updates (1–3 sentences) before/after important actions.
|
|
5
|
+
- Provide a high-signal summary at completion highlighting key mismatches and next steps.
|
|
6
|
+
|
|
3
7
|
1) Ask me for:
|
|
4
8
|
- Feature name (if not provided)
|
|
5
9
|
- Then locate docs by feature name:
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
You are helping me perform a local code review **before** I push changes. This review is restricted to standards conformance only.
|
|
2
2
|
|
|
3
|
+
## Workflow Alignment
|
|
4
|
+
- Provide brief status updates (1–3 sentences) before/after important actions.
|
|
5
|
+
- Provide a high-signal summary at completion highlighting key findings and impact.
|
|
6
|
+
|
|
3
7
|
## Step 1: Gather Context (minimal)
|
|
4
8
|
- Ask for feature name if not provided (must be kebab-case).
|
|
5
9
|
- Then locate and read:
|
|
@@ -14,6 +18,15 @@ You are helping me perform a local code review **before** I push changes. This r
|
|
|
14
18
|
- **Do NOT** provide design opinions, performance guesses, or alternative architectures.
|
|
15
19
|
- **Do NOT** infer requirements beyond what standards explicitly state.
|
|
16
20
|
|
|
21
|
+
### Automated Checks (recommended)
|
|
22
|
+
- Detect tools from project config and run non-interactive checks:
|
|
23
|
+
- JS/TS: `npx eslint .` (or `pnpm eslint .`), consider `--max-warnings=0`; type checks with `npx tsc --noEmit`
|
|
24
|
+
- Python: `ruff .` or `flake8 .`; type checks with `mypy .` or `pyright`
|
|
25
|
+
- Go: `golangci-lint run` or `go vet ./...`
|
|
26
|
+
- Rust: `cargo clippy -- -D warnings`
|
|
27
|
+
- Java: `./gradlew check` or `mvn -q -DskipTests=false -Dspotbugs.failOnError=true verify`
|
|
28
|
+
- Use results to focus the review; still report only clear violations per standards.
|
|
29
|
+
|
|
17
30
|
## Step 3: File-by-File Review (standards violations only)
|
|
18
31
|
For every relevant file, report ONLY standards violations per the two docs above. Do not assess broader design or run git commands.
|
|
19
32
|
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
|
|
2
1
|
## Goal
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
Generate a planning doc at `docs/ai/planning/feature-{name}.md` using the template, with minimal, actionable content aligned to the 4-phase workflow. Also initialize the implementation doc at `docs/ai/implementation/feature-{name}.md` based on the implementation template.
|
|
4
|
+
|
|
5
|
+
## Workflow Alignment
|
|
6
|
+
|
|
7
|
+
- Provide brief status updates (1–3 sentences) before/after important actions.
|
|
8
|
+
- For medium/large tasks, create todos (≤14 words, verb-led). Keep only one `in_progress` item.
|
|
9
|
+
- Update todos immediately after progress; mark completed upon finish.
|
|
4
10
|
|
|
5
11
|
## Step 1: Clarify Scope (Focused Q&A Guidelines)
|
|
12
|
+
|
|
6
13
|
Purpose: the agent MUST generate a short, numbered Q&A for the user to clarify scope; keep it relevant, avoid off-topic, and do not build a static question bank.
|
|
7
14
|
|
|
8
15
|
Principles:
|
|
16
|
+
|
|
9
17
|
- Quickly classify context: a) Micro-UI, b) Page/Flow, c) Service/API/Data, d) Cross-cutting.
|
|
10
18
|
- Ask only what is missing to produce Goal, Tasks, Risks, and DoD. Keep to 3–7 questions.
|
|
11
19
|
- Do not re-ask what the user already stated; if ambiguous, confirm briefly (yes/no or single choice).
|
|
@@ -13,58 +21,75 @@ Principles:
|
|
|
13
21
|
- Answers may be a/b/c or free text; the agent is not required to present fixed option lists.
|
|
14
22
|
|
|
15
23
|
Output format for Q&A:
|
|
24
|
+
|
|
16
25
|
- Number questions sequentially starting at 1 (e.g., "1.", "2.").
|
|
17
26
|
- Under each question, provide 2–4 suggested options labeled with lowercase letters + ")" (e.g., "a)", "b)").
|
|
18
27
|
- Keep options short (≤7 words) and add an "other" when useful.
|
|
19
28
|
- Example:
|
|
20
29
|
1. UI library?
|
|
21
|
-
a) TailwindCSS
|
|
30
|
+
a) TailwindCSS b) Bootstrap c) SCSS d) Other
|
|
22
31
|
|
|
23
32
|
Scope checklist to cover (ask only missing items, based on context):
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
|
|
34
|
+
1. Problem & Users: the core problem and target user groups.
|
|
35
|
+
2. In-scope vs Out-of-scope: what is included and excluded (e.g., MVP, no i18n, no payments).
|
|
36
|
+
3. Acceptance Criteria (GWT): 2–3 key Given–When–Then scenarios.
|
|
37
|
+
4. Constraints & Dependencies: technical constraints, libraries, real API vs mock, deadlines, external deps.
|
|
38
|
+
5. Risks & Assumptions: known risks and key assumptions.
|
|
39
|
+
6. Tasks Overview: 3–7 high-level work items.
|
|
40
|
+
7. Definition of Done: completion criteria (build/test/docs/review).
|
|
31
41
|
|
|
32
42
|
Adaptive behavior:
|
|
43
|
+
|
|
33
44
|
- Always reduce questions to what is necessary; once Goal/Tasks/Risks/DoD can be written, stop asking.
|
|
34
45
|
- Prioritize clarifying scope and acceptance criteria before implementation details.
|
|
35
46
|
- If the user already specified items (framework, API/Mock, deadlines, etc.), confirm briefly only.
|
|
36
47
|
|
|
37
48
|
Then collect inputs (after Q&A):
|
|
49
|
+
|
|
38
50
|
- Feature name (kebab-case, e.g., `user-authentication`)
|
|
39
51
|
- Short goal and scope
|
|
40
52
|
- High-level tasks overview (3–7 items)
|
|
41
53
|
- Definition of Done (build/test/review/docs)
|
|
42
54
|
|
|
43
55
|
## Step 2: Load Templates
|
|
56
|
+
|
|
44
57
|
**Before creating docs, read the following files:**
|
|
58
|
+
|
|
45
59
|
- `docs/ai/planning/feature-template.md` - Template structure to follow
|
|
60
|
+
- `docs/ai/implementation/feature-template.md` - Template structure to follow for the implementation doc
|
|
46
61
|
|
|
47
62
|
This template defines the required structure and format. Use it as the baseline for creating the planning doc.
|
|
48
63
|
|
|
49
64
|
## Step 3: Draft the Plan (auto-generate)
|
|
65
|
+
|
|
50
66
|
Using the Q&A results and templates, immediately generate the plan without asking for confirmation.
|
|
51
67
|
|
|
52
68
|
Auto-name feature:
|
|
69
|
+
|
|
53
70
|
- Derive `feature-{name}` from user prompt + Q&A (kebab-case, concise, specific).
|
|
54
71
|
- Example: "Login Page (HTML/CSS)" → `feature-login-page`.
|
|
55
72
|
- If a file with the same name already exists, append a numeric suffix: `feature-{name}-2`, `feature-{name}-3`, ...
|
|
56
73
|
|
|
57
|
-
Create the following
|
|
74
|
+
Create the following files automatically and populate initial content:
|
|
75
|
+
|
|
58
76
|
- `docs/ai/planning/feature-{name}.md` - Use structure from `feature-template.md`
|
|
77
|
+
- `docs/ai/implementation/feature-{name}.md` - Use structure from `docs/ai/implementation/feature-template.md` (read this template before writing)
|
|
59
78
|
|
|
60
|
-
Do NOT create the implementation or testing files at this step.
|
|
61
79
|
Notify the user when done.
|
|
62
80
|
|
|
63
81
|
Produce a Markdown doc following the template structure:
|
|
82
|
+
|
|
64
83
|
- Match sections from `docs/ai/planning/feature-template.md`
|
|
65
84
|
- Fill in content from Q&A inputs
|
|
66
85
|
- Ensure all required sections are present
|
|
67
86
|
|
|
68
87
|
## Step 4: Next Actions
|
|
69
|
-
|
|
88
|
+
|
|
89
|
+
Suggest running `execute-plan` to begin task execution. Implementation work will be driven from `docs/ai/implementation/feature-{name}.md` as the task source.
|
|
70
90
|
Note: Test documentation will be created separately using the `writing-test` command.
|
|
91
|
+
|
|
92
|
+
## Notes
|
|
93
|
+
|
|
94
|
+
- This command creates the planning doc and initializes the implementation doc; it does not modify unrelated existing files.
|
|
95
|
+
- Idempotent: safe to re-run; auto-appends numeric suffix if files exist.
|
|
@@ -1,72 +1,109 @@
|
|
|
1
1
|
## Goal
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Execute the feature plan by implementing tasks from the implementation doc and persisting notes to docs.
|
|
4
|
+
|
|
5
|
+
## Workflow Alignment
|
|
6
|
+
|
|
7
|
+
- Provide brief status updates (1–3 sentences) before each operation.
|
|
8
|
+
- For medium/large tasks, create todos (≤14 words, verb-led). Keep only one `in_progress` item.
|
|
9
|
+
- Update todos immediately after progress; mark completed upon finish.
|
|
10
|
+
- Perform edits via file editing tools, not by printing code for copy-paste.
|
|
3
11
|
|
|
4
12
|
### Prerequisites
|
|
13
|
+
|
|
5
14
|
- Feature name (kebab-case, e.g., `user-authentication`)
|
|
6
|
-
-
|
|
15
|
+
- Implementation doc exists: `docs/ai/implementation/feature-{name}.md`
|
|
16
|
+
- Planning doc exists: `docs/ai/planning/feature-{name}.md` (reference only; tasks are driven by implementation doc)
|
|
7
17
|
|
|
8
18
|
## Step 1: Gather Context
|
|
19
|
+
|
|
9
20
|
- Ask for feature name if not provided (must be kebab-case).
|
|
10
|
-
- Load
|
|
21
|
+
- Load implementation doc: `docs/ai/implementation/feature-{name}.md`.
|
|
11
22
|
- **Load template:** Read `docs/ai/implementation/feature-template.md` to understand required structure.
|
|
12
|
-
- Ensure implementation doc exists or will be created: `docs/ai/implementation/feature-{name}.md`.
|
|
13
23
|
|
|
14
24
|
## Step 2: Build Task Queue
|
|
15
|
-
|
|
25
|
+
|
|
26
|
+
- Parse tasks (checkboxes `[ ]`, `[x]`) from the implementation doc:
|
|
27
|
+
- Primary source: `## Changes` section with `[ ] [ACTION] ...` entries.
|
|
28
|
+
- For `[MODIFIED]` files, parse sub-bullets representing distinct logic items with line ranges.
|
|
29
|
+
- Optionally include other `[ ]` sections (e.g., `## Follow-ups`) if designated in-scope.
|
|
16
30
|
- Build prioritized task queue (top-to-bottom unless dependencies block).
|
|
17
31
|
- Identify blocked tasks and note reasons.
|
|
18
32
|
|
|
19
33
|
## Step 3: Implement Iteratively (per task)
|
|
34
|
+
|
|
20
35
|
For each task in queue:
|
|
21
|
-
|
|
36
|
+
|
|
37
|
+
1. **Status update**: Brief note (1–3 sentences) on what will be done.
|
|
38
|
+
2. Plan minimal change set:
|
|
22
39
|
- Identify files/regions to modify
|
|
23
|
-
- Map changes to acceptance criteria from plan
|
|
24
|
-
|
|
25
|
-
- Write/edit code according to the
|
|
40
|
+
- Map changes to acceptance criteria from plan (reference if needed)
|
|
41
|
+
3. Implement changes:
|
|
42
|
+
- Write/edit code according to the implementation doc entries (`[ACTION]` items)
|
|
26
43
|
- Keep changes minimal and incremental
|
|
27
|
-
- Avoid speculative changes beyond
|
|
28
|
-
|
|
44
|
+
- Avoid speculative changes beyond implementation scope
|
|
45
|
+
4. Quick validation:
|
|
29
46
|
- Run build/compile if available
|
|
30
47
|
- Run fast unit/smoke tests if available
|
|
31
48
|
- Fix immediate issues before proceeding
|
|
32
|
-
|
|
49
|
+
5. Persist notes to implementation doc:
|
|
33
50
|
- File: `docs/ai/implementation/feature-{name}.md`
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
5. Update planning doc:
|
|
40
|
-
- Mark completed tasks `[x]` with brief note
|
|
51
|
+
- Update the relevant `[ ]` entry to `[x]` when completed
|
|
52
|
+
- For `MODIFIED` files with sub-bullets, mark each completed sub-bullet `[x]`
|
|
53
|
+
- Include line ranges and concise summaries as per template
|
|
54
|
+
6. Update implementation doc:
|
|
55
|
+
- Mark completed tasks `[x]` with brief notes
|
|
41
56
|
- Mark blocked tasks with reason
|
|
57
|
+
- Do not mirror completion state in the planning doc
|
|
42
58
|
|
|
43
59
|
## Step 4: Implementation Doc Structure
|
|
60
|
+
|
|
44
61
|
**Before creating the implementation doc, ensure you have read:**
|
|
62
|
+
|
|
45
63
|
- `docs/ai/implementation/feature-template.md` - Template structure to follow
|
|
46
64
|
|
|
47
|
-
If creating implementation doc for first task:
|
|
65
|
+
If creating implementation doc for the first task (should already exist from create-plan):
|
|
66
|
+
|
|
48
67
|
- Use the structure from `feature-template.md` exactly
|
|
49
|
-
-
|
|
68
|
+
- Ensure these sections exist:
|
|
50
69
|
- `# Implementation Notes: {Feature Name}`
|
|
51
70
|
- `## Summary` - Brief description of overall approach
|
|
52
|
-
- `## Changes`
|
|
71
|
+
- `## Changes` — Use `[ ] [ACTION] ...` format with allowed actions ADDED | MODIFIED | DELETED | RENAMED
|
|
72
|
+
- For MODIFIED, use sub-bullets with line ranges and per-logic summaries
|
|
53
73
|
- `## Edge Cases` - List of handled edge cases
|
|
54
74
|
- `## Follow-ups` - TODOs or deferred work
|
|
55
|
-
-
|
|
75
|
+
- `## Execution Discipline`
|
|
56
76
|
|
|
57
77
|
## Step 5: Quality Checks
|
|
78
|
+
|
|
58
79
|
After completing Step 4 for each task batch:
|
|
59
|
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
80
|
+
|
|
81
|
+
- Detect available tools from project config (e.g., `package.json`, `pyproject.toml`, `go.mod`, `Cargo.toml`, build files) and run the appropriate non-interactive checks.
|
|
82
|
+
- Linting on changed files (prefer non-interactive):
|
|
83
|
+
- JavaScript/TypeScript: `npx eslint .` or `pnpm eslint .` (add `--max-warnings=0` if desired)
|
|
84
|
+
- Python: `ruff .` or `flake8 .`
|
|
85
|
+
- Go: `golangci-lint run` or `go vet ./...`
|
|
86
|
+
- Rust: `cargo clippy -- -D warnings`
|
|
87
|
+
- Java: `./gradlew check` or `mvn -q -DskipTests=false -Dspotbugs.failOnError=true verify`
|
|
88
|
+
- Scope to changed files when possible for speed
|
|
89
|
+
- Type checks (non-emitting where applicable):
|
|
90
|
+
- TypeScript: `npx tsc --noEmit`
|
|
91
|
+
- Python: `mypy .` (if configured) or `pyright` if present
|
|
92
|
+
- Go/Rust/Java: rely on compiler/type system via build step
|
|
93
|
+
- Parallelize lint and type-check when safe; fix issues (up to 3 attempts) before proceeding.
|
|
62
94
|
|
|
63
95
|
## Step 6: Next Actions
|
|
96
|
+
|
|
64
97
|
After completing tasks:
|
|
98
|
+
|
|
65
99
|
- Suggest running `code-review` to verify against standards
|
|
66
100
|
- Suggest running `writing-test` if edge cases need coverage
|
|
67
|
-
- Suggest running `check-implementation` to validate alignment with
|
|
101
|
+
- Suggest running `check-implementation` to validate alignment with implementation entries
|
|
68
102
|
|
|
69
103
|
## Notes
|
|
70
|
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
104
|
+
|
|
105
|
+
- Keep code changes minimal and focused on implementation tasks
|
|
106
|
+
- Document all changes in the implementation doc; use checkboxes to track progress
|
|
107
|
+
- Avoid implementing features not in the implementation doc scope
|
|
108
|
+
- Modifies source code per implementation scope; updates `docs/ai/implementation/feature-{name}.md`. Does not modify unrelated files.
|
|
109
|
+
- Idempotent: safe to re-run; updates checkboxes deterministically.
|
|
@@ -1,19 +1,36 @@
|
|
|
1
1
|
## Goal
|
|
2
|
+
|
|
2
3
|
Generate or update `docs/ai/project/CODE_CONVENTIONS.md` and `PROJECT_STRUCTURE.md` from the current codebase with brief Q&A refinement.
|
|
3
4
|
|
|
4
|
-
## Step 1:
|
|
5
|
+
## Step 1: Detect Project Context
|
|
6
|
+
|
|
7
|
+
Detect project languages/frameworks/libraries from repository metadata:
|
|
8
|
+
|
|
9
|
+
- Analyze `package.json`, `pyproject.toml`, lockfiles, config files
|
|
10
|
+
- Identify primary languages (JavaScript/TypeScript, Python, etc.)
|
|
11
|
+
- Identify frameworks (React, Vue, Angular, etc.)
|
|
12
|
+
- Identify libraries and tooling (ESLint, Prettier, testing frameworks, etc.)
|
|
13
|
+
- Note any build tools or bundlers in use
|
|
14
|
+
|
|
15
|
+
**Output**: The detected project context will be written to `CODE_CONVENTIONS.md` as the foundation for code conventions.
|
|
16
|
+
|
|
17
|
+
## Step 2: Clarify Scope (3–6 questions max)
|
|
18
|
+
|
|
5
19
|
Quick classification and targeted questions:
|
|
20
|
+
|
|
6
21
|
- Languages/frameworks detected: confirm correct? (a/b/other)
|
|
7
|
-
- Import/style tools in use: (a) ESLint/Prettier
|
|
8
|
-
- Test placement preference: (a) Colocated `*.spec.*`
|
|
9
|
-
- Error handling strategy: (a) Exceptions/try-catch
|
|
10
|
-
- Module organization: (a) By feature
|
|
22
|
+
- Import/style tools in use: (a) ESLint/Prettier (b) Other formatter (c) None
|
|
23
|
+
- Test placement preference: (a) Colocated `*.spec.*` (b) `__tests__/` directory (c) Other
|
|
24
|
+
- Error handling strategy: (a) Exceptions/try-catch (b) Result types (c) Other
|
|
25
|
+
- Module organization: (a) By feature (b) By layer (c) Mixed
|
|
11
26
|
- Any performance/security constraints to encode? (yes/no, brief)
|
|
12
27
|
|
|
13
28
|
Keep questions short and single-purpose. Stop once sufficient info gathered.
|
|
14
29
|
|
|
15
|
-
## Step
|
|
30
|
+
## Step 3: Auto-Discovery
|
|
31
|
+
|
|
16
32
|
Analyze repository to infer:
|
|
33
|
+
|
|
17
34
|
- Dominant naming patterns:
|
|
18
35
|
- Variables/functions: camelCase/PascalCase/snake_case
|
|
19
36
|
- Classes/types: PascalCase
|
|
@@ -33,16 +50,26 @@ Analyze repository to infer:
|
|
|
33
50
|
- Strategy patterns
|
|
34
51
|
- Other architectural patterns
|
|
35
52
|
|
|
36
|
-
## Step
|
|
53
|
+
## Step 4: Draft Standards
|
|
54
|
+
|
|
37
55
|
Generate two documents (with template preload):
|
|
38
56
|
|
|
39
57
|
### CODE_CONVENTIONS.md
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
58
|
+
|
|
59
|
+
- Template preload (flexible matching based on detected project context):
|
|
60
|
+
|
|
61
|
+
1. Read all files in `docs/ai/project/template-convention/` directory
|
|
62
|
+
2. For each template file, determine if it matches the detected project context:
|
|
63
|
+
- Match by language (e.g., `javascript.md`, `typescript.md`, `python.md`)
|
|
64
|
+
- Match by framework (e.g., `react.md`, `vue.md`, `angular.md`)
|
|
65
|
+
- Match by common patterns (e.g., `common.md` — always include if present)
|
|
66
|
+
3. Load and merge all matching templates in a logical order:
|
|
67
|
+
- `common.md` first (if present)
|
|
68
|
+
- Language-specific templates (e.g., `javascript.md`, `typescript.md`)
|
|
69
|
+
- Framework-specific templates (e.g., `react.md`, `vue.md`)
|
|
70
|
+
- Other relevant templates based on detected tooling/patterns
|
|
71
|
+
4. These templates take precedence and should appear at the top of the generated document, followed by auto-discovered rules from codebase analysis.
|
|
72
|
+
|
|
46
73
|
- Naming conventions (variables, functions, classes, constants)
|
|
47
74
|
- Import order and grouping
|
|
48
75
|
- Formatting tools (ESLint/Prettier/etc.) if detected
|
|
@@ -53,6 +80,7 @@ Generate two documents (with template preload):
|
|
|
53
80
|
- Async/await patterns if applicable
|
|
54
81
|
|
|
55
82
|
### PROJECT_STRUCTURE.md
|
|
83
|
+
|
|
56
84
|
- Folder layout summary:
|
|
57
85
|
- `src/`: source code organization
|
|
58
86
|
- `docs/ai/**`: documentation structure
|
|
@@ -61,7 +89,8 @@ Generate two documents (with template preload):
|
|
|
61
89
|
- Test placement and naming conventions
|
|
62
90
|
- Config/secrets handling summary
|
|
63
91
|
|
|
64
|
-
## Step
|
|
92
|
+
## Step 5: Persist (Update-in-place, Non-destructive)
|
|
93
|
+
|
|
65
94
|
- Target files:
|
|
66
95
|
- `docs/ai/project/CODE_CONVENTIONS.md`
|
|
67
96
|
- `docs/ai/project/PROJECT_STRUCTURE.md`
|
|
@@ -69,12 +98,15 @@ Generate two documents (with template preload):
|
|
|
69
98
|
- Do NOT blindly overwrite entire files. Update only the managed blocks using markers:
|
|
70
99
|
|
|
71
100
|
### Managed Block Markers
|
|
101
|
+
|
|
72
102
|
Use these exact markers to wrap generated content:
|
|
103
|
+
|
|
73
104
|
```
|
|
74
105
|
<!-- GENERATED: CODE_CONVENTIONS:START -->
|
|
75
106
|
... generated content ...
|
|
76
107
|
<!-- GENERATED: CODE_CONVENTIONS:END -->
|
|
77
108
|
```
|
|
109
|
+
|
|
78
110
|
```
|
|
79
111
|
<!-- GENERATED: PROJECT_STRUCTURE:START -->
|
|
80
112
|
... generated content ...
|
|
@@ -82,25 +114,29 @@ Use these exact markers to wrap generated content:
|
|
|
82
114
|
```
|
|
83
115
|
|
|
84
116
|
### Update Rules
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
117
|
+
|
|
118
|
+
1. If the target file exists and contains the corresponding markers, replace only the content between START/END with the newly generated content.
|
|
119
|
+
2. If the file exists but does not contain markers, append a new managed block to the end of the file (preserve all existing manual content).
|
|
120
|
+
3. If the file does not exist, create it with the header note and a single managed block.
|
|
121
|
+
4. Never modify content outside the managed blocks.
|
|
89
122
|
|
|
90
123
|
### Generated Content Order (for CODE_CONVENTIONS)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
-
|
|
97
|
-
|
|
98
|
-
|
|
124
|
+
|
|
125
|
+
1. **Project Context Section**: Write the detected project context from Step 1 (languages, frameworks, libraries, tooling)
|
|
126
|
+
2. **Template Rules Section**: Merge all matching templates from `docs/ai/project/template-convention/` directory:
|
|
127
|
+
- Read all files in the directory
|
|
128
|
+
- Filter templates that match the detected project context (by language, framework, or common patterns)
|
|
129
|
+
- Merge in logical order: common → language → framework → tooling-specific
|
|
130
|
+
3. **Auto-Discovered Rules Section**: Append auto-discovered rules from codebase analysis (Step 3)
|
|
131
|
+
4. **Project-Specific Rules Section**: Include any project-specific conventions from Q&A (Step 2)
|
|
132
|
+
|
|
133
|
+
## Step 6: Next Actions
|
|
134
|
+
|
|
99
135
|
- Suggest running `code-review` to validate new standards are being followed
|
|
100
136
|
- Inform user they can manually edit these files anytime
|
|
101
137
|
|
|
102
138
|
## Notes
|
|
139
|
+
|
|
103
140
|
- Focus on patterns actually present in codebase, not ideal patterns
|
|
104
141
|
- Keep generated docs concise and actionable
|
|
105
142
|
- User can refine standards manually after generation
|
|
106
|
-
|
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
## Goal
|
|
2
|
+
|
|
2
3
|
Initialize a new chat by loading and aligning to `AGENTS.md` so the AI agent consistently follows project rules (workflow, tooling, communication, language mirroring) from the first message.
|
|
3
4
|
|
|
4
5
|
## What this command does
|
|
6
|
+
|
|
5
7
|
1. Read `AGENTS.md` and extract the actionable rules.
|
|
6
8
|
2. Summarize responsibilities and constraints the agent must follow in this session.
|
|
7
9
|
3. Confirm language-mirroring: respond in the user's chat language; default to English if the user's language is unclear or ambiguous.
|
|
8
10
|
4. Acknowledge the 4-phase workflow and TODO discipline for future commands.
|
|
9
11
|
|
|
10
12
|
## Steps
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
|
|
14
|
+
1. Open and read `AGENTS.md` (project root).
|
|
15
|
+
2. Read `docs/ai/project/CODE_CONVENTIONS.md` and `docs/ai/project/PROJECT_STRUCTURE.md` if they exist in the repository.
|
|
16
|
+
3. Produce a short confirmation in the chat including:
|
|
15
17
|
- Workflow alignment: Plan → Implement → Test → Review
|
|
16
18
|
- Tooling strategy: semantic search first; parallelize independent steps
|
|
17
19
|
- Communication: minimal Markdown; status updates; high-signal summaries; mirror user language (default English if unclear)
|
|
18
20
|
- Code presentation: code references for existing code; fenced blocks for new code
|
|
19
21
|
- TODO policy: create/update todos; keep only one `in_progress`
|
|
20
|
-
|
|
22
|
+
4. If any section is missing or unclear, ask a single concise clarification question; otherwise proceed silently in future commands.
|
|
21
23
|
|
|
22
24
|
## Output format (concise)
|
|
25
|
+
|
|
23
26
|
- Use the language of the triggering user message (mirror). If ambiguous, use English.
|
|
24
27
|
- One short paragraph confirming alignment + a 4–6 bullet checklist of the above items.
|
|
25
28
|
- No code unless strictly needed.
|
|
26
29
|
|
|
27
30
|
## Notes
|
|
28
|
-
- This command is idempotent—safe to re-run at the start of any chat.
|
|
29
|
-
- It does not modify files; it only sets expectations for subsequent commands.
|
|
30
31
|
|
|
32
|
+
- This command is idempotent—safe to re-run at the start of any chat.
|
|
33
|
+
- It does not modify existing files; it only sets expectations for subsequent commands.
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
Use `docs/ai/testing/feature-{name}.md` as the source of truth.
|
|
2
2
|
|
|
3
|
+
## Workflow Alignment
|
|
4
|
+
- Provide brief status updates (1–3 sentences) before/after important actions.
|
|
5
|
+
- For medium/large tasks, create todos (≤14 words, verb-led). Keep only one `in_progress` item.
|
|
6
|
+
- Update todos immediately after progress; mark completed upon finish.
|
|
7
|
+
- Default to parallel execution for independent operations; use sequential steps only when dependencies exist.
|
|
8
|
+
|
|
3
9
|
## Step 1: Gather Context (minimal)
|
|
4
10
|
- Ask for feature name if not provided (must be kebab-case).
|
|
5
11
|
- **Load template:** Read `docs/ai/testing/feature-template.md` to understand required structure.
|
|
6
12
|
- Then locate docs by convention:
|
|
7
13
|
- Planning: `docs/ai/planning/feature-{name}.md`
|
|
8
14
|
- Implementation (optional): `docs/ai/implementation/feature-{name}.md`
|
|
9
|
-
- **Detect test framework:** Check `package.json` and project structure to identify test framework (Vitest, Jest, Mocha, pytest, etc.)
|
|
15
|
+
- **Detect test framework:** Check `package.json` and project structure to identify test framework (Vitest, Jest, Mocha, pytest, etc.). Auto-detect from `package.json` first; if no test runner found, create skeleton test and report missing runner.
|
|
10
16
|
- **Load standards:** Read `docs/ai/project/PROJECT_STRUCTURE.md` for test file placement rules
|
|
11
17
|
- **Load conventions:** Read `docs/ai/project/CODE_CONVENTIONS.md` for coding standards
|
|
12
18
|
|
|
@@ -115,12 +121,12 @@ describe('functionToTest', () => {
|
|
|
115
121
|
## Step 5: Run Tests with Logging (automatic)
|
|
116
122
|
After generating test code:
|
|
117
123
|
|
|
118
|
-
1. **Execute test command** based on detected framework:
|
|
119
|
-
- Vitest: `npm test` or `npx vitest run`
|
|
120
|
-
- Jest: `npm test` or `npx jest`
|
|
121
|
-
- Mocha: `npm test` or `npx mocha`
|
|
122
|
-
- pytest: `pytest` or `python -m pytest`
|
|
123
|
-
- Other: detect from `package.json` scripts
|
|
124
|
+
1. **Execute test command** based on detected framework (use non-interactive flags):
|
|
125
|
+
- Vitest: `npm test` or `npx vitest run --run`
|
|
126
|
+
- Jest: `npm test` or `npx jest --ci`
|
|
127
|
+
- Mocha: `npm test` or `npx mocha --reporter spec`
|
|
128
|
+
- pytest: `pytest` or `python -m pytest -v`
|
|
129
|
+
- Other: detect from `package.json` scripts, add `--no-interactive` or equivalent flags
|
|
124
130
|
|
|
125
131
|
2. **Capture and display output** in terminal with detailed logging:
|
|
126
132
|
- Show test execution progress (which tests are running)
|
|
@@ -214,3 +220,5 @@ Ensure all required sections from template are present. Keep the document brief
|
|
|
214
220
|
- Test execution must show clear, detailed logging in terminal
|
|
215
221
|
- AI excels at: edge case generation, parameter combinations, property-based testing, coverage analysis
|
|
216
222
|
- Keep tests deterministic (avoid external dependencies, random values without seeds, time-dependent logic)
|
|
223
|
+
- Creates test files only; does not edit non-test source files.
|
|
224
|
+
- Idempotent: safe to re-run; appends entries or updates test doc deterministically.
|
package/cli.js
CHANGED
|
@@ -1,48 +1,98 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const { execSync } = require(
|
|
4
|
-
const { existsSync, mkdirSync } = require(
|
|
3
|
+
const { execSync } = require("child_process");
|
|
4
|
+
const { existsSync, mkdirSync } = require("fs");
|
|
5
|
+
const readline = require("readline");
|
|
5
6
|
|
|
6
7
|
// Repo workflow gốc của bạn
|
|
7
|
-
const REPO =
|
|
8
|
-
const RAW_BASE =
|
|
8
|
+
const REPO = "phananhtuan09/ai-agent-workflow";
|
|
9
|
+
const RAW_BASE =
|
|
10
|
+
"https://raw.githubusercontent.com/phananhtuan09/ai-agent-workflow/main";
|
|
9
11
|
|
|
10
12
|
// In ra helper log
|
|
11
13
|
function step(msg) {
|
|
12
|
-
console.log(
|
|
14
|
+
console.log("\x1b[36m%s\x1b[0m", msg); // cyan
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
function run(cmd) {
|
|
16
18
|
try {
|
|
17
|
-
execSync(cmd, { stdio:
|
|
19
|
+
execSync(cmd, { stdio: "inherit" });
|
|
18
20
|
} catch (e) {
|
|
19
|
-
console.error(
|
|
21
|
+
console.error("❌ Failed:", cmd);
|
|
20
22
|
process.exit(1);
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
// Hỏi user chọn IDE
|
|
27
|
+
const rl = readline.createInterface({
|
|
28
|
+
input: process.stdin,
|
|
29
|
+
output: process.stdout,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
function askIDE() {
|
|
33
|
+
return new Promise((resolve) => {
|
|
34
|
+
console.log("\n🤖 Which AI tool(s) do you want to setup?");
|
|
35
|
+
console.log("1. Cursor");
|
|
36
|
+
console.log("2. GitHub Copilot");
|
|
37
|
+
console.log("3. Both");
|
|
38
|
+
|
|
39
|
+
rl.question("\nEnter your choice (1-3): ", (answer) => {
|
|
40
|
+
rl.close();
|
|
41
|
+
resolve(answer.trim());
|
|
42
|
+
});
|
|
43
|
+
});
|
|
30
44
|
}
|
|
31
45
|
|
|
32
|
-
|
|
33
|
-
|
|
46
|
+
async function main() {
|
|
47
|
+
const choice = await askIDE();
|
|
48
|
+
const installCursor = ["1", "3"].includes(choice);
|
|
49
|
+
const installCopilot = ["2", "3"].includes(choice);
|
|
50
|
+
|
|
51
|
+
if (!["1", "2", "3"].includes(choice)) {
|
|
52
|
+
console.error("❌ Invalid choice. Please enter 1, 2, or 3.");
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Kiểm tra và tạo folder nếu chưa có
|
|
57
|
+
if (!existsSync("docs/ai")) {
|
|
58
|
+
mkdirSync("docs/ai", { recursive: true });
|
|
59
|
+
}
|
|
34
60
|
|
|
35
|
-
step(
|
|
36
|
-
run(`npx degit ${REPO}
|
|
61
|
+
step("🚚 Downloading workflow template (docs/ai)...");
|
|
62
|
+
run(`npx degit ${REPO}/docs/ai docs/ai --force`);
|
|
63
|
+
|
|
64
|
+
// Clone Cursor commands
|
|
65
|
+
if (installCursor) {
|
|
66
|
+
if (!existsSync(".cursor/commands")) {
|
|
67
|
+
mkdirSync(".cursor/commands", { recursive: true });
|
|
68
|
+
}
|
|
69
|
+
step("🚚 Downloading Cursor agent commands (.cursor/commands)...");
|
|
70
|
+
run(`npx degit ${REPO}/.cursor/commands .cursor/commands --force`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Clone GitHub Copilot commands (nếu có folder khác)
|
|
74
|
+
if (installCopilot) {
|
|
75
|
+
if (!existsSync(".copilot/commands")) {
|
|
76
|
+
mkdirSync(".copilot/commands", { recursive: true });
|
|
77
|
+
}
|
|
78
|
+
step("🚚 Downloading GitHub Copilot agent commands (.copilot/commands)...");
|
|
79
|
+
run(`npx degit ${REPO}/.copilot/commands .copilot/commands --force`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
step("🚚 Downloading AGENTS.md ...");
|
|
83
|
+
try {
|
|
84
|
+
run(`curl -fsSL ${RAW_BASE}/AGENTS.md -o AGENTS.md`);
|
|
85
|
+
} catch (_) {
|
|
86
|
+
// Fallback cho môi trường không có curl
|
|
87
|
+
run(`wget -qO AGENTS.md ${RAW_BASE}/AGENTS.md`);
|
|
88
|
+
}
|
|
37
89
|
|
|
38
|
-
step(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
run(`wget -qO AGENTS.md ${RAW_BASE}/AGENTS.md`);
|
|
90
|
+
step(
|
|
91
|
+
"✅ All AI workflow docs and selected command templates have been copied!"
|
|
92
|
+
);
|
|
93
|
+
console.log(
|
|
94
|
+
"\n🌱 You can now use your AI workflow! Edit docs/ai/ and AGENTS.md as needed.\n"
|
|
95
|
+
);
|
|
45
96
|
}
|
|
46
97
|
|
|
47
|
-
|
|
48
|
-
console.log('\n🌱 You can now use your AI workflow! Edit docs/ai/ and AGENTS.md as needed.\n');
|
|
98
|
+
main();
|
|
@@ -3,19 +3,29 @@
|
|
|
3
3
|
Note: All content in this document must be written in English.
|
|
4
4
|
|
|
5
5
|
## Summary
|
|
6
|
+
|
|
6
7
|
- Short description of the solution approach
|
|
7
8
|
|
|
8
9
|
## Changes
|
|
9
|
-
|
|
10
|
-
-
|
|
10
|
+
|
|
11
|
+
- [ ] [ACTION] path/to/file (lines: x–y) — Summary of change
|
|
12
|
+
- [ ] [ACTION] path/to/file (lines: a–b) — Summary of change
|
|
13
|
+
|
|
14
|
+
Notes:
|
|
15
|
+
|
|
16
|
+
- ACTION must be one of: ADDED | MODIFIED | DELETED | RENAMED
|
|
17
|
+
- For MODIFIED files, use sub-bullets for each distinct logic change and include line ranges.
|
|
11
18
|
|
|
12
19
|
## Edge Cases
|
|
20
|
+
|
|
13
21
|
- List of handled edge cases
|
|
14
22
|
|
|
15
23
|
## Follow-ups
|
|
24
|
+
|
|
16
25
|
- TODOs or deferred work
|
|
17
26
|
|
|
18
27
|
## Execution Discipline
|
|
28
|
+
|
|
19
29
|
- Before each edit, provide a short status update describing the next action (1–3 sentences).
|
|
20
30
|
- Perform edits via file editing tools; avoid printing large code blocks for copy-paste.
|
|
21
31
|
- After each batch of edits, run linter/type/build on changed files; auto-fix issues (up to 3 attempts) before requesting review.
|