@brainfile/cli 0.13.3 → 0.15.1
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 +50 -0
- package/README.md +129 -354
- package/dist/cli.js +91 -5
- package/dist/cli.js.map +1 -1
- package/dist/commands/add.d.ts +3 -0
- package/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +163 -3
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/adr.d.ts +22 -0
- package/dist/commands/adr.d.ts.map +1 -0
- package/dist/commands/adr.js +182 -0
- package/dist/commands/adr.js.map +1 -0
- package/dist/commands/archive.d.ts.map +1 -1
- package/dist/commands/archive.js +147 -0
- package/dist/commands/archive.js.map +1 -1
- package/dist/commands/complete.d.ts +30 -0
- package/dist/commands/complete.d.ts.map +1 -0
- package/dist/commands/complete.js +254 -0
- package/dist/commands/complete.js.map +1 -0
- package/dist/commands/contract.d.ts.map +1 -1
- package/dist/commands/contract.js +2 -0
- package/dist/commands/contract.js.map +1 -1
- package/dist/commands/delete.d.ts.map +1 -1
- package/dist/commands/delete.js +29 -1
- package/dist/commands/delete.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +38 -19
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/list.d.ts +1 -0
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +35 -12
- package/dist/commands/list.js.map +1 -1
- 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.map +1 -1
- package/dist/commands/mcp.js +864 -44
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/migrate.d.ts +4 -3
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +225 -33
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/move.d.ts.map +1 -1
- package/dist/commands/move.js +90 -0
- package/dist/commands/move.js.map +1 -1
- package/dist/commands/patch.d.ts.map +1 -1
- package/dist/commands/patch.js +85 -13
- package/dist/commands/patch.js.map +1 -1
- 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.map +1 -1
- package/dist/commands/show.js +75 -1
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/subtask.d.ts.map +1 -1
- package/dist/commands/subtask.js +72 -5
- package/dist/commands/subtask.js.map +1 -1
- package/dist/commands/tui.d.ts.map +1 -1
- package/dist/commands/tui.js +10 -0
- package/dist/commands/tui.js.map +1 -1
- 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 +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/contractRunner.d.ts.map +1 -1
- package/dist/lib/contractRunner.js +177 -12
- package/dist/lib/contractRunner.js.map +1 -1
- package/dist/schemas/board.json +105 -18
- package/dist/tui/BrainfileTUI.d.ts.map +1 -1
- package/dist/tui/BrainfileTUI.js +23 -20
- package/dist/tui/BrainfileTUI.js.map +1 -1
- package/dist/tui/actions.d.ts +5 -5
- package/dist/tui/actions.d.ts.map +1 -1
- package/dist/tui/actions.js +335 -47
- package/dist/tui/actions.js.map +1 -1
- package/dist/tui/components/ArchivePanel.js +1 -1
- package/dist/tui/components/ArchivePanel.js.map +1 -1
- package/dist/tui/components/ColumnTabs.d.ts.map +1 -1
- package/dist/tui/components/ColumnTabs.js +6 -2
- package/dist/tui/components/ColumnTabs.js.map +1 -1
- package/dist/tui/components/HelpOverlay.js +3 -3
- package/dist/tui/components/HelpOverlay.js.map +1 -1
- 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 +2 -2
- package/dist/tui/components/MainPanelTabs.d.ts.map +1 -1
- package/dist/tui/components/MainPanelTabs.js +3 -3
- package/dist/tui/components/MainPanelTabs.js.map +1 -1
- package/dist/tui/components/StackedTaskList.d.ts +2 -1
- package/dist/tui/components/StackedTaskList.d.ts.map +1 -1
- package/dist/tui/components/StackedTaskList.js +9 -9
- package/dist/tui/components/StackedTaskList.js.map +1 -1
- package/dist/tui/components/TaskCard.d.ts +2 -1
- package/dist/tui/components/TaskCard.d.ts.map +1 -1
- package/dist/tui/components/TaskCard.js +41 -5
- package/dist/tui/components/TaskCard.js.map +1 -1
- package/dist/tui/components/TaskCardMeasure.d.ts +2 -16
- package/dist/tui/components/TaskCardMeasure.d.ts.map +1 -1
- package/dist/tui/components/TaskCardMeasure.js +30 -25
- package/dist/tui/components/TaskCardMeasure.js.map +1 -1
- package/dist/tui/components/TaskDetail.d.ts +2 -3
- package/dist/tui/components/TaskDetail.d.ts.map +1 -1
- package/dist/tui/components/TaskDetail.js +35 -12
- package/dist/tui/components/TaskDetail.js.map +1 -1
- package/dist/tui/components/TaskList.d.ts +2 -1
- package/dist/tui/components/TaskList.d.ts.map +1 -1
- package/dist/tui/components/TaskList.js +5 -5
- package/dist/tui/components/TaskList.js.map +1 -1
- package/dist/tui/components/index.d.ts +2 -2
- package/dist/tui/components/index.d.ts.map +1 -1
- package/dist/tui/components/index.js +3 -3
- package/dist/tui/components/index.js.map +1 -1
- package/dist/tui/hooks/useBrainfileLoader.d.ts.map +1 -1
- package/dist/tui/hooks/useBrainfileLoader.js +97 -31
- package/dist/tui/hooks/useBrainfileLoader.js.map +1 -1
- package/dist/tui/hooks/useKeyboardNavigation.d.ts.map +1 -1
- package/dist/tui/hooks/useKeyboardNavigation.js +47 -47
- package/dist/tui/hooks/useKeyboardNavigation.js.map +1 -1
- package/dist/tui/types.d.ts +7 -7
- package/dist/tui/types.d.ts.map +1 -1
- 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/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/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-tasks.d.ts +121 -0
- package/dist/utils/v2-tasks.d.ts.map +1 -0
- package/dist/utils/v2-tasks.js +384 -0
- package/dist/utils/v2-tasks.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/package.json +3 -3
- package/state.json +3 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Logger } from '../utils/logger';
|
|
2
|
+
export interface TypeEntry {
|
|
3
|
+
idPrefix: string;
|
|
4
|
+
completable?: boolean;
|
|
5
|
+
schema?: string;
|
|
6
|
+
}
|
|
7
|
+
export type TypesConfig = Record<string, TypeEntry>;
|
|
8
|
+
export interface TypesListOptions {
|
|
9
|
+
file: string;
|
|
10
|
+
json?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface TypesAddOptions {
|
|
13
|
+
file: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
idPrefix?: string;
|
|
16
|
+
completable?: boolean;
|
|
17
|
+
schema?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface TypesListResult {
|
|
20
|
+
success: true;
|
|
21
|
+
strict: boolean;
|
|
22
|
+
types: TypesConfig;
|
|
23
|
+
}
|
|
24
|
+
export interface TypesAddResult {
|
|
25
|
+
success: true;
|
|
26
|
+
strict: boolean;
|
|
27
|
+
typeName: string;
|
|
28
|
+
entry: TypeEntry;
|
|
29
|
+
filePath: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function parseBooleanFlag(value: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* List configured board types for v1/v2 boards.
|
|
34
|
+
*/
|
|
35
|
+
export declare function typesListCommand(options: TypesListOptions, logger?: Logger): TypesListResult;
|
|
36
|
+
/**
|
|
37
|
+
* Add or update a type entry under board frontmatter.types for v1/v2 boards.
|
|
38
|
+
*/
|
|
39
|
+
export declare function typesAddCommand(options: TypesAddOptions, logger?: Logger): TypesAddResult;
|
|
40
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/commands/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAiB,MAAM,iBAAiB,CAAC;AAU7D,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAEpD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,IAAI,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,WAAW,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,IAAI,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAsHD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAgBvD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,gBAAgB,EACzB,MAAM,GAAE,MAAsB,GAC7B,eAAe,CAwCjB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,eAAe,EACxB,MAAM,GAAE,MAAsB,GAC7B,cAAc,CA8DhB"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.parseBooleanFlag = parseBooleanFlag;
|
|
40
|
+
exports.typesListCommand = typesListCommand;
|
|
41
|
+
exports.typesAddCommand = typesAddCommand;
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const yaml = __importStar(require("js-yaml"));
|
|
44
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
45
|
+
const logger_1 = require("../utils/logger");
|
|
46
|
+
const cli_error_1 = require("../utils/cli-error");
|
|
47
|
+
const brainfile_path_1 = require("../utils/brainfile-path");
|
|
48
|
+
const v2_detect_1 = require("../utils/v2-detect");
|
|
49
|
+
function parseFrontmatter(content) {
|
|
50
|
+
const lines = content.split('\n');
|
|
51
|
+
if (lines.length === 0 || lines[0].trim() !== '---') {
|
|
52
|
+
throw (0, cli_error_1.parseFailure)('Missing YAML frontmatter start delimiter (---)');
|
|
53
|
+
}
|
|
54
|
+
let endIndex = -1;
|
|
55
|
+
for (let i = 1; i < lines.length; i++) {
|
|
56
|
+
if (lines[i].trim() === '---') {
|
|
57
|
+
endIndex = i;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (endIndex === -1) {
|
|
62
|
+
throw (0, cli_error_1.parseFailure)('Missing YAML frontmatter end delimiter (---)');
|
|
63
|
+
}
|
|
64
|
+
const yamlContent = lines.slice(1, endIndex).join('\n');
|
|
65
|
+
const parsed = yaml.load(yamlContent);
|
|
66
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
67
|
+
throw (0, cli_error_1.parseFailure)('YAML frontmatter must be a mapping/object');
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
data: parsed,
|
|
71
|
+
body: lines.slice(endIndex + 1).join('\n'),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function serializeFrontmatter(doc) {
|
|
75
|
+
const yamlContent = yaml.dump(doc.data, {
|
|
76
|
+
indent: 2,
|
|
77
|
+
lineWidth: -1,
|
|
78
|
+
noRefs: true,
|
|
79
|
+
sortKeys: false,
|
|
80
|
+
quotingType: '"',
|
|
81
|
+
forceQuotes: false,
|
|
82
|
+
});
|
|
83
|
+
return `---\n${yamlContent}---\n${doc.body}`;
|
|
84
|
+
}
|
|
85
|
+
function readFrontmatter(filePath) {
|
|
86
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
87
|
+
return parseFrontmatter(content);
|
|
88
|
+
}
|
|
89
|
+
function writeFrontmatter(filePath, doc) {
|
|
90
|
+
fs.writeFileSync(filePath, serializeFrontmatter(doc), 'utf-8');
|
|
91
|
+
}
|
|
92
|
+
function sanitizeTypesConfig(raw) {
|
|
93
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
94
|
+
return {};
|
|
95
|
+
}
|
|
96
|
+
const entries = raw;
|
|
97
|
+
const out = {};
|
|
98
|
+
for (const [name, value] of Object.entries(entries)) {
|
|
99
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const maybeEntry = value;
|
|
103
|
+
const idPrefix = typeof maybeEntry.idPrefix === 'string' && maybeEntry.idPrefix.trim()
|
|
104
|
+
? maybeEntry.idPrefix.trim()
|
|
105
|
+
: name;
|
|
106
|
+
const entry = { idPrefix };
|
|
107
|
+
if (typeof maybeEntry.completable === 'boolean') {
|
|
108
|
+
entry.completable = maybeEntry.completable;
|
|
109
|
+
}
|
|
110
|
+
if (typeof maybeEntry.schema === 'string' && maybeEntry.schema.trim()) {
|
|
111
|
+
entry.schema = maybeEntry.schema.trim();
|
|
112
|
+
}
|
|
113
|
+
out[name] = entry;
|
|
114
|
+
}
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
117
|
+
function getV1TypesConfig(filePath) {
|
|
118
|
+
const doc = readFrontmatter(filePath);
|
|
119
|
+
const strict = doc.data.strict === true;
|
|
120
|
+
const types = getBoardTypes(doc.data);
|
|
121
|
+
return { strict, types };
|
|
122
|
+
}
|
|
123
|
+
function getBoardTypes(board) {
|
|
124
|
+
return sanitizeTypesConfig(board.types);
|
|
125
|
+
}
|
|
126
|
+
function normalizeName(name) {
|
|
127
|
+
const normalized = name?.trim();
|
|
128
|
+
if (!normalized) {
|
|
129
|
+
throw (0, cli_error_1.missingRequired)('<name>', 'brainfile types add <name> [options]');
|
|
130
|
+
}
|
|
131
|
+
return normalized;
|
|
132
|
+
}
|
|
133
|
+
function normalizeIdPrefix(name, idPrefix) {
|
|
134
|
+
const normalized = idPrefix?.trim();
|
|
135
|
+
if (!normalized)
|
|
136
|
+
return name;
|
|
137
|
+
return normalized;
|
|
138
|
+
}
|
|
139
|
+
function parseBooleanFlag(value) {
|
|
140
|
+
const normalized = value.trim().toLowerCase();
|
|
141
|
+
if (['true', '1', 'yes', 'y', 'on'].includes(normalized)) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
if (['false', '0', 'no', 'n', 'off'].includes(normalized)) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
throw new cli_error_1.CLIError(`Invalid boolean value: ${value}`, undefined, 'Use one of: true, false, 1, 0, yes, no, on, off');
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* List configured board types for v1/v2 boards.
|
|
151
|
+
*/
|
|
152
|
+
function typesListCommand(options, logger = logger_1.defaultLogger) {
|
|
153
|
+
const filePath = (0, brainfile_path_1.resolveCliBrainfilePath)(options.file);
|
|
154
|
+
if (!fs.existsSync(filePath)) {
|
|
155
|
+
throw (0, cli_error_1.fileNotFound)(filePath);
|
|
156
|
+
}
|
|
157
|
+
let strict = false;
|
|
158
|
+
let types = {};
|
|
159
|
+
if ((0, v2_detect_1.isV2)(filePath)) {
|
|
160
|
+
const board = (0, v2_detect_1.readV2BoardConfig)(filePath);
|
|
161
|
+
strict = board.strict === true;
|
|
162
|
+
types = getBoardTypes(board);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
const config = getV1TypesConfig(filePath);
|
|
166
|
+
strict = config.strict;
|
|
167
|
+
types = config.types;
|
|
168
|
+
}
|
|
169
|
+
if (options.json) {
|
|
170
|
+
logger.log(JSON.stringify({ strict, types }, null, 2));
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
logger.log(`Strict mode: ${strict ? 'on' : 'off'}`);
|
|
174
|
+
const entries = Object.entries(types);
|
|
175
|
+
if (entries.length === 0) {
|
|
176
|
+
logger.log('No custom types defined. Add types to your brainfile.md or use \'brainfile types add\'.');
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
logger.log('Types:');
|
|
180
|
+
const sorted = [...entries].sort(([a], [b]) => a.localeCompare(b));
|
|
181
|
+
for (const [name, entry] of sorted) {
|
|
182
|
+
const completable = entry.completable ?? true;
|
|
183
|
+
const schema = entry.schema ? `, schema=${entry.schema}` : '';
|
|
184
|
+
logger.log(` ${name}: idPrefix=${entry.idPrefix}, completable=${completable}${schema}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return { success: true, strict, types };
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Add or update a type entry under board frontmatter.types for v1/v2 boards.
|
|
192
|
+
*/
|
|
193
|
+
function typesAddCommand(options, logger = logger_1.defaultLogger) {
|
|
194
|
+
const filePath = (0, brainfile_path_1.resolveCliBrainfilePath)(options.file);
|
|
195
|
+
if (!fs.existsSync(filePath)) {
|
|
196
|
+
throw (0, cli_error_1.fileNotFound)(filePath);
|
|
197
|
+
}
|
|
198
|
+
const name = normalizeName(options.name);
|
|
199
|
+
const idPrefix = normalizeIdPrefix(name, options.idPrefix);
|
|
200
|
+
const completable = options.completable ?? true;
|
|
201
|
+
const schema = options.schema?.trim();
|
|
202
|
+
const doc = readFrontmatter(filePath);
|
|
203
|
+
const strict = doc.data.strict === true;
|
|
204
|
+
const existingTypes = doc.data.types && typeof doc.data.types === 'object' && !Array.isArray(doc.data.types)
|
|
205
|
+
? { ...doc.data.types }
|
|
206
|
+
: {};
|
|
207
|
+
const existingEntry = existingTypes[name] && typeof existingTypes[name] === 'object' && !Array.isArray(existingTypes[name])
|
|
208
|
+
? { ...existingTypes[name] }
|
|
209
|
+
: {};
|
|
210
|
+
const updatedEntry = {
|
|
211
|
+
...existingEntry,
|
|
212
|
+
idPrefix,
|
|
213
|
+
completable,
|
|
214
|
+
};
|
|
215
|
+
if (schema) {
|
|
216
|
+
updatedEntry.schema = schema;
|
|
217
|
+
}
|
|
218
|
+
existingTypes[name] = updatedEntry;
|
|
219
|
+
doc.data.types = existingTypes;
|
|
220
|
+
writeFrontmatter(filePath, doc);
|
|
221
|
+
const resultEntry = {
|
|
222
|
+
idPrefix,
|
|
223
|
+
completable,
|
|
224
|
+
};
|
|
225
|
+
if (typeof updatedEntry.schema === 'string' && updatedEntry.schema.trim()) {
|
|
226
|
+
resultEntry.schema = updatedEntry.schema.trim();
|
|
227
|
+
}
|
|
228
|
+
logger.log(chalk_1.default.green(`Saved type '${name}'.`));
|
|
229
|
+
logger.log(chalk_1.default.gray(` idPrefix: ${idPrefix}`));
|
|
230
|
+
logger.log(chalk_1.default.gray(` completable: ${completable}`));
|
|
231
|
+
if (schema) {
|
|
232
|
+
logger.log(chalk_1.default.gray(` schema: ${schema}`));
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
success: true,
|
|
236
|
+
strict,
|
|
237
|
+
typeName: name,
|
|
238
|
+
entry: resultEntry,
|
|
239
|
+
filePath,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/commands/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoKA,4CAgBC;AAKD,4CA2CC;AAKD,0CAiEC;AA1SD,uCAAyB;AACzB,8CAAgC;AAChC,kDAA0B;AAC1B,4CAA6D;AAC7D,kDAK4B;AAC5B,4DAAkE;AAClE,kDAA6D;AA0C7D,SAAS,gBAAgB,CAAC,OAAe;IACvC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAElC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,EAAE,CAAC;QACpD,MAAM,IAAA,wBAAY,EAAC,gDAAgD,CAAC,CAAC;IACvE,CAAC;IAED,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,EAAE,CAAC;YAC9B,QAAQ,GAAG,CAAC,CAAC;YACb,MAAM;QACR,CAAC;IACH,CAAC;IAED,IAAI,QAAQ,KAAK,CAAC,CAAC,EAAE,C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,EAAE,CAAC;QAC1E,WAAW,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAClD,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,eAAe,IAAI,IAAI,CAAC,CAAC,CAAC;IACjD,MAAM,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,eAAe,QAAQ,EAAE,CAAC,CAAC,CAAC;IAClD,MAAM,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,kBAAkB,WAAW,EAAE,CAAC,CAAC,CAAC;IACxD,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,aAAa,MAAM,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,MAAM;QACN,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,WAAW;QAClB,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { moveCommand } from './commands/move';
|
|
|
4
4
|
export { templateCommand } from './commands/template';
|
|
5
5
|
export { lintCommand } from './commands/lint';
|
|
6
6
|
export { contractPickupCommand, contractDeliverCommand, contractValidateCommand, contractAttachCommand, } from './commands/contract';
|
|
7
|
+
export { adrPromoteCommand } from './commands/adr';
|
|
7
8
|
export { initCommand } from './commands/init';
|
|
8
9
|
export { migrateCommand } from './commands/migrate';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.migrateCommand = exports.initCommand = exports.contractAttachCommand = exports.contractValidateCommand = exports.contractDeliverCommand = exports.contractPickupCommand = exports.lintCommand = exports.templateCommand = exports.moveCommand = exports.addCommand = exports.listCommand = void 0;
|
|
3
|
+
exports.migrateCommand = exports.initCommand = exports.adrPromoteCommand = exports.contractAttachCommand = exports.contractValidateCommand = exports.contractDeliverCommand = exports.contractPickupCommand = exports.lintCommand = exports.templateCommand = exports.moveCommand = exports.addCommand = exports.listCommand = void 0;
|
|
4
4
|
// Export commands for programmatic use
|
|
5
5
|
var list_1 = require("./commands/list");
|
|
6
6
|
Object.defineProperty(exports, "listCommand", { enumerable: true, get: function () { return list_1.listCommand; } });
|
|
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "contractPickupCommand", { enumerable: true, get:
|
|
|
17
17
|
Object.defineProperty(exports, "contractDeliverCommand", { enumerable: true, get: function () { return contract_1.contractDeliverCommand; } });
|
|
18
18
|
Object.defineProperty(exports, "contractValidateCommand", { enumerable: true, get: function () { return contract_1.contractValidateCommand; } });
|
|
19
19
|
Object.defineProperty(exports, "contractAttachCommand", { enumerable: true, get: function () { return contract_1.contractAttachCommand; } });
|
|
20
|
+
var adr_1 = require("./commands/adr");
|
|
21
|
+
Object.defineProperty(exports, "adrPromoteCommand", { enumerable: true, get: function () { return adr_1.adrPromoteCommand; } });
|
|
20
22
|
var init_1 = require("./commands/init");
|
|
21
23
|
Object.defineProperty(exports, "initCommand", { enumerable: true, get: function () { return init_1.initCommand; } });
|
|
22
24
|
var migrate_1 = require("./commands/migrate");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,wCAA8C;AAArC,mGAAA,WAAW,OAAA;AACpB,sCAA4C;AAAnC,iGAAA,UAAU,OAAA;AACnB,wCAA8C;AAArC,mGAAA,WAAW,OAAA;AACpB,gDAAsD;AAA7C,2GAAA,eAAe,OAAA;AACxB,wCAA8C;AAArC,mGAAA,WAAW,OAAA;AACpB,gDAK6B;AAJ3B,iHAAA,qBAAqB,OAAA;AACrB,kHAAA,sBAAsB,OAAA;AACtB,mHAAA,uBAAuB,OAAA;AACvB,iHAAA,qBAAqB,OAAA;AAEvB,wCAA8C;AAArC,mGAAA,WAAW,OAAA;AACpB,8CAAoD;AAA3C,yGAAA,cAAc,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,wCAA8C;AAArC,mGAAA,WAAW,OAAA;AACpB,sCAA4C;AAAnC,iGAAA,UAAU,OAAA;AACnB,wCAA8C;AAArC,mGAAA,WAAW,OAAA;AACpB,gDAAsD;AAA7C,2GAAA,eAAe,OAAA;AACxB,wCAA8C;AAArC,mGAAA,WAAW,OAAA;AACpB,gDAK6B;AAJ3B,iHAAA,qBAAqB,OAAA;AACrB,kHAAA,sBAAsB,OAAA;AACtB,mHAAA,uBAAuB,OAAA;AACvB,iHAAA,qBAAqB,OAAA;AAEvB,sCAAmD;AAA1C,wGAAA,iBAAiB,OAAA;AAC1B,wCAA8C;AAArC,mGAAA,WAAW,OAAA;AACpB,8CAAoD;AAA3C,yGAAA,cAAc,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contractRunner.d.ts","sourceRoot":"","sources":["../../src/lib/contractRunner.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"contractRunner.d.ts","sourceRoot":"","sources":["../../src/lib/contractRunner.ts"],"names":[],"mappings":"AAGA,OAAO,EAKL,KAAK,KAAK,EACV,KAAK,QAAQ,EACb,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AASzB,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;AAE/D,MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CA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AK,EAAE,MAAM,CAAA;CAAE,CA6BlG;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,kBAAkB,GAAG,sBAAsB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAgHpG"}
|
|
@@ -41,6 +41,8 @@ const fs = __importStar(require("fs"));
|
|
|
41
41
|
const path = __importStar(require("path"));
|
|
42
42
|
const child_process_1 = require("child_process");
|
|
43
43
|
const core_1 = require("@brainfile/core");
|
|
44
|
+
const core_2 = require("@brainfile/core");
|
|
45
|
+
const v2_detect_1 = require("../utils/v2-detect");
|
|
44
46
|
/**
|
|
45
47
|
* Detects if a command changes directories, which can cause brainfile resolution issues.
|
|
46
48
|
* Returns a warning message if detected, undefined otherwise.
|
|
@@ -88,6 +90,31 @@ function getContractOrError(taskId, contract) {
|
|
|
88
90
|
return { ok: false, error: `Task ${taskId} has no contract` };
|
|
89
91
|
return { ok: true, contract };
|
|
90
92
|
}
|
|
93
|
+
function applyPickupMetrics(contract, at = new Date()) {
|
|
94
|
+
const withMetrics = contract;
|
|
95
|
+
const metrics = { ...(withMetrics.metrics ?? {}) };
|
|
96
|
+
metrics.pickedUpAt = at.toISOString();
|
|
97
|
+
if (typeof metrics.reworkCount === 'number' && Number.isFinite(metrics.reworkCount)) {
|
|
98
|
+
metrics.reworkCount = Math.max(0, Math.round(metrics.reworkCount)) + 1;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
metrics.reworkCount = 0;
|
|
102
|
+
}
|
|
103
|
+
withMetrics.metrics = metrics;
|
|
104
|
+
}
|
|
105
|
+
function applyDeliverMetrics(contract, at = new Date()) {
|
|
106
|
+
const withMetrics = contract;
|
|
107
|
+
const metrics = { ...(withMetrics.metrics ?? {}) };
|
|
108
|
+
metrics.deliveredAt = at.toISOString();
|
|
109
|
+
if (typeof metrics.pickedUpAt === 'string') {
|
|
110
|
+
const pickedUpMs = Date.parse(metrics.pickedUpAt);
|
|
111
|
+
const deliveredMs = at.getTime();
|
|
112
|
+
if (Number.isFinite(pickedUpMs)) {
|
|
113
|
+
metrics.duration = Math.max(0, Math.round((deliveredMs - pickedUpMs) / 1000));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
withMetrics.metrics = metrics;
|
|
117
|
+
}
|
|
91
118
|
function formatContractContextMarkdown(params) {
|
|
92
119
|
const { taskId, taskTitle, description, columnTitle, contract, relatedFiles } = params;
|
|
93
120
|
const deliverables = contract.deliverables ?? [];
|
|
@@ -166,6 +193,10 @@ function formatContractContextMarkdown(params) {
|
|
|
166
193
|
}
|
|
167
194
|
function pickupContract(ctx) {
|
|
168
195
|
const resolvedFilePath = (0, core_1.resolveBrainfilePath)({ filePath: ctx.filePath, startDir: process.cwd() });
|
|
196
|
+
// V2 per-task file architecture
|
|
197
|
+
if ((0, v2_detect_1.isV2)(resolvedFilePath)) {
|
|
198
|
+
return pickupContractV2(ctx, resolvedFilePath);
|
|
199
|
+
}
|
|
169
200
|
const read = readBoardFromFile(resolvedFilePath);
|
|
170
201
|
if ('error' in read)
|
|
171
202
|
return { error: read.error };
|
|
@@ -179,20 +210,13 @@ function pickupContract(ctx) {
|
|
|
179
210
|
const result = (0, core_1.setTaskContractStatus)(board, ctx.taskId, 'in_progress');
|
|
180
211
|
if (!result.success || !result.board)
|
|
181
212
|
return { error: result.error || 'Failed to update contract status' };
|
|
182
|
-
writeBoardToFile(resolvedFilePath, result.board);
|
|
183
213
|
const updatedTaskInfo = (0, core_1.findTaskById)(result.board, ctx.taskId);
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const agent = process.env.BRAINFILE_AGENT ||
|
|
187
|
-
process.env.CURSOR_AGENT ||
|
|
188
|
-
process.env.GITHUB_ACTOR ||
|
|
189
|
-
process.env.USER ||
|
|
190
|
-
'unknown';
|
|
191
|
-
(0, core_1.recordContractPickup)({ brainfilePath: resolvedFilePath, taskId: ctx.taskId, agent });
|
|
192
|
-
}
|
|
193
|
-
catch {
|
|
194
|
-
// Never fail contract pickup due to state tracking.
|
|
214
|
+
if (!updatedTaskInfo?.task.contract) {
|
|
215
|
+
return { error: `Task ${ctx.taskId} has no contract` };
|
|
195
216
|
}
|
|
217
|
+
applyPickupMetrics(updatedTaskInfo.task.contract);
|
|
218
|
+
writeBoardToFile(resolvedFilePath, result.board);
|
|
219
|
+
const updatedContract = updatedTaskInfo.task.contract;
|
|
196
220
|
const markdown = formatContractContextMarkdown({
|
|
197
221
|
taskId: updatedTaskInfo.task.id,
|
|
198
222
|
taskTitle: updatedTaskInfo.task.title,
|
|
@@ -205,6 +229,9 @@ function pickupContract(ctx) {
|
|
|
205
229
|
}
|
|
206
230
|
function deliverContract(ctx) {
|
|
207
231
|
const resolvedFilePath = (0, core_1.resolveBrainfilePath)({ filePath: ctx.filePath, startDir: process.cwd() });
|
|
232
|
+
if ((0, v2_detect_1.isV2)(resolvedFilePath)) {
|
|
233
|
+
return deliverContractV2(ctx, resolvedFilePath);
|
|
234
|
+
}
|
|
208
235
|
const read = readBoardFromFile(resolvedFilePath);
|
|
209
236
|
if ('error' in read)
|
|
210
237
|
return { error: read.error };
|
|
@@ -218,11 +245,19 @@ function deliverContract(ctx) {
|
|
|
218
245
|
const result = (0, core_1.setTaskContractStatus)(board, ctx.taskId, 'delivered');
|
|
219
246
|
if (!result.success || !result.board)
|
|
220
247
|
return { error: result.error || 'Failed to update contract status' };
|
|
248
|
+
const updatedTaskInfo = (0, core_1.findTaskById)(result.board, ctx.taskId);
|
|
249
|
+
if (!updatedTaskInfo?.task.contract) {
|
|
250
|
+
return { error: `Task ${ctx.taskId} has no contract` };
|
|
251
|
+
}
|
|
252
|
+
applyDeliverMetrics(updatedTaskInfo.task.contract);
|
|
221
253
|
writeBoardToFile(resolvedFilePath, result.board);
|
|
222
254
|
return { action: 'deliver', board: result.board };
|
|
223
255
|
}
|
|
224
256
|
function validateContract(ctx) {
|
|
225
257
|
const resolvedFilePath = (0, core_1.resolveBrainfilePath)({ filePath: ctx.filePath, startDir: process.cwd() });
|
|
258
|
+
if ((0, v2_detect_1.isV2)(resolvedFilePath)) {
|
|
259
|
+
return validateContractV2(ctx, resolvedFilePath);
|
|
260
|
+
}
|
|
226
261
|
const read = readBoardFromFile(resolvedFilePath);
|
|
227
262
|
if ('error' in read)
|
|
228
263
|
return { error: read.error };
|
|
@@ -316,4 +351,134 @@ function validateContract(ctx) {
|
|
|
316
351
|
ok,
|
|
317
352
|
};
|
|
318
353
|
}
|
|
354
|
+
// ============================================================================
|
|
355
|
+
// V2 Contract Operations (per-task files)
|
|
356
|
+
// ============================================================================
|
|
357
|
+
function pickupContractV2(ctx, resolvedFilePath) {
|
|
358
|
+
const dirs = (0, v2_detect_1.getV2Dirs)(resolvedFilePath);
|
|
359
|
+
const found = (0, v2_detect_1.findV2Task)(dirs, ctx.taskId, false);
|
|
360
|
+
if (!found)
|
|
361
|
+
return { error: `Task not found: ${ctx.taskId}` };
|
|
362
|
+
const { doc, filePath: taskPath } = found;
|
|
363
|
+
const task = doc.task;
|
|
364
|
+
if (!task.contract)
|
|
365
|
+
return { error: `Task ${ctx.taskId} has no contract` };
|
|
366
|
+
// Update contract status + metrics atomically
|
|
367
|
+
task.contract.status = 'in_progress';
|
|
368
|
+
applyPickupMetrics(task.contract);
|
|
369
|
+
(0, core_2.writeTaskFile)(taskPath, task, doc.body);
|
|
370
|
+
const description = task.description || (0, v2_detect_1.extractDescription)(doc.body);
|
|
371
|
+
const markdown = formatContractContextMarkdown({
|
|
372
|
+
taskId: task.id,
|
|
373
|
+
taskTitle: task.title,
|
|
374
|
+
description,
|
|
375
|
+
columnTitle: task.column,
|
|
376
|
+
contract: task.contract,
|
|
377
|
+
relatedFiles: task.relatedFiles,
|
|
378
|
+
});
|
|
379
|
+
// Build a minimal board for the result
|
|
380
|
+
const board = { title: '', columns: [] };
|
|
381
|
+
return { action: 'pickup', board, markdown };
|
|
382
|
+
}
|
|
383
|
+
function deliverContractV2(ctx, resolvedFilePath) {
|
|
384
|
+
const dirs = (0, v2_detect_1.getV2Dirs)(resolvedFilePath);
|
|
385
|
+
const found = (0, v2_detect_1.findV2Task)(dirs, ctx.taskId, false);
|
|
386
|
+
if (!found)
|
|
387
|
+
return { error: `Task not found: ${ctx.taskId}` };
|
|
388
|
+
const { doc, filePath: taskPath } = found;
|
|
389
|
+
const task = doc.task;
|
|
390
|
+
if (!task.contract)
|
|
391
|
+
return { error: `Task ${ctx.taskId} has no contract` };
|
|
392
|
+
task.contract.status = 'delivered';
|
|
393
|
+
applyDeliverMetrics(task.contract);
|
|
394
|
+
(0, core_2.writeTaskFile)(taskPath, task, doc.body);
|
|
395
|
+
const board = { title: '', columns: [] };
|
|
396
|
+
return { action: 'deliver', board };
|
|
397
|
+
}
|
|
398
|
+
function validateContractV2(ctx, resolvedFilePath) {
|
|
399
|
+
const dirs = (0, v2_detect_1.getV2Dirs)(resolvedFilePath);
|
|
400
|
+
const found = (0, v2_detect_1.findV2Task)(dirs, ctx.taskId, false);
|
|
401
|
+
if (!found)
|
|
402
|
+
return { error: `Task not found: ${ctx.taskId}` };
|
|
403
|
+
const { doc, filePath: taskPath } = found;
|
|
404
|
+
const task = doc.task;
|
|
405
|
+
if (!task.contract)
|
|
406
|
+
return { error: `Task ${ctx.taskId} has no contract` };
|
|
407
|
+
const contract = task.contract;
|
|
408
|
+
const brainfileAbs = path.resolve(resolvedFilePath);
|
|
409
|
+
const brainfileDir = path.dirname(brainfileAbs);
|
|
410
|
+
const baseDir = path.basename(brainfileDir) === '.brainfile'
|
|
411
|
+
? path.dirname(brainfileDir)
|
|
412
|
+
: brainfileDir;
|
|
413
|
+
const deliverables = contract.deliverables ?? [];
|
|
414
|
+
const deliverableChecks = [];
|
|
415
|
+
for (const d of deliverables) {
|
|
416
|
+
if (d.type !== 'file') {
|
|
417
|
+
deliverableChecks.push({ deliverable: d, ok: true });
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
const normalized = normalizeNonEmpty(d.path, 'Deliverable path is required');
|
|
421
|
+
if (!normalized.ok) {
|
|
422
|
+
deliverableChecks.push({ deliverable: d, ok: false, error: normalized.error });
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
const resolved = path.isAbsolute(normalized.value)
|
|
426
|
+
? normalized.value
|
|
427
|
+
: path.join(baseDir, normalized.value);
|
|
428
|
+
if (!fs.existsSync(resolved)) {
|
|
429
|
+
deliverableChecks.push({ deliverable: d, ok: false, resolvedPath: resolved, error: 'File not found' });
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
deliverableChecks.push({ deliverable: d, ok: true, resolvedPath: resolved });
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
const deliverablesOk = deliverableChecks.every(c => c.ok);
|
|
436
|
+
const commandResults = [];
|
|
437
|
+
const warnings = [];
|
|
438
|
+
let ok = deliverablesOk;
|
|
439
|
+
if (ok) {
|
|
440
|
+
const commands = contract.validation?.commands ?? [];
|
|
441
|
+
for (const raw of commands) {
|
|
442
|
+
const normalized = normalizeNonEmpty(raw, 'Validation command is required');
|
|
443
|
+
if (!normalized.ok) {
|
|
444
|
+
commandResults.push({ command: raw, exitCode: 1, stdout: '', stderr: normalized.error });
|
|
445
|
+
ok = false;
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
const dirWarning = detectDirectoryChangeWarning(normalized.value);
|
|
449
|
+
if (dirWarning) {
|
|
450
|
+
warnings.push({ command: normalized.value, message: dirWarning });
|
|
451
|
+
}
|
|
452
|
+
const res = (0, child_process_1.spawnSync)(normalized.value, {
|
|
453
|
+
shell: true,
|
|
454
|
+
cwd: baseDir,
|
|
455
|
+
encoding: 'utf-8',
|
|
456
|
+
});
|
|
457
|
+
const exitCode = typeof res.status === 'number' ? res.status : 1;
|
|
458
|
+
commandResults.push({
|
|
459
|
+
command: normalized.value,
|
|
460
|
+
exitCode,
|
|
461
|
+
stdout: res.stdout ?? '',
|
|
462
|
+
stderr: res.stderr ?? '',
|
|
463
|
+
});
|
|
464
|
+
if (exitCode !== 0) {
|
|
465
|
+
ok = false;
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
// Update contract status in task file
|
|
471
|
+
const status = ok ? 'done' : 'failed';
|
|
472
|
+
task.contract.status = status;
|
|
473
|
+
(0, core_2.writeTaskFile)(taskPath, task, doc.body);
|
|
474
|
+
const board = { title: '', columns: [] };
|
|
475
|
+
return {
|
|
476
|
+
action: 'validate',
|
|
477
|
+
board,
|
|
478
|
+
deliverableChecks,
|
|
479
|
+
commandResults,
|
|
480
|
+
warnings,
|
|
481
|
+
ok,
|
|
482
|
+
};
|
|
483
|
+
}
|
|
319
484
|
//# sourceMappingURL=contractRunner.js.map
|