mdboard 1.2.0 → 2.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 (40) hide show
  1. package/bin.js +130 -44
  2. package/index.html +3321 -1195
  3. package/package.json +10 -11
  4. package/presets/kanban/api.json +91 -0
  5. package/presets/kanban/cli.json +69 -0
  6. package/presets/kanban/docs.json +29 -0
  7. package/presets/kanban/entities.json +128 -0
  8. package/presets/kanban/structure.json +15 -0
  9. package/presets/kanban/ui.json +86 -0
  10. package/presets/scrum/api.json +98 -0
  11. package/presets/scrum/cli.json +120 -0
  12. package/presets/scrum/docs.json +43 -0
  13. package/presets/scrum/entities.json +268 -0
  14. package/presets/scrum/structure.json +32 -0
  15. package/presets/scrum/ui.json +201 -0
  16. package/presets/shape-up/api.json +40 -0
  17. package/presets/shape-up/cli.json +44 -0
  18. package/presets/shape-up/docs.json +32 -0
  19. package/presets/shape-up/entities.json +140 -0
  20. package/presets/shape-up/structure.json +28 -0
  21. package/presets/shape-up/ui.json +114 -0
  22. package/src/cli/cli.js +338 -0
  23. package/src/cli/config.js +234 -0
  24. package/src/cli/init.js +175 -0
  25. package/src/cli/preset.js +849 -0
  26. package/src/cli/skill.js +417 -0
  27. package/src/cli/status.js +180 -0
  28. package/src/core/config.js +551 -0
  29. package/src/core/history.js +146 -0
  30. package/src/core/scanner.js +521 -0
  31. package/{workspace.js → src/core/workspace.js} +0 -15
  32. package/{yaml.js → src/core/yaml.js} +5 -1
  33. package/src/server/api.js +616 -0
  34. package/{server.js → src/server/server.js} +180 -132
  35. package/{watcher.js → src/server/watcher.js} +40 -9
  36. package/api.js +0 -752
  37. package/config.js +0 -73
  38. package/defaults.json +0 -43
  39. package/init.js +0 -109
  40. package/scanner.js +0 -491
package/bin.js CHANGED
@@ -1,9 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ /**
4
+ * mdboard — CLI entry point
5
+ *
6
+ * All commands, entity types, and flags are resolved dynamically from config.
7
+ * The only hardcoded commands are structural: init, help, version, cache, theme, server.
8
+ */
9
+
10
+ 'use strict';
11
+
3
12
  const path = require('path');
4
13
  const args = process.argv.slice(2);
5
14
 
