ai-workflow-init 1.1.2 → 1.2.1

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.
@@ -34,9 +34,15 @@ Analyze repository to infer:
34
34
  - Other architectural patterns
35
35
 
36
36
  ## Step 3: Draft Standards
37
- Generate two documents:
37
+ Generate two documents (with template preload):
38
38
 
39
39
  ### CODE_CONVENTIONS.md
40
+ - Template preload (in order, if present):
41
+ 1) `docs/ai/project/template-convention/common.md` — always preload first.
42
+ 2) `docs/ai/project/template-convention/javascript.md` — preload if the repository primarily uses JavaScript/TypeScript.
43
+ 3) `docs/ai/project/template-convention/react.md` — preload if the repository uses React (detect via dependencies like `react`, file patterns like `.jsx/.tsx`, or imports from `react`).
44
+
45
+ These templates take precedence and should appear at the top of the generated document, followed by auto-discovered rules.
40
46
  - Naming conventions (variables, functions, classes, constants)
41
47
  - Import order and grouping
42
48
  - Formatting tools (ESLint/Prettier/etc.) if detected
@@ -55,11 +61,38 @@ Generate two documents:
55
61
  - Test placement and naming conventions
56
62
  - Config/secrets handling summary
57
63
 
58
- ## Step 4: Persist
59
- - Overwrite or create:
64
+ ## Step 4: Persist (Update-in-place, Non-destructive)
65
+ - Target files:
60
66
  - `docs/ai/project/CODE_CONVENTIONS.md`
61
67
  - `docs/ai/project/PROJECT_STRUCTURE.md`
62
68
  - Add header note: "This document is auto-generated from codebase analysis + brief Q&A. Edit manually as needed."
69
+ - Do NOT blindly overwrite entire files. Update only the managed blocks using markers:
70
+
71
+ ### Managed Block Markers
72
+ Use these exact markers to wrap generated content:
73
+ ```
74
+ <!-- GENERATED: CODE_CONVENTIONS:START -->
75
+ ... generated content ...
76
+ <!-- GENERATED: CODE_CONVENTIONS:END -->
77
+ ```
78
+ ```
79
+ <!-- GENERATED: PROJECT_STRUCTURE:START -->
80
+ ... generated content ...
81
+ <!-- GENERATED: PROJECT_STRUCTURE:END -->
82
+ ```
83
+
84
+ ### Update Rules
85
+ 1) If the target file exists and contains the corresponding markers, replace only the content between START/END with the newly generated content.
86
+ 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).
87
+ 3) If the file does not exist, create it with the header note and a single managed block.
88
+ 4) Never modify content outside the managed blocks.
89
+
90
+ ### Generated Content Order (for CODE_CONVENTIONS)
91
+ - Merge templates in preload order (when present):
92
+ 1) `docs/ai/project/template-convention/common.md`
93
+ 2) `docs/ai/project/template-convention/javascript.md` (when JS/TS repo)
94
+ 3) `docs/ai/project/template-convention/react.md` (when React is detected)
95
+ - After the merged templates, append auto-discovered rules from the codebase analysis.
63
96
 
64
97
  ## Step 5: Next Actions
65
98
  - Suggest running `code-review` to validate new standards are being followed
@@ -0,0 +1,28 @@
1
+ ## Goal
2
+ 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
+ ## What this command does
5
+ 1. Read `AGENTS.md` and extract the actionable rules.
6
+ 2. Summarize responsibilities and constraints the agent must follow in this session.
7
+ 3. Confirm language-mirroring: respond in the user's chat language; default to English if the user's language is unclear or ambiguous.
8
+ 4. Acknowledge the 4-phase workflow and TODO discipline for future commands.
9
+
10
+ ## Steps
11
+ 1) Open and read `AGENTS.md` (project root).
12
+ 2) Produce a short confirmation in the chat including:
13
+ - Workflow alignment: Plan → Implement → Test → Review
14
+ - Tooling strategy: semantic search first; parallelize independent steps
15
+ - Communication: minimal Markdown; status updates; high-signal summaries; mirror user language (default English if unclear)
16
+ - Code presentation: code references for existing code; fenced blocks for new code
17
+ - TODO policy: create/update todos; keep only one `in_progress`
18
+ 3) If any section is missing or unclear, ask a single concise clarification question; otherwise proceed silently in future commands.
19
+
20
+ ## Output format (concise)
21
+ - Use the language of the triggering user message (mirror). If ambiguous, use English.
22
+ - One short paragraph confirming alignment + a 4–6 bullet checklist of the above items.
23
+ - No code unless strictly needed.
24
+
25
+ ## Notes
26
+ - This command is idempotent—safe to re-run at the start of any chat.
27
+ - It does not modify files; it only sets expectations for subsequent commands.
28
+
package/AGENTS.md CHANGED
@@ -1,21 +1,24 @@
1
- # AI DevKit Rules (Personal Workflow)
1
+ # AI Agent Guidelines
2
2
 
