brainfile 0.18.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/README.md +222 -0
- package/dist/__tests__/helpers/v2.d.ts +12 -0
- package/dist/__tests__/helpers/v2.d.ts.map +1 -0
- package/dist/__tests__/helpers/v2.js +73 -0
- package/dist/__tests__/helpers/v2.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +480 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/add.d.ts +34 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +255 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/adr.d.ts +22 -0
- package/dist/commands/adr.d.ts.map +1 -0
- package/dist/commands/adr.js +195 -0
- package/dist/commands/adr.js.map +1 -0
- package/dist/commands/archive.d.ts +20 -0
- package/dist/commands/archive.d.ts.map +1 -0
- package/dist/commands/archive.js +590 -0
- package/dist/commands/archive.js.map +1 -0
- package/dist/commands/auth.d.ts +26 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +245 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/complete.d.ts +30 -0
- package/dist/commands/complete.d.ts.map +1 -0
- package/dist/commands/complete.js +267 -0
- package/dist/commands/complete.js.map +1 -0
- package/dist/commands/config.d.ts +29 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +210 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/contract.d.ts +84 -0
- package/dist/commands/contract.d.ts.map +1 -0
- package/dist/commands/contract.js +715 -0
- package/dist/commands/contract.js.map +1 -0
- package/dist/commands/delete.d.ts +8 -0
- package/dist/commands/delete.d.ts.map +1 -0
- package/dist/commands/delete.js +139 -0
- package/dist/commands/delete.js.map +1 -0
- package/dist/commands/hooks.d.ts +35 -0
- package/dist/commands/hooks.d.ts.map +1 -0
- package/dist/commands/hooks.js +324 -0
- package/dist/commands/hooks.js.map +1 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +118 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/lint.d.ts +16 -0
- package/dist/commands/lint.d.ts.map +1 -0
- package/dist/commands/lint.js +123 -0
- package/dist/commands/lint.js.map +1 -0
- package/dist/commands/list.d.ts +20 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +175 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/log.d.ts +52 -0
- package/dist/commands/log.d.ts.map +1 -0
- package/dist/commands/log.js +246 -0
- package/dist/commands/log.js.map +1 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +96 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/migrate.d.ts +16 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +388 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/move.d.ts +16 -0
- package/dist/commands/move.d.ts.map +1 -0
- package/dist/commands/move.js +225 -0
- package/dist/commands/move.js.map +1 -0
- package/dist/commands/patch.d.ts +17 -0
- package/dist/commands/patch.d.ts.map +1 -0
- package/dist/commands/patch.js +226 -0
- package/dist/commands/patch.js.map +1 -0
- package/dist/commands/restore.d.ts +8 -0
- package/dist/commands/restore.d.ts.map +1 -0
- package/dist/commands/restore.js +111 -0
- package/dist/commands/restore.js.map +1 -0
- package/dist/commands/rules.d.ts +68 -0
- package/dist/commands/rules.d.ts.map +1 -0
- package/dist/commands/rules.js +322 -0
- package/dist/commands/rules.js.map +1 -0
- package/dist/commands/schema.d.ts +31 -0
- package/dist/commands/schema.d.ts.map +1 -0
- package/dist/commands/schema.js +374 -0
- package/dist/commands/schema.js.map +1 -0
- package/dist/commands/search.d.ts +33 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/search.js +209 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/show.d.ts +20 -0
- package/dist/commands/show.d.ts.map +1 -0
- package/dist/commands/show.js +272 -0
- package/dist/commands/show.js.map +1 -0
- package/dist/commands/subtask.d.ts +12 -0
- package/dist/commands/subtask.d.ts.map +1 -0
- package/dist/commands/subtask.js +212 -0
- package/dist/commands/subtask.js.map +1 -0
- package/dist/commands/template.d.ts +17 -0
- package/dist/commands/template.d.ts.map +1 -0
- package/dist/commands/template.js +149 -0
- package/dist/commands/template.js.map +1 -0
- package/dist/commands/tui.d.ts +6 -0
- package/dist/commands/tui.d.ts.map +1 -0
- package/dist/commands/tui.js +79 -0
- package/dist/commands/tui.js.map +1 -0
- package/dist/commands/types.d.ts +40 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +242 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/contractRunner.d.ts +59 -0
- package/dist/lib/contractRunner.d.ts.map +1 -0
- package/dist/lib/contractRunner.js +511 -0
- package/dist/lib/contractRunner.js.map +1 -0
- package/dist/mcp/helpers.d.ts +32 -0
- package/dist/mcp/helpers.d.ts.map +1 -0
- package/dist/mcp/helpers.js +125 -0
- package/dist/mcp/helpers.js.map +1 -0
- package/dist/mcp/tools/contract.d.ts +25 -0
- package/dist/mcp/tools/contract.d.ts.map +1 -0
- package/dist/mcp/tools/contract.js +33 -0
- package/dist/mcp/tools/contract.js.map +1 -0
- package/dist/mcp/tools/contract_tool.d.ts +3 -0
- package/dist/mcp/tools/contract_tool.d.ts.map +1 -0
- package/dist/mcp/tools/contract_tool.js +328 -0
- package/dist/mcp/tools/contract_tool.js.map +1 -0
- package/dist/mcp/tools/get_task_tool.d.ts +3 -0
- package/dist/mcp/tools/get_task_tool.d.ts.map +1 -0
- package/dist/mcp/tools/get_task_tool.js +55 -0
- package/dist/mcp/tools/get_task_tool.js.map +1 -0
- package/dist/mcp/tools/list_tasks_tool.d.ts +3 -0
- package/dist/mcp/tools/list_tasks_tool.d.ts.map +1 -0
- package/dist/mcp/tools/list_tasks_tool.js +82 -0
- package/dist/mcp/tools/list_tasks_tool.js.map +1 -0
- package/dist/mcp/tools/search_tool.d.ts +3 -0
- package/dist/mcp/tools/search_tool.d.ts.map +1 -0
- package/dist/mcp/tools/search_tool.js +155 -0
- package/dist/mcp/tools/search_tool.js.map +1 -0
- package/dist/mcp/tools/subtask_tool.d.ts +3 -0
- package/dist/mcp/tools/subtask_tool.d.ts.map +1 -0
- package/dist/mcp/tools/subtask_tool.js +321 -0
- package/dist/mcp/tools/subtask_tool.js.map +1 -0
- package/dist/mcp/tools/task_add_tool.d.ts +3 -0
- package/dist/mcp/tools/task_add_tool.d.ts.map +1 -0
- package/dist/mcp/tools/task_add_tool.js +196 -0
- package/dist/mcp/tools/task_add_tool.js.map +1 -0
- package/dist/mcp/tools/task_complete_tool.d.ts +3 -0
- package/dist/mcp/tools/task_complete_tool.d.ts.map +1 -0
- package/dist/mcp/tools/task_complete_tool.js +265 -0
- package/dist/mcp/tools/task_complete_tool.js.map +1 -0
- package/dist/mcp/tools/task_delete_tool.d.ts +3 -0
- package/dist/mcp/tools/task_delete_tool.d.ts.map +1 -0
- package/dist/mcp/tools/task_delete_tool.js +87 -0
- package/dist/mcp/tools/task_delete_tool.js.map +1 -0
- package/dist/mcp/tools/task_move_tool.d.ts +3 -0
- package/dist/mcp/tools/task_move_tool.d.ts.map +1 -0
- package/dist/mcp/tools/task_move_tool.js +187 -0
- package/dist/mcp/tools/task_move_tool.js.map +1 -0
- package/dist/mcp/tools/task_patch_tool.d.ts +3 -0
- package/dist/mcp/tools/task_patch_tool.d.ts.map +1 -0
- package/dist/mcp/tools/task_patch_tool.js +189 -0
- package/dist/mcp/tools/task_patch_tool.js.map +1 -0
- package/dist/schemas/base.json +159 -0
- package/dist/schemas/board.json +290 -0
- package/dist/tui/BrainfileTUI.d.ts +4 -0
- package/dist/tui/BrainfileTUI.d.ts.map +1 -0
- package/dist/tui/BrainfileTUI.js +272 -0
- package/dist/tui/BrainfileTUI.js.map +1 -0
- package/dist/tui/actions.d.ts +84 -0
- package/dist/tui/actions.d.ts.map +1 -0
- package/dist/tui/actions.js +1251 -0
- package/dist/tui/actions.js.map +1 -0
- package/dist/tui/components/ColumnTabs.d.ts +9 -0
- package/dist/tui/components/ColumnTabs.d.ts.map +1 -0
- package/dist/tui/components/ColumnTabs.js +34 -0
- package/dist/tui/components/ColumnTabs.js.map +1 -0
- package/dist/tui/components/Header.d.ts +15 -0
- package/dist/tui/components/Header.d.ts.map +1 -0
- package/dist/tui/components/Header.js +48 -0
- package/dist/tui/components/Header.js.map +1 -0
- package/dist/tui/components/HelpOverlay.d.ts +9 -0
- package/dist/tui/components/HelpOverlay.d.ts.map +1 -0
- package/dist/tui/components/HelpOverlay.js +116 -0
- package/dist/tui/components/HelpOverlay.js.map +1 -0
- package/dist/tui/components/LogsPanel.d.ts +16 -0
- package/dist/tui/components/LogsPanel.d.ts.map +1 -0
- package/dist/tui/components/LogsPanel.js +115 -0
- package/dist/tui/components/LogsPanel.js.map +1 -0
- package/dist/tui/components/MainPanelTabs.d.ts +10 -0
- package/dist/tui/components/MainPanelTabs.d.ts.map +1 -0
- package/dist/tui/components/MainPanelTabs.js +56 -0
- package/dist/tui/components/MainPanelTabs.js.map +1 -0
- package/dist/tui/components/ManualBorder.d.ts +42 -0
- package/dist/tui/components/ManualBorder.d.ts.map +1 -0
- package/dist/tui/components/ManualBorder.js +56 -0
- package/dist/tui/components/ManualBorder.js.map +1 -0
- package/dist/tui/components/Overlays.d.ts +41 -0
- package/dist/tui/components/Overlays.d.ts.map +1 -0
- package/dist/tui/components/Overlays.js +127 -0
- package/dist/tui/components/Overlays.js.map +1 -0
- package/dist/tui/components/ProgressBar.d.ts +8 -0
- package/dist/tui/components/ProgressBar.d.ts.map +1 -0
- package/dist/tui/components/ProgressBar.js +35 -0
- package/dist/tui/components/ProgressBar.js.map +1 -0
- package/dist/tui/components/RulesPanel.d.ts +25 -0
- package/dist/tui/components/RulesPanel.d.ts.map +1 -0
- package/dist/tui/components/RulesPanel.js +139 -0
- package/dist/tui/components/RulesPanel.js.map +1 -0
- package/dist/tui/components/SearchBar.d.ts +8 -0
- package/dist/tui/components/SearchBar.d.ts.map +1 -0
- package/dist/tui/components/SearchBar.js +38 -0
- package/dist/tui/components/SearchBar.js.map +1 -0
- package/dist/tui/components/StackedTaskList.d.ts +27 -0
- package/dist/tui/components/StackedTaskList.d.ts.map +1 -0
- package/dist/tui/components/StackedTaskList.js +120 -0
- package/dist/tui/components/StackedTaskList.js.map +1 -0
- package/dist/tui/components/StatusBar.d.ts +14 -0
- package/dist/tui/components/StatusBar.d.ts.map +1 -0
- package/dist/tui/components/StatusBar.js +42 -0
- package/dist/tui/components/StatusBar.js.map +1 -0
- package/dist/tui/components/TaskCard.d.ts +25 -0
- package/dist/tui/components/TaskCard.d.ts.map +1 -0
- package/dist/tui/components/TaskCard.js +221 -0
- package/dist/tui/components/TaskCard.js.map +1 -0
- package/dist/tui/components/TaskCardMeasure.d.ts +31 -0
- package/dist/tui/components/TaskCardMeasure.d.ts.map +1 -0
- package/dist/tui/components/TaskCardMeasure.js +133 -0
- package/dist/tui/components/TaskCardMeasure.js.map +1 -0
- package/dist/tui/components/TaskDetail.d.ts +13 -0
- package/dist/tui/components/TaskDetail.d.ts.map +1 -0
- package/dist/tui/components/TaskDetail.js +64 -0
- package/dist/tui/components/TaskDetail.js.map +1 -0
- package/dist/tui/components/TaskList.d.ts +12 -0
- package/dist/tui/components/TaskList.d.ts.map +1 -0
- package/dist/tui/components/TaskList.js +75 -0
- package/dist/tui/components/TaskList.js.map +1 -0
- package/dist/tui/components/index.d.ts +31 -0
- package/dist/tui/components/index.d.ts.map +1 -0
- package/dist/tui/components/index.js +43 -0
- package/dist/tui/components/index.js.map +1 -0
- package/dist/tui/hooks/index.d.ts +3 -0
- package/dist/tui/hooks/index.d.ts.map +1 -0
- package/dist/tui/hooks/index.js +8 -0
- package/dist/tui/hooks/index.js.map +1 -0
- package/dist/tui/hooks/useBrainfileLoader.d.ts +5 -0
- package/dist/tui/hooks/useBrainfileLoader.d.ts.map +1 -0
- package/dist/tui/hooks/useBrainfileLoader.js +237 -0
- package/dist/tui/hooks/useBrainfileLoader.js.map +1 -0
- package/dist/tui/hooks/useKeyboardNavigation.d.ts +20 -0
- package/dist/tui/hooks/useKeyboardNavigation.d.ts.map +1 -0
- package/dist/tui/hooks/useKeyboardNavigation.js +806 -0
- package/dist/tui/hooks/useKeyboardNavigation.js.map +1 -0
- package/dist/tui/index.d.ts +10 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +38 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/tui/theme.d.ts +119 -0
- package/dist/tui/theme.d.ts.map +1 -0
- package/dist/tui/theme.js +138 -0
- package/dist/tui/theme.js.map +1 -0
- package/dist/tui/types.d.ts +53 -0
- package/dist/tui/types.d.ts.map +1 -0
- package/dist/tui/types.js +12 -0
- package/dist/tui/types.js.map +1 -0
- package/dist/tui/utils.d.ts +24 -0
- package/dist/tui/utils.d.ts.map +1 -0
- package/dist/tui/utils.js +161 -0
- package/dist/tui/utils.js.map +1 -0
- 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/auth-store.d.ts +69 -0
- package/dist/utils/auth-store.d.ts.map +1 -0
- package/dist/utils/auth-store.js +308 -0
- package/dist/utils/auth-store.js.map +1 -0
- package/dist/utils/board-types.d.ts +13 -0
- package/dist/utils/board-types.d.ts.map +1 -0
- package/dist/utils/board-types.js +7 -0
- package/dist/utils/board-types.js.map +1 -0
- package/dist/utils/brainfile-finder.d.ts +12 -0
- package/dist/utils/brainfile-finder.d.ts.map +1 -0
- package/dist/utils/brainfile-finder.js +69 -0
- package/dist/utils/brainfile-finder.js.map +1 -0
- package/dist/utils/brainfile-path.d.ts +10 -0
- package/dist/utils/brainfile-path.d.ts.map +1 -0
- package/dist/utils/brainfile-path.js +88 -0
- package/dist/utils/brainfile-path.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 +119 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +304 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/contractSpec.d.ts +13 -0
- package/dist/utils/contractSpec.d.ts.map +1 -0
- package/dist/utils/contractSpec.js +61 -0
- package/dist/utils/contractSpec.js.map +1 -0
- package/dist/utils/dot-brainfile.d.ts +9 -0
- package/dist/utils/dot-brainfile.d.ts.map +1 -0
- package/dist/utils/dot-brainfile.js +74 -0
- package/dist/utils/dot-brainfile.js.map +1 -0
- package/dist/utils/errorHandler.d.ts +106 -0
- package/dist/utils/errorHandler.d.ts.map +1 -0
- package/dist/utils/errorHandler.js +223 -0
- package/dist/utils/errorHandler.js.map +1 -0
- package/dist/utils/git-helper.d.ts +17 -0
- package/dist/utils/git-helper.d.ts.map +1 -0
- package/dist/utils/git-helper.js +62 -0
- package/dist/utils/git-helper.js.map +1 -0
- package/dist/utils/github-auth.d.ts +56 -0
- package/dist/utils/github-auth.d.ts.map +1 -0
- package/dist/utils/github-auth.js +341 -0
- package/dist/utils/github-auth.js.map +1 -0
- package/dist/utils/hook-parser.d.ts +15 -0
- package/dist/utils/hook-parser.d.ts.map +1 -0
- package/dist/utils/hook-parser.js +69 -0
- package/dist/utils/hook-parser.js.map +1 -0
- package/dist/utils/hook-settings.d.ts +27 -0
- package/dist/utils/hook-settings.d.ts.map +1 -0
- package/dist/utils/hook-settings.js +364 -0
- package/dist/utils/hook-settings.js.map +1 -0
- package/dist/utils/linear-auth.d.ts +59 -0
- package/dist/utils/linear-auth.d.ts.map +1 -0
- package/dist/utils/linear-auth.js +295 -0
- package/dist/utils/linear-auth.js.map +1 -0
- 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/dist/utils/strict-validation.d.ts +8 -0
- package/dist/utils/strict-validation.d.ts.map +1 -0
- package/dist/utils/strict-validation.js +41 -0
- package/dist/utils/strict-validation.js.map +1 -0
- package/dist/utils/v2-detect.d.ts +28 -0
- package/dist/utils/v2-detect.d.ts.map +1 -0
- package/dist/utils/v2-detect.js +112 -0
- package/dist/utils/v2-detect.js.map +1 -0
- package/dist/utils/v2-only.d.ts +9 -0
- package/dist/utils/v2-only.d.ts.map +1 -0
- package/dist/utils/v2-only.js +64 -0
- package/dist/utils/v2-only.js.map +1 -0
- package/dist/utils/workspace-format.d.ts +25 -0
- package/dist/utils/workspace-format.d.ts.map +1 -0
- package/dist/utils/workspace-format.js +106 -0
- package/dist/utils/workspace-format.js.map +1 -0
- package/dist/validation/command-lint.d.ts +11 -0
- package/dist/validation/command-lint.d.ts.map +1 -0
- package/dist/validation/command-lint.js +88 -0
- package/dist/validation/command-lint.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLIError = void 0;
|
|
4
|
+
exports.fileNotFound = fileNotFound;
|
|
5
|
+
exports.parseFailure = parseFailure;
|
|
6
|
+
exports.missingRequired = missingRequired;
|
|
7
|
+
exports.operationFailed = operationFailed;
|
|
8
|
+
exports.columnNotFound = columnNotFound;
|
|
9
|
+
exports.taskNotFound = taskNotFound;
|
|
10
|
+
exports.subtaskNotFound = subtaskNotFound;
|
|
11
|
+
exports.validationError = validationError;
|
|
12
|
+
const errorHandler_1 = require("./errorHandler");
|
|
13
|
+
/**
|
|
14
|
+
* Custom error class for CLI errors.
|
|
15
|
+
* Thrown by commands to signal failure without calling process.exit directly.
|
|
16
|
+
* The CLI entry point catches this and handles exit codes.
|
|
17
|
+
*/
|
|
18
|
+
class CLIError extends Error {
|
|
19
|
+
constructor(message, exitCode = errorHandler_1.ExitCode.USER_ERROR, details) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = 'CLIError';
|
|
22
|
+
this.exitCode = exitCode;
|
|
23
|
+
this.details = details;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.CLIError = CLIError;
|
|
27
|
+
/**
|
|
28
|
+
* Create a CLIError for file not found.
|
|
29
|
+
*/
|
|
30
|
+
function fileNotFound(filePath) {
|
|
31
|
+
return new CLIError(`File not found: ${filePath}`, errorHandler_1.ExitCode.USER_ERROR, 'To create a new brainfile, run: brainfile init');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a CLIError for parse errors.
|
|
35
|
+
*/
|
|
36
|
+
function parseFailure(error) {
|
|
37
|
+
const msg = error ? `Failed to parse brainfile: ${error}` : 'Failed to parse brainfile';
|
|
38
|
+
return new CLIError(msg, errorHandler_1.ExitCode.USER_ERROR, 'To validate and fix syntax issues, run: brainfile lint --fix');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create a CLIError for missing required options.
|
|
42
|
+
*/
|
|
43
|
+
function missingRequired(option, usage) {
|
|
44
|
+
return new CLIError(`${option} is required`, errorHandler_1.ExitCode.USER_ERROR, `Usage: ${usage}`);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create a CLIError from a core operation failure.
|
|
48
|
+
*/
|
|
49
|
+
function operationFailed(error) {
|
|
50
|
+
return new CLIError(error, errorHandler_1.ExitCode.USER_ERROR);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Create a CLIError for column not found.
|
|
54
|
+
*/
|
|
55
|
+
function columnNotFound(columnId, availableColumns) {
|
|
56
|
+
const listStr = availableColumns.join(', ');
|
|
57
|
+
return new CLIError(`Column not found: ${columnId}`, errorHandler_1.ExitCode.USER_ERROR, `Available columns: ${listStr}`);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create a CLIError for task not found.
|
|
61
|
+
*/
|
|
62
|
+
function taskNotFound(taskId, availableTasks = []) {
|
|
63
|
+
let details;
|
|
64
|
+
if (availableTasks.length > 0) {
|
|
65
|
+
details = `Available tasks:\n${availableTasks.map(t => ` - ${t}`).join('\n')}`;
|
|
66
|
+
}
|
|
67
|
+
return new CLIError(`Task not found: ${taskId}`, errorHandler_1.ExitCode.USER_ERROR, details);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create a CLIError for subtask not found.
|
|
71
|
+
*/
|
|
72
|
+
function subtaskNotFound(subtaskId, availableSubtasks = []) {
|
|
73
|
+
let details;
|
|
74
|
+
if (availableSubtasks.length > 0) {
|
|
75
|
+
details = `Available subtasks:\n${availableSubtasks.map(t => ` - ${t}`).join('\n')}`;
|
|
76
|
+
}
|
|
77
|
+
return new CLIError(`Subtask not found: ${subtaskId}`, errorHandler_1.ExitCode.USER_ERROR, details);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Create a CLIError for validation errors.
|
|
81
|
+
*/
|
|
82
|
+
function validationError(message) {
|
|
83
|
+
return new CLIError(`Validation error: ${message}`, errorHandler_1.ExitCode.USER_ERROR);
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=cli-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-error.js","sourceRoot":"","sources":["../../src/utils/cli-error.ts"],"names":[],"mappings":";;;AAsBA,oCAMC;AAKD,oCAOC;AAKD,0CAMC;AAKD,0CAEC;AAKD,wCAOC;AAID,oCAMC;AAKD,0CAMC;AAKD,0CAEC;AAlGD,iDAA6D;AAE7D;;;;GAIG;AACH,MAAa,QAAS,SAAQ,KAAK;IAI/B,YAAY,OAAe,EAAE,WAAyB,uBAAQ,CAAC,UAAU,EAAE,OAAgB;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I,OAA2B,CAAC;IAChC,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,GAAG,qBAAqB,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACpF,CAAC;IACD,OAAO,IAAI,QAAQ,CAAC,mBAAmB,MAAM,EAAE,EAAE,uBAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACnF,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,SAAiB,EAAE,oBAA8B,EAAE;IAC/E,IAAI,OAA2B,CAAC;IAChC,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,OAAO,GAAG,wBAAwB,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1F,CAAC;IACD,OAAO,IAAI,QAAQ,CAAC,sBAAsB,SAAS,EAAE,EAAE,uBAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACzF,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,OAAe;IAC3C,OAAO,IAAI,QAAQ,CAAC,qBAAqB,OAAO,EAAE,EAAE,uBAAQ,CAAC,UAAU,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration file management for Brainfile CLI
|
|
3
|
+
*
|
|
4
|
+
* Handles reading/writing ~/.config/brainfile/config.json for:
|
|
5
|
+
* - Archive destination defaults
|
|
6
|
+
* - GitHub connection details (owner, repo)
|
|
7
|
+
* - Linear connection details (teamId)
|
|
8
|
+
* - User preferences
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
export interface GitHubConfig {
|
|
13
|
+
/** GitHub repository owner (username or org) */
|
|
14
|
+
owner?: string;
|
|
15
|
+
/** GitHub repository name */
|
|
16
|
+
repo?: string;
|
|
17
|
+
/** Extra labels to add to archived issues */
|
|
18
|
+
labels?: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface LinearConfig {
|
|
21
|
+
/** Linear team ID */
|
|
22
|
+
teamId?: string;
|
|
23
|
+
/** Linear project ID (optional) */
|
|
24
|
+
projectId?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ArchiveConfig {
|
|
27
|
+
/** Default archive destination: 'local' | 'github' | 'linear' */
|
|
28
|
+
default?: 'local' | 'github' | 'linear';
|
|
29
|
+
/** GitHub-specific settings */
|
|
30
|
+
github?: GitHubConfig;
|
|
31
|
+
/** Linear-specific settings */
|
|
32
|
+
linear?: LinearConfig;
|
|
33
|
+
}
|
|
34
|
+
export interface BrainfileConfig {
|
|
35
|
+
/** Archive configuration */
|
|
36
|
+
archive?: ArchiveConfig;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get the path to the config directory
|
|
40
|
+
*/
|
|
41
|
+
export declare function getConfigDir(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Get the path to the config file
|
|
44
|
+
*/
|
|
45
|
+
export declare function getConfigPath(): string;
|
|
46
|
+
/**
|
|
47
|
+
* Ensure the config directory exists
|
|
48
|
+
*/
|
|
49
|
+
export declare function ensureConfigDir(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Load the config file
|
|
52
|
+
* @returns Config object, or empty object if file doesn't exist
|
|
53
|
+
*/
|
|
54
|
+
export declare function loadConfig(): BrainfileConfig;
|
|
55
|
+
/**
|
|
56
|
+
* Save the config file
|
|
57
|
+
* @param config - Config object to save
|
|
58
|
+
*/
|
|
59
|
+
export declare function saveConfig(config: BrainfileConfig): void;
|
|
60
|
+
/**
|
|
61
|
+
* Update specific config values (merges with existing)
|
|
62
|
+
* @param updates - Partial config to merge
|
|
63
|
+
*/
|
|
64
|
+
export declare function updateConfig(updates: Partial<BrainfileConfig>): BrainfileConfig;
|
|
65
|
+
/**
|
|
66
|
+
* Get archive configuration with defaults
|
|
67
|
+
*/
|
|
68
|
+
export declare function getArchiveConfig(): ArchiveConfig;
|
|
69
|
+
/**
|
|
70
|
+
* Set archive default destination
|
|
71
|
+
*/
|
|
72
|
+
export declare function setArchiveDefault(destination: 'local' | 'github' | 'linear'): void;
|
|
73
|
+
/**
|
|
74
|
+
* Set GitHub configuration
|
|
75
|
+
*/
|
|
76
|
+
export declare function setGitHubConfig(github: GitHubConfig): void;
|
|
77
|
+
/**
|
|
78
|
+
* Set Linear configuration
|
|
79
|
+
*/
|
|
80
|
+
export declare function setLinearConfig(linear: LinearConfig): void;
|
|
81
|
+
/**
|
|
82
|
+
* Get the effective archive destination
|
|
83
|
+
* Priority: brainfile.md archive.destination > config default > 'local'
|
|
84
|
+
*
|
|
85
|
+
* @param brainfileDestination - Destination from brainfile.md (if any)
|
|
86
|
+
* @returns The effective destination
|
|
87
|
+
*/
|
|
88
|
+
export declare function getEffectiveArchiveDestination(brainfileDestination?: string): 'local' | 'github' | 'linear';
|
|
89
|
+
export interface ParsedDestination {
|
|
90
|
+
type: 'local' | 'github' | 'linear';
|
|
91
|
+
/** GitHub owner (from github:owner/repo) */
|
|
92
|
+
owner?: string;
|
|
93
|
+
/** GitHub repo (from github:owner/repo) */
|
|
94
|
+
repo?: string;
|
|
95
|
+
/** Linear team key (from linear:TEAM) */
|
|
96
|
+
teamKey?: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Parse an archive destination string
|
|
100
|
+
*
|
|
101
|
+
* Formats:
|
|
102
|
+
* - `local` → local archive
|
|
103
|
+
* - `github` → GitHub with config defaults
|
|
104
|
+
* - `github:owner/repo` → GitHub with explicit owner/repo
|
|
105
|
+
* - `linear` → Linear with config defaults
|
|
106
|
+
* - `linear:TEAM` → Linear with explicit team key
|
|
107
|
+
*
|
|
108
|
+
* @param destination - Destination string from brainfile.md or CLI
|
|
109
|
+
* @returns Parsed destination with type and optional target info
|
|
110
|
+
*/
|
|
111
|
+
export declare function parseArchiveDestination(destination: string): ParsedDestination | null;
|
|
112
|
+
/**
|
|
113
|
+
* Get effective archive destination with full config resolution
|
|
114
|
+
*
|
|
115
|
+
* @param brainfileDestination - Destination from brainfile.md (may include target)
|
|
116
|
+
* @returns Fully resolved destination with type and target info
|
|
117
|
+
*/
|
|
118
|
+
export declare function getEffectiveDestination(brainfileDestination?: string): ParsedDestination;
|
|
119
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAUH,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,qBAAqB;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,iEAAiE;IACjE,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACxC,+BAA+B;IAC/B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,+BAA+B;IAC/B,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,4BAA4B;IAC5B,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAoBD;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAOrC;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAKtC;A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json for:
|
|
6
|
+
* - Archive destination defaults
|
|
7
|
+
* - GitHub connection details (owner, repo)
|
|
8
|
+
* - Linear connection details (teamId)
|
|
9
|
+
* - User preferences
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.getConfigDir = getConfigDir;
|
|
48
|
+
exports.getConfigPath = getConfigPath;
|
|
49
|
+
exports.ensureConfigDir = ensureConfigDir;
|
|
50
|
+
exports.loadConfig = loadConfig;
|
|
51
|
+
exports.saveConfig = saveConfig;
|
|
52
|
+
exports.updateConfig = updateConfig;
|
|
53
|
+
exports.getArchiveConfig = getArchiveConfig;
|
|
54
|
+
exports.setArchiveDefault = setArchiveDefault;
|
|
55
|
+
exports.setGitHubConfig = setGitHubConfig;
|
|
56
|
+
exports.setLinearConfig = setLinearConfig;
|
|
57
|
+
exports.getEffectiveArchiveDestination = getEffectiveArchiveDestination;
|
|
58
|
+
exports.parseArchiveDestination = parseArchiveDestination;
|
|
59
|
+
exports.getEffectiveDestination = getEffectiveDestination;
|
|
60
|
+
const fs = __importStar(require("fs"));
|
|
61
|
+
const path = __importStar(require("path"));
|
|
62
|
+
const os = __importStar(require("os"));
|
|
63
|
+
// ============================================================================
|
|
64
|
+
// Constants
|
|
65
|
+
// ============================================================================
|
|
66
|
+
function resolveHomeDir() {
|
|
67
|
+
const envHome = process.env.XDG_CONFIG_HOME?.trim();
|
|
68
|
+
if (envHome) {
|
|
69
|
+
return envHome;
|
|
70
|
+
}
|
|
71
|
+
const home = process.env.HOME?.trim();
|
|
72
|
+
return home || os.homedir();
|
|
73
|
+
}
|
|
74
|
+
// ============================================================================
|
|
75
|
+
// Config Functions
|
|
76
|
+
// ============================================================================
|
|
77
|
+
/**
|
|
78
|
+
* Get the path to the config directory
|
|
79
|
+
*/
|
|
80
|
+
function getConfigDir() {
|
|
81
|
+
const xdgConfigHome = process.env.XDG_CONFIG_HOME?.trim();
|
|
82
|
+
if (xdgConfigHome) {
|
|
83
|
+
return path.join(xdgConfigHome, 'brainfile');
|
|
84
|
+
}
|
|
85
|
+
return path.join(resolveHomeDir(), '.config', 'brainfile');
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get the path to the config file
|
|
89
|
+
*/
|
|
90
|
+
function getConfigPath() {
|
|
91
|
+
return path.join(getConfigDir(), 'config.json');
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Ensure the config directory exists
|
|
95
|
+
*/
|
|
96
|
+
function ensureConfigDir() {
|
|
97
|
+
const configDir = getConfigDir();
|
|
98
|
+
if (!fs.existsSync(configDir)) {
|
|
99
|
+
fs.mkdirSync(configDir, { recursive: true, mode: 0o700 });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Load the config file
|
|
104
|
+
* @returns Config object, or empty object if file doesn't exist
|
|
105
|
+
*/
|
|
106
|
+
function loadConfig() {
|
|
107
|
+
const configFile = getConfigPath();
|
|
108
|
+
try {
|
|
109
|
+
if (fs.existsSync(configFile)) {
|
|
110
|
+
const content = fs.readFileSync(configFile, 'utf-8');
|
|
111
|
+
return JSON.parse(content);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
// If file is corrupted, return empty config
|
|
116
|
+
console.error(`Warning: Could not read config file: ${error}`);
|
|
117
|
+
}
|
|
118
|
+
return {};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Save the config file
|
|
122
|
+
* @param config - Config object to save
|
|
123
|
+
*/
|
|
124
|
+
function saveConfig(config) {
|
|
125
|
+
const configFile = getConfigPath();
|
|
126
|
+
ensureConfigDir();
|
|
127
|
+
fs.writeFileSync(configFile, JSON.stringify(config, null, 2), {
|
|
128
|
+
encoding: 'utf-8',
|
|
129
|
+
mode: 0o600, // Owner read/write only
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Update specific config values (merges with existing)
|
|
134
|
+
* @param updates - Partial config to merge
|
|
135
|
+
*/
|
|
136
|
+
function updateConfig(updates) {
|
|
137
|
+
const current = loadConfig();
|
|
138
|
+
const updated = deepMerge(current, updates);
|
|
139
|
+
saveConfig(updated);
|
|
140
|
+
return updated;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Get archive configuration with defaults
|
|
144
|
+
*/
|
|
145
|
+
function getArchiveConfig() {
|
|
146
|
+
const config = loadConfig();
|
|
147
|
+
return config.archive || { default: 'local' };
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Set archive default destination
|
|
151
|
+
*/
|
|
152
|
+
function setArchiveDefault(destination) {
|
|
153
|
+
const config = loadConfig();
|
|
154
|
+
config.archive = config.archive || {};
|
|
155
|
+
config.archive.default = destination;
|
|
156
|
+
saveConfig(config);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Set GitHub configuration
|
|
160
|
+
*/
|
|
161
|
+
function setGitHubConfig(github) {
|
|
162
|
+
const config = loadConfig();
|
|
163
|
+
config.archive = config.archive || {};
|
|
164
|
+
config.archive.github = { ...config.archive.github, ...github };
|
|
165
|
+
saveConfig(config);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Set Linear configuration
|
|
169
|
+
*/
|
|
170
|
+
function setLinearConfig(linear) {
|
|
171
|
+
const config = loadConfig();
|
|
172
|
+
config.archive = config.archive || {};
|
|
173
|
+
config.archive.linear = { ...config.archive.linear, ...linear };
|
|
174
|
+
saveConfig(config);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Get the effective archive destination
|
|
178
|
+
* Priority: brainfile.md archive.destination > config default > 'local'
|
|
179
|
+
*
|
|
180
|
+
* @param brainfileDestination - Destination from brainfile.md (if any)
|
|
181
|
+
* @returns The effective destination
|
|
182
|
+
*/
|
|
183
|
+
function getEffectiveArchiveDestination(brainfileDestination) {
|
|
184
|
+
// Priority 1: brainfile.md setting
|
|
185
|
+
if (brainfileDestination && isValidDestination(brainfileDestination)) {
|
|
186
|
+
return brainfileDestination;
|
|
187
|
+
}
|
|
188
|
+
// Priority 2: config default
|
|
189
|
+
const config = getArchiveConfig();
|
|
190
|
+
if (config.default && isValidDestination(config.default)) {
|
|
191
|
+
return config.default;
|
|
192
|
+
}
|
|
193
|
+
// Priority 3: fallback to local
|
|
194
|
+
return 'local';
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Parse an archive destination string
|
|
198
|
+
*
|
|
199
|
+
* Formats:
|
|
200
|
+
* - `local` → local archive
|
|
201
|
+
* - `github` → GitHub with config defaults
|
|
202
|
+
* - `github:owner/repo` → GitHub with explicit owner/repo
|
|
203
|
+
* - `linear` → Linear with config defaults
|
|
204
|
+
* - `linear:TEAM` → Linear with explicit team key
|
|
205
|
+
*
|
|
206
|
+
* @param destination - Destination string from brainfile.md or CLI
|
|
207
|
+
* @returns Parsed destination with type and optional target info
|
|
208
|
+
*/
|
|
209
|
+
function parseArchiveDestination(destination) {
|
|
210
|
+
if (!destination)
|
|
211
|
+
return null;
|
|
212
|
+
// Simple destinations
|
|
213
|
+
if (destination === 'local') {
|
|
214
|
+
return { type: 'local' };
|
|
215
|
+
}
|
|
216
|
+
if (destination === 'github') {
|
|
217
|
+
return { type: 'github' };
|
|
218
|
+
}
|
|
219
|
+
if (destination === 'linear') {
|
|
220
|
+
return { type: 'linear' };
|
|
221
|
+
}
|
|
222
|
+
// Extended format: github:owner/repo
|
|
223
|
+
if (destination.startsWith('github:')) {
|
|
224
|
+
const target = destination.slice(7); // Remove 'github:'
|
|
225
|
+
const parts = target.split('/');
|
|
226
|
+
if (parts.length === 2 && parts[0] && parts[1]) {
|
|
227
|
+
return { type: 'github', owner: parts[0], repo: parts[1] };
|
|
228
|
+
}
|
|
229
|
+
// Invalid format, treat as plain github
|
|
230
|
+
return { type: 'github' };
|
|
231
|
+
}
|
|
232
|
+
// Extended format: linear:TEAM
|
|
233
|
+
if (destination.startsWith('linear:')) {
|
|
234
|
+
const teamKey = destination.slice(7); // Remove 'linear:'
|
|
235
|
+
if (teamKey) {
|
|
236
|
+
return { type: 'linear', teamKey };
|
|
237
|
+
}
|
|
238
|
+
// Invalid format, treat as plain linear
|
|
239
|
+
return { type: 'linear' };
|
|
240
|
+
}
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Get effective archive destination with full config resolution
|
|
245
|
+
*
|
|
246
|
+
* @param brainfileDestination - Destination from brainfile.md (may include target)
|
|
247
|
+
* @returns Fully resolved destination with type and target info
|
|
248
|
+
*/
|
|
249
|
+
function getEffectiveDestination(brainfileDestination) {
|
|
250
|
+
// Priority 1: brainfile.md setting (may have inline target)
|
|
251
|
+
if (brainfileDestination) {
|
|
252
|
+
const parsed = parseArchiveDestination(brainfileDestination);
|
|
253
|
+
if (parsed) {
|
|
254
|
+
// Fill in missing config from global config
|
|
255
|
+
const config = getArchiveConfig();
|
|
256
|
+
if (parsed.type === 'github' && !parsed.owner) {
|
|
257
|
+
parsed.owner = config.github?.owner;
|
|
258
|
+
parsed.repo = config.github?.repo;
|
|
259
|
+
}
|
|
260
|
+
if (parsed.type === 'linear' && !parsed.teamKey) {
|
|
261
|
+
// We'll resolve teamKey to teamId later in the archive command
|
|
262
|
+
}
|
|
263
|
+
return parsed;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// Priority 2: config default
|
|
267
|
+
const config = getArchiveConfig();
|
|
268
|
+
if (config.default && isValidDestination(config.default)) {
|
|
269
|
+
return { type: config.default };
|
|
270
|
+
}
|
|
271
|
+
// Priority 3: fallback to local
|
|
272
|
+
return { type: 'local' };
|
|
273
|
+
}
|
|
274
|
+
// ============================================================================
|
|
275
|
+
// Helper Functions
|
|
276
|
+
// ============================================================================
|
|
277
|
+
function isValidDestination(dest) {
|
|
278
|
+
return ['local', 'github', 'linear'].includes(dest);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Deep merge two objects
|
|
282
|
+
*/
|
|
283
|
+
function deepMerge(target, source) {
|
|
284
|
+
const result = { ...target };
|
|
285
|
+
for (const key in source) {
|
|
286
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
287
|
+
const sourceValue = source[key];
|
|
288
|
+
const targetValue = result[key];
|
|
289
|
+
if (sourceValue !== null &&
|
|
290
|
+
typeof sourceValue === 'object' &&
|
|
291
|
+
!Array.isArray(sourceValue) &&
|
|
292
|
+
targetValue !== null &&
|
|
293
|
+
typeof targetValue === 'object' &&
|
|
294
|
+
!Array.isArray(targetValue)) {
|
|
295
|
+
result[key] = deepMerge(targetValue, sourceValue);
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
result[key] = sourceValue;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return result;
|
|
303
|
+
}
|
|
304
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DH,oCAOC;AAKD,sCAEC;AAKD,0CAKC;AAMD,gCAYC;AAMD,gCAOC;AAMD,oCAKC;AAKD,4CAGC;AAKD,8CAKC;AAKD,0CAKC;AAKD,0CAKC;AASD,wEAgBC;AA6BD,0DAsCC;AAQD,0DA6BC;AApSD,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AAoCzB,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,SAAS,cAAc;IACrB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC;IACpD,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;IACtC,OAAO,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;AAC9B,CAAC;AAED,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;GAEG;AACH,SAAgB,YAAY;IAC1B,MAAM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,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAC3B,CAAC;gBACD,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;YACpD,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,GAAG,CAAC,GAAG,WAA0C,CAAC;YAC3D,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Contract, Deliverable } from '@brainfile/core';
|
|
2
|
+
export declare const ALLOWED_DELIVERABLE_TYPES: readonly ["file", "test", "docs", "design", "research"];
|
|
3
|
+
export type AllowedDeliverableType = (typeof ALLOWED_DELIVERABLE_TYPES)[number];
|
|
4
|
+
export declare function normalizeToArray(input?: string | string[]): string[];
|
|
5
|
+
export declare function parseDeliverableSpec(spec: string): Deliverable;
|
|
6
|
+
export declare function buildContract(params: {
|
|
7
|
+
deliverableSpecs?: string | string[];
|
|
8
|
+
validationCommands?: string | string[];
|
|
9
|
+
constraints?: string | string[];
|
|
10
|
+
/** Contract status — defaults to 'draft'. Pass 'ready' to make immediately dispatchable. */
|
|
11
|
+
status?: import('@brainfile/core').ContractStatus;
|
|
12
|
+
}): Contract;
|
|
13
|
+
//# sourceMappingURL=contractSpec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contractSpec.d.ts","sourceRoot":"","sources":["../../src/utils/contractSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE7D,eAAO,MAAM,yBAAyB,yDAA0D,CAAC;AACjG,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhF,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,CAGpE;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CA8C9D;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE;IACpC,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,4FAA4F;IAC5F,MAAM,CAAC,EAAE,OAAO,iBAAiB,EAAE,cAAc,CAAC;CACnD,GAAG,QAAQ,CAmBX"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ALLOWED_DELIVERABLE_TYPES = void 0;
|
|
4
|
+
exports.normalizeToArray = normalizeToArray;
|
|
5
|
+
exports.parseDeliverableSpec = parseDeliverableSpec;
|
|
6
|
+
exports.buildContract = buildContract;
|
|
7
|
+
exports.ALLOWED_DELIVERABLE_TYPES = ['file', 'test', 'docs', 'design', 'research'];
|
|
8
|
+
function normalizeToArray(input) {
|
|
9
|
+
if (!input)
|
|
10
|
+
return [];
|
|
11
|
+
return Array.isArray(input) ? input : [input];
|
|
12
|
+
}
|
|
13
|
+
function parseDeliverableSpec(spec) {
|
|
14
|
+
const raw = spec.trim();
|
|
15
|
+
if (!raw) {
|
|
16
|
+
throw new Error('Deliverable spec is required');
|
|
17
|
+
}
|
|
18
|
+
const firstColon = raw.indexOf(':');
|
|
19
|
+
if (firstColon === -1) {
|
|
20
|
+
throw new Error(`Invalid deliverable format: "${spec}". Expected "type:path:description" (description optional).`);
|
|
21
|
+
}
|
|
22
|
+
const type = raw.slice(0, firstColon).trim();
|
|
23
|
+
const rest = raw.slice(firstColon + 1);
|
|
24
|
+
const secondColon = rest.indexOf(':');
|
|
25
|
+
const path = (secondColon === -1 ? rest : rest.slice(0, secondColon)).trim();
|
|
26
|
+
const description = (secondColon === -1 ? '' : rest.slice(secondColon + 1)).trim();
|
|
27
|
+
if (!type) {
|
|
28
|
+
throw new Error(`Invalid deliverable format: "${spec}". Expected "type:path:description" with non-empty type.`);
|
|
29
|
+
}
|
|
30
|
+
if (!path) {
|
|
31
|
+
throw new Error(`Invalid deliverable format: "${spec}". Expected "type:path:description" with non-empty path.`);
|
|
32
|
+
}
|
|
33
|
+
const typeLower = type.toLowerCase();
|
|
34
|
+
if (!exports.ALLOWED_DELIVERABLE_TYPES.includes(typeLower)) {
|
|
35
|
+
throw new Error(`Invalid deliverable type: "${type}". Expected one of: ${exports.ALLOWED_DELIVERABLE_TYPES.join(', ')}`);
|
|
36
|
+
}
|
|
37
|
+
const deliverable = {
|
|
38
|
+
type: typeLower,
|
|
39
|
+
path,
|
|
40
|
+
...(description ? { description } : {}),
|
|
41
|
+
};
|
|
42
|
+
return deliverable;
|
|
43
|
+
}
|
|
44
|
+
function buildContract(params) {
|
|
45
|
+
const deliverableSpecs = normalizeToArray(params.deliverableSpecs);
|
|
46
|
+
const validationCommands = normalizeToArray(params.validationCommands).map((c) => c.trim()).filter(Boolean);
|
|
47
|
+
const constraints = normalizeToArray(params.constraints).map((c) => c.trim()).filter(Boolean);
|
|
48
|
+
const status = params.status ?? 'draft';
|
|
49
|
+
const deliverables = deliverableSpecs.map(parseDeliverableSpec);
|
|
50
|
+
const contract = {
|
|
51
|
+
status,
|
|
52
|
+
...(deliverables.length > 0 ? { deliverables } : {}),
|
|
53
|
+
...(validationCommands.length > 0 ? { validation: { commands: validationCommands } } : {}),
|
|
54
|
+
...(constraints.length > 0 ? { constraints } : {}),
|
|
55
|
+
...(status === 'ready'
|
|
56
|
+
? { metrics: { readyAt: new Date().toISOString() } }
|
|
57
|
+
: {}),
|
|
58
|
+
};
|
|
59
|
+
return contract;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=contractSpec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contractSpec.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,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9F,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC;IAExC,MAAM,YAAY,GAAG,gBAAgB,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAEhE,MAAM,QAAQ,GAAa;QACzB,MAAM;QACN,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpD,GAAG,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1F,GAAG,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,GAAG,CAAC,MAAM,KAAK,OAAO;YACpB,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAyB,EAAE;YAC3E,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensure `.brainfile/.gitignore` exists and remove legacy `state.json` entries.
|
|
3
|
+
*/
|
|
4
|
+
export declare function ensureDotBrainfileGitignore(brainfilePath: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Remove legacy `.brainfile/state.json` if it exists.
|
|
7
|
+
*/
|
|
8
|
+
export declare function removeLegacyStateFile(brainfilePath: string): string;
|
|
9
|
+
//# sourceMappingURL=dot-brainfile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dot-brainfile.d.ts","sourceRoot":"","sources":["../../src/utils/dot-brainfile.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAezE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAOnE"}
|