@basementuniverse/kanbn 0.10.0 → 1.0.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.
Files changed (50) hide show
  1. package/README.md +1 -0
  2. package/docs/commands/burndown.txt +7 -1
  3. package/docs/commands/gantt.txt +36 -0
  4. package/docs/commands/help.txt +1 -0
  5. package/docs/quick-start.md +1 -1
  6. package/docs/task-structure.md +47 -0
  7. package/example/.kanbn/index.md +63 -0
  8. package/example/.kanbn/tasks/add-basic-activity-feed.md +53 -0
  9. package/example/.kanbn/tasks/add-passwordless-login-option.md +34 -0
  10. package/example/.kanbn/tasks/add-usage-alert-email-thresholds.md +35 -0
  11. package/example/.kanbn/tasks/build-email-template-system.md +30 -0
  12. package/example/.kanbn/tasks/build-invoice-download-endpoint.md +43 -0
  13. package/example/.kanbn/tasks/build-tenant-settings-page.md +48 -0
  14. package/example/.kanbn/tasks/create-organization-switcher.md +53 -0
  15. package/example/.kanbn/tasks/create-sandbox-environment-provisioner.md +36 -0
  16. package/example/.kanbn/tasks/create-self-serve-cancellation-flow.md +38 -0
  17. package/example/.kanbn/tasks/define-product-pricing-strategy.md +37 -0
  18. package/example/.kanbn/tasks/design-onboarding-checklist.md +30 -0
  19. package/example/.kanbn/tasks/design-team-invite-expiry-flow.md +33 -0
  20. package/example/.kanbn/tasks/implement-data-retention-policy-jobs.md +30 -0
  21. package/example/.kanbn/tasks/implement-feature-flags-foundation.md +36 -0
  22. package/example/.kanbn/tasks/implement-project-creation-wizard.md +44 -0
  23. package/example/.kanbn/tasks/implement-stripe-webhook-signature-check.md +54 -0
  24. package/example/.kanbn/tasks/implement-team-permissions-ui.md +57 -0
  25. package/example/.kanbn/tasks/implement-user-signup-and-login.md +62 -0
  26. package/example/.kanbn/tasks/integrate-crm-lead-sync.md +35 -0
  27. package/example/.kanbn/tasks/legal-review-terms-and-privacy.md +30 -0
  28. package/example/.kanbn/tasks/migrate-legacy-events-to-new-schema.md +48 -0
  29. package/example/.kanbn/tasks/optimize-dashboard-first-load.md +52 -0
  30. package/example/.kanbn/tasks/prototype-report-export-scheduler.md +34 -0
  31. package/example/.kanbn/tasks/publish-internal-qa-checklist.md +53 -0
  32. package/example/.kanbn/tasks/setup-ci-pipeline.md +53 -0
  33. package/package.json +3 -2
  34. package/routes/gantt.json +27 -0
  35. package/skills/kanbn-plan/SKILL.md +211 -0
  36. package/skills/kanbn-plan/references/index-structure.md +89 -0
  37. package/skills/kanbn-plan/references/planning-rules.md +58 -0
  38. package/skills/kanbn-plan/references/task-structure.md +143 -0
  39. package/skills/kanbn-plan/scripts/check-dependency-cycles.mjs +273 -0
  40. package/skills/kanbn-plan/scripts/validate-kanbn.mjs +135 -0
  41. package/src/controller/add.js +33 -1
  42. package/src/controller/burndown.js +72 -5
  43. package/src/controller/edit.js +68 -1
  44. package/src/controller/find.js +5 -0
  45. package/src/controller/gantt.js +375 -0
  46. package/src/controller/init.js +2 -1
  47. package/src/controller/sort.js +8 -0
  48. package/src/main.d.ts +295 -340
  49. package/src/main.js +2591 -2050
  50. package/src/parse-task.js +211 -3