3
- ## Documentation Structure
4
- - `docs/ai/project/` Project docs (PROJECT_STRUCTURE, CODE_CONVENTIONS, patterns)
5
- - `docs/ai/planning/` Feature plans (`feature-{name}.md`)
6
- - `docs/ai/implementation/` Implementation notes per feature (`feature-{name}.md`)
7
- - `docs/ai/testing/` Test plans per feature (`feature-{name}.md`)
3
+ ## Workflow alignment (Plan → Implement → Test → Review)
4
+ - Plan: Before coding, create a feature execution checklist (todo) from the plan. Do not start Implementation until the todo list exists and is agreed.
5
+ - Implementation: Before each operation, write a short status update (1–3 sentences). Perform edits via file editing tools, not by printing code for copy-paste.
6
+ - Testing: After each batch of edits, run linter/typing/build on the changed files; auto-fix issues (up to 3 attempts) before asking for help.
7
+ - Review: When todos are completed and checks pass, provide a concise summary highlighting key changes and their impact.
8
8
 
9
- ## Development Workflow (4 phases)
10
- 1. Plan: define goals, scope, and acceptance criteria
11
- 2. Implementation: code against acceptance criteria, small and shippable changes
12
- 3. Testing: cover main flows and critical edges
13
- 4. Review: self-review + tool-assisted review, then ship
9
+ ## Tooling strategy
10
+ - Prefer semantic search across the codebase; use grep only for exact matches.
11
+ - Default to parallel execution for independent operations; use sequential steps only when dependencies exist.
14
12
 
15
- ## Code Style & Standards
16
- - Follow `docs/ai/project/CODE_CONVENTIONS.md`
17
- - Use clear names and keep comments focused on non-obvious logic
13
+ ## Communication
14
+ - Use Markdown only when necessary; use backticks for `files/dirs/functions/classes`.
15
+ - Provide status updates before/after important actions; provide a high-signal summary at completion.
16
+ - Mirror the user's chat language in responses (respond in the user's language); default to English if the user's language is unclear or ambiguous.
18
17
 
19
- ## AI Interaction Guidelines
20
- - Reference the active feature docs in planning/implementation/testing
21
- - Keep docs concise and aligned with actual work
18
+ ## Code presentation
19
+ - Existing code: cite using a code reference block with `startLine:endLine:filepath` (no language tag).
20
+ - New code: use fenced code blocks with a language tag, no line numbers, no extra leading indentation.
21
+
22
+ ## TODO policy
23
+ - For medium/large tasks, create todos (≤14 words, verb-led). Keep only one `in_progress` item.
24
+ - Update the todo list immediately after progress; mark completed and close upon finish.
@@ -33,6 +33,11 @@ Implementation docs serve as:
33
33
  - **Review reference**: For code-review and check-implementation commands
34
34
  - **Refactor guide**: Understanding what was done for future improvements
35
35
 
36
+ ### Execution Discipline
37
+ - Provide a short status update before each meaningful action (1–3 sentences).
38
+ - Perform edits via file editing tools; avoid printing large code for copy-paste.
39
+ - After each batch of edits, run linter/type/build on changed files; auto-fix issues (up to 3 attempts) before requesting review.
40
+
36
41
  ## Template Reference
37
42
  See `feature-template.md` for the exact structure required for implementation notes.
38
43
 
@@ -12,3 +12,8 @@
12
12
 
13
13
  ## Follow-ups
14
14
  - TODOs or deferred work
