@e0ipso/ai-task-manager 1.18.4 → 1.18.5
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/package.json
CHANGED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Update or add approval_method field in a plan file's YAML frontmatter
|
|
8
|
+
* @param {string} filePath - Path to the plan file
|
|
9
|
+
* @param {string} approvalMethod - Approval method value ('auto' or 'manual')
|
|
10
|
+
* @returns {boolean} True if successful, false otherwise
|
|
11
|
+
*/
|
|
12
|
+
function setApprovalMethod(filePath, approvalMethod) {
|
|
13
|
+
// Validate inputs
|
|
14
|
+
if (!filePath) {
|
|
15
|
+
throw new Error('File path is required');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (!approvalMethod || !['auto', 'manual'].includes(approvalMethod)) {
|
|
19
|
+
throw new Error('Approval method must be "auto" or "manual"');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Check file exists
|
|
23
|
+
if (!fs.existsSync(filePath)) {
|
|
24
|
+
throw new Error(`File not found: ${filePath}`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Read file content
|
|
28
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
29
|
+
|
|
30
|
+
// Parse frontmatter - handle both empty and non-empty frontmatter
|
|
31
|
+
const frontmatterRegex = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n([\s\S]*))?$/;
|
|
32
|
+
const match = content.match(frontmatterRegex);
|
|
33
|
+
|
|
34
|
+
if (!match) {
|
|
35
|
+
throw new Error('No frontmatter found in file');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const frontmatterContent = match[1] || '';
|
|
39
|
+
const bodyContent = match[2] || '';
|
|
40
|
+
const frontmatterLines = frontmatterContent ? frontmatterContent.split('\n') : [];
|
|
41
|
+
|
|
42
|
+
// Update or add approval_method field
|
|
43
|
+
let approvalMethodFound = false;
|
|
44
|
+
const updatedFrontmatter = frontmatterLines.map(line => {
|
|
45
|
+
const trimmed = line.trim();
|
|
46
|
+
if (trimmed.startsWith('approval_method:')) {
|
|
47
|
+
approvalMethodFound = true;
|
|
48
|
+
return `approval_method: ${approvalMethod}`;
|
|
49
|
+
}
|
|
50
|
+
return line;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Add approval_method if not found
|
|
54
|
+
if (!approvalMethodFound) {
|
|
55
|
+
updatedFrontmatter.push(`approval_method: ${approvalMethod}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Reconstruct file
|
|
59
|
+
const updated = '---\n' + updatedFrontmatter.join('\n') + '\n---\n' + bodyContent;
|
|
60
|
+
|
|
61
|
+
// Write back to file
|
|
62
|
+
fs.writeFileSync(filePath, updated, 'utf8');
|
|
63
|
+
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Main execution with error handling
|
|
68
|
+
try {
|
|
69
|
+
const args = process.argv.slice(2);
|
|
70
|
+
|
|
71
|
+
if (args.length < 2) {
|
|
72
|
+
console.error('Usage: set-approval-method.cjs <file-path> <approval-method>');
|
|
73
|
+
console.error(' file-path: Path to the plan file');
|
|
74
|
+
console.error(' approval-method: "auto" or "manual"');
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const [filePath, approvalMethod] = args;
|
|
79
|
+
|
|
80
|
+
// Resolve relative paths
|
|
81
|
+
const resolvedPath = path.isAbsolute(filePath) ? filePath : path.resolve(process.cwd(), filePath);
|
|
82
|
+
|
|
83
|
+
setApprovalMethod(resolvedPath, approvalMethod);
|
|
84
|
+
|
|
85
|
+
console.log(`✓ Successfully set approval_method to "${approvalMethod}" in ${path.basename(resolvedPath)}`);
|
|
86
|
+
process.exit(0);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.error(`✗ Error: ${error.message}`);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
@@ -42,13 +42,15 @@ Use your internal Todo task tool to track the workflow execution:
|
|
|
42
42
|
|
|
43
43
|
#### Step 1: Determine Next Plan ID
|
|
44
44
|
|
|
45
|
-
Before creating the plan, determine what the next plan ID will be:
|
|
45
|
+
Before creating the plan, determine what the next plan ID will be and store it persistently:
|
|
46
46
|
|
|
47
47
|
```bash
|
|
48
|
-
node .ai/task-manager/config/scripts/get-next-plan-id.cjs
|
|
48
|
+
PLAN_ID=$(node .ai/task-manager/config/scripts/get-next-plan-id.cjs)
|
|
49
|
+
echo "$PLAN_ID" > /tmp/full-workflow-plan-id-$$.txt
|
|
50
|
+
echo "Next plan ID: $PLAN_ID"
|
|
49
51
|
```
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
This stores the plan ID in a temporary file that persists across all workflow steps.
|
|
52
54
|
|
|
53
55
|
#### Step 2: Execute Plan Creation
|
|
54
56
|
|
|
@@ -60,8 +62,12 @@ Use the SlashCommand tool to execute plan creation with the user's prompt:
|
|
|
60
62
|
|
|
61
63
|
**Important**: The plan creation command may ask clarification questions. Wait for user responses before continuing. This is expected behavior and maintains quality control.
|
|
62
64
|
|
|
63
|
-
After plan creation completes, provide
|
|
64
|
-
|
|
65
|
+
After plan creation completes, retrieve the plan ID and provide a progress update:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
PLAN_ID=$(cat /tmp/full-workflow-plan-id-$$.txt)
|
|
69
|
+
echo "Step 1/4: Plan created (ID: $PLAN_ID)"
|
|
70
|
+
```
|
|
65
71
|
|
|
66
72
|
**CRITICAL**: Do not wait for user approval or review of the plan. In full-workflow mode, plan validation is automated (Step 3 performs file existence checking only). Proceed immediately to Step 3 without waiting for user input.
|
|
67
73
|
|
|
@@ -70,46 +76,55 @@ After plan creation completes, provide minimal progress update:
|
|
|
70
76
|
Verify the plan was created successfully and set it to automated workflow mode:
|
|
71
77
|
|
|
72
78
|
```bash
|
|
79
|
+
# Retrieve the plan ID from temp file
|
|
80
|
+
PLAN_ID=$(cat /tmp/full-workflow-plan-id-$$.txt)
|
|
81
|
+
|
|
73
82
|
# Find the created plan file
|
|
74
|
-
PLAN_FILE=$(find .ai/task-manager/plans -name "plan-[0-9][0-9]*--*.md" -type f -exec grep -l "^id:
|
|
83
|
+
PLAN_FILE=$(find .ai/task-manager/plans -name "plan-[0-9][0-9]*--*.md" -type f -exec grep -l "^id: \?${PLAN_ID}$" {} \;)
|
|
75
84
|
|
|
76
85
|
# Verify plan exists
|
|
77
86
|
if [ -z "$PLAN_FILE" ]; then
|
|
78
|
-
echo "❌ Error: Plan creation failed. Expected plan with ID
|
|
87
|
+
echo "❌ Error: Plan creation failed. Expected plan with ID ${PLAN_ID} not found."
|
|
79
88
|
exit 1
|
|
80
89
|
fi
|
|
81
90
|
|
|
82
91
|
# Set approval_method to auto for automated workflow execution
|
|
83
92
|
# This ensures generate-tasks and execute-blueprint run without interruption
|
|
84
|
-
|
|
85
|
-
# Insert approval_method after the created: line in frontmatter
|
|
86
|
-
sed -i.bak '/^created:/a\
|
|
87
|
-
approval_method: auto' "$PLAN_FILE" && rm -f "${PLAN_FILE}.bak"
|
|
88
|
-
else
|
|
89
|
-
# Update existing approval_method to auto
|
|
90
|
-
sed -i.bak 's/^approval_method:.*/approval_method: auto/' "$PLAN_FILE" && rm -f "${PLAN_FILE}.bak"
|
|
91
|
-
fi
|
|
93
|
+
node .ai/task-manager/config/scripts/set-approval-method.cjs "$PLAN_FILE" auto
|
|
92
94
|
```
|
|
93
95
|
|
|
94
96
|
**Note**: Setting `approval_method: auto` in the plan metadata signals to subordinate commands (generate-tasks, execute-blueprint) that they are running in automated workflow mode and should suppress interactive prompts for plan review. This metadata persists in the plan document and is reliably read by subsequent commands, eliminating dependency on environment variables.
|
|
95
97
|
|
|
96
98
|
#### Step 4: Execute Task Generation
|
|
97
99
|
|
|
98
|
-
|
|
100
|
+
Retrieve the plan ID and use the SlashCommand tool to generate tasks:
|
|
99
101
|
|
|
102
|
+
```bash
|
|
103
|
+
PLAN_ID=$(cat /tmp/full-workflow-plan-id-$$.txt)
|
|
104
|
+
echo "Generating tasks for plan $PLAN_ID"
|
|
100
105
|
```
|
|
101
|
-
|
|
106
|
+
|
|
107
|
+
Now use the SlashCommand tool with the plan ID from above:
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
/tasks:generate-tasks [plan-id-from-above]
|
|
102
111
|
```
|
|
103
112
|
|
|
104
|
-
After task generation completes, provide minimal progress update
|
|
105
|
-
"Step 2/4: Tasks generated for plan [plan-id]"
|
|
113
|
+
After task generation completes, provide minimal progress update referencing the plan ID.
|
|
106
114
|
|
|
107
115
|
#### Step 5: Execute Blueprint
|
|
108
116
|
|
|
109
|
-
|
|
117
|
+
Retrieve the plan ID and use the SlashCommand tool to execute the blueprint:
|
|
110
118
|
|
|
119
|
+
```bash
|
|
120
|
+
PLAN_ID=$(cat /tmp/full-workflow-plan-id-$$.txt)
|
|
121
|
+
echo "Executing blueprint for plan $PLAN_ID"
|
|
111
122
|
```
|
|
112
|
-
|
|
123
|
+
|
|
124
|
+
Now use the SlashCommand tool with the plan ID from above:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
/tasks:execute-blueprint [plan-id-from-above]
|
|
113
128
|
```
|
|
114
129
|
|
|
115
130
|
After blueprint execution completes, provide minimal progress update:
|
|
@@ -119,22 +134,29 @@ Note: The execute-blueprint command automatically archives the plan upon success
|
|
|
119
134
|
|
|
120
135
|
#### Step 6: Generate Execution Summary
|
|
121
136
|
|
|
122
|
-
After all steps complete successfully, generate a
|
|
123
|
-
|
|
124
|
-
```
|
|
125
|
-
✅ Full workflow completed successfully!
|
|
137
|
+
After all steps complete successfully, retrieve the plan details and generate a summary:
|
|
126
138
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
139
|
+
```bash
|
|
140
|
+
PLAN_ID=$(cat /tmp/full-workflow-plan-id-$$.txt)
|
|
141
|
+
PLAN_DIR=$(find .ai/task-manager/archive -type d -name "${PLAN_ID}--*" 2>/dev/null | head -n 1)
|
|
142
|
+
PLAN_NAME=$(basename "$PLAN_DIR")
|
|
143
|
+
|
|
144
|
+
echo "✅ Full workflow completed successfully!"
|
|
145
|
+
echo ""
|
|
146
|
+
echo "Plan: $PLAN_NAME"
|
|
147
|
+
echo "Location: .ai/task-manager/archive/$PLAN_NAME/"
|
|
148
|
+
echo ""
|
|
149
|
+
echo "Status: Archived and ready for review"
|
|
150
|
+
echo ""
|
|
151
|
+
echo "📋 Next Steps:"
|
|
152
|
+
echo "- Review the implementation in the archived plan"
|
|
153
|
+
echo "- Check the execution summary in the plan document"
|
|
154
|
+
echo "- Verify all validation gates passed"
|
|
155
|
+
echo ""
|
|
156
|
+
echo "Plan document: .ai/task-manager/archive/$PLAN_NAME/plan-$PLAN_NAME.md"
|
|
157
|
+
|
|
158
|
+
# Clean up temp file
|
|
159
|
+
rm -f /tmp/full-workflow-plan-id-$$.txt
|
|
138
160
|
```
|
|
139
161
|
|
|
140
162
|
### Error Handling
|
|
@@ -143,10 +165,12 @@ If any step fails:
|
|
|
143
165
|
1. Halt execution immediately
|
|
144
166
|
2. Report clear error message indicating which step failed
|
|
145
167
|
3. Preserve all created artifacts (plan, tasks) for manual review
|
|
146
|
-
4.
|
|
168
|
+
4. Read the plan ID from temp file if needed: `cat /tmp/full-workflow-plan-id-$$.txt`
|
|
169
|
+
5. Provide guidance for manual continuation:
|
|
147
170
|
- If plan creation failed: Review error and retry
|
|
148
171
|
- If task generation failed: Run `/tasks:generate-tasks [plan-id]` manually after reviewing plan
|
|
149
172
|
- If blueprint execution failed: Review tasks and run `/tasks:execute-blueprint [plan-id]` manually
|
|
173
|
+
6. Clean up temp file: `rm -f /tmp/full-workflow-plan-id-$$.txt`
|
|
150
174
|
|
|
151
175
|
### Output Requirements
|
|
152
176
|
|