@basementuniverse/kanbn 0.10.0 → 1.0.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.
Files changed (44) hide show
  1. package/docs/commands/burndown.txt +7 -1
  2. package/docs/commands/gantt.txt +36 -0
  3. package/docs/commands/help.txt +1 -0
  4. package/docs/quick-start.md +1 -1
  5. package/docs/task-structure.md +47 -0
  6. package/example/.kanbn/index.md +63 -0
  7. package/example/.kanbn/tasks/add-basic-activity-feed.md +53 -0
  8. package/example/.kanbn/tasks/add-passwordless-login-option.md +34 -0
  9. package/example/.kanbn/tasks/add-usage-alert-email-thresholds.md +35 -0
  10. package/example/.kanbn/tasks/build-email-template-system.md +30 -0
  11. package/example/.kanbn/tasks/build-invoice-download-endpoint.md +43 -0
  12. package/example/.kanbn/tasks/build-tenant-settings-page.md +48 -0
  13. package/example/.kanbn/tasks/create-organization-switcher.md +53 -0
  14. package/example/.kanbn/tasks/create-sandbox-environment-provisioner.md +36 -0
  15. package/example/.kanbn/tasks/create-self-serve-cancellation-flow.md +38 -0
  16. package/example/.kanbn/tasks/define-product-pricing-strategy.md +37 -0
  17. package/example/.kanbn/tasks/design-onboarding-checklist.md +30 -0
  18. package/example/.kanbn/tasks/design-team-invite-expiry-flow.md +33 -0
  19. package/example/.kanbn/tasks/implement-data-retention-policy-jobs.md +30 -0
  20. package/example/.kanbn/tasks/implement-feature-flags-foundation.md +36 -0
  21. package/example/.kanbn/tasks/implement-project-creation-wizard.md +44 -0
  22. package/example/.kanbn/tasks/implement-stripe-webhook-signature-check.md +54 -0
  23. package/example/.kanbn/tasks/implement-team-permissions-ui.md +57 -0
  24. package/example/.kanbn/tasks/implement-user-signup-and-login.md +62 -0
  25. package/example/.kanbn/tasks/integrate-crm-lead-sync.md +35 -0
  26. package/example/.kanbn/tasks/legal-review-terms-and-privacy.md +30 -0
  27. package/example/.kanbn/tasks/migrate-legacy-events-to-new-schema.md +48 -0
  28. package/example/.kanbn/tasks/optimize-dashboard-first-load.md +52 -0
  29. package/example/.kanbn/tasks/prototype-report-export-scheduler.md +34 -0
  30. package/example/.kanbn/tasks/publish-internal-qa-checklist.md +53 -0
  31. package/example/.kanbn/tasks/setup-ci-pipeline.md +53 -0
  32. package/package.json +3 -2
  33. package/routes/gantt.json +27 -0
  34. package/skills/kanbn-plan/SKILL.md +0 -0
  35. package/src/controller/add.js +33 -1
  36. package/src/controller/burndown.js +72 -5
  37. package/src/controller/edit.js +68 -1
  38. package/src/controller/find.js +5 -0
  39. package/src/controller/gantt.js +375 -0
  40. package/src/controller/init.js +2 -1
  41. package/src/controller/sort.js +8 -0
  42. package/src/main.d.ts +295 -340
  43. package/src/main.js +2591 -2050
  44. package/src/parse-task.js +211 -3
@@ -23,6 +23,11 @@ async function interactiveCreateTask(taskData, taskIds, columnName, columnNames)
23
23
  'due' in taskData.metadata &&
24
24
  taskData.metadata.due != null
25
25
  );
26
+ const postponedDateExists = (
27
+ 'metadata' in taskData &&
28
+ 'postponed' in taskData.metadata &&
29
+ taskData.metadata.postponed != null
30
+ );
26
31
  const assignedExists = (
27
32
  'metadata' in taskData &&
28
33
  'assigned' in taskData.metadata &&
@@ -76,6 +81,21 @@ async function interactiveCreateTask(taskData, taskIds, columnName, columnNames)
76
81
  format: ['Y', '/', 'MM', '/', 'DD'],
77
82
  when: answers => answers.setDue,
78
83
  },