15
+
16
+ ## Execution Discipline
17
+ - Before each edit, provide a short status update describing the next action (1–3 sentences).
18
+ - Perform edits via file editing tools; avoid printing large code blocks for copy-paste.
19
+ - After each batch of edits, run linter/type/build on changed files; auto-fix issues (up to 3 attempts) before requesting review.
@@ -24,6 +24,10 @@ Each feature plan follows the template structure:
24
24
  - **Risks/Assumptions**: Key risks and assumptions
25
25
  - **Metrics / Definition of Done**: Completion criteria (build/test/review/docs)
26
26
 
27
+ ### From Plan to Execution (Todos)
28
+ - After the plan is written, generate an execution todo checklist from the plan.
29
+ - Do not start Implementation until the todo list exists and is agreed.
30
+
27
31
  ### Feature Plan Naming Convention
28
32
  - Format: `feature-{name}.md` (kebab-case)
29
33
  - Example: `feature-user-authentication.md`
@@ -3,6 +3,11 @@
3
3
  ## Goal
4
4
  - Objectives, scope, acceptance criteria (Given-When-Then)
5
5
 
6
+ ### Acceptance Criteria (Given/When/Then)
7
+ - Given ...
8
+ - When ...
9
+ - Then ...
10
+
6
11
  ## Tasks (overview)
7
12
  - [ ] Task 1
8
13
  - [ ] Task 2
@@ -11,5 +16,13 @@
11
16
  ## Risks/Assumptions
12
17
  - Key risks / assumptions
13
18
 
19
+ ## Observability
20
+ - Logging requirements:
21
+ - Metrics/telemetry:
22
+
14
23
  ## Metrics / Definition of Done
15
24
  - Build green, tests added, review passed, docs updated
25
+
26
+ ## Execution Checklist (Todo)
27
+ - Before starting implementation, generate a todo checklist from this plan.
28
+ - Do not start coding until the todo list exists and is agreed.
@@ -1,31 +1,10 @@
1
1
  # Code Conventions
2
2
 
3
- > This document can be auto-generated via `generate-standards`. Edit manually as needed.
3
+ This document is auto-generated by the `generate-standards` command.
4
4
 
5
- ## Naming
6
- - camelCase: variables, functions
7
- - PascalCase: classes, types
8
- - CONSTANT_CASE: constants
5
+ Do not edit manually. To influence the generated content, edit the preload templates instead:
6
+ - `docs/ai/project/template-convention/common.md` (always loaded first)
7
+ - `docs/ai/project/template-convention/javascript.md` (loaded if JS/TS repo)
8
+ - `docs/ai/project/template-convention/react.md` (loaded if React is detected)
9
9
 
10
- ## Structure
11
- - One primary concept per file
12
- - Prefer functions < 50 lines; refactor into helpers when needed
13
-
14
- ## Error Handling & Logging
15
- - Throw errors with clear messages
16
- - Use appropriate log levels: debug/info/warn/error
17
-
18
- ## Tests
19
- - Write unit tests first; add integration tests when necessary
20
- - Test names should describe behavior
21
-
22
- ## Comments
23
- - Only for complex logic or non-obvious decisions
24
-
25
- ## Guiding Questions (for AI regeneration)
26
- - What languages/frameworks are used, and do they impose naming/structure patterns?
27
- - What are the preferred file/module boundaries for this project?
28
- - What error handling strategy is standard (exceptions vs result types), and logging levels?
29
- - What is the minimum test level required per change (unit/integration/E2E)?
30
- - Are there performance/security constraints that influence coding style?
31
- - Any repository-wide conventions (imports order, lint rules, formatting tools)?
10
+ The generator merges the above templates (when present) and then appends auto-discovered rules from the codebase.
@@ -17,6 +17,12 @@
17
17
  - Import/module conventions
18
18
  - Config & secrets handling (if applicable)
19
19
 
20
+ ## AI Docs Roles (existing only)
21
+ - `docs/ai/project/`: repository-wide conventions and structure; workflow overview and navigation live in `README.md`.
22
+ - `docs/ai/planning/`: feature plans using `feature-template.md` with Acceptance Criteria; plans should drive a todo checklist before coding.
23
+ - `docs/ai/implementation/`: per-feature implementation notes tracking what changed and why.
24
+ - `docs/ai/testing/`: per-feature test plans and results; include quality checks and coverage targets.
25
+
20
26
  ## Guiding Questions (for AI regeneration)
