autoworkflow 2.0.1 → 2.2.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.
@@ -0,0 +1,142 @@
1
+ # /init - Initialize AutoWorkflow
2
+
3
+ Set up AutoWorkflow files in the current project.
4
+
5
+ ## Trigger
6
+ - User invokes `/init`
7
+ - User invokes `/init autoworkflow`
8
+ - User says "set up autoworkflow" or "initialize workflow"
9
+
10
+ ## Purpose
11
+ Copy AutoWorkflow files from `node_modules/autoworkflow/` to the project root.
12
+
13
+ ## Workflow
14
+
15
+ ### Step 1: Check if autoworkflow is installed
16
+ ```bash
17
+ [ -d node_modules/autoworkflow ] && echo "Found" || echo "Not found"
18
+ ```
19
+
20
+ If not found:
21
+ ```
22
+ ⚠️ autoworkflow not found in node_modules.
23
+
24
+ Run this first:
25
+ npm install autoworkflow
26
+
27
+ Then run /init again.
28
+ ```
29
+
30
+ ### Step 2: Check what's already set up
31
+ ```bash
32
+ [ -f CLAUDE.md ] && echo "CLAUDE.md exists"
33
+ [ -d system ] && echo "system/ exists"
34
+ [ -d instructions ] && echo "instructions/ exists"
35
+ [ -d .claude ] && echo ".claude/ exists"
36
+ [ -d scripts ] && echo "scripts/ exists"
37
+ [ -d hooks ] && echo "hooks/ exists"
38
+ ```
39
+
40
+ ### Step 3: Present setup options
41
+ ```
42
+ ## AutoWorkflow Setup
43
+
44
+ **Source:** node_modules/autoworkflow/
45
+
46
+ ### Required Files
47
+ | File/Folder | Status | Action |
48
+ |-------------|--------|--------|
49
+ | CLAUDE.md | ❌ Missing | Will copy |
50
+ | system/ | ❌ Missing | Will copy |
51
+ | instructions/ | ❌ Missing | Will copy |
52
+ | .claude/ | ❌ Missing | Will copy |
53
+
54
+ ### Recommended Files
55
+ | File/Folder | Status | Action |
56
+ |-------------|--------|--------|
57
+ | scripts/ | ❌ Missing | Will copy |
58
+ | hooks/ | ❌ Missing | Will copy |
59
+
60
+ ### Optional Files
61
+ | File/Folder | Status | Action |
62
+ |-------------|--------|--------|
63
+ | .vscode/ | ❌ Missing | Skip (add with --vscode) |
64
+ | .prettierrc | ❌ Missing | Skip (add with --configs) |
65
+ | eslint.config.js | ❌ Missing | Skip (add with --configs) |
66
+ | tsconfig.json | ❌ Missing | Skip (add with --configs) |
67
+
68
+ ---
69
+
70
+ **Should I set up AutoWorkflow?**
71
+ Options:
72
+ - `yes` - Copy required + recommended
73
+ - `all` - Copy everything including optional
74
+ - `minimal` - Copy required only
75
+ ```
76
+
77
+ ### Step 4: Copy files after approval
78
+ ```bash
79
+ # Required
80
+ cp node_modules/autoworkflow/CLAUDE.md .
81
+ cp -r node_modules/autoworkflow/system ./system
82
+ cp -r node_modules/autoworkflow/instructions ./instructions
83
+ cp -r node_modules/autoworkflow/.claude ./.claude
84
+
85
+ # Recommended
86
+ cp -r node_modules/autoworkflow/scripts ./scripts
87
+ cp -r node_modules/autoworkflow/hooks ./hooks
88
+
89
+ # Optional (if requested)
90
+ cp -r node_modules/autoworkflow/.vscode ./.vscode
91
+ cp node_modules/autoworkflow/.prettierrc .
92
+ cp node_modules/autoworkflow/eslint.config.example.js ./eslint.config.js
93
+ cp node_modules/autoworkflow/tsconfig.example.json ./tsconfig.json
94
+ ```
95
+
96
+ ### Step 5: Set up git hooks
97
+ ```bash
98
+ npm run setup:hooks
99
+ ```
100
+
101
+ ### Step 6: Confirm setup
102
+ ```
103
+ ## ✅ AutoWorkflow Initialized
104
+
105
+ **Files copied:**
106
+ - CLAUDE.md (entry point)
107
+ - system/ (triggers, loops, gates, router)
108
+ - instructions/ (workflow, AI rules, blueprint)
109
+ - .claude/ (settings, commands)
110
+ - scripts/ (automation)
111
+ - hooks/ (git hooks)
112
+
113
+ **Git hooks installed:**
114
+ - pre-commit
115
+ - commit-msg
116
+
117
+ **Next steps:**
118
+ 1. Edit `instructions/AI_RULES.md` with your coding standards
119
+ 2. Edit `instructions/BLUEPRINT.md` with your project spec
120
+ 3. Start using Claude Code - it will follow the workflow!
121
+
122
+ Run `/audit project` to auto-generate BLUEPRINT.md from your codebase.
123
+ ```
124
+
125
+ ## Arguments
126
+ - `/init` - Standard setup (required + recommended)
127
+ - `/init --all` - Include optional files (.vscode, configs)
128
+ - `/init --minimal` - Required files only
129
+ - `/init --vscode` - Include .vscode settings
130
+ - `/init --configs` - Include config templates
131
+
132
+ ## Examples
133
+ ```
134
+ User: /init
135
+ → Sets up required + recommended files
136
+
137
+ User: /init --all
138
+ → Sets up everything including .vscode and configs
139
+
140
+ User: set up autoworkflow
141
+ → Same as /init
142
+ ```
@@ -5,6 +5,7 @@
5
5
  "description": "System prompt layer that controls Claude's workflow with triggers, loops, and gates",
