draftgo-cli 1.0.4

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 (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +249 -0
  3. package/bin/draftgo.js +9 -0
  4. package/package.json +70 -0
  5. package/resources/project-design/README.md +42 -0
  6. package/resources/skill/SKILL.md +62 -0
  7. package/resources/skill/init/SKILL.md +41 -0
  8. package/resources/skill/manifest.json +35 -0
  9. package/resources/skill/references/ai.md +41 -0
  10. package/resources/skill/references/app-api.md +97 -0
  11. package/resources/skill/references/architecture.md +13 -0
  12. package/resources/skill/references/chat-sdk.md +205 -0
  13. package/resources/skill/references/checkout.md +140 -0
  14. package/resources/skill/references/data.md +49 -0
  15. package/resources/skill/references/db-relations.md +29 -0
  16. package/resources/skill/references/delivery.md +33 -0
  17. package/resources/skill/references/development.md +41 -0
  18. package/resources/skill/references/diagnostics.md +50 -0
  19. package/resources/skill/references/frontend.md +158 -0
  20. package/resources/skill/references/mcp.md +110 -0
  21. package/resources/skill/references/methods.md +143 -0
  22. package/resources/skill/references/modules.md +75 -0
  23. package/resources/skill/references/runtime.md +109 -0
  24. package/resources/skill/references/services.md +32 -0
  25. package/src/apiContractCache.js +120 -0
  26. package/src/cli.js +100 -0
  27. package/src/commandRegistry.js +46 -0
  28. package/src/commands/api.js +244 -0
  29. package/src/commands/apiKey.js +30 -0
  30. package/src/commands/autoPush.js +36 -0
  31. package/src/commands/capabilities.js +100 -0
  32. package/src/commands/check.js +82 -0
  33. package/src/commands/checkout.js +18 -0
  34. package/src/commands/clean.js +72 -0
  35. package/src/commands/commit.js +47 -0
  36. package/src/commands/components.js +554 -0
  37. package/src/commands/conflict.js +30 -0
  38. package/src/commands/conflicts.js +16 -0
  39. package/src/commands/connect.js +91 -0
  40. package/src/commands/delete.js +95 -0
  41. package/src/commands/deploy.js +77 -0
  42. package/src/commands/diff.js +39 -0
  43. package/src/commands/group.js +37 -0
  44. package/src/commands/help.js +190 -0
  45. package/src/commands/init.js +126 -0
  46. package/src/commands/listTargets.js +13 -0
  47. package/src/commands/local.js +79 -0
  48. package/src/commands/map.js +395 -0
  49. package/src/commands/mcp.js +150 -0
  50. package/src/commands/reconcile.js +20 -0
  51. package/src/commands/role.js +31 -0
  52. package/src/commands/status.js +98 -0
  53. package/src/commands/uninstall.js +52 -0
  54. package/src/commands/update.js +79 -0
  55. package/src/commands/verify.js +188 -0
  56. package/src/commands/visualVerify.js +281 -0
  57. package/src/commands/worklog.js +117 -0
  58. package/src/consoleEncoding.js +34 -0
  59. package/src/contractCompatibility.js +65 -0
  60. package/src/detect.js +25 -0
  61. package/src/diffReport.js +106 -0
  62. package/src/fsx.js +67 -0
  63. package/src/index.js +46 -0
  64. package/src/localRuntime/compose.js +119 -0
  65. package/src/localRuntime/detect.js +77 -0
  66. package/src/localRuntime/index.js +211 -0
  67. package/src/localRuntime/mysqlClient.js +155 -0
  68. package/src/localRuntime/services.js +117 -0
  69. package/src/logger.js +37 -0
  70. package/src/mcp/client.js +558 -0
  71. package/src/mcp/hosts.js +520 -0
  72. package/src/mcp/parallel.js +54 -0
  73. package/src/mcp/protocol.js +223 -0
  74. package/src/mcp/stdio.js +300 -0
  75. package/src/mcp/tools.js +51 -0
  76. package/src/paths.js +32 -0
  77. package/src/platforms.js +110 -0
  78. package/src/projectConfig.js +139 -0
  79. package/src/projectDesign.js +19 -0
  80. package/src/projectHealth.js +33 -0
  81. package/src/projectMap.js +220 -0
  82. package/src/prompt.js +94 -0
  83. package/src/releaseInstall.js +105 -0
  84. package/src/runtimeFiles.js +45 -0
  85. package/src/skill.js +295 -0
  86. package/src/targets.js +43 -0
  87. package/src/timeout.js +18 -0
  88. package/src/updateCheck.js +100 -0
  89. package/src/worklog.js +276 -0
  90. package/src/worktree/backend.js +438 -0
  91. package/src/worktree/errors.js +28 -0
  92. package/src/worktree/index.js +751 -0
  93. package/src/worktree/inlineScripts.js +99 -0
  94. package/src/worktree/locks.js +52 -0
  95. package/src/worktree/manifest.js +89 -0
  96. package/src/worktree/status.js +124 -0
  97. package/src/worktree/streams.js +200 -0
  98. package/src/worktree/types.js +103 -0
  99. package/src/worktree/validate.js +37 -0
@@ -0,0 +1,117 @@
1
+ 'use strict';
2
+
3
+ // Shared local runtime dependencies live outside individual projects. Project Compose
4
+ // files run DraftGo and isolated Redis, then connect back to MySQL and Qdrant.
5
+ const net = require('net');
6
+ const os = require('os');
7
+ const path = require('path');
8
+ const http = require('http');
9
+ const https = require('https');
10
+ const { spawnSync } = require('child_process');
11
+ const { ensureDir, writeText } = require('../fsx');
12
+
13
+ const SERVICES_DIR = path.join(os.homedir(), '.draftgo', 'local-services');
14
+ const COMPOSE_FILE = path.join(SERVICES_DIR, 'docker-compose.yaml');
15
+ const MYSQL_INIT_FILE = path.join(SERVICES_DIR, 'mysql-init.sql');
16
+
17
+ const defaults = {
18
+ mysql: { host: '127.0.0.1', port: 3306, user: 'draftgo', password: 'draftgo' },
19
+ qdrant: { host: '127.0.0.1', port: 26333, apiKey: '' },
20
+ };
21
+
22
+ function writeServiceFiles() {
23
+ ensureDir(SERVICES_DIR);
24
+ ensureDir(path.join(SERVICES_DIR, 'data', 'mysql'));
25
+ ensureDir(path.join(SERVICES_DIR, 'data', 'qdrant'));
26
+ writeText(MYSQL_INIT_FILE, [
27
+ "GRANT ALL PRIVILEGES ON `draftgo\\_%`.* TO 'draftgo'@'%';",
28
+ 'FLUSH PRIVILEGES;',
29
+ '',
30
+ ].join('\n'));
31
+ writeText(COMPOSE_FILE, [
32
+ 'name: draftgo-local-services',
33
+ 'services:',
34
+ ' mysql:',
35
+ ' image: mysql:8.0',
36
+ ' container_name: draftgo-local-mysql',
37
+ ' restart: unless-stopped',
38
+ ' command: ["--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]',
39
+ ' environment:',
40
+ ' MYSQL_ROOT_PASSWORD: draftgo',
41
+ ' MYSQL_DATABASE: draftgo_bootstrap',
42
+ ' MYSQL_USER: draftgo',
43
+ ' MYSQL_PASSWORD: draftgo',
44
+ ' ports:',
45
+ ' - "127.0.0.1:3306:3306"',
46
+ ' volumes:',
47
+ ' - ./data/mysql:/var/lib/mysql',
48
+ ' - ./mysql-init.sql:/docker-entrypoint-initdb.d/01-grants.sql:ro',
49
+ ' healthcheck:',
50
+ ' test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-pdraftgo"]',
51
+ ' interval: 5s',
52
+ ' timeout: 5s',
53
+ ' retries: 24',
54
+ ' start_period: 20s',
55
+ ' qdrant:',
56
+ ' image: qdrant/qdrant:v1.19.0',
57
+ ' container_name: draftgo-local-qdrant',
58
+ ' restart: unless-stopped',
59
+ ' ports:',
60
+ ' - "127.0.0.1:26333:6333"',
61
+ ' volumes:',
62
+ ' - ./data/qdrant:/qdrant/storage',
63
+ ' healthcheck:',
64
+ ' test: ["CMD-SHELL", "bash -c \':> /dev/tcp/127.0.0.1/6333\'"]',
65
+ ' interval: 10s',
66
+ ' timeout: 5s',
67
+ ' retries: 12',
68
+ ' start_period: 30s',
69
+ '',
70
+ ].join('\n'));
71
+ }
72
+
73
+ function portOpen(host, port, timeoutMs = 800) {
74
+ return new Promise((resolve) => {
75
+ const socket = net.createConnection({ host, port });
76
+ const finish = (ok) => { socket.destroy(); resolve(ok); };
77
+ socket.setTimeout(timeoutMs);
78
+ socket.once('connect', () => finish(true));
79
+ socket.once('timeout', () => finish(false));
80
+ socket.once('error', () => finish(false));
81
+ });
82
+ }
83
+
84
+ function probeQdrant({ host, port, apiKey = '' }) {
85
+ return new Promise((resolve) => {
86
+ const client = String(host || '').startsWith('https://') ? https : http;
87
+ const hostname = String(host || '').replace(/^https?:\/\//, '');
88
+ const request = client.get({
89
+ hostname,
90
+ port,
91
+ path: '/healthz',
92
+ headers: apiKey ? { 'api-key': apiKey } : undefined,
93
+ timeout: 4000,
94
+ }, (response) => {
95
+ response.resume();
96
+ resolve(response.statusCode >= 200 && response.statusCode < 300);
97
+ });
98
+ request.once('timeout', () => { request.destroy(); resolve(false); });
99
+ request.once('error', () => resolve(false));
100
+ });
101
+ }
102
+
103
+ function startService(docker, service) {
104
+ writeServiceFiles();
105
+ const result = spawnSync(docker.composeCmd, [
106
+ ...docker.composeArgs, '-f', COMPOSE_FILE, 'up', '-d', '--wait', service,
107
+ ], { cwd: SERVICES_DIR, stdio: 'inherit', shell: false });
108
+ return result.status === 0;
109
+ }
110
+
111
+ module.exports = {
112
+ SERVICES_DIR,
113
+ defaults,
114
+ portOpen,
115
+ probeQdrant,
116
+ startService,
117
+ };
package/src/logger.js ADDED
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ // Minimal ANSI color helpers - no external deps.
4
+ const isTTY = process.stdout && process.stdout.isTTY;
5
+ const supportsColor = isTTY && !process.env.NO_COLOR;
6
+ const isWindows = process.platform === 'win32';
7
+ const wantsUnicode = process.env.DRAFTGO_UNICODE === '1';
8
+ const useUnicode = wantsUnicode || !isWindows || process.env.TERM_PROGRAM === 'vscode' || process.env.WT_SESSION;
9
+ const sym = useUnicode
10
+ ? { info: '\u2139', ok: '\u2713', err: '\u2717', step: '\u2192' }
11
+ : { info: 'i', ok: 'OK', err: 'x', step: '>' };
12
+
13
+ const wrap = (code) => (s) => supportsColor ? `\x1b[${code}m${s}\x1b[0m` : String(s);
14
+
15
+ const c = {
16
+ bold: wrap(1),
17
+ dim: wrap(2),
18
+ red: wrap(31),
19
+ green: wrap(32),
20
+ yellow: wrap(33),
21
+ blue: wrap(34),
22
+ magenta: wrap(35),
23
+ cyan: wrap(36),
24
+ gray: wrap(90),
25
+ };
26
+
27
+ function info(msg) { console.log(`${c.cyan(sym.info)} ${msg}`); }
28
+ function ok(msg) { console.log(`${c.green(sym.ok)} ${msg}`); }
29
+ function warn(msg) { console.warn(`${c.yellow('!')} ${msg}`); }
30
+ function err(msg) { console.error(`${c.red(sym.err)} ${msg}`); }
31
+ function step(msg) { console.log(`${c.blue(sym.step)} ${msg}`); }
32
+ function title(msg) { console.log(`
33
+ ${c.bold(c.magenta(msg))}`); }
34
+ function plain(msg) { console.log(msg); }
35
+ function dim(msg) { console.log(c.dim(msg)); }
36
+
37
+ module.exports = { c, info, ok, warn, err, step, title, plain, dim };