devassist-agent 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 (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +467 -0
  3. package/bin/devassist.js +220 -0
  4. package/package.json +44 -0
  5. package/src/ai/adapter.js +464 -0
  6. package/src/ai/providers/claude.js +80 -0
  7. package/src/ai/providers/hunyuan.js +87 -0
  8. package/src/ai/providers/openai.js +74 -0
  9. package/src/ai/providers/qwen.js +81 -0
  10. package/src/cli/commands/ai.js +944 -0
  11. package/src/cli/commands/ask.js +79 -0
  12. package/src/cli/commands/backup.js +30 -0
  13. package/src/cli/commands/check.js +327 -0
  14. package/src/cli/commands/clean.js +130 -0
  15. package/src/cli/commands/comparison-report.js +326 -0
  16. package/src/cli/commands/convention.js +91 -0
  17. package/src/cli/commands/debt.js +49 -0
  18. package/src/cli/commands/deploy.js +88 -0
  19. package/src/cli/commands/diff.js +193 -0
  20. package/src/cli/commands/doctor.js +186 -0
  21. package/src/cli/commands/fix.js +195 -0
  22. package/src/cli/commands/init.js +431 -0
  23. package/src/cli/commands/inject.js +254 -0
  24. package/src/cli/commands/report.js +310 -0
  25. package/src/cli/commands/restore.js +78 -0
  26. package/src/cli/commands/schema.js +93 -0
  27. package/src/cli/commands/watch.js +212 -0
  28. package/src/cli/shared/code-context.js +51 -0
  29. package/src/cli/shared/config-loader.js +89 -0
  30. package/src/cli/shared/file-collector.js +116 -0
  31. package/src/cli/shared/inline-ignore.js +142 -0
  32. package/src/cli/shared/watch-list.js +281 -0
  33. package/src/core/event-bus.js +83 -0
  34. package/src/core/fsm.js +103 -0
  35. package/src/core/logger.js +54 -0
  36. package/src/core/rule-engine.js +117 -0
  37. package/src/index.js +64 -0
  38. package/src/modules/dev-time/arch-risk-assessor.js +250 -0
  39. package/src/modules/dev-time/code-quality-guard.js +1340 -0
  40. package/src/modules/dev-time/convention-store.js +201 -0
  41. package/src/modules/dev-time/impact-analyzer.js +292 -0
  42. package/src/modules/dev-time/pre-deploy-guard.js +284 -0
  43. package/src/modules/dev-time/schema-registry.js +284 -0
  44. package/src/modules/dev-time/tech-debt-tracker.js +225 -0
  45. package/src/modules/dev-time/version-manager.js +280 -0
  46. package/src/modules/runtime/channel-agent.js +404 -0
  47. package/src/modules/runtime/channel-middleware.js +316 -0
  48. package/src/modules/runtime/index.js +64 -0
  49. package/src/modules/runtime/infrastructure-guard.js +582 -0
  50. package/src/modules/runtime/notification-center.js +443 -0
  51. package/src/modules/runtime/schema-gatekeeper.js +664 -0
  52. package/src/modules/runtime/tool-registry.js +329 -0
  53. package/templates/ci/github-actions.yml +60 -0
  54. package/templates/ci/gitlab-ci.yml +30 -0
  55. package/templates/ci/pre-commit-hook.sh +18 -0
  56. package/templates/git-hooks/pre-commit +61 -0
  57. package/tests/run-all.js +434 -0
  58. package/tests/test-layer2.js +461 -0
  59. package/tests/test-new-rules.js +157 -0
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Qwen provider (通义千问, Alibaba Cloud)
3
+ *
4
+ * API: https://help.aliyun.com/zh/dashscope/developer-reference/api-details
5
+ *
6
+ * Uses the DashScope compatible API (OpenAI-compatible format).
7
+ * Set baseUrl to your DashScope endpoint, e.g.:
8
+ * https://dashscope.aliyuncs.com/compatible-mode/v1
9
+ */
10
+
11
+ const https = require('https');
12
+ const http = require('http');
13
+ const { URL } = require('url');
14
+
15
+ async function chat(messages, options) {
16
+ const baseUrl = options.baseUrl || 'https://dashscope.aliyuncs.com/compatible-mode/v1';
17
+ const model = options.model || 'qwen-plus';
18
+ const apiKey = options.apiKey;
19
+
20
+ if (!apiKey) {
21
+ throw new Error('Qwen API key required. Set DASHSCOPE_API_KEY or configure in ai-config.json');
22
+ }
23
+
24
+ const url = new URL(`${baseUrl}/chat/completions`);
25
+ const body = JSON.stringify({
26
+ model,
27
+ messages,
28
+ temperature: options.temperature ?? 0.1,
29
+ max_tokens: options.maxTokens || 2000,
30
+ });
31
+
32
+ const response = await request(url, {
33
+ method: 'POST',
34
+ headers: {
35
+ 'Content-Type': 'application/json',
36
+ 'Authorization': `Bearer ${apiKey}`,
37
+ },
38
+ body,
39
+ });
40
+
41
+ const data = JSON.parse(response.body);
42
+ return {
43
+ content: data.choices?.[0]?.message?.content || '',
44
+ usage: data.usage || {},
45
+ model: data.model || model,
46
+ };
47
+ }
48
+
49
+ /**
50
+ * Generic HTTP request helper using built-in http/https modules.
51
+ * No external dependencies.
52
+ */
53
+ function request(url, options) {
54
+ return new Promise((resolve, reject) => {
55
+ const lib = url.protocol === 'https:' ? https : http;
56
+ const req = lib.request(url, {
57
+ method: options.method || 'GET',
58
+ headers: options.headers || {},
59
+ }, (res) => {
60
+ let body = '';
61
+ res.on('data', (chunk) => body += chunk);
62
+ res.on('end', () => {
63
+ if (res.statusCode >= 400) {
64
+ reject(new Error(`HTTP ${res.statusCode}: ${body.substring(0, 500)}`));
65
+ } else {
66
+ resolve({ statusCode: res.statusCode, body });
67
+ }
68
+ });
69
+ });
70
+
71
+ req.on('error', reject);
72
+ req.setTimeout(90000, () => {
73
+ req.destroy(new Error('Request timeout (90s)'));
74
+ });
75
+
76
+ if (options.body) req.write(options.body);
77
+ req.end();
78
+ });
79
+ }
80
+
81
+ module.exports = { chat, name: 'qwen' };