@@ -0,0 +1,273 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import process from 'process';
6
+
7
+ function usage() {
8
+ console.error('Usage: node skills/kanbn-plan/scripts/check-dependency-cycles.mjs [project-root] [--json]');
9
+ }
10
+
11
+ function parseArgs(argv) {
12
+ let projectRoot = process.cwd();
13
+ let json = false;
14
+
15
+ for (const arg of argv) {
16
+ if (arg === '--json') {
17
+ json = true;
18
+ continue;
19
+ }
20
+
21
+ if (arg.startsWith('-')) {
22
+ usage();
23
+ process.exit(1);
24
+ }
25
+
26
+ if (projectRoot !== process.cwd()) {
27
+ usage();
28
+ process.exit(1);
29
+ }
30
+
31
+ projectRoot = arg;
32
+ }
33
+
34
+ return {
35
+ json,
36
+ projectRoot: path.resolve(projectRoot)
37
+ };
38
+ }
39
+
40
+ function ensureKanbnFiles(projectRoot) {
41
+ const tasksPath = path.join(projectRoot, '.kanbn', 'tasks');
42
+ if (!fs.existsSync(tasksPath)) {
43
+ throw new Error(`No Kanbn tasks directory found at ${tasksPath}`);
44
+ }
45
+ return tasksPath;
46
+ }
47
+
48
+ function normaliseRelationType(type) {
49
+ return String(type || '').trim().toLowerCase();
50
+ }
51
+
52
+ function getTaskIdFromHref(href) {
53
+ const fileName = path.basename(String(href || '').trim());
54
+ return fileName.endsWith('.md') ? fileName.slice(0, -3) : fileName;
55
+ }
56
+
57
+ function extractRelationsSection(markdown) {
58
+ const lines = markdown.split(/\r?\n/);
59
+ const sectionLines = [];
60
+ let inSection = false;
61
+
62
+ for (const line of lines) {
63
+ if (/^##\s+Relations\s*$/.test(line.trim())) {
64
+ inSection = true;
65
+ continue;
66
+ }
67
+
68
+ if (inSection && /^##\s+/.test(line.trim())) {
69
+ break;
70
+ }
71
+
72
+ if (inSection) {
73
+ sectionLines.push(line);
74
+ }
75
+ }
76
+
77
+ return sectionLines.join('\n').trim();
78
+ }
79
+
80
+ function parseRelations(markdown) {
81
+ const section = extractRelationsSection(markdown);
82
+ if (!section) {
83
+ return [];
84
+ }
85
+
86
+ const relations = [];
87
+ const lines = section.split(/\r?\n/);
88
+ const relationPattern = /^-\s+\[([^\]]+)\]\(([^)]+)\)\s*$/;
89
+
90
+ for (const line of lines) {
91
+ const match = line.trim().match(relationPattern);
92
+ if (!match) {
93
+ continue;
94
+ }
95
+
96
+ const text = match[1].trim();
97
+ const href = match[2].trim();
98
+ const targetTaskId = getTaskIdFromHref(href);
99
+ const relationType = text.endsWith(targetTaskId)
100
+ ? text.slice(0, text.length - targetTaskId.length).trim()
101
+ : text;
102
+
103
+ relations.push({
104
+ task: targetTaskId,
105
+ type: normaliseRelationType(relationType)
106
+ });
107
+ }
108
+
109
+ return relations;
110
+ }
111
+
112
+ function loadTasks(tasksPath) {
113
+ const tasks = new Map();
114
+
115
+ for (const entry of fs.readdirSync(tasksPath, { withFileTypes: true })) {
116
+ if (!entry.isFile() || !entry.name.endsWith('.md')) {
117
+ continue;
118
+ }
119
+
120
+ const taskId = entry.name.slice(0, -3);
121
+ const markdown = fs.readFileSync(path.join(tasksPath, entry.name), 'utf8');
122
+ tasks.set(taskId, {
123
+ id: taskId,
124
+ relations: parseRelations(markdown)
125
+ });
126
+ }
127
+
128
+ return tasks;
129
+ }
130
+
131
+ function buildDependencyGraph(tasks) {
132
+ const graph = new Map();
133
+ const danglingReferences = [];
134
+
135
+ for (const taskId of tasks.keys()) {
136
+ graph.set(taskId, new Set());
137
+ }
138
+
139
+ for (const [taskId, task] of tasks.entries()) {
140
+ for (const relation of task.relations) {
141
+ if (!relation.task) {
142
+ continue;
143
+ }
144
+
145
+ let fromId = null;
146
+ let toId = null;
147
+
148
+ if (relation.type === 'depends-on') {
149
+ fromId = relation.task;
150
+ toId = taskId;
151
+ } else if (relation.type === 'blocks') {
152
+ fromId = taskId;
153
+ toId = relation.task;
154
+ } else {
155
+ continue;
156
+ }
157
+
158
+ if (!tasks.has(fromId) || !tasks.has(toId)) {
159
+ danglingReferences.push({
160
+ from: taskId,
161
+ relationType: relation.type,
162
+ target: relation.task
163
+ });
164
+ continue;
165
+ }
166
+
167
+ graph.get(fromId).add(toId);
168
+ }
169
+ }
170
+
171
+ return { danglingReferences, graph };
172
+ }
173
+
174
+ function findCycles(graph) {
175
+ const visited = new Set();
176
+ const visiting = new Set();
177
+ const stack = [];
178
+ const cycles = [];
179
+ const seenCycleKeys = new Set();
180
+
181
+ function recordCycle(startNode) {
182
+ const startIndex = stack.indexOf(startNode);
183
+ if (startIndex === -1) {
184
+ return;
185
+ }
186
+
187
+ const cycle = stack.slice(startIndex).concat(startNode);
188
+ const uniqueNodes = cycle.slice(0, -1);
189
+ const canonicalStart = [...uniqueNodes].sort()[0];
190
+ const canonicalIndex = uniqueNodes.indexOf(canonicalStart);
191
+ const rotated = uniqueNodes.slice(canonicalIndex).concat(uniqueNodes.slice(0, canonicalIndex));
192
+ const cycleKey = rotated.join('>');
193
+
194
+ if (!seenCycleKeys.has(cycleKey)) {
195
+ seenCycleKeys.add(cycleKey);
196
+ cycles.push(rotated.concat(rotated[0]));
197
+ }
198
+ }
199
+
200
+ function visit(node) {
201
+ visited.add(node);
202
+ visiting.add(node);
203
+ stack.push(node);
204
+
205
+ for (const nextNode of graph.get(node) || []) {
206
+ if (!visited.has(nextNode)) {
207
+ visit(nextNode);
208
+ } else if (visiting.has(nextNode)) {
209
+ recordCycle(nextNode);
210
+ }
211
+ }
212
+
213
+ stack.pop();
214
+ visiting.delete(node);
215
+ }
216
+
217
+ for (const node of graph.keys()) {
218
+ if (!visited.has(node)) {
219
+ visit(node);
220
+ }
221
+ }
222
+
223
+ return cycles;
224
+ }
225
+
226
+ function printTextReport(result) {
227
+ if (result.danglingReferences.length > 0) {
228
+ console.error(`Dangling dependency references: ${result.danglingReferences.length}`);
229
+ for (const reference of result.danglingReferences) {
230
+ console.error(`- ${reference.from}: ${reference.relationType} ${reference.target}`);
231
+ }
232
+ }
233
+
234
+ if (result.cycles.length > 0) {
235
+ console.error(`Dependency cycles detected: ${result.cycles.length}`);
236
+ for (const cycle of result.cycles) {
237
+ console.error(`- ${cycle.join(' -> ')}`);
238
+ }
239
+ }
240
+
241
+ if (result.danglingReferences.length === 0 && result.cycles.length === 0) {
242
+ console.log('No dependency cycles or dangling dependency references found');
243
+ }
244
+ }
245
+
246
+ function main() {
247
+ const { json, projectRoot } = parseArgs(process.argv.slice(2));
248
+
249
+ let tasksPath;
250
+ try {
251
+ tasksPath = ensureKanbnFiles(projectRoot);
252
+ } catch (error) {
253
+ console.error(error.message);
254
+ process.exit(1);
255
+ }
256
+
257
+ const tasks = loadTasks(tasksPath);
258
+ const { graph, danglingReferences } = buildDependencyGraph(tasks);
259
+ const cycles = findCycles(graph);
260
+ const result = { cycles, danglingReferences };
261
+
262
+ if (json) {
263
+ console.log(JSON.stringify(result, null, 2));
264
+ } else {
265
+ printTextReport(result);
266
+ }
267
+
268
+ if (cycles.length > 0 || danglingReferences.length > 0) {
269
+ process.exit(1);
270
+ }
271
+ }
272
+
273
+ main();
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import process from 'process';
6
+ import { spawnSync } from 'child_process';
7
+
8
+ function usage() {
9
+ console.error('Usage: node skills/kanbn-plan/scripts/validate-kanbn.mjs [project-root]');
10
+ }
11
+
12
+ function resolveProjectRoot(argv) {
13
+ if (argv.length > 1) {
14
+ usage();
15
+ process.exit(1);
16
+ }
17
+
18
+ return path.resolve(argv[0] || process.cwd());
19
+ }
20
+
21
+ function ensureKanbnFiles(projectRoot) {
22
+ const indexPath = path.join(projectRoot, '.kanbn', 'index.md');
23
+ const tasksPath = path.join(projectRoot, '.kanbn', 'tasks');
24
+
25
+ if (!fs.existsSync(indexPath)) {
26
+ console.error(`No Kanbn index found at ${indexPath}`);
27
+ process.exit(1);
28
+ }
29
+
30
+ if (!fs.existsSync(tasksPath)) {
31
+ console.error(`No Kanbn tasks directory found at ${tasksPath}`);
32
+ process.exit(1);
33
+ }
34
+ }
35
+
36
+ function getCandidates(projectRoot) {
37
+ const candidates = [];
38
+ const localBin = path.join(projectRoot, 'node_modules', '.bin', 'kanbn');
39
+
40
+ if (process.env.KANBN_BIN) {
41
+ candidates.push({ command: process.env.KANBN_BIN, args: [], label: process.env.KANBN_BIN });
42
+ }
43
+
44
+ if (fs.existsSync(localBin)) {
45
+ candidates.push({ command: localBin, args: [], label: localBin });
46
+ }
47
+
48
+ candidates.push({ command: 'kanbn', args: [], label: 'kanbn' });
49
+ candidates.push({ command: 'npx', args: ['-y', '@basementuniverse/kanbn'], label: 'npx -y @basementuniverse/kanbn' });
50
+
51
+ return candidates;
52
+ }
53
+
54
+ function runValidate(projectRoot) {
55
+ const candidates = getCandidates(projectRoot);
56
+ let lastError = null;
57
+
58
+ for (const candidate of candidates) {
59
+ const result = spawnSync(
60
+ candidate.command,
61
+ [...candidate.args, 'validate', '--json'],
62
+ {
63
+ cwd: projectRoot,
64
+ encoding: 'utf8'
65
+ }
66
+ );
67
+
68
+ if (result.error && result.error.code === 'ENOENT') {
69
+ lastError = result.error;
70
+ continue;
71
+ }
72
+
73
+ return { candidate, result };
74
+ }
75
+
76
+ throw lastError || new Error('Unable to locate a runnable Kanbn CLI');
77
+ }
78
+
79
+ function extractValidationErrors(output) {
80
+ const start = output.indexOf('[');
81
+ const end = output.lastIndexOf(']');
82
+
83
+ if (start === -1 || end === -1 || end < start) {
84
+ return null;
85
+ }
86
+
87
+ try {
88
+ return JSON.parse(output.slice(start, end + 1));
89
+ } catch (error) {
90
+ return null;
91
+ }
92
+ }
93
+
94
+ function main() {
95
+ const projectRoot = resolveProjectRoot(process.argv.slice(2));
96
+ ensureKanbnFiles(projectRoot);
97
+
98
+ let execution;
99
+ try {
100
+ execution = runValidate(projectRoot);
101
+ } catch (error) {
102
+ console.error(`Unable to run Kanbn validation: ${error.message}`);
103
+ process.exit(1);
104
+ }
105
+
106
+ const { candidate, result } = execution;
107
+ const combinedOutput = [result.stdout, result.stderr].filter(Boolean).join('\n').trim();
108
+
109
+ if (result.status === 0) {
110
+ if (combinedOutput) {
111
+ console.log(combinedOutput);
112
+ } else {
113
+ console.log(`Kanbn validation passed via ${candidate.label}`);
114
+ }
115
+ return;
116
+ }
117
+
118
+ const errors = extractValidationErrors(combinedOutput);
119
+ if (errors) {
120
+ console.error(`Kanbn validation reported ${errors.length} error(s) via ${candidate.label}:`);
121
+ for (const error of errors) {
122
+ if (error && typeof error === 'object') {
123
+ console.error(JSON.stringify(error, null, 2));
124
+ } else {
125
+ console.error(String(error));
126
+ }
127
+ }
128
+ process.exit(1);
129
+ }
130
+
131
+ console.error(combinedOutput || `Kanbn validation failed via ${candidate.label}`);
132
+ process.exit(result.status || 1);
133
+ }
134
+
135
+ main();
@@ -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',