@e0ipso/ai-task-manager 1.18.7 → 1.20.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/dist/cli.js +17 -63
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +86 -83
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/ai-task-manager/config/scripts/compose-prompt.cjs +234 -0
- package/templates/ai-task-manager/config/scripts/validate-plan-blueprint.cjs +27 -8
- package/templates/ai-task-manager/config/templates/PLAN_TEMPLATE.md +0 -2
- package/templates/assistant/commands/tasks/create-plan.md +3 -35
- package/templates/assistant/commands/tasks/execute-blueprint.md +312 -64
- package/templates/assistant/commands/tasks/full-workflow.md +437 -0
- package/templates/assistant/commands/tasks/generate-tasks.md +3 -28
- package/dist/logger.d.ts +0 -70
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -185
- package/dist/logger.js.map +0 -1
- package/templates/ai-task-manager/config/scripts/get-approval-methods.cjs +0 -229
package/dist/logger.js
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Simple Logging Utility
|
|
4
|
-
*
|
|
5
|
-
* This file provides a simple logging interface for the CLI
|
|
6
|
-
* Handles different log levels and formatted output with optional color support
|
|
7
|
-
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
-
}) : function(o, v) {
|
|
22
|
-
o["default"] = v;
|
|
23
|
-
});
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.sync = exports.isDebugMode = void 0;
|
|
43
|
-
exports.getChalk = getChalk;
|
|
44
|
-
exports.setDebugMode = setDebugMode;
|
|
45
|
-
exports.info = info;
|
|
46
|
-
exports.success = success;
|
|
47
|
-
exports.error = error;
|
|
48
|
-
exports.warning = warning;
|
|
49
|
-
exports.debug = debug;
|
|
50
|
-
exports.initLogger = initLogger;
|
|
51
|
-
// Chalk instance - loaded dynamically to handle ESM module
|
|
52
|
-
let chalkInstance = null;
|
|
53
|
-
let chalkInitialized = false;
|
|
54
|
-
/**
|
|
55
|
-
* Initialize chalk instance dynamically
|
|
56
|
-
* This handles the ESM import in a CommonJS environment
|
|
57
|
-
*/
|
|
58
|
-
async function initChalk() {
|
|
59
|
-
if (chalkInitialized)
|
|
60
|
-
return;
|
|
61
|
-
try {
|
|
62
|
-
const { default: chalk } = await Promise.resolve().then(() => __importStar(require('chalk')));
|
|
63
|
-
chalkInstance = chalk;
|
|
64
|
-
}
|
|
65
|
-
catch (_error) {
|
|
66
|
-
// Chalk not available, will fall back to plain console output
|
|
67
|
-
chalkInstance = null;
|
|
68
|
-
}
|
|
69
|
-
chalkInitialized = true;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Get chalk instance, initializing if necessary
|
|
73
|
-
*/
|
|
74
|
-
async function getChalk() {
|
|
75
|
-
await initChalk();
|
|
76
|
-
return chalkInstance;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Debug mode flag - can be set externally
|
|
80
|
-
*/
|
|
81
|
-
exports.isDebugMode = false;
|
|
82
|
-
/**
|
|
83
|
-
* Enable or disable debug mode
|
|
84
|
-
*/
|
|
85
|
-
function setDebugMode(enabled) {
|
|
86
|
-
exports.isDebugMode = enabled;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Log an informational message
|
|
90
|
-
*/
|
|
91
|
-
async function info(message) {
|
|
92
|
-
const chalk = await getChalk();
|
|
93
|
-
const formattedMessage = chalk?.blue(`ℹ ${message}`) || `ℹ ${message}`;
|
|
94
|
-
console.log(formattedMessage);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Log a success message
|
|
98
|
-
*/
|
|
99
|
-
async function success(message) {
|
|
100
|
-
const chalk = await getChalk();
|
|
101
|
-
const formattedMessage = chalk?.green(`✓ ${message}`) || `✓ ${message}`;
|
|
102
|
-
console.log(formattedMessage);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Log an error message
|
|
106
|
-
*/
|
|
107
|
-
async function error(message) {
|
|
108
|
-
const chalk = await getChalk();
|
|
109
|
-
const formattedMessage = chalk?.red(`✗ ${message}`) || `✗ ${message}`;
|
|
110
|
-
console.error(formattedMessage);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Log a warning message
|
|
114
|
-
*/
|
|
115
|
-
async function warning(message) {
|
|
116
|
-
const chalk = await getChalk();
|
|
117
|
-
const formattedMessage = chalk?.yellow(`⚠ ${message}`) || `⚠ ${message}`;
|
|
118
|
-
console.log(formattedMessage);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Log a debug message (only shown in debug mode)
|
|
122
|
-
*/
|
|
123
|
-
async function debug(message) {
|
|
124
|
-
if (!exports.isDebugMode)
|
|
125
|
-
return;
|
|
126
|
-
const chalk = await getChalk();
|
|
127
|
-
const formattedMessage = chalk?.gray(`🐛 DEBUG: ${message}`) || `🐛 DEBUG: ${message}`;
|
|
128
|
-
console.log(formattedMessage);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Synchronous versions for cases where async is not suitable
|
|
132
|
-
* These will only use colors if chalk was previously initialized
|
|
133
|
-
*/
|
|
134
|
-
exports.sync = {
|
|
135
|
-
/**
|
|
136
|
-
* Log an informational message (sync)
|
|
137
|
-
*/
|
|
138
|
-
info(message) {
|
|
139
|
-
const formattedMessage = chalkInstance?.blue(`ℹ ${message}`) || `ℹ ${message}`;
|
|
140
|
-
console.log(formattedMessage);
|
|
141
|
-
},
|
|
142
|
-
/**
|
|
143
|
-
* Log a success message (sync)
|
|
144
|
-
*/
|
|
145
|
-
success(message) {
|
|
146
|
-
const formattedMessage = chalkInstance?.green(`✓ ${message}`) || `✓ ${message}`;
|
|
147
|
-
console.log(formattedMessage);
|
|
148
|
-
},
|
|
149
|
-
/**
|
|
150
|
-
* Log an error message (sync)
|
|
151
|
-
*/
|
|
152
|
-
error(message) {
|
|
153
|
-
const formattedMessage = chalkInstance?.red(`✗ ${message}`) || `✗ ${message}`;
|
|
154
|
-
console.error(formattedMessage);
|
|
155
|
-
},
|
|
156
|
-
/**
|
|
157
|
-
* Log a warning message (sync)
|
|
158
|
-
*/
|
|
159
|
-
warning(message) {
|
|
160
|
-
const formattedMessage = chalkInstance?.yellow(`⚠ ${message}`) || `⚠ ${message}`;
|
|
161
|
-
console.log(formattedMessage);
|
|
162
|
-
},
|
|
163
|
-
/**
|
|
164
|
-
* Log a debug message (sync, only shown in debug mode)
|
|
165
|
-
*/
|
|
166
|
-
debug(message) {
|
|
167
|
-
if (!exports.isDebugMode)
|
|
168
|
-
return;
|
|
169
|
-
const formattedMessage = chalkInstance?.gray(`🐛 DEBUG: ${message}`) || `🐛 DEBUG: ${message}`;
|
|
170
|
-
console.log(formattedMessage);
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
/**
|
|
174
|
-
* Initialize the logger - call this early in your application
|
|
175
|
-
* This pre-loads chalk to avoid delays on first use
|
|
176
|
-
*/
|
|
177
|
-
async function initLogger() {
|
|
178
|
-
await initChalk();
|
|
179
|
-
}
|
|
180
|
-
// Pre-initialize chalk on module load (non-blocking)
|
|
181
|
-
initChalk().catch(() => {
|
|
182
|
-
// Silently handle initialization errors
|
|
183
|
-
// Logger will work without colors if chalk fails to load
|
|
184
|
-
});
|
|
185
|
-
//# sourceMappingURL=logger.js.map
|
package/dist/logger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BH,4BAGC;AAUD,oCAEC;AAKD,oBAIC;AAKD,0BAIC;AAKD,sBAIC;AAKD,0BAIC;AAKD,sBAMC;AAsDD,gCAEC;AA/ID,2DAA2D;AAC3D,IAAI,aAAa,GAAe,IAAI,CAAC;AACrC,IAAI,gBAAgB,GAAG,KAAK,CAAC;AAE7B;;;GAGG;AACH,KAAK,UAAU,SAAS;IACtB,IAAI,gBAAgB;QAAE,OAAO;IAE7B,IAAI,CAAC;QACH,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,wDAAa,OAAO,GAAC,CAAC;QACjD,aAAa,GAAG,KAAK,CAAC;IACxB,CAAC;IAAC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,KAAK,OAAO,EAAE,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QACjF,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAe;QACnB,IAAI,CAAC,mBAAW;YAAE,OAAO;QAEzB,MAAM,gBAAgB,GAAG,aAAa,EAAE,IAAI,CAAC,aAAa,OAAO,EAAE,CAAC,IAAI,aAAa,OAAO,EAAE,CAAC;QAC/F,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAChC,CAAC;CACF,CAAC;AAEF;;;GAGG;AACI,KAAK,UAAU,UAAU;IAC9B,MAAM,SAAS,EAAE,CAAC;AACpB,CAAC;AAED,qDAAqD;AACrD,SAAS,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;IACrB,wCAAwC;IACxC,yDAAyD;AAC3D,CAAC,CAAC,CAAC"}
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
|
|
6
|
-
// Enable debug logging via environment variable
|
|
7
|
-
const DEBUG = process.env.DEBUG === 'true';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Debug logging utility
|
|
11
|
-
* @param {string} message - Debug message
|
|
12
|
-
* @param {...any} args - Additional arguments to log
|
|
13
|
-
*/
|
|
14
|
-
function debugLog(message, ...args) {
|
|
15
|
-
if (DEBUG) {
|
|
16
|
-
console.error(`[DEBUG] ${message}`, ...args);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Error logging utility
|
|
22
|
-
* @param {string} message - Error message
|
|
23
|
-
* @param {...any} args - Additional arguments to log
|
|
24
|
-
*/
|
|
25
|
-
function errorLog(message, ...args) {
|
|
26
|
-
console.error(`[ERROR] ${message}`, ...args);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Find the task manager root directory by traversing up from current working directory
|
|
31
|
-
* @returns {string|null} Path to task manager root or null if not found
|
|
32
|
-
*/
|
|
33
|
-
function findTaskManagerRoot() {
|
|
34
|
-
let currentPath = process.cwd();
|
|
35
|
-
const filesystemRoot = path.parse(currentPath).root;
|
|
36
|
-
|
|
37
|
-
debugLog(`Starting search for task manager root from: ${currentPath}`);
|
|
38
|
-
|
|
39
|
-
while (currentPath !== filesystemRoot) {
|
|
40
|
-
const taskManagerPlansPath = path.join(currentPath, '.ai', 'task-manager', 'plans');
|
|
41
|
-
debugLog(`Checking for task manager at: ${taskManagerPlansPath}`);
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
if (fs.existsSync(taskManagerPlansPath)) {
|
|
45
|
-
const stats = fs.lstatSync(taskManagerPlansPath);
|
|
46
|
-
if (stats.isDirectory()) {
|
|
47
|
-
const taskManagerRoot = path.join(currentPath, '.ai', 'task-manager');
|
|
48
|
-
debugLog(`Found valid task manager root at: ${taskManagerRoot}`);
|
|
49
|
-
return taskManagerRoot;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
} catch (err) {
|
|
53
|
-
debugLog(`Filesystem error checking ${taskManagerPlansPath}: ${err.message}`);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const parentPath = path.dirname(currentPath);
|
|
57
|
-
if (parentPath === currentPath) {
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
currentPath = parentPath;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
debugLog(`Task manager root not found in any parent directory`);
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Find plan file by ID in plans or archive directories
|
|
70
|
-
* @param {string} taskManagerRoot - Path to task manager root
|
|
71
|
-
* @param {string} planId - Plan ID to find
|
|
72
|
-
* @returns {string|null} Path to plan file or null if not found
|
|
73
|
-
*/
|
|
74
|
-
function findPlanFile(taskManagerRoot, planId) {
|
|
75
|
-
const plansDir = path.join(taskManagerRoot, 'plans');
|
|
76
|
-
const archiveDir = path.join(taskManagerRoot, 'archive');
|
|
77
|
-
|
|
78
|
-
debugLog(`Searching for plan ${planId} in ${plansDir} and ${archiveDir}`);
|
|
79
|
-
|
|
80
|
-
for (const dir of [plansDir, archiveDir]) {
|
|
81
|
-
if (!fs.existsSync(dir)) {
|
|
82
|
-
debugLog(`Directory does not exist: ${dir}`);
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
try {
|
|
87
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
88
|
-
|
|
89
|
-
for (const entry of entries) {
|
|
90
|
-
if (entry.isDirectory() && entry.name.match(/^\d+--/)) {
|
|
91
|
-
// Check if directory matches plan ID
|
|
92
|
-
const dirMatch = entry.name.match(/^(\d+)--/);
|
|
93
|
-
if (dirMatch && dirMatch[1] === planId) {
|
|
94
|
-
const planDirPath = path.join(dir, entry.name);
|
|
95
|
-
debugLog(`Found plan directory: ${planDirPath}`);
|
|
96
|
-
|
|
97
|
-
// Look for plan file inside directory
|
|
98
|
-
try {
|
|
99
|
-
const planDirEntries = fs.readdirSync(planDirPath, { withFileTypes: true });
|
|
100
|
-
|
|
101
|
-
for (const planEntry of planDirEntries) {
|
|
102
|
-
if (planEntry.isFile() && planEntry.name.match(/^plan-\d+--.*\.md$/)) {
|
|
103
|
-
const planFilePath = path.join(planDirPath, planEntry.name);
|
|
104
|
-
debugLog(`Found plan file: ${planFilePath}`);
|
|
105
|
-
return planFilePath;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
} catch (err) {
|
|
109
|
-
debugLog(`Failed to read plan directory ${planDirPath}: ${err.message}`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
} else if (entry.isFile() && entry.name.match(/^plan-\d+--.*\.md$/)) {
|
|
113
|
-
// Legacy: direct plan file in plans/archive directory
|
|
114
|
-
const filenameMatch = entry.name.match(/^plan-(\d+)--/);
|
|
115
|
-
if (filenameMatch && filenameMatch[1] === planId) {
|
|
116
|
-
const planFilePath = path.join(dir, entry.name);
|
|
117
|
-
debugLog(`Found legacy plan file: ${planFilePath}`);
|
|
118
|
-
return planFilePath;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
} catch (err) {
|
|
123
|
-
errorLog(`Failed to read directory ${dir}: ${err.message}`);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Extract a field value from YAML frontmatter
|
|
132
|
-
* @param {string} frontmatter - YAML frontmatter text
|
|
133
|
-
* @param {string} fieldName - Field name to extract
|
|
134
|
-
* @param {string} defaultValue - Default value if field not found
|
|
135
|
-
* @returns {string} Field value or default
|
|
136
|
-
*/
|
|
137
|
-
function extractField(frontmatter, fieldName, defaultValue = 'manual') {
|
|
138
|
-
debugLog(`Extracting field: ${fieldName}`);
|
|
139
|
-
|
|
140
|
-
// Pattern to match field with various formatting:
|
|
141
|
-
// - field: value
|
|
142
|
-
// - field: "value"
|
|
143
|
-
// - field: 'value'
|
|
144
|
-
// - "field": value
|
|
145
|
-
// - field : value (extra spaces)
|
|
146
|
-
const regex = new RegExp(`^\\s*["']?${fieldName}["']?\\s*:\\s*(.+)$`, 'm');
|
|
147
|
-
const match = frontmatter.match(regex);
|
|
148
|
-
|
|
149
|
-
if (!match) {
|
|
150
|
-
debugLog(`Field ${fieldName} not found, using default: ${defaultValue}`);
|
|
151
|
-
return defaultValue;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Clean up value: remove quotes and trim
|
|
155
|
-
let value = match[1].trim();
|
|
156
|
-
value = value.replace(/^['"]|['"]$/g, '');
|
|
157
|
-
|
|
158
|
-
debugLog(`Extracted ${fieldName}: ${value}`);
|
|
159
|
-
return value || defaultValue;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Main function to get approval methods from plan file
|
|
164
|
-
*/
|
|
165
|
-
function main() {
|
|
166
|
-
// Get plan ID from command line
|
|
167
|
-
const planId = process.argv[2];
|
|
168
|
-
if (!planId) {
|
|
169
|
-
errorLog('Error: Plan ID is required');
|
|
170
|
-
console.error('Usage: node get-approval-methods.cjs <plan-id>');
|
|
171
|
-
process.exit(1);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
debugLog(`Looking for plan ID: ${planId}`);
|
|
175
|
-
|
|
176
|
-
// Find task manager root
|
|
177
|
-
const taskManagerRoot = findTaskManagerRoot();
|
|
178
|
-
if (!taskManagerRoot) {
|
|
179
|
-
errorLog('No .ai/task-manager directory found in current directory or any parent directory.');
|
|
180
|
-
errorLog('Please ensure you are in a project with task manager initialized.');
|
|
181
|
-
errorLog(`Current working directory: ${process.cwd()}`);
|
|
182
|
-
process.exit(1);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Find plan file
|
|
186
|
-
const planFile = findPlanFile(taskManagerRoot, planId);
|
|
187
|
-
if (!planFile) {
|
|
188
|
-
errorLog(`Plan file for ID ${planId} not found in plans or archive directories.`);
|
|
189
|
-
process.exit(1);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
debugLog(`Reading plan file: ${planFile}`);
|
|
193
|
-
|
|
194
|
-
// Read plan file
|
|
195
|
-
let content;
|
|
196
|
-
try {
|
|
197
|
-
content = fs.readFileSync(planFile, 'utf8');
|
|
198
|
-
} catch (err) {
|
|
199
|
-
errorLog(`Failed to read plan file ${planFile}: ${err.message}`);
|
|
200
|
-
process.exit(1);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Extract YAML frontmatter
|
|
204
|
-
const frontmatterRegex = /^---\s*\r?\n([\s\S]*?)\r?\n---/;
|
|
205
|
-
const match = content.match(frontmatterRegex);
|
|
206
|
-
|
|
207
|
-
if (!match) {
|
|
208
|
-
errorLog('No YAML frontmatter found in plan file');
|
|
209
|
-
process.exit(1);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const frontmatter = match[1];
|
|
213
|
-
debugLog(`Found frontmatter:\n${frontmatter}`);
|
|
214
|
-
|
|
215
|
-
// Extract approval method fields
|
|
216
|
-
const approvalMethodPlan = extractField(frontmatter, 'approval_method_plan');
|
|
217
|
-
const approvalMethodTasks = extractField(frontmatter, 'approval_method_tasks');
|
|
218
|
-
|
|
219
|
-
// Output JSON
|
|
220
|
-
const result = {
|
|
221
|
-
approval_method_plan: approvalMethodPlan,
|
|
222
|
-
approval_method_tasks: approvalMethodTasks
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
console.log(JSON.stringify(result, null, 2));
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// Run main function
|
|
229
|
-
main();
|