@brainfile/cli 0.12.3 → 0.12.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/CHANGELOG.md +24 -0
- package/dist/cli.js +32 -9
- package/dist/cli.js.map +1 -1
- package/dist/commands/add.d.ts +12 -3
- package/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +83 -81
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/archive.d.ts.map +1 -1
- package/dist/commands/archive.js +70 -47
- package/dist/commands/archive.js.map +1 -1
- package/dist/commands/contract.d.ts +20 -0
- package/dist/commands/contract.d.ts.map +1 -0
- package/dist/commands/contract.js +62 -0
- package/dist/commands/contract.js.map +1 -0
- package/dist/commands/hooks.d.ts +7 -6
- package/dist/commands/hooks.d.ts.map +1 -1
- package/dist/commands/hooks.js +130 -124
- package/dist/commands/hooks.js.map +1 -1
- package/dist/commands/lint.d.ts +9 -1
- package/dist/commands/lint.d.ts.map +1 -1
- package/dist/commands/lint.js +74 -77
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/list.d.ts +12 -3
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +59 -58
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +104 -17
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/move.d.ts +9 -1
- package/dist/commands/move.d.ts.map +1 -1
- package/dist/commands/move.js +78 -64
- package/dist/commands/move.js.map +1 -1
- package/dist/commands/restore.d.ts.map +1 -1
- package/dist/commands/restore.js +15 -13
- package/dist/commands/restore.js.map +1 -1
- package/dist/commands/template.d.ts +7 -1
- package/dist/commands/template.d.ts.map +1 -1
- package/dist/commands/template.js +105 -124
- package/dist/commands/template.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/contractRunner.d.ts +54 -0
- package/dist/lib/contractRunner.d.ts.map +1 -0
- package/dist/lib/contractRunner.js +273 -0
- package/dist/lib/contractRunner.js.map +1 -0
- package/dist/tui/BrainfileTUI.d.ts.map +1 -1
- package/dist/tui/BrainfileTUI.js +7 -1
- package/dist/tui/BrainfileTUI.js.map +1 -1
- package/dist/tui/actions.d.ts +5 -0
- package/dist/tui/actions.d.ts.map +1 -1
- package/dist/tui/actions.js +122 -0
- package/dist/tui/actions.js.map +1 -1
- package/dist/tui/components/StackedTaskList.d.ts.map +1 -1
- package/dist/tui/components/StackedTaskList.js +4 -4
- package/dist/tui/components/StackedTaskList.js.map +1 -1
- package/dist/tui/components/TaskCard.d.ts +3 -1
- package/dist/tui/components/TaskCard.d.ts.map +1 -1
- package/dist/tui/components/TaskCard.js +33 -9
- package/dist/tui/components/TaskCard.js.map +1 -1
- package/dist/tui/components/TaskCardMeasure.d.ts +1 -1
- package/dist/tui/components/TaskCardMeasure.d.ts.map +1 -1
- package/dist/tui/components/TaskCardMeasure.js +11 -1
- package/dist/tui/components/TaskCardMeasure.js.map +1 -1
- package/dist/tui/components/TaskDetail.d.ts +14 -0
- package/dist/tui/components/TaskDetail.d.ts.map +1 -0
- package/dist/tui/components/TaskDetail.js +41 -0
- package/dist/tui/components/TaskDetail.js.map +1 -0
- package/dist/tui/components/TaskList.d.ts.map +1 -1
- package/dist/tui/components/TaskList.js +5 -4
- package/dist/tui/components/TaskList.js.map +1 -1
- package/dist/tui/hooks/useKeyboardNavigation.d.ts.map +1 -1
- package/dist/tui/hooks/useKeyboardNavigation.js +15 -9
- package/dist/tui/hooks/useKeyboardNavigation.js.map +1 -1
- package/dist/utils/archive.d.ts +57 -0
- package/dist/utils/archive.d.ts.map +1 -0
- package/dist/utils/archive.js +304 -0
- package/dist/utils/archive.js.map +1 -0
- package/dist/utils/cli-error.d.ts +44 -0
- package/dist/utils/cli-error.d.ts.map +1 -0
- package/dist/utils/cli-error.js +85 -0
- package/dist/utils/cli-error.js.map +1 -0
- package/dist/utils/config.d.ts +30 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +80 -0
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/errorHandler.d.ts +2 -2
- package/dist/utils/errorHandler.d.ts.map +1 -1
- package/dist/utils/errorHandler.js +8 -13
- package/dist/utils/errorHandler.js.map +1 -1
- package/dist/utils/git-helper.d.ts +8 -4
- package/dist/utils/git-helper.d.ts.map +1 -1
- package/dist/utils/git-helper.js +12 -9
- package/dist/utils/git-helper.js.map +1 -1
- package/dist/utils/logger.d.ts +34 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +56 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +2 -2
- package/.aider/sessions/auto-save.json +0 -23
- package/.aider.chat.history.md +0 -81
- package/.aider.input.history +0 -12
- package/.aider.tags.cache.v8/cache.db +0 -0
- package/.aider.tags.cache.v8/cache.db-shm +0 -0
- package/.aider.tags.cache.v8/cache.db-wal +0 -0
- package/.claude/settings.json +0 -7
- package/brainfile.md +0 -102
- package/logo.png +0 -0
package/dist/commands/lint.js
CHANGED
|
@@ -41,86 +41,83 @@ const fs = __importStar(require("fs"));
|
|
|
41
41
|
const path = __importStar(require("path"));
|
|
42
42
|
const core_1 = require("@brainfile/core");
|
|
43
43
|
const chalk_1 = __importDefault(require("chalk"));
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
else if (fixable.length > 0 && !options.fix) {
|
|
100
|
-
console.log(chalk_1.default.gray(`💡 Run with --fix to automatically fix ${fixable.length} issue${fixable.length > 1 ? 's' : ''}\n`));
|
|
101
|
-
}
|
|
102
|
-
// Summary
|
|
103
|
-
console.log(chalk_1.default.gray('─'.repeat(60)));
|
|
104
|
-
console.log(chalk_1.default.gray(`Total: ${result.issues.length} issue${result.issues.length > 1 ? 's' : ''} found`));
|
|
105
|
-
if (fixable.length > 0 && !options.fix) {
|
|
106
|
-
console.log(chalk_1.default.gray(` ${fixable.length} fixable with --fix`));
|
|
107
|
-
}
|
|
108
|
-
console.log();
|
|
109
|
-
// Exit with error code in check mode
|
|
110
|
-
if (options.check) {
|
|
111
|
-
if (errors.length > 0 || warnings.length > 0) {
|
|
112
|
-
process.exit(1);
|
|
113
|
-
}
|
|
44
|
+
const logger_1 = require("../utils/logger");
|
|
45
|
+
const cli_error_1 = require("../utils/cli-error");
|
|
46
|
+
const errorHandler_1 = require("../utils/errorHandler");
|
|
47
|
+
function lintCommand(options, logger = logger_1.defaultLogger) {
|
|
48
|
+
// Resolve file path
|
|
49
|
+
const filePath = path.resolve(options.file);
|
|
50
|
+
// Check if file exists
|
|
51
|
+
if (!fs.existsSync(filePath)) {
|
|
52
|
+
throw (0, cli_error_1.fileNotFound)(filePath);
|
|
53
|
+
}
|
|
54
|
+
// Read file content
|
|
55
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
56
|
+
logger.log(chalk_1.default.blue(`\n🔍 Linting: ${filePath}\n`));
|
|
57
|
+
// Run linter from core
|
|
58
|
+
const result = core_1.BrainfileLinter.lint(content, { autoFix: options.fix });
|
|
59
|
+
// Report findings
|
|
60
|
+
if (result.issues.length === 0) {
|
|
61
|
+
logger.log(chalk_1.default.green('✓ No issues found! Your brainfile.md is valid.\n'));
|
|
62
|
+
return { success: true, issues: [], fixed: false, fixedCount: 0 };
|
|
63
|
+
}
|
|
64
|
+
// Group issues by type
|
|
65
|
+
const grouped = core_1.BrainfileLinter.groupIssues(result);
|
|
66
|
+
const { errors, warnings, fixable } = grouped;
|
|
67
|
+
// Display errors
|
|
68
|
+
if (errors.length > 0) {
|
|
69
|
+
logger.log(chalk_1.default.red.bold(`✗ ${errors.length} Error${errors.length > 1 ? 's' : ''}:`));
|
|
70
|
+
errors.forEach(issue => {
|
|
71
|
+
const location = issue.line ? chalk_1.default.gray(` [line ${issue.line}]`) : '';
|
|
72
|
+
logger.log(chalk_1.default.red(` • ${issue.message}${location}`));
|
|
73
|
+
});
|
|
74
|
+
logger.log('');
|
|
75
|
+
}
|
|
76
|
+
// Display warnings
|
|
77
|
+
if (warnings.length > 0) {
|
|
78
|
+
logger.log(chalk_1.default.yellow.bold(`⚠ ${warnings.length} Warning${warnings.length > 1 ? 's' : ''}:`));
|
|
79
|
+
warnings.forEach(issue => {
|
|
80
|
+
const location = issue.line ? chalk_1.default.gray(` [line ${issue.line}]`) : '';
|
|
81
|
+
const fixableTag = issue.fixable ? chalk_1.default.gray(' [fixable]') : '';
|
|
82
|
+
logger.log(chalk_1.default.yellow(` • ${issue.message}${location}${fixableTag}`));
|
|
83
|
+
});
|
|
84
|
+
logger.log('');
|
|
85
|
+
}
|
|
86
|
+
let fixedCount = 0;
|
|
87
|
+
let fixed = false;
|
|
88
|
+
// Apply fixes if requested and content was fixed
|
|
89
|
+
if (options.fix && result.fixedContent) {
|
|
90
|
+
fs.writeFileSync(filePath, result.fixedContent, 'utf-8');
|
|
91
|
+
fixedCount = fixable.length;
|
|
92
|
+
fixed = true;
|
|
93
|
+
logger.log(chalk_1.default.green(`✓ Fixed ${fixable.length} issue${fixable.length > 1 ? 's' : ''}!\n`));
|
|
94
|
+
// Recheck after fixes
|
|
95
|
+
const recheckResult = core_1.BrainfileLinter.lint(result.fixedContent, { autoFix: false });
|
|
96
|
+
const remainingIssues = recheckResult.issues;
|
|
97
|
+
if (remainingIssues.length > 0) {
|
|
98
|
+
logger.log(chalk_1.default.yellow(`⚠ ${remainingIssues.length} issue${remainingIssues.length > 1 ? 's' : ''} remaining (not auto-fixable)\n`));
|
|
114
99
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
100
|
+
}
|
|
101
|
+
else if (fixable.length > 0 && !options.fix) {
|
|
102
|
+
logger.log(chalk_1.default.gray(`💡 Run with --fix to automatically fix ${fixable.length} issue${fixable.length > 1 ? 's' : ''}\n`));
|
|
103
|
+
}
|
|
104
|
+
// Summary
|
|
105
|
+
logger.log(chalk_1.default.gray('─'.repeat(60)));
|
|
106
|
+
logger.log(chalk_1.default.gray(`Total: ${result.issues.length} issue${result.issues.length > 1 ? 's' : ''} found`));
|
|
107
|
+
if (fixable.length > 0 && !options.fix) {
|
|
108
|
+
logger.log(chalk_1.default.gray(` ${fixable.length} fixable with --fix`));
|
|
109
|
+
}
|
|
110
|
+
logger.log('');
|
|
111
|
+
// Exit with error code in check mode
|
|
112
|
+
if (options.check) {
|
|
113
|
+
if (errors.length > 0 || warnings.length > 0) {
|
|
114
|
+
throw new cli_error_1.CLIError('Lint check failed', errorHandler_1.ExitCode.USER_ERROR);
|
|
118
115
|
}
|
|
119
|
-
// Success - don't exit, just return
|
|
120
116
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
117
|
+
// Normal mode: only exit 1 on errors (not warnings)
|
|
118
|
+
if (errors.length > 0) {
|
|
119
|
+
throw new cli_error_1.CLIError('Lint failed with errors', errorHandler_1.ExitCode.USER_ERROR);
|
|
124
120
|
}
|
|
121
|
+
return { success: true, issues: result.issues, fixed, fixedCount };
|
|
125
122
|
}
|
|
126
123
|
//# sourceMappingURL=lint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../src/commands/lint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../src/commands/lint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,kCA0FC;AA/GD,uCAAyB;AACzB,2CAA6B;AAC7B,0CAA6D;AAC7D,kDAA0B;AAC1B,4CAA6D;AAC7D,kDAA0E;AAC1E,wDAAiD;AAejD,SAAgB,WAAW,CAAC,OAAoB,EAAE,SAAiB,sBAAa;IAC9E,oBAAoB;IACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5C,uBAAuB;IACvB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAA,wBAAY,EAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;IAED,oBAAoB;IACpB,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAEnD,MAAM,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,iBAAiB,QAAQ,IAAI,CAAC,CAAC,CAAC;IAEtD,uBAAuB;IACvB,MAAM,MAAM,GAAG,sBAAe,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAEvE,kBAAkB;IAClB,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,MAAM,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC,CAAC;QAC5E,OAAO,EA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AE,CAAC;YAC7C,MAAM,IAAI,oBAAQ,CAAC,mBAAmB,EAAE,uBAAQ,CAAC,UAAU,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IAED,oDAAoD;IACpD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,oBAAQ,CAAC,yBAAyB,EAAE,uBAAQ,CAAC,UAAU,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACrE,CAAC"}
|
package/dist/commands/list.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { type Logger } from '../utils/logger';
|
|
2
|
+
export interface ListOptions {
|
|
2
3
|
file: string;
|
|
3
4
|
column?: string;
|
|
4
5
|
tag?: string;
|
|
5
6
|
}
|
|
6
|
-
export
|
|
7
|
-
|
|
7
|
+
export interface ListResult {
|
|
8
|
+
success: true;
|
|
9
|
+
totalTasks: number;
|
|
10
|
+
columnsDisplayed: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* List tasks from a brainfile.
|
|
14
|
+
* Throws CLIError on failure instead of calling process.exit.
|
|
15
|
+
*/
|
|
16
|
+
export declare function listCommand(options: ListOptions, logger?: Logger): ListResult;
|
|
8
17
|
//# sourceMappingURL=list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAiB,MAAM,iBAAiB,CAAC;AAG7D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,IAAI,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,GAAE,MAAsB,GAAG,UAAU,CAgE5F"}
|
package/dist/commands/list.js
CHANGED
|
@@ -41,82 +41,83 @@ const fs = __importStar(require("fs"));
|
|
|
41
41
|
const path = __importStar(require("path"));
|
|
42
42
|
const core_1 = require("@brainfile/core");
|
|
43
43
|
const chalk_1 = __importDefault(require("chalk"));
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
const logger_1 = require("../utils/logger");
|
|
45
|
+
const cli_error_1 = require("../utils/cli-error");
|
|
46
|
+
/**
|
|
47
|
+
* List tasks from a brainfile.
|
|
48
|
+
* Throws CLIError on failure instead of calling process.exit.
|
|
49
|
+
*/
|
|
50
|
+
function listCommand(options, logger = logger_1.defaultLogger) {
|
|
51
|
+
// Resolve file path
|
|
52
|
+
const filePath = path.resolve(options.file);
|
|
53
|
+
// Check if file exists
|
|
54
|
+
if (!fs.existsSync(filePath)) {
|
|
55
|
+
throw (0, cli_error_1.fileNotFound)(filePath);
|
|
56
|
+
}
|
|
57
|
+
// Read and parse the file
|
|
58
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
59
|
+
const result = core_1.Brainfile.parseWithErrors(content);
|
|
60
|
+
if (!result.board) {
|
|
61
|
+
throw (0, cli_error_1.parseFailure)(result.error);
|
|
62
|
+
}
|
|
63
|
+
const board = result.board;
|
|
64
|
+
// Filter columns if specified
|
|
65
|
+
const columns = options.column
|
|
66
|
+
? board.columns.filter(col => col.id === options.column || col.title === options.column)
|
|
67
|
+
: board.columns;
|
|
68
|
+
if (columns.length === 0) {
|
|
69
|
+
logger.log(chalk_1.default.yellow(`No columns found matching: ${options.column}`));
|
|
70
|
+
return { success: true, totalTasks: 0, columnsDisplayed: 0 };
|
|
71
|
+
}
|
|
72
|
+
// Display board title
|
|
73
|
+
logger.log(chalk_1.default.bold.white(`\n${board.title || 'Brainfile Board'}\n`));
|
|
74
|
+
// Display each column
|
|
75
|
+
for (const column of columns) {
|
|
76
|
+
// Filter tasks by tag if specified
|
|
77
|
+
const tasks = options.tag
|
|
78
|
+
? column.tasks.filter(task => task.tags?.includes(options.tag))
|
|
79
|
+
: column.tasks;
|
|
80
|
+
if (tasks.length === 0 && options.tag) {
|
|
81
|
+
continue;
|
|
58
82
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
console.log(chalk_1.default.yellow(`No columns found matching: ${options.column}`));
|
|
66
|
-
return;
|
|
83
|
+
// Column header
|
|
84
|
+
logger.log(chalk_1.default.bold.cyan(`${column.title} (${tasks.length})`));
|
|
85
|
+
logger.log(chalk_1.default.gray('─'.repeat(50)));
|
|
86
|
+
if (tasks.length === 0) {
|
|
87
|
+
logger.log(chalk_1.default.gray(' (no tasks)\n'));
|
|
88
|
+
continue;
|
|
67
89
|
}
|
|
68
|
-
// Display
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
for (const column of columns) {
|
|
72
|
-
// Filter tasks by tag if specified
|
|
73
|
-
const tasks = options.tag
|
|
74
|
-
? column.tasks.filter(task => task.tags?.includes(options.tag))
|
|
75
|
-
: column.tasks;
|
|
76
|
-
if (tasks.length === 0 && options.tag) {
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
// Column header
|
|
80
|
-
console.log(chalk_1.default.bold.cyan(`${column.title} (${tasks.length})`));
|
|
81
|
-
console.log(chalk_1.default.gray('─'.repeat(50)));
|
|
82
|
-
if (tasks.length === 0) {
|
|
83
|
-
console.log(chalk_1.default.gray(' (no tasks)\n'));
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
// Display tasks
|
|
87
|
-
for (const task of tasks) {
|
|
88
|
-
displayTask(task);
|
|
89
|
-
}
|
|
90
|
-
console.log('');
|
|
90
|
+
// Display tasks
|
|
91
|
+
for (const task of tasks) {
|
|
92
|
+
displayTask(task, logger);
|
|
91
93
|
}
|
|
92
|
-
|
|
93
|
-
const totalTasks = board.columns.reduce((sum, col) => sum + col.tasks.length, 0);
|
|
94
|
-
console.log(chalk_1.default.gray(`Total tasks: ${totalTasks}`));
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
(0, errorHandler_1.handleError)(error);
|
|
94
|
+
logger.log('');
|
|
98
95
|
}
|
|
96
|
+
// Display summary
|
|
97
|
+
const totalTasks = board.columns.reduce((sum, col) => sum + col.tasks.length, 0);
|
|
98
|
+
logger.log(chalk_1.default.gray(`Total tasks: ${totalTasks}`));
|
|
99
|
+
return { success: true, totalTasks, columnsDisplayed: columns.length };
|
|
99
100
|
}
|
|
100
|
-
function displayTask(task) {
|
|
101
|
+
function displayTask(task, logger) {
|
|
101
102
|
// Task ID and title
|
|
102
103
|
const idStr = chalk_1.default.gray(`[${task.id}]`);
|
|
103
104
|
const titleStr = chalk_1.default.white(task.title);
|
|
104
|
-
|
|
105
|
+
logger.log(` ${idStr} ${titleStr}`);
|
|
105
106
|
// Priority
|
|
106
107
|
if (task.priority) {
|
|
107
108
|
const priorityColor = task.priority === 'high' ? chalk_1.default.red :
|
|
108
109
|
task.priority === 'medium' ? chalk_1.default.yellow :
|
|
109
110
|
chalk_1.default.blue;
|
|
110
|
-
|
|
111
|
+
logger.log(` ${chalk_1.default.gray('Priority:')} ${priorityColor(task.priority)}`);
|
|
111
112
|
}
|
|
112
113
|
// Tags
|
|
113
114
|
if (task.tags && task.tags.length > 0) {
|
|
114
115
|
const tagStr = task.tags.map(t => chalk_1.default.cyan(`#${t}`)).join(' ');
|
|
115
|
-
|
|
116
|
+
logger.log(` ${chalk_1.default.gray('Tags:')} ${tagStr}`);
|
|
116
117
|
}
|
|
117
118
|
// Template
|
|
118
119
|
if (task.template) {
|
|
119
|
-
|
|
120
|
+
logger.log(` ${chalk_1.default.gray('Template:')} ${chalk_1.default.magenta(task.template)}`);
|
|
120
121
|
}
|
|
121
122
|
// Subtasks summary
|
|
122
123
|
if (task.subtasks && task.subtasks.length > 0) {
|
|
@@ -124,8 +125,8 @@ function displayTask(task) {
|
|
|
124
125
|
const total = task.subtasks.length;
|
|
125
126
|
const progressStr = `${completed}/${total}`;
|
|
126
127
|
const progressColor = completed === total ? chalk_1.default.green : chalk_1.default.yellow;
|
|
127
|
-
|
|
128
|
+
logger.log(` ${chalk_1.default.gray('Subtasks:')} ${progressColor(progressStr)}`);
|
|
128
129
|
}
|
|
129
|
-
|
|
130
|
+
logger.log('');
|
|
130
131
|
}
|
|
131
132
|
//# sourceMappingURL=list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,kCAgEC;AAvFD,uCAAyB;AACzB,2CAA6B;AAC7B,0CAAkD;AAClD,kDAA0B;AAC1B,4CAA6D;AAC7D,kDAA0E;AAc1E;;;GAGG;AACH,SAAgB,WAAW,CAAC,OAAoB,EAAE,SAAiB,sBAAa;IAC9E,oBAAoB;IACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5C,uBAAuB;IACvB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QA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OAAO,eAAK,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,eAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED,mBAAmB;IACnB,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9C,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;QAClE,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QACnC,MAAM,WAAW,GAAG,GAAG,SAAS,IAAI,KAAK,EAAE,CAAC;QAC5C,MAAM,aAAa,GAAG,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,eAAK,CAAC,KAAK,CAAC,CAAC,CAAC,eAAK,CAAC,MAAM,CAAC;QACvE,MAAM,CAAC,GAAG,CAAC,OAAO,eAAK,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":"AA4CA,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAiDD,wBAAsB,UAAU,CAAC,OAAO,EAAE,UAAU,iBA4vCnD"}
|
package/dist/commands/mcp.js
CHANGED
|
@@ -45,6 +45,8 @@ const config_1 = require("../utils/config");
|
|
|
45
45
|
const github_auth_1 = require("../utils/github-auth");
|
|
46
46
|
const linear_auth_1 = require("../utils/linear-auth");
|
|
47
47
|
const core_2 = require("@brainfile/core");
|
|
48
|
+
const contractRunner_1 = require("../lib/contractRunner");
|
|
49
|
+
const archive_1 = require("../utils/archive");
|
|
48
50
|
function resolveBrainfile(filePath) {
|
|
49
51
|
return path.resolve(filePath);
|
|
50
52
|
}
|
|
@@ -498,15 +500,15 @@ async function mcpCommand(options) {
|
|
|
498
500
|
// Determine effective destination
|
|
499
501
|
const brainfileDestination = board.archive?.destination;
|
|
500
502
|
const effectiveDestination = destination || (0, config_1.getEffectiveArchiveDestination)(brainfileDestination);
|
|
501
|
-
// Handle local archive
|
|
503
|
+
// Handle local archive (to separate brainfile-archive.md file)
|
|
502
504
|
if (effectiveDestination === 'local') {
|
|
503
|
-
const archiveResult = (0,
|
|
505
|
+
const archiveResult = (0, archive_1.archiveTaskToFile)(filePath, board, taskInfo.column.id, task);
|
|
504
506
|
if (!archiveResult.success) {
|
|
505
507
|
return { content: [{ type: 'text', text: `Error: ${archiveResult.error}` }], isError: true };
|
|
506
508
|
}
|
|
507
|
-
|
|
509
|
+
const archivePath = (0, archive_1.getArchivePath)(filePath);
|
|
508
510
|
return {
|
|
509
|
-
content: [{ type: 'text', text: `Task ${task} archived
|
|
511
|
+
content: [{ type: 'text', text: `Task ${task} archived to ${path.basename(archivePath)}` }]
|
|
510
512
|
};
|
|
511
513
|
}
|
|
512
514
|
// Handle GitHub archive
|
|
@@ -671,11 +673,19 @@ async function mcpCommand(options) {
|
|
|
671
673
|
if (!targetColumn) {
|
|
672
674
|
return { content: [{ type: 'text', text: `Error: Column not found: ${column}` }], isError: true };
|
|
673
675
|
}
|
|
674
|
-
|
|
676
|
+
// Restore from separate archive file
|
|
677
|
+
const restoreResult = (0, archive_1.restoreFromArchive)(filePath, task, targetColumn.id);
|
|
675
678
|
if (!restoreResult.success) {
|
|
679
|
+
// Provide helpful error if archive is empty
|
|
680
|
+
const { tasks } = (0, archive_1.loadArchivedTasks)(filePath);
|
|
681
|
+
if (tasks.length === 0) {
|
|
682
|
+
return {
|
|
683
|
+
content: [{ type: 'text', text: `Error: Archive is empty (${path.basename((0, archive_1.getArchivePath)(filePath))})` }],
|
|
684
|
+
isError: true
|
|
685
|
+
};
|
|
686
|
+
}
|
|
676
687
|
return { content: [{ type: 'text', text: `Error: ${restoreResult.error}` }], isError: true };
|
|
677
688
|
}
|
|
678
|
-
writeBoard(filePath, restoreResult.board);
|
|
679
689
|
return {
|
|
680
690
|
content: [{ type: 'text', text: `Task ${task} restored to "${targetColumn.title}"` }]
|
|
681
691
|
};
|
|
@@ -984,31 +994,108 @@ async function mcpCommand(options) {
|
|
|
984
994
|
// Bulk archive tasks tool
|
|
985
995
|
server.registerTool('bulk_archive_tasks', {
|
|
986
996
|
title: 'Bulk Archive Tasks',
|
|
987
|
-
description: 'Archive multiple tasks
|
|
997
|
+
description: 'Archive multiple tasks to the separate archive file',
|
|
988
998
|
inputSchema: {
|
|
989
999
|
file: zod_1.z.string().optional().describe('Path to brainfile.md (default: brainfile.md)'),
|
|
990
1000
|
tasks: zod_1.z.array(zod_1.z.string()).describe('Array of task IDs to archive')
|
|
991
1001
|
}
|
|
992
1002
|
}, async ({ file, tasks }) => {
|
|
993
1003
|
const filePath = file || defaultFile;
|
|
994
|
-
const
|
|
1004
|
+
const results = [];
|
|
1005
|
+
let successCount = 0;
|
|
1006
|
+
let failureCount = 0;
|
|
1007
|
+
// Archive each task individually (need to re-read board after each archive)
|
|
1008
|
+
for (const taskId of tasks) {
|
|
1009
|
+
const boardResult = readBoard(filePath);
|
|
1010
|
+
if ('error' in boardResult) {
|
|
1011
|
+
results.push({ taskId, success: false, error: boardResult.error });
|
|
1012
|
+
failureCount++;
|
|
1013
|
+
continue;
|
|
1014
|
+
}
|
|
1015
|
+
const { board } = boardResult;
|
|
1016
|
+
const taskInfo = (0, core_1.findTaskById)(board, taskId);
|
|
1017
|
+
if (!taskInfo) {
|
|
1018
|
+
results.push({ taskId, success: false, error: 'Task not found' });
|
|
1019
|
+
failureCount++;
|
|
1020
|
+
continue;
|
|
1021
|
+
}
|
|
1022
|
+
const archiveResult = (0, archive_1.archiveTaskToFile)(filePath, board, taskInfo.column.id, taskId);
|
|
1023
|
+
if (archiveResult.success) {
|
|
1024
|
+
results.push({ taskId, success: true });
|
|
1025
|
+
successCount++;
|
|
1026
|
+
}
|
|
1027
|
+
else {
|
|
1028
|
+
results.push({ taskId, success: false, error: archiveResult.error });
|
|
1029
|
+
failureCount++;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
const output = {
|
|
1033
|
+
success: failureCount === 0,
|
|
1034
|
+
successCount,
|
|
1035
|
+
failureCount,
|
|
1036
|
+
results,
|
|
1037
|
+
archiveFile: path.basename((0, archive_1.getArchivePath)(filePath))
|
|
1038
|
+
};
|
|
1039
|
+
return {
|
|
1040
|
+
content: [{ type: 'text', text: JSON.stringify(output, null, 2) }],
|
|
1041
|
+
isError: failureCount > 0 && successCount === 0
|
|
1042
|
+
};
|
|
1043
|
+
});
|
|
1044
|
+
// ==========================================================================
|
|
1045
|
+
// CONTRACTS
|
|
1046
|
+
// ==========================================================================
|
|
1047
|
+
server.registerTool('contract_pickup', {
|
|
1048
|
+
title: 'Contract Pickup',
|
|
1049
|
+
description: 'Claim a task contract (sets status to in_progress) and return agent context as markdown',
|
|
1050
|
+
inputSchema: {
|
|
1051
|
+
file: zod_1.z.string().optional().describe('Path to brainfile.md (default: brainfile.md)'),
|
|
1052
|
+
task: zod_1.z.string().describe('Task ID to pick up'),
|
|
1053
|
+
}
|
|
1054
|
+
}, async ({ file, task }) => {
|
|
1055
|
+
const filePath = file || defaultFile;
|
|
1056
|
+
const result = (0, contractRunner_1.pickupContract)({ filePath, taskId: task });
|
|
995
1057
|
if ('error' in result) {
|
|
996
1058
|
return { content: [{ type: 'text', text: `Error: ${result.error}` }], isError: true };
|
|
997
1059
|
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1060
|
+
return { content: [{ type: 'text', text: result.markdown }] };
|
|
1061
|
+
});
|
|
1062
|
+
server.registerTool('contract_deliver', {
|
|
1063
|
+
title: 'Contract Deliver',
|
|
1064
|
+
description: 'Mark a task contract as delivered (sets status to delivered)',
|
|
1065
|
+
inputSchema: {
|
|
1066
|
+
file: zod_1.z.string().optional().describe('Path to brainfile.md (default: brainfile.md)'),
|
|
1067
|
+
task: zod_1.z.string().describe('Task ID to deliver'),
|
|
1068
|
+
}
|
|
1069
|
+
}, async ({ file, task }) => {
|
|
1070
|
+
const filePath = file || defaultFile;
|
|
1071
|
+
const result = (0, contractRunner_1.deliverContract)({ filePath, taskId: task });
|
|
1072
|
+
if ('error' in result) {
|
|
1073
|
+
return { content: [{ type: 'text', text: `Error: ${result.error}` }], isError: true };
|
|
1074
|
+
}
|
|
1075
|
+
return { content: [{ type: 'text', text: `Contract delivered: ${task}` }] };
|
|
1076
|
+
});
|
|
1077
|
+
server.registerTool('contract_validate', {
|
|
1078
|
+
title: 'Contract Validate',
|
|
1079
|
+
description: 'Validate contract deliverables + commands; sets status to done/failed',
|
|
1080
|
+
inputSchema: {
|
|
1081
|
+
file: zod_1.z.string().optional().describe('Path to brainfile.md (default: brainfile.md)'),
|
|
1082
|
+
task: zod_1.z.string().describe('Task ID to validate'),
|
|
1083
|
+
}
|
|
1084
|
+
}, async ({ file, task }) => {
|
|
1085
|
+
const filePath = file || defaultFile;
|
|
1086
|
+
const result = (0, contractRunner_1.validateContract)({ filePath, taskId: task });
|
|
1087
|
+
if ('error' in result) {
|
|
1088
|
+
return { content: [{ type: 'text', text: `Error: ${result.error}` }], isError: true };
|
|
1002
1089
|
}
|
|
1003
1090
|
const output = {
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1091
|
+
ok: result.ok,
|
|
1092
|
+
status: result.ok ? 'done' : 'failed',
|
|
1093
|
+
deliverables: result.deliverableChecks,
|
|
1094
|
+
commands: result.commandResults,
|
|
1008
1095
|
};
|
|
1009
1096
|
return {
|
|
1010
1097
|
content: [{ type: 'text', text: JSON.stringify(output, null, 2) }],
|
|
1011
|
-
isError: !
|
|
1098
|
+
isError: !result.ok
|
|
1012
1099
|
};
|
|
1013
1100
|
});
|
|
1014
1101
|
// Connect via stdio
|