21
27
  - How is the codebase organized by domain/feature vs layers?
22
28
  - What are the module boundaries and dependency directions to preserve?
@@ -41,11 +41,17 @@ Both files can be edited manually at any time. They are marked with a note indic
41
41
 
42
42
  ## Usage in Workflow
43
43
 
44
+ ### Development Workflow (4 phases)
45
+ 1) Plan: define goals, scope, and Acceptance Criteria; create a todo checklist from the plan before any coding.
46
+ 2) Implementation: make small, shippable edits; provide status updates before actions; perform edits via file editing tools.
47
+ 3) Testing: cover main and edge flows; run linter/type/build on changed files and auto-fix issues (up to 3 attempts).
48
+ 4) Review: self-review; when todos are done and checks pass, provide a concise summary and ship.
49
+
44
50
  ### Code Review
45
- The `code-review` command strictly checks code against these two standards:
46
- - Only reports violations of explicit rules
47
- - Does not provide design opinions or performance guesses
48
- - Focuses on conformance to standards
51
+ The `code-review` command checks conformance to these standards and project structure:
52
+ - Reports violations of explicit rules
53
+ - Avoids subjective design opinions or performance guesses
54
+ - Focuses on adherence to conventions and structure
49
55
 
50
56
  ### Implementation
51
57
  When implementing features (`execute-plan`), follow these standards:
@@ -59,6 +65,13 @@ When implementing features (`execute-plan`), follow these standards:
59
65
  - Implementation notes: `../implementation/`
60
66
  - Test plans: `../testing/`
61
67
 
68
+ ## Navigation
69
+ - Code conventions: `CODE_CONVENTIONS.md`
70
+ - Project structure: `PROJECT_STRUCTURE.md`
71
+ - Planning template: `../planning/feature-template.md`
72
+ - Implementation template: `../implementation/feature-template.md`
73
+ - Testing template: `../testing/feature-template.md`
74
+
62
75
  ---
63
76
 
64
77
  **Note**: These standards are project-specific and should reflect actual patterns in your codebase. Regenerate when codebase evolves significantly.