84
+ {
85
+ type: 'confirm',
86
+ name: 'setPostponed',
87
+ message: 'Set a postponed date?',
88
+ default: false,
89
+ when: answers => !postponedDateExists
90
+ },
91
+ {
92
+ type: 'datepicker',
93
+ name: 'postponed',
94
+ message: 'Postponed date:',
95
+ default: postponedDateExists ? taskData.metadata.postponed : new Date(),
96
+ format: ['Y', '/', 'MM', '/', 'DD'],
97
+ when: answers => answers.setPostponed,
98
+ },
79
99
  {
80
100
  type: 'confirm',
81
101
  name: 'setAssigned',
@@ -323,6 +343,15 @@ module.exports = async args => {
323
343
  }
324
344
  }
325
345
 
346
+ // Postponed date
347
+ if (args.postponed) {
348
+ taskData.metadata.postponed = chrono.parseDate(utility.strArg(args.postponed));
349
+ if (taskData.metadata.postponed === null) {
350
+ utility.error('Unable to parse postponed date');
351
+ return;
352
+ }
353
+ }
354
+
326
355
  // Progress
327
356
  if (args.progress) {
328
357
  const progressValue = parseFloat(utility.strArg(args.progress));
@@ -450,7 +479,10 @@ module.exports = async args => {
450
479
  taskData.description = answers.description;
451
480
  }
452
481
  if ('due' in answers) {
453
- taskData.metadata.due = answers.due.toISOString();
482
+ taskData.metadata.due = answers.due;
483
+ }
484
+ if ('postponed' in answers) {
485
+ taskData.metadata.postponed = answers.postponed;
454
486
  }
455
487
  if ('assigned' in answers) {
456
488
  taskData.metadata.assigned = answers.assigned;
@@ -5,6 +5,61 @@ const term = require('terminal-kit').terminal;
5
5
  const chrono = require('chrono-node');
6
6
  const formatDate = require('dateformat');
7
7
 
8
+ const getLabelPlacements = (from, to, width, dateFormat, maxLabels) => {
9
+ for (let count = maxLabels; count >= 1; count--) {
10
+ const placements = [];
11
+ let previousEnd = -1;
12
+
13
+ for (let i = 0; i < count; i++) {
14
+ const ratio = count === 1 ? 0 : i / (count - 1);
15
+ const position = Math.round(ratio * (width - 1));
16
+ const value = new Date(from.getTime() + Math.round((to.getTime() - from.getTime()) * ratio));
17
+ const label = formatDate(value, dateFormat);
18
+
19
+ let start = position - Math.floor(label.length / 2);
20
+ if (start < 0) {
21
+ start = 0;
22
+ }
23
+ if (start + label.length > width) {
24
+ start = Math.max(0, width - label.length);
25
+ }
26
+
27
+ const end = start + label.length - 1;
28
+ if (i > 0 && start <= previousEnd + 1) {
29
+ placements.length = 0;
30
+ break;
31
+ }
32
+
33
+ placements.push({ position, start, label, end });
34
+ previousEnd = end;
35
+ }
36
+
37
+ if (placements.length) {
38
+ return placements;
39
+ }
40
+ }
41
+
42
+ return [];
43
+ };
44
+
45
+ const renderXAxisLabels = (from, to, width, dateFormat, leftPadding) => {
46
+ const sampleLabel = formatDate(from, dateFormat);
47
+ const maxLabels = Math.max(1, Math.floor((width + 2) / (sampleLabel.length + 2)));
48
+ const placements = getLabelPlacements(from, to, width, dateFormat, maxLabels);
49
+
50
+ const ticks = Array(width).fill(' ');
51
+ const labels = Array(width).fill(' ');
52
+
53
+ for (const placement of placements) {
54
+ ticks[placement.position] = '|';
55
+ for (let i = 0; i < placement.label.length; i++) {
56
+ labels[placement.start + i] = placement.label[i];
57
+ }
58
+ }
59
+
60
+ return `${leftPadding}${ticks.join('')}\n${leftPadding}${labels.join('')}`;
61
+ };
62
+
8
63
  module.exports = async args => {
9
64
 
10
65
  // Make sure kanbn has been initialised
@@ -72,18 +127,23 @@ module.exports = async args => {
72
127
 
73
128
  // Render chart
74
129
  const PADDING = ' ';
75
- const width = term.width - (PADDING.length + 1);
130
+ const width = Math.max(1, term.width - (PADDING.length + 1));
76
131
 
77
132
  const plots = [];
78
- for (s of data.series) {
79
- const plot = [], delta = Math.floor((s.to.getTime() - s.from.getTime()) / width);
133
+ for (const s of data.series) {
134
+ const plot = [];
135
+ const span = Math.max(1, s.to.getTime() - s.from.getTime());
136
+ const delta = width > 1 ? span / (width - 1) : 0;
80
137
  for (let i = 0; i < width; i++) {
81
- plot.push((s.dataPoints.find(d => d.x >= new Date(s.from.getTime() + i * delta)) || s.dataPoints[0]).y);
138
+ const x = new Date(s.from.getTime() + Math.round(i * delta));
139
+ plot.push((s.dataPoints.find(d => d.x >= x) || s.dataPoints[0]).y);
82
140
  }
83
141
  plots.push(plot);
84
142
  }
143
+
144
+ const referenceSeries = data.series[0];
85
145
  const dateFormat = kanbn.getDateFormat(index);
86
- console.log(`${formatDate(s.from, dateFormat)} to ${formatDate(s.to, dateFormat)}:`);
146
+ console.log(`${formatDate(referenceSeries.from, dateFormat)} to ${formatDate(referenceSeries.to, dateFormat)}:`);
87
147
  console.log(asciichart.plot(
88
148
  plots,
89
149
  {
@@ -99,6 +159,13 @@ module.exports = async args => {
99
159
  ]
100
160
  }
101
161
  ));
162
+ console.log(renderXAxisLabels(
163
+ referenceSeries.from,
164
+ referenceSeries.to,
165
+ width,
166
+ dateFormat,
167
+ ' '.repeat(PADDING.length + 1)
168
+ ));
102
169
  }
103
170
  })
104
171
  .catch(error => {
@@ -23,6 +23,11 @@ async function interactive(taskData, taskIds, columnName, columnNames) {
23
23
  'due' in taskData.metadata &&
24
24
  taskData.metadata.due != null
25
25
  );
26
+ const postponedDateExists = (
27
+ 'metadata' in taskData &&
28
+ 'postponed' in taskData.metadata &&
29
+ taskData.metadata.postponed != null
30
+ );
26
31
  const assignedExists = (
27
32
  'metadata' in taskData &&
28
33
  'assigned' in taskData.metadata &&
@@ -101,6 +106,46 @@ async function interactive(taskData, taskIds, columnName, columnNames) {
101
106
  format: ['Y', '/', 'MM', '/', 'DD'],
102
107
  when: answers => answers.setDue || answers.editDue === 'edit'
103
108
  },
109
+ {
110
+ type: 'expand',
111
+ name: 'editPostponed',
112
+ message: 'Edit or remove postponed date?',
113
+ default: 'none',
114
+ when: answers => postponedDateExists,
115
+ choices: [
116
+ {
117
+ key: 'e',
118
+ name: 'Edit',
119
+ value: 'edit'
120
+ },
121
+ {
122
+ key: 'r',
123
+ name: 'Remove',
124
+ value: 'remove'
125
+ },
126
+ new inquirer.Separator(),
127
+ {
128
+ key: 'n',
129
+ name: 'Do nothing',
130
+ value: 'none'
131
+ }
132
+ ]
133
+ },
134
+ {
135
+ type: 'confirm',
136
+ name: 'setPostponed',
137
+ message: 'Set a postponed date?',
138
+ default: false,
139
+ when: answers => !postponedDateExists
140
+ },
141
+ {
142
+ type: 'datepicker',
143
+ name: 'postponed',
144
+ message: 'Postponed date:',
145
+ default: postponedDateExists ? taskData.metadata.postponed : new Date(),
146
+ format: ['Y', '/', 'MM', '/', 'DD'],
147
+ when: answers => answers.setPostponed || answers.editPostponed === 'edit'
148
+ },
104
149
  {
105
150
  type: 'expand',
106
151
  name: 'editAssigned',
@@ -430,6 +475,18 @@ module.exports = async args => {
430
475
  }
431
476
  }
432
477
 
478
+ // Postponed date
479
+ if (args.postponed) {
480
+ if (!('metadata' in taskData)) {
481
+ taskData.metadata = {};
482
+ }
483
+ taskData.metadata.postponed = chrono.parseDate(utility.strArg(args.postponed));
484
+ if (taskData.metadata.postponed === null) {
485
+ utility.error('Unable to parse postponed date');
486
+ return;
487
+ }
488
+ }
489
+
433
490
  // Progress
434
491
  if (args.progress) {
435
492
  if (!('metadata' in taskData)) {
@@ -660,7 +717,17 @@ module.exports = async args => {
660
717
 
661
718
  // Due date
662
719
  if ('due' in answers) {
663
- taskData.metadata.due = answers.due.toISOString();
720
+ taskData.metadata.due = answers.due;
721
+ }
722
+
723
+ // Remove postponed date
724
+ if ('editPostponed' in answers && answers.editPostponed === 'remove') {
725
+ delete taskData.metadata.postponed;
726
+ }
727
+
728
+ // Postponed date
729
+ if ('postponed' in answers) {
730
+ taskData.metadata.postponed = answers.postponed;
664
731
  }
665
732
 
666
733
  // Remove assigned
@@ -52,6 +52,11 @@ const searchFields = [
52
52
  field: 'due',
53
53
  type: 'date'
54
54
  },
55
+ {
56
+ name: 'Postponed',
57
+ field: 'postponed',
58
+ type: 'date'
59
+ },
55
60
  {
56
61
  name: 'Progress',
57
62
  field: 'progress',
@@ -0,0 +1,375 @@
1
+ const kanbn = require('../main');
2
+ const utility = require('../utility');
3
+ const formatDate = require('dateformat');
4
+ const chrono = require('chrono-node');
5
+
6
+ const NOW_MARKER = '┆';
7
+ const ANSI_RESET = '\x1b[0m';
8
+ const ANSI_FG_LINE = '\x1b[97m';
9
+ const ANSI_FG_NOW = '\x1b[90m';
10
+ const ANSI_BG_NOT_STARTED = '\x1b[100m';
11
+ const ANSI_BG_STARTED = '\x1b[44m';
12
+ const ANSI_BG_COMPLETED = '\x1b[42m';
13
+
14
+ const DIR_UP = 1;
15
+ const DIR_DOWN = 2;
16
+ const DIR_LEFT = 4;
17
+ const DIR_RIGHT = 8;
18
+
19
+ const LINE_CHARS = {
20
+ [DIR_UP]: '│',
21
+ [DIR_DOWN]: '│',
22
+ [DIR_LEFT]: '─',
23
+ [DIR_RIGHT]: '─',
24
+ [DIR_UP | DIR_DOWN]: '│',
25
+ [DIR_LEFT | DIR_RIGHT]: '─',
26
+ [DIR_DOWN | DIR_RIGHT]: '┌',
27
+ [DIR_DOWN | DIR_LEFT]: '┐',
28
+ [DIR_UP | DIR_RIGHT]: '└',
29
+ [DIR_UP | DIR_LEFT]: '┘',
30
+ [DIR_UP | DIR_DOWN | DIR_RIGHT]: '├',
31
+ [DIR_UP | DIR_DOWN | DIR_LEFT]: '┤',
32
+ [DIR_UP | DIR_LEFT | DIR_RIGHT]: '┴',
33
+ [DIR_DOWN | DIR_LEFT | DIR_RIGHT]: '┬',
34
+ [DIR_UP | DIR_DOWN | DIR_LEFT | DIR_RIGHT]: '┼'
35
+ };
36
+
37
+ function getBarGeometry(task, from, to, width) {
38
+ if (width <= 1 || from.getTime() === to.getTime()) {
39
+ return { start: 0, end: 0 };
40
+ }
41
+
42
+ // Calculate the position in the chart
43
+ const totalSpan = to.getTime() - from.getTime();
44
+ const taskStartPos = Math.max(0, Math.round((task.start.getTime() - from.getTime()) / totalSpan * (width - 1)));
45
+ const taskEndPos = Math.min(width - 1, Math.round((task.end.getTime() - from.getTime()) / totalSpan * (width - 1)));
46
+
47
+ return {
48
+ start: taskStartPos,
49
+ end: taskEndPos
50
+ };
51
+ }
52
+
53
+ function getBarBackground(task) {
54
+ if (task.completed instanceof Date) {
55
+ return ANSI_BG_COMPLETED;
56
+ }
57
+ if (task.started instanceof Date) {
58
+ return ANSI_BG_STARTED;
59
+ }
60
+ return ANSI_BG_NOT_STARTED;
61
+ }
62
+
63
+ function createChartCell() {
64
+ return {
65
+ bg: null,
66
+ lineMask: 0,
67
+ arrowChar: null
68
+ };
69
+ }
70
+
71
+ function createChartGrid(height, width) {
72
+ return Array.from({ length: height }, () => Array.from({ length: width }, createChartCell));
73
+ }
74
+
75
+ function addMask(cell, mask) {
76
+ cell.lineMask |= mask;
77
+ }
78
+
79
+ function addHorizontalConnection(grid, row, fromCol, toCol) {
80
+ if (fromCol === toCol) {
81
+ return;
82
+ }
83
+
84
+ const step = fromCol < toCol ? 1 : -1;
85
+ for (let col = fromCol; col !== toCol; col += step) {
86
+ addMask(grid[row][col], step > 0 ? DIR_RIGHT : DIR_LEFT);
87
+ addMask(grid[row][col + step], step > 0 ? DIR_LEFT : DIR_RIGHT);
88
+ }
89
+ }
90
+
91
+ function addVerticalConnection(grid, col, fromRow, toRow) {
92
+ if (fromRow === toRow) {
93
+ return;
94
+ }
95
+
96
+ const step = fromRow < toRow ? 1 : -1;
97
+ for (let row = fromRow; row !== toRow; row += step) {
98
+ addMask(grid[row][col], step > 0 ? DIR_DOWN : DIR_UP);
99
+ addMask(grid[row + step][col], step > 0 ? DIR_UP : DIR_DOWN);
100
+ }
101
+ }
102
+
103
+ function routeDependency(grid, sourceRow, sourceCol, targetRow, targetCol) {
104
+ if (sourceRow === null || targetRow === null) {
105
+ return;
106
+ }
107
+
108
+ if (sourceRow === targetRow) {
109
+ addHorizontalConnection(grid, sourceRow, sourceCol, targetCol);
110
+ grid[targetRow][targetCol].arrowChar = targetCol >= sourceCol ? '→' : '←';
111
+ return;
112
+ }
113
+
114
+ const moveRight = targetCol >= sourceCol;
115
+ let routeCol = moveRight ? Math.max(sourceCol + 1, targetCol - 1) : Math.min(sourceCol - 1, targetCol + 1);
116
+ routeCol = Math.max(0, Math.min(grid[0].length - 1, routeCol));
117
+
118
+ addHorizontalConnection(grid, sourceRow, sourceCol, routeCol);
119
+ addVerticalConnection(grid, routeCol, sourceRow, targetRow);
120
+ addHorizontalConnection(grid, targetRow, routeCol, targetCol);
121
+ grid[targetRow][targetCol].arrowChar = targetCol >= routeCol ? '→' : '←';
122
+ }
123
+
124
+ function buildDependencyOverlay(tasks, barGeometries, width) {
125
+ const grid = createChartGrid(tasks.length, width);
126
+ const taskRowMap = new Map(tasks.map((task, index) => [task.id, index]));
127
+
128
+ tasks.forEach((task, targetRow) => {
129
+ (task.dependencies || []).forEach((dependencyId) => {
130
+ const sourceRow = taskRowMap.get(dependencyId);
131
+ if (sourceRow === undefined) {
132
+ return;
133
+ }
134
+
135
+ routeDependency(
136
+ grid,
137
+ sourceRow,
138
+ barGeometries[sourceRow].end,
139
+ targetRow,
140
+ barGeometries[targetRow].start
141
+ );
142
+ });
143
+ });
144
+
145
+ return grid;
146
+ }
147
+
148
+ function styleCell(char, fg = null, bg = null) {
149
+ if (!fg && !bg) {
150
+ return char;
151
+ }
152
+
153
+ return `${fg || ''}${bg || ''}${char}${ANSI_RESET}`;
154
+ }
155
+
156
+ function renderChartRow(gridRow, barGeometry, barBackground, nowPosition) {
157
+ return gridRow.map((cell, column) => {
158
+ const bg = column >= barGeometry.start && column <= barGeometry.end ? barBackground : null;
159
+ if (cell.arrowChar) {
160
+ return styleCell(cell.arrowChar, ANSI_FG_LINE, bg);
161
+ }
162
+
163
+ const lineChar = LINE_CHARS[cell.lineMask] || null;
164
+ if (lineChar) {
165
+ return styleCell(lineChar, ANSI_FG_LINE, bg);
166
+ }
167
+
168
+ if (nowPosition === column) {
169
+ return styleCell(NOW_MARKER, ANSI_FG_NOW, bg);
170
+ }
171
+
172
+ return styleCell(' ', null, bg);
173
+ }).join('');
174
+ }
175
+
176
+ function renderTickRow(ticks, nowPosition) {
177
+ return ticks.split('').map((char, column) => {
178
+ if (char !== ' ') {
179
+ return styleCell(char, ANSI_FG_LINE, null);
180
+ }
181
+ if (nowPosition === column) {
182
+ return styleCell(NOW_MARKER, ANSI_FG_NOW, null);
183
+ }
184
+ return char;
185
+ }).join('');
186
+ }
187
+
188
+ function getLabelPlacements(from, to, width, dateFormat, maxLabels) {
189
+ for (let count = maxLabels; count >= 1; count--) {
190
+ const placements = [];
191
+ let previousEnd = -1;
192
+
193
+ for (let i = 0; i < count; i++) {
194
+ const ratio = count === 1 ? 0 : i / (count - 1);
195
+ const position = Math.round(ratio * (width - 1));
196
+ const value = new Date(from.getTime() + Math.round((to.getTime() - from.getTime()) * ratio));
197
+ const label = formatDate(value, dateFormat);
198
+
199
+ let start = position - Math.floor(label.length / 2);
200
+ if (start < 0) {
201
+ start = 0;
202
+ }
203
+ if (start + label.length > width) {
204
+ start = Math.max(0, width - label.length);
205
+ }
206
+
207
+ const end = start + label.length - 1;
208
+ if (i > 0 && start <= previousEnd + 1) {
209
+ placements.length = 0;
210
+ break;
211
+ }
212
+
213
+ placements.push({ position, start, label, end });
214
+ previousEnd = end;
215
+ }
216
+
217
+ if (placements.length) {
218
+ return placements;
219
+ }
220
+ }
221
+
222
+ return [];
223
+ }
224
+
225
+ function renderXAxisLabels(from, to, width, dateFormat) {
226
+ const sampleLabel = formatDate(from, dateFormat);
227
+ const maxLabels = Math.max(1, Math.floor((width + 2) / (sampleLabel.length + 2)));
228
+ const placements = getLabelPlacements(from, to, width, dateFormat, maxLabels);
229
+
230
+ const ticks = Array(width).fill(' ');
231
+ const labels = Array(width).fill(' ');
232
+
233
+ for (const placement of placements) {
234
+ ticks[placement.position] = '│';
235
+ for (let i = 0; i < placement.label.length; i++) {
236
+ labels[placement.start + i] = placement.label[i];
237
+ }
238
+ }
239
+
240
+ return [ticks.join(''), labels.join('')];
241
+ }
242
+
243
+ function getNowPosition(from, to, width, now = new Date()) {
244
+ if (now < from || now > to) {
245
+ return null;
246
+ }
247
+
248
+ const totalSpan = to.getTime() - from.getTime();
249
+ return Math.round((now.getTime() - from.getTime()) / totalSpan * (width - 1));
250
+ }
251
+
252
+ function renderNowOverlay(line, nowPosition) {
253
+ if (nowPosition === null || nowPosition < 0 || nowPosition >= line.length) {
254
+ return line;
255
+ }
256
+
257
+ const result = line.split('');
258
+ result[nowPosition] = NOW_MARKER;
259
+ return result.join('');
260
+ }
261
+
262
+ function truncateName(name, maxWidth) {
263
+ if (name.length <= maxWidth) {
264
+ return name;
265
+ }
266
+ return name.substring(0, maxWidth - 1) + '…';
267
+ }
268
+
269
+ module.exports = async args => {
270
+
271
+ // Make sure kanbn has been initialised
272
+ if (!await kanbn.initialised()) {
273
+ utility.error('Kanbn has not been initialised in this folder\nTry running: {b}kanbn init{b}');
274
+ return;
275
+ }
276
+ const index = await kanbn.getIndex();
277
+
278
+ // Get assigned
279
+ let assigned = null;
280
+ if (args.assigned) {
281
+ assigned = utility.strArg(args.assigned);
282
+ }
283
+
284
+ // Get columns
285
+ let columns = null;
286
+ if (args.column) {
287
+ columns = utility.arrayArg(args.column);
288
+ }
289
+
290
+ // Get dates
291
+ let dates = null;
292
+ if (args.date) {
293
+ dates = utility.arrayArg(args.date);
294
+ if (dates.length) {
295
+ for (let i = 0; i < dates.length; i++) {
296
+ const dateValue = chrono.parseDate(dates[i]);
297
+ if (dateValue === null) {
298
+ utility.error('Unable to parse date');
299
+ return;
300
+ }
301
+ dates[i] = dateValue;
302
+ }
303
+ }
304
+ }
305
+
306
+ // Get mocked now date
307
+ let now = null;
308
+ if (args.now) {
309
+ now = chrono.parseDate(utility.strArg(args.now));
310
+ if (now === null) {
311
+ utility.error('Unable to parse now date');
312
+ return;
313
+ }
314
+ }
315
+
316
+ // Show gantt chart data
317
+ kanbn
318
+ .gantt(assigned, columns, dates, now)
319
+ .then(data => {
320
+ if (args.json) {
321
+
322
+ // Output raw data
323
+ console.log(JSON.stringify(data, null, 2));
324
+ } else {
325
+
326
+ // Render chart
327
+ const dateFormat = kanbn.getDateFormat(index);
328
+ const maxNameWidth = 16;
329
+ const nowDate = now || new Date();
330
+
331
+ // Keep each rendered task line within terminal width where possible.
332
+ // Line shape: "<prefix> <name> │<bar>│" => maxNameWidth + barWidth + 5 columns.
333
+ const terminalWidth = Number.isFinite(process.stdout.columns) && process.stdout.columns > 0
334
+ ? process.stdout.columns
335
+ : 120;
336
+ const barWidth = Math.max(1, terminalWidth - maxNameWidth - 5);
337
+ const nowPosition = getNowPosition(data.from, data.to, barWidth, nowDate);
338
+ const barGeometries = data.tasks.map((task) => getBarGeometry(task, data.from, data.to, barWidth));
339
+ const dependencyOverlay = buildDependencyOverlay(data.tasks, barGeometries, barWidth);
340
+
341
+ // Render header
342
+ console.log(`Gantt chart: ${formatDate(data.from, dateFormat)} to ${formatDate(data.to, dateFormat)}`);
343
+ if (data.dependencyCycleDetected) {
344
+ const cycleDescription = Array.isArray(data.dependencyCycleTaskIds) && data.dependencyCycleTaskIds.length
345
+ ? ` Cycle: ${data.dependencyCycleTaskIds.join(' -> ')}.`
346
+ : '';
347
+ console.error(`Warning: dependency cycle detected; using fallback ordering for ${data.cycleFallbackTaskIds.length} task(s).${cycleDescription}`);
348
+ }
349
+ console.log('');
350
+
351
+ // Render tasks with bars
352
+ data.tasks.forEach((task, taskIndex) => {
353
+ const prefix = task.blocked ? '⧗' : ' ';
354
+ const truncatedName = truncateName(task.name, maxNameWidth);
355
+ const bar = renderChartRow(
356
+ dependencyOverlay[taskIndex],
357
+ barGeometries[taskIndex],
358
+ getBarBackground(task),
359
+ nowPosition
360
+ );
361
+
362
+ console.log(`${prefix} ${truncatedName.padEnd(maxNameWidth)} │${bar}│`);
363
+ });
364
+
365
+ // Render x-axis
366
+ console.log('');
367
+ const [ticks, labels] = renderXAxisLabels(data.from, data.to, barWidth, dateFormat);
368
+ console.log(` ${''.padEnd(maxNameWidth)} │${renderTickRow(ticks, nowPosition)}│`);
369
+ console.log(` ${''.padEnd(maxNameWidth)} │${labels}│`);
370
+ }
371
+ })
372
+ .catch(error => {
373
+ utility.error(error);
374
+ });
375
+ };
@@ -1,4 +1,5 @@
1
- const kanbn = require('../main');
1
+ const kanbn_module = require('../main');
2
+ const kanbn = new kanbn_module.Kanbn();
2
3
  const utility = require('../utility');
3
4
  const inquirer = require('inquirer');
4
5
 
@@ -122,6 +122,14 @@ const sorterFields = [
122
122
  ],
123
123
  filterable: false
124
124
  },
125
+ {
126
+ name: 'Postponed date',
127
+ field: 'postponed',
128
+ options: [
129
+ '--postponed'
130
+ ],
131
+ filterable: false
132
+ },
125
133
  {
126
134
  name: 'Completed date',
127
135
  field: 'completed',