6
- // Pre-process --config and --workspace flags before dispatching commands
15
+ // Pre-process global flags before dispatching commands
7
16
  for (let i = 0; i < args.length; i++) {
8
17
  if (args[i] === '--config' && args[i + 1]) {
9
18
  process.env.MDBOARD_CONFIG = path.resolve(args[i + 1]);
@@ -11,36 +20,87 @@ for (let i = 0; i < args.length; i++) {
11
20
  if (args[i] === '--workspace' && args[i + 1]) {
12
21
  process.env.MDBOARD_WORKSPACE = path.resolve(args[i + 1]);
13
22
  }
23
+ if (args[i] === '--preset' && args[i + 1]) {
24
+ process.env.MDBOARD_PRESET = args[i + 1];
25
+ }
14
26
  }
15
27
 
16
28
  const command = args[0];
17
29
 
30
+ // --- Version ---
18
31
  if (command === '--version' || command === '-v') {
19
32
  const pkg = require('./package.json');
20
33
  console.log('mdboard v' + pkg.version);
21
34
  process.exit(0);
22
35
  }
23
36
 
24
- if (command === '--help' || command === '-h') {
37
+ // --- Help ---
38
+ if (command === '--help' || command === '-h' || command === 'help') {
25
39
  printHelp();
26
40
  process.exit(0);
27
41
  }
28
42
 
43
+ // --- Init ---
29
44
  if (command === 'init') {
30
- require('./init.js');
31
- } else if (command === 'help') {
32
- printHelp();
45
+ require('./src/cli/init');
33
46
  process.exit(0);
34
- } else if (command === 'cache') {
47
+ }
48
+
49
+ // --- Cache ---
50
+ if (command === 'cache') {
35
51
  handleCache();
52
+ process.exit(0);
53
+ }
54
+
55
+ // --- History ---
56
+ if (command === 'history') {
57
+ handleHistory();
58
+ process.exit(0);
59
+ }
60
+
61
+ // --- Status ---
62
+ if (command === 'status') {
63
+ const { resolveProjectDir } = require('./src/cli/cli');
64
+ const { generateStatus } = require('./src/cli/status');
65
+ generateStatus(resolveProjectDir(args));
66
+ process.exit(0);
67
+ }
68
+
69
+ // --- CRUD: create, update, delete ---
70
+ if (command === 'create') {
71
+ const { resolveProjectDir, handleCreate } = require('./src/cli/cli');
72
+ handleCreate(resolveProjectDir(args), args.slice(1));
73
+ } else if (command === 'update') {
74
+ const { resolveProjectDir, handleUpdate } = require('./src/cli/cli');
75
+ handleUpdate(resolveProjectDir(args), args.slice(1));
76
+ } else if (command === 'delete') {
77
+ const { resolveProjectDir, handleDelete } = require('./src/cli/cli');
78
+ handleDelete(resolveProjectDir(args), args.slice(1));
79
+ } else if (command === 'list') {
80
+ const { resolveProjectDir, handleList } = require('./src/cli/cli');
81
+ handleList(resolveProjectDir(args), args.slice(1));
82
+ } else if (command === 'preset') {
83
+ require('./src/cli/preset').run(args.slice(1));
84
+ } else if (command === 'config') {
85
+ require('./src/cli/config').run(args.slice(1));
86
+ // readline keeps process alive; config.js calls process.exit(0) when done
87
+ } else if (command === 'skill') {
88
+ require('./src/cli/skill').run(args.slice(1));
89
+ // readline keeps process alive; skill.js calls process.exit(0) when done
90
+ } else if (!command || command.startsWith('--')) {
91
+ // Default: start server (flags like --port are handled by server.js)
92
+ require('./src/server/server.js');
36
93
  } else {
37
- // Default: start server. Pass all args through.
38
- require('./server.js');
94
+ console.error(' Unknown command: ' + command);
95
+ console.error(' Run `mdboard --help` for usage.');
96
+ process.exit(1);
39
97
  }
40
98
 
99
+ // --- Cache handler ---
100
+
41
101
  function handleCache() {
42
102
  const subCmd = args[1];
43
- const { listCache, cleanCache, CACHE_DIR } = require('./workspace');
103
+ const { listCache, cleanCache, CACHE_DIR } = require('./src/core/workspace');
44
104
 
45
105
  if (subCmd === 'list') {
46
106
  const entries = listCache();
@@ -59,44 +119,70 @@ function handleCache() {
59
119
  console.log('\n No cache to clean or error occurred.\n');
60
120
  }
61
121
  } else {
62
- console.log(`
63
- mdboard cache — Manage remote source cache
122
+ console.log('\n mdboard cache — Manage remote source cache\n\n Subcommands:\n mdboard cache list List cached remote repos\n mdboard cache clean Remove all cached repos\n');
123
+ }
124
+ }
64
125
 
65
- Subcommands:
66
- mdboard cache list List cached remote repos
67
- mdboard cache clean Remove all cached repos
68
- `);
126
+ // --- History handler ---
127
+
128
+ function handleHistory() {
129
+ const subCmd = args[1];
130
+ const { readHistory, pruneHistory } = require('./src/core/history');
131
+
132
+ if (subCmd === 'list') {
133
+ const entries = readHistory();
134
+ if (entries.length === 0) {
135
+ console.log('\n No projects in history.\n');
136
+ } else {
137
+ console.log('\n Project history (' + entries.length + '):\n');
138
+ const fs = require('fs');
139
+ entries.forEach(function(e) {
140
+ const exists = fs.existsSync(e.path);
141
+ const marker = exists ? ' ' : '✗ ';
142
+ console.log(' ' + marker + e.name + ' ' + e.path);
143
+ });
144
+ console.log('');
145
+ }
146
+ } else if (subCmd === 'clean') {
147
+ const { removed, kept } = pruneHistory();
148
+ if (removed.length === 0) {
149
+ console.log('\n History is clean — all entries point to existing directories.\n');
150
+ } else {
151
+ console.log('\n Removed ' + removed.length + ' stale entr' + (removed.length === 1 ? 'y' : 'ies') + ':\n');
152
+ removed.forEach(function(p) { console.log(' ✗ ' + p); });
153
+ console.log('\n ' + kept + ' entr' + (kept === 1 ? 'y' : 'ies') + ' remaining.\n');
154
+ }
155
+ } else {
156
+ console.log('\n mdboard history — Manage project switch history\n\n Subcommands:\n mdboard history list List all projects in history\n mdboard history clean Remove entries with missing directories\n');
69
157
  }
70
- process.exit(0);
71
158
  }
72
159
 
160
+ // --- Help ---
161
+
73
162
  function printHelp() {
74
- console.log(`
75
- mdboard Git-based project management dashboard
76
-
77
- Usage:
78
- mdboard Start the dashboard server
79
- mdboard init Scaffold a new project/ directory
80
- mdboard cache list|clean Manage remote source cache
81
- mdboard --version Print version
82
- mdboard --help Show this help
83
-
84
- Server options:
85
- --project <path> Workspace root directory (default: cwd)
86
- --port <number> Server port (default: 3333)
87
- --config <path> Path to mdboard.json config file
88
- --workspace <path> Path to workspace.json
89
-
90
- Multi-repo workspace:
91
- Create a workspace.json in your project root to manage
92
- multiple repositories from a single dashboard.
93
-
94
- Examples:
95
- npx mdboard Start dashboard in current directory
96
- npx mdboard init Create project/ with templates
97
- npx mdboard --port 4000 Start on port 4000
98
- npx mdboard --workspace ./workspace.json
99
- npx mdboard cache list Show cached remote repos
100
- npx mdboard cache clean Clear remote cache
101
- `);
163
+ // Load config to generate dynamic examples
164
+ let entityExamples = '';
165
+ try {
166
+ const configEngine = require('./src/core/config');
167
+ const cfg = configEngine.loadConfig(process.cwd(), process.env.MDBOARD_CONFIG);
168
+ const types = configEngine.getEntityTypes(cfg);
169
+
170
+ if (types.length > 0) {
171
+ const examples = [];
172
+ for (const type of types) {
173
+ const entity = configEngine.getEntity(cfg, type);
174
+ const ancestors = configEngine.getAncestors(cfg, type);
175
+ let example = ' mdboard create ' + type + ' "My ' + entity.singular + '"';
176
+ for (const anc of ancestors) {
177
+ example += ' --' + anc.replace(/_/g, '-') + ' <slug>';
178
+ }
179
+ examples.push(example);
180
+ }
181
+ entityExamples = '\n CRUD examples (from ' + cfg._preset + ' preset):\n' + examples.join('\n') + '\n mdboard update task TASK-001 --status done\n mdboard delete task TASK-001\n mdboard list task\n';
182
+ }
183
+ } catch (e) {
184
+ entityExamples = '\n CRUD examples:\n mdboard create <entity> "title" [--flags]\n mdboard update <entity> <id> --field value\n mdboard delete <entity> <id>\n mdboard list <entity>\n';
185
+ }
186
+
187
+ console.log('\n mdboard — Git-based project management dashboard\n\n Usage:\n mdboard Start the dashboard server\n mdboard init [name] Scaffold a new workspace\n mdboard create <entity> Create an entity\n mdboard update <entity> Update an entity\n mdboard delete <entity> Delete an entity\n mdboard list <entity> List entities\n mdboard status Generate status report\n mdboard preset Create & manage presets (scrum, kanban)\n mdboard config Setup preferences & AI skill\n mdboard skill Install AI skill to IDE/agent\n mdboard history list|clean Manage project switch history\n mdboard cache list|clean Manage remote source cache\n mdboard --version Print version\n mdboard --help Show this help\n' + entityExamples + '\n Options:\n --project <path> Workspace root (default: cwd)\n --preset <name> Methodology preset (shape-up, scrum, kanban)\n --config <path> Path to config directory\n --port <number> Server port (default: 3333)\n --workspace <path> Path to workspace.json\n');
102
188
  }