@@ -0,0 +1,41 @@
1
+ # CODE_CONVENTIONS Common Rules (Template Preload)
2
+
3
+ > These rules are preloaded by the standards generator before analyzing the codebase. They establish non-negotiable, high-signal conventions. The generator should merge these rules first, then append auto-discovered patterns.
4
+
5
+ ## Naming — Clarity & Descriptiveness
6
+ - Prefer meaningful, verbose names over abbreviations.
7
+ - Avoid 1–2 character identifiers (except conventional counters in very small scopes).
8
+
9
+ ## Control Flow
10
+ - Prefer guard clauses (early returns) to reduce nesting depth.
11
+ - Handle errors and edge cases first.
12
+ - Avoid deep nesting beyond 2–3 levels.
13
+
14
+ ## Error Handling
15
+ - Throw errors with clear, actionable messages.
16
+ - Do not catch errors without meaningful handling.
17
+
18
+ ## Comments
19
+ - Add comments only for complex or non-obvious logic; explain "why", not "how".
20
+ - Place comments above code blocks or use language-specific docstrings.
21
+ - Avoid trailing inline comments.
22
+
23
+ ## Formatting
24
+ - Match existing repository formatting tools and styles.
25
+ - Prefer multi-line over long one-liners or complex ternaries.
26
+ - Wrap long lines and do not reformat unrelated code.
27
+
28
+ ## Types (for statically typed languages)
29
+ - Explicitly annotate public APIs and function signatures.
30
+ - Avoid unsafe casts or overly broad types (e.g., `any`).
31
+
32
+ ## Change Discipline
33
+ - Perform changes via file editing tools; avoid pasting large code blobs in reviews.
34
+ - Re-read target files before editing to ensure accurate context.
35
+ - After edits, run only fast, non-interactive validation on changed files:
36
+ - If ESLint is configured, run ESLint on changed paths (e.g., `eslint --max-warnings=0 <changed-paths>`). Use `--fix` when safe to auto-fix.
37
+ - If TypeScript is used, run type-check only (e.g., `tsc --noEmit` or `tsc -p . --noEmit`).
38
+ - Do NOT run Prettier as part of validation (formatting is enforced separately by tooling/CI).
39
+ - Do NOT run full build or dev server (to avoid unnecessary time cost).
40
+ - Attempt auto-fixes up to 3 times for linter issues before requesting help.
41
+
@@ -0,0 +1,22 @@
1
+ # JavaScript Conventions (Essential)
2
+
3
+ ## Language
4
+ - Use ES Modules (`import`/`export`).
5
+ - Prefer `const` (default) and `let`; avoid `var`.
6
+ - Use strict equality `===`/`!==`.
7
+ - Prefer optional chaining `?.` and nullish coalescing `??` over `||` when `0/''/false` are valid values.
8
+
9
+ ## Functions & Data
10
+ - Keep functions small and single-purpose.
11
+ - Avoid mutations; prefer immutable updates for objects/arrays.
12
+ - Return early (guard clauses) to reduce nesting.
13
+
14
+ ## Errors & Async
15
+ - Use `async/await`; avoid unhandled promises (no floating promises).
16
+ - Throw Errors with clear messages; catch only to handle meaningfully.
17
+
18
+ ## Style & Safety
19
+ - Avoid implicit globals; module scope only.
20
+ - Prefer explicit returns over side effects.
21
+ - Keep imports minimal and ordered (std/third-party/internal).
22
+
@@ -0,0 +1,24 @@
1
+ # React Conventions (Essential)
2
+
3
+ ## Components
4
+ - Use PascalCase for component names; one component per file (primary export).
5
+ - Props are immutable; derive minimal state. Lift state up when shared.
6
+ - Use stable `key` for lists (not index) when order can change.
7
+
8
+ ## Hooks
9
+ - Follow the Rules of Hooks (top-level, consistent order).
10
+ - Declare all hook dependencies explicitly; prefer stable callbacks with `useCallback` when passed to children.
11
+ - Memoize expensive computations with `useMemo` only when measured bottlenecks exist.
12
+
13
+ ## State & Effects
14
+ - Keep state minimal and serializable; avoid duplicating derived data.
15
+ - Side effects belong in `useEffect` with correct deps; cleanup subscriptions/timers.
16
+
17
+ ## Performance
18
+ - Avoid unnecessary re-renders: memo child components when props are stable.
19
+ - Prefer split code (lazy + Suspense) for large routes/widgets.
20
+
21
+ ## Accessibility
22
+ - Use semantic elements first; include `aria-*` only when needed.
23
+ - Ensure interactive elements are keyboard-accessible and have discernible labels.
24
+
@@ -87,6 +87,13 @@ See `feature-template.md` for the exact structure required for test plans.
87
87
  - Implementation notes: `../implementation/`
88
88
  - Project standards: `../project/`
89
89
 
90
+ ## Validation Requirements
91
+ - After each batch of implementation edits, run:
92
+ - Linter on changed files (must pass; auto-fix up to 3 attempts)
93
+ - Type checks (must pass)
94
+ - Build (must be green)
95
+ - Map test cases to the feature's Acceptance Criteria.
96
+
90
97
  ---
91
98
 
92
99
  **Note**: For complex E2E tests, performance testing, or bug tracking strategies, document these separately or in project-level documentation. The `writing-test` command focuses on automated, logic-focused testing that AI agents excel at.
@@ -46,3 +46,12 @@ npx vitest run
46
46
  - Test results logged to terminal with detailed output
47
47
  - Focus on logic testing, edge cases, and parameter variations
48
48
  - No complex integration or UI rendering tests
49
+
50
+ ## Quality Checks
51
+ - Linter: pass on changed files
52
+ - Type checks: pass
53
+ - Build: green
54
+
55
+ ## Process
56
+ - After each batch of implementation edits, run linter/type/build on changed files.
57
+ - Auto-fix linter issues (up to 3 attempts) before requesting review.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-workflow-init",
3
- "version": "1.1.2",
3
+ "version": "1.2.1",
4
4
  "description": "Initialize AI workflow docs & commands into any repo with one command",
5
5
  "bin": {
6
6
  "ai-workflow-init": "./cli.js"