6
6
 
7
7
  "instructions": [
8
+ "IF autoworkflow in node_modules but CLAUDE.md missing: suggest running /init",
8
9
  "ALWAYS read CLAUDE.md (entry point) at the start of EVERY task",
9
10
  "ALWAYS check if instructions/BLUEPRINT.md exists at session start",
10
11
  "IF BLUEPRINT.md missing: run /audit project to generate it",
@@ -81,7 +82,8 @@
81
82
  },
82
83
 
83
84
  "triggers": {
84
- "on_conversation_start": ["Read CLAUDE.md", "Check BLUEPRINT.md exists", "Route via system/router.md"],
85
+ "on_conversation_start": ["Check if /init needed", "Read CLAUDE.md", "Check BLUEPRINT.md exists", "Route via system/router.md"],
86
+ "on_init_needed": ["Notify autoworkflow detected", "Suggest running /init"],
85
87
  "on_blueprint_missing": ["Run project audit", "Generate AI_RULES.md + BLUEPRINT.md", "Present for approval"],
86
88
  "on_task_start": ["Read CLAUDE.md", "Route via system/router.md"],
87
89
  "on_implementation_complete": ["Enter VERIFY phase", "Run verify_loop"],
@@ -3,7 +3,8 @@
3
3
  "allow": [
4
4
  "Bash(git push)",
5
5
  "Bash(npm publish:*)",
6
- "Bash(npm version:*)"
6
+ "Bash(npm version:*)",
7
+ "Bash(node bin/cli.js:*)"
7
8
  ]
8
9
  }
9
10
  }
package/README.md CHANGED
@@ -8,13 +8,25 @@ A system prompt architecture that controls Claude Code's behavior through trigge
8
8
 
9
9
  ## Installation
10
10
 
11
- ### Via npm (Recommended)
11
+ ### One Command Setup (Recommended)
12
+
13
+ ```bash
14
+ npx autoworkflow init
15
+ ```
16
+
17
+ This copies all workflow files to your project. Options:
18
+ - `npx autoworkflow init` - Required + recommended files
19
+ - `npx autoworkflow init --all` - Include .vscode and config templates
20
+ - `npx autoworkflow init --minimal` - Required files only
21
+
22
+ ### Or Install as Dependency
12
23
 
13
24
  ```bash
14
25
  npm install autoworkflow
26
+ npx autoworkflow init
15
27
  ```
16
28
 
17
- Then copy files to your project:
29
+ **Or copy manually:**
18
30
 
19
31
  ```bash
20
32
  # Copy all workflow files
@@ -125,6 +137,7 @@ Claude will STOP and cannot proceed if:
125
137
 
126
138
  | Command | Purpose |
127
139
  |---------|---------|
140
+ | `/init` | Set up AutoWorkflow files from node_modules |
128
141
  | `/analyze [task]` | Analyze codebase for a task |
129
142
  | `/plan [task]` | Create implementation plan |
130
143
  | `/build [feature]` | Full workflow for features |
@@ -201,6 +214,7 @@ autoworkflow/
201
214
  ├── .claude/ # Claude Code Integration
202
215
  │ ├── settings.json # Settings + hard rules
203
216
  │ └── commands/ # Slash command definitions
217
+ │ ├── init.md
204
218
  │ ├── analyze.md
205
219
  │ ├── plan.md
206
220
  │ ├── build.md
package/bin/cli.js ADDED
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { existsSync, cpSync, mkdirSync, chmodSync } from 'fs';
4
+ import { dirname, join } from 'path';
5
+ import { fileURLToPath } from 'url';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+ const packageRoot = join(__dirname, '..');
10
+
11
+ const args = process.argv.slice(2);
12
+ const command = args[0];
13
+
14
+ const colors = {
15
+ green: (text) => `\x1b[32m${text}\x1b[0m`,
16
+ yellow: (text) => `\x1b[33m${text}\x1b[0m`,
17
+ red: (text) => `\x1b[31m${text}\x1b[0m`,
18
+ cyan: (text) => `\x1b[36m${text}\x1b[0m`,
19
+ bold: (text) => `\x1b[1m${text}\x1b[0m`,
20
+ };
21
+
22
+ function printHelp() {
23
+ console.log(`
24
+ ${colors.bold('AutoWorkflow CLI')}
25
+
26
+ Usage: npx autoworkflow <command> [options]
27
+
28
+ Commands:
29
+ init Set up AutoWorkflow in current directory
30
+ init --all Include optional files (.vscode, configs)
31
+ init --minimal Required files only
32
+ help Show this help message
33
+
34
+ Examples:
35
+ npx autoworkflow init
36
+ npx autoworkflow init --all
37
+ `);
38
+ }
39
+
40
+ function copyFile(src, dest, name) {
41
+ if (existsSync(src)) {
42
+ try {
43
+ cpSync(src, dest, { recursive: true });
44
+ console.log(` ${colors.green('✓')} ${name}`);
45
+ return true;
46
+ } catch (err) {
47
+ console.log(` ${colors.red('✗')} ${name}: ${err.message}`);
48
+ return false;
49
+ }
50
+ } else {
51
+ console.log(` ${colors.yellow('⚠')} ${name}: not found in package`);
52
+ return false;
53
+ }
54
+ }
55
+
56
+ function init(options = {}) {
57
+ const cwd = process.cwd();
58
+ const all = options.all || args.includes('--all');
59
+ const minimal = options.minimal || args.includes('--minimal');
60
+
61
+ console.log(`\n${colors.bold('AutoWorkflow Setup')}\n`);
62
+ console.log(`Installing to: ${colors.cyan(cwd)}\n`);
63
+
64
+ // Check if already initialized
65
+ if (existsSync(join(cwd, 'CLAUDE.md'))) {
66
+ console.log(`${colors.yellow('⚠')} CLAUDE.md already exists.`);
67
+ console.log(` Use --force to overwrite (not implemented yet)\n`);
68
+ }
69
+
70
+ // Required files
71
+ console.log(colors.bold('Required files:'));
72
+ copyFile(join(packageRoot, 'CLAUDE.md'), join(cwd, 'CLAUDE.md'), 'CLAUDE.md');
73
+ copyFile(join(packageRoot, 'system'), join(cwd, 'system'), 'system/');
74
+ copyFile(join(packageRoot, 'instructions'), join(cwd, 'instructions'), 'instructions/');
75
+ copyFile(join(packageRoot, '.claude'), join(cwd, '.claude'), '.claude/');
76
+
77
+ if (!minimal) {
78
+ // Recommended files
79
+ console.log(`\n${colors.bold('Recommended files:')}`);
80
+ copyFile(join(packageRoot, 'scripts'), join(cwd, 'scripts'), 'scripts/');
81
+ copyFile(join(packageRoot, 'hooks'), join(cwd, 'hooks'), 'hooks/');
82
+ }
83
+
84
+ if (all) {
85
+ // Optional files
86
+ console.log(`\n${colors.bold('Optional files:')}`);
87
+ copyFile(join(packageRoot, '.vscode'), join(cwd, '.vscode'), '.vscode/');
88
+ copyFile(join(packageRoot, '.prettierrc'), join(cwd, '.prettierrc'), '.prettierrc');
89
+
90
+ // Copy example configs with proper names
91
+ if (existsSync(join(packageRoot, 'eslint.config.example.js'))) {
92
+ copyFile(join(packageRoot, 'eslint.config.example.js'), join(cwd, 'eslint.config.js'), 'eslint.config.js');
93
+ }
94
+ if (existsSync(join(packageRoot, 'tsconfig.example.json'))) {
95
+ copyFile(join(packageRoot, 'tsconfig.example.json'), join(cwd, 'tsconfig.json'), 'tsconfig.json');
96
+ }
97
+ }
98
+
99
+ // Setup git hooks if hooks were copied
100
+ if (!minimal && existsSync(join(cwd, 'hooks')) && existsSync(join(cwd, '.git'))) {
101
+ console.log(`\n${colors.bold('Git hooks:')}`);
102
+ const hooksDir = join(cwd, '.git', 'hooks');
103
+ mkdirSync(hooksDir, { recursive: true });
104
+
105
+ const hooksCopied = copyFile(join(cwd, 'hooks', 'pre-commit'), join(hooksDir, 'pre-commit'), 'pre-commit');
106
+ copyFile(join(cwd, 'hooks', 'commit-msg'), join(hooksDir, 'commit-msg'), 'commit-msg');
107
+
108
+ // Make hooks executable (Unix only)
109
+ if (hooksCopied && process.platform !== 'win32') {
110
+ try {
111
+ chmodSync(join(hooksDir, 'pre-commit'), 0o755);
112
+ chmodSync(join(hooksDir, 'commit-msg'), 0o755);
113
+ } catch (e) {
114
+ // Ignore chmod errors
115
+ }
116
+ }
117
+ }
118
+
119
+ console.log(`\n${colors.green('✓')} ${colors.bold('AutoWorkflow initialized!')}\n`);
120
+
121
+ console.log(`${colors.bold('Next steps:')}`);
122
+ console.log(` 1. Edit ${colors.cyan('instructions/AI_RULES.md')} with your coding standards`);
123
+ console.log(` 2. Open VS Code with Claude Code extension`);
124
+ console.log(` 3. Claude will auto-generate ${colors.cyan('BLUEPRINT.md')} on first task\n`);
125
+
126
+ console.log(`Or run ${colors.cyan('/audit project')} in Claude Code to scan your codebase now.\n`);
127
+ }
128
+
129
+ // Main
130
+ switch (command) {
131
+ case 'init':
132
+ init();
133
+ break;
134
+ case 'help':
135
+ case '--help':
136
+ case '-h':
137
+ case undefined:
138
+ printHelp();
139
+ break;
140
+ default:
141
+ console.log(`${colors.red('Unknown command:')} ${command}`);
142
+ printHelp();
143
+ process.exit(1);
144
+ }
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "autoworkflow",
3
- "version": "2.0.1",
3
+ "version": "2.2.0",
4
4
  "description": "System prompt layer that controls Claude Code's workflow with triggers, loops, and gates",
5
5
  "type": "module",
6
+ "bin": {
7
+ "autoworkflow": "./bin/cli.js"
8
+ },
6
9
  "keywords": [
7
10
  "claude",
8
11
  "claude-code",
@@ -17,6 +20,7 @@
17
20
  "url": ""
18
21
  },
19
22
  "files": [
23
+ "bin/",
20
24
  "CLAUDE.md",
21
25
  "system/",
22
26
  "instructions/",
@@ -11,16 +11,19 @@
11
11
 
12
12
  **When:** Claude begins a new conversation or task
13
13
  **Action:**
14
- 1. Read root `CLAUDE.md` (entry point)
15
- 2. Check if `instructions/BLUEPRINT.md` exists
16
- 3. If NO → Trigger `on:blueprint_missing`
17
- 4. If YESLoad blueprint and proceed
18
- 5. Load `system/router.md` to determine task type
19
- 6. Load `system/gates.md` for blocking rules
20
- 7. Await user request
14
+ 1. Check if autoworkflow needs initialization
15
+ 2. Read root `CLAUDE.md` (entry point)
16
+ 3. Check if `instructions/BLUEPRINT.md` exists
17
+ 4. If NOTrigger `on:blueprint_missing`
18
+ 5. If YES Load blueprint and proceed
19
+ 6. Load `system/router.md` to determine task type
20
+ 7. Load `system/gates.md` for blocking rules
21
+ 8. Await user request
21
22
 
22
23
  ```
23
24
  TRIGGER: conversation_start
25
+ ├── Check: node_modules/autoworkflow exists AND CLAUDE.md missing?
26
+ │ └── YES → Trigger: on:init_needed
24
27
  ├── Read: CLAUDE.md
25
28
  ├── Check: instructions/BLUEPRINT.md exists?
26
29
  │ ├── NO → Trigger: on:blueprint_missing
@@ -32,6 +35,39 @@ TRIGGER: conversation_start
32
35
 
33
36
  ---
34
37
 
38
+ ### `on:init_needed`
39
+
40
+ **When:** autoworkflow is in node_modules but CLAUDE.md is missing
41
+ **Action:**
42
+ 1. Notify user that autoworkflow needs setup
43
+ 2. Suggest running /init command
44
+
45
+ ```
46
+ TRIGGER: init_needed
47
+ ├── Notify: "AutoWorkflow detected but not initialized"
48
+ ├── Suggest: "Run /init to set up workflow files"
49
+ └── Await: user response
50
+ ```
51
+
52
+ **Output Format:**
53
+ ```
54
+ 📦 **AutoWorkflow detected in node_modules**
55
+
56
+ The workflow files haven't been copied to your project yet.
57
+
58
+ Run `/init` to set up:
59
+ - CLAUDE.md (entry point)
60
+ - system/ (triggers, loops, gates)
61
+ - instructions/ (workflow, rules, blueprint)
62
+ - .claude/ (commands)
63
+ - scripts/ (automation)
64
+ - hooks/ (git hooks)
65
+
66
+ Or run `/init --all` to include .vscode and config templates.
67
+ ```
68
+
69
+ ---
70
+
35
71
  ### `on:blueprint_missing`
36
72
 
37
73
  **When:** BLUEPRINT.md does not exist at session start