@chemx/starter-kit 26.9.21-8 → 26.9.23-1269

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 (130) hide show
  1. package/cli/audit/ast-visitors.js +10 -17
  2. package/cli/audit/autofix.js +17 -2
  3. package/cli/audit/clone-detector.js +64 -0
  4. package/cli/audit/clone-detector.spec.js +46 -0
  5. package/cli/audit/hook-shape-validator.js +312 -0
  6. package/cli/audit/prompts.js +1 -1
  7. package/cli/audit/reporter-clones.js +33 -0
  8. package/cli/audit/reporter-hotspot-graph.js +34 -0
  9. package/cli/audit/rules-registry.js +6 -1
  10. package/cli/audit/rules.js +10 -2
  11. package/cli/audit/rules.spec.js +129 -0
  12. package/cli/audit-stages.spec.js +30 -0
  13. package/cli/audit.js +12 -3
  14. package/cli/commands/cmd-audit.js +43 -3
  15. package/cli/commands/cmd-project.js +100 -0
  16. package/cli/commands/cmd-router.js +34 -2
  17. package/cli/commands-schema.js +14 -0
  18. package/cli/create.spec.js +2 -2
  19. package/cli/exploder.js +258 -0
  20. package/cli/exploder.spec.js +99 -0
  21. package/cli/generator-compact.spec.js +104 -0
  22. package/cli/generator-framework.spec.js +72 -0
  23. package/cli/generator-templates/archetypes/collection-archetypes.js +9 -9
  24. package/cli/generator-templates/archetypes/index.js +34 -4
  25. package/cli/generator-templates/archetypes/input-archetypes.js +2 -2
  26. package/cli/generator-templates/archetypes/layout-archetypes.js +2 -2
  27. package/cli/generator-templates/archetypes/minimal-archetypes.js +131 -0
  28. package/cli/generator-templates/archetypes/status-archetypes.js +4 -4
  29. package/cli/generator-templates/archetypes/vector-matcher.js +50 -0
  30. package/cli/generator-templates/archetypes/vector-matcher.spec.js +25 -0
  31. package/cli/generator-templates/compact.js +130 -0
  32. package/cli/generator-templates/controller-converters.js +93 -0
  33. package/cli/generator-templates/controller.js +2 -64
  34. package/cli/generator-templates/react.js +1 -1
  35. package/cli/generator-templates/svelte.js +1 -1
  36. package/cli/generator-templates/types.js +2 -2
  37. package/cli/generator-templates/vue.js +1 -1
  38. package/cli/generator-templates.js +1 -0
  39. package/cli/generator-templates.spec.js +6 -1
  40. package/cli/generator.js +94 -7
  41. package/cli/help.js +1 -1
  42. package/cli/index.js +21 -8
  43. package/cli/installer-templates.js +1 -1
  44. package/cli/mcp/antigravity.js +3 -2
  45. package/cli/mcp/installer.js +7 -7
  46. package/cli/mcp/installer.spec.js +3 -3
  47. package/cli/mcp/manifests.js +3 -2
  48. package/cli/mcp/prompts.js +1 -1
  49. package/cli/mcp/server.js +2 -0
  50. package/cli/mcp/tools-audit.js +95 -0
  51. package/cli/mcp/tools-generate.js +62 -0
  52. package/cli/mcp/tools-patch.js +72 -0
  53. package/cli/mcp/tools-patterns.js +71 -0
  54. package/cli/mcp/tools-project.js +75 -0
  55. package/cli/mcp/tools-project.spec.js +51 -0
  56. package/cli/mcp/tools-q-modes.js +69 -0
  57. package/cli/mcp/tools-q.js +58 -0
  58. package/cli/mcp/tools-read.js +69 -0
  59. package/cli/mcp/tools-search-util.js +35 -0
  60. package/cli/mcp/tools-search.js +15 -294
  61. package/cli/mcp/tools-team-feed.js +57 -0
  62. package/cli/mcp/tools-team-locks.js +63 -0
  63. package/cli/mcp/tools-team-mailbox.js +32 -0
  64. package/cli/mcp/tools-team-tasks.js +84 -0
  65. package/cli/mcp/tools-team.js +37 -183
  66. package/cli/mcp/tools-verify.js +47 -0
  67. package/cli/mcp/tools-write.js +33 -0
  68. package/cli/mcp/tools.js +72 -376
  69. package/cli/mutators.js +10 -23
  70. package/cli/pillars-schema.js +3 -3
  71. package/cli/project-detector.js +47 -0
  72. package/cli/reader-shorthand.spec.js +60 -0
  73. package/cli/reader.js +67 -24
  74. package/cli/search-bulletproof.spec.js +104 -0
  75. package/cli/search-db.js +33 -5
  76. package/cli/search-queries-hotspot-graph.js +65 -0
  77. package/cli/search-queries-hotspot-graph.spec.js +66 -0
  78. package/cli/search-queries-similar.js +84 -0
  79. package/cli/search-queries-similar.spec.js +43 -0
  80. package/cli/search-schema.js +30 -10
  81. package/cli/search.js +9 -2
  82. package/cli/team/index.js +9 -0
  83. package/cli/team/team-commands.js +104 -64
  84. package/cli/team/team-concurrency-stress.spec.js +95 -0
  85. package/cli/team/team-db-mailbox.js +86 -0
  86. package/cli/team/team-db-task-helpers.js +30 -28
  87. package/cli/team/team-db-tasks.js +13 -5
  88. package/cli/team/team-flags.js +69 -0
  89. package/cli/team/team-format.js +87 -46
  90. package/cli/team/team-mailbox-empirical.spec.js +191 -0
  91. package/cli/team/team-mailbox.spec.js +93 -0
  92. package/cli/team/team-memory.js +84 -0
  93. package/cli/team/team-memory.spec.js +74 -0
  94. package/cli/team/team-projects-coordinator.js +100 -0
  95. package/cli/team/team-projects-format.js +45 -0
  96. package/cli/team/team-projects-memory.js +70 -0
  97. package/cli/team/team-projects.js +94 -0
  98. package/cli/team/team-projects.spec.js +116 -0
  99. package/cli/team/team-schema-memory.js +25 -0
  100. package/cli/team/team-schema-projects.js +50 -0
  101. package/cli/team/team-schema.js +33 -14
  102. package/cli/team/team-tasks-hierarchy.spec.js +80 -0
  103. package/cli/team/team-tokens.js +95 -0
  104. package/cli/team/team-triage.js +159 -12
  105. package/cli/team/team-verification-gate.spec.js +253 -0
  106. package/cli/team/team.spec.js +1 -1
  107. package/cli/trend.js +84 -0
  108. package/cli/trend.spec.js +51 -0
  109. package/cli/ui-actions-tasks.js +13 -5
  110. package/cli/ui-actions.js +10 -2
  111. package/cli/ui-client-api.js +2 -2
  112. package/cli/ui-client-script.js +12 -15
  113. package/cli/ui-e2e-verification.spec.js +13 -3
  114. package/cli/ui-filetree.spec.js +5 -5
  115. package/cli/ui-handlers.js +10 -2
  116. package/cli/ui-html.js +26 -34
  117. package/cli/ui-index.html +905 -0
  118. package/cli/ui-kanban.spec.js +12 -12
  119. package/cli/ui-server.js +7 -0
  120. package/cli/ui-sse.js +57 -0
  121. package/cli/ui-sse.spec.js +74 -0
  122. package/cli/ui-styles.js +195 -81
  123. package/cli/ui-template-kanban.js +15 -1
  124. package/cli/ui-vbulletin.spec.js +12 -13
  125. package/cli/ui.spec.js +12 -5
  126. package/cli/verify.js +19 -8
  127. package/package.json +3 -1
  128. package/scripts/check-framework-generation.mjs +195 -0
  129. package/scripts/pre-commit.sh +2 -7
  130. package/scripts/publish-both.mjs +4 -0
@@ -1,186 +1,40 @@
1
- import { openIndexDb } from '../search-db.js';
2
- import { toColumnar } from '../columnar.js';
3
- import {
4
- getSwarmStatus,
5
- queryFeed,
6
- postFeedEvent,
7
- listTasks,
8
- getTask,
9
- createTask,
10
- claimTask,
11
- updateTaskStatus,
12
- requestFileLock,
13
- releaseFileLock,
14
- getFileLockStatus,
15
- registerAgent
16
- } from '../team/team-db.js';
17
- import { completeTaskWithAudit, autoGenerateTasksFromAudit } from '../team/team-triage.js';
18
- import { handleError } from '../errors/index.js';
19
-
20
- export const handleChemxTeamStatus = async (args = {}, cwd = process.cwd()) => {
21
- const db = openIndexDb(cwd);
22
- if (!db) return { error: 'sqlite_unavailable' };
23
- const status = getSwarmStatus(db);
24
- return {
25
- agents: status.agents,
26
- tasks: status.tasks,
27
- locks: {
28
- active: status.locks.active,
29
- waiting: status.locks.waiting,
30
- leases: toColumnar(status.locks.leases, ['file_path', 'locked_by', 'expires_at'])
31
- },
32
- tokens: status.tokens,
33
- blockedTasks: toColumnar(status.blockedTasks, ['id', 'title', 'assigned_agent_id', 'blocked_reason']),
34
- recentFeed: toColumnar(status.recentFeed, ['id', 'timestamp', 'author_id', 'event_type', 'message'])
35
- };
36
- };
37
-
38
- export const handleChemxTeamFeed = async (args = {}, cwd = process.cwd()) => {
39
- const db = openIndexDb(cwd);
40
- if (!db) return { error: 'sqlite_unavailable' };
41
- const events = queryFeed(db, {
42
- since_id: args.sinceId,
43
- thread_id: args.threadId,
44
- task_id: args.taskId,
45
- agent_id: args.agentId,
46
- limit: args.limit
47
- });
48
- return toColumnar(events, ['id', 'timestamp', 'author_id', 'recipient_id', 'event_type', 'file_path', 'message']);
49
- };
50
-
51
- export const handleChemxTeamPost = async (args = {}, cwd = process.cwd()) => {
52
- const db = openIndexDb(cwd);
53
- if (!db) return { error: 'sqlite_unavailable' };
54
- const authorHandle = args.authorId || '@agent';
55
- registerAgent(db, { id: authorHandle, role: 'contributor' });
56
- return postFeedEvent(db, {
57
- message: args.message,
58
- author_id: authorHandle,
59
- recipient_id: args.recipientId,
60
- thread_id: args.threadId,
61
- task_id: args.taskId,
62
- file_path: args.filePath,
63
- event_type: args.eventType
64
- });
65
- };
66
-
67
- export const handleChemxTeamTask = async (args = {}, cwd = process.cwd()) => {
68
- const db = openIndexDb(cwd);
69
- if (!db) return { error: 'sqlite_unavailable' };
70
- const action = args.action || 'list';
71
-
72
- if (action === 'list') {
73
- const tasks = listTasks(db, { status: args.status, assigned_agent_id: args.agentId });
74
- const col = toColumnar(tasks, ['id', 'title', 'tier', 'status', 'priority', 'assigned_agent_id', 'target_path']);
75
- return { ...col, total: tasks.length };
76
- }
77
- if (action === 'create' || action === 'add') {
78
- const authorHandle = args.agentId || '@agent';
79
- registerAgent(db, { id: authorHandle, role: 'contributor' });
80
- if (args.assignedAgentId) {
81
- registerAgent(db, { id: args.assignedAgentId, role: 'executor' });
82
- }
83
- const task = createTask(db, {
84
- title: args.title,
85
- target_path: args.targetPath,
86
- tier: args.tier || 'molecule',
87
- priority: args.priority || 2,
88
- assigned_agent_id: args.assignedAgentId || null
89
- });
90
- if (task) {
91
- postFeedEvent(db, {
92
- author_id: authorHandle,
93
- task_id: task.id,
94
- event_type: 'task_created',
95
- message: `Created task #${task.id}: ${task.title}`
96
- });
97
- }
98
- return task;
99
- }
100
- if (action === 'claim') {
101
- const agentHandle = args.agentId || '@agent';
102
- registerAgent(db, { id: agentHandle, role: 'executor' });
103
- return claimTask(db, args.taskId, agentHandle);
104
- }
105
- if (action === 'done' || action === 'complete') {
106
- const agentHandle = args.agentId || '@agent';
107
- registerAgent(db, { id: agentHandle, role: 'executor' });
108
- return completeTaskWithAudit(db, args.taskId, agentHandle, { cwd, force: args.force, noTargetConfirm: args.noTargetConfirm, tokens: args.tokens });
109
- }
110
- if (action === 'block') {
111
- return updateTaskStatus(db, args.taskId, 'blocked', { blockedReason: args.blockedReason || 'Blocked' });
112
- }
113
- if (action === 'update') {
114
- const targetStatus = args.status || 'in_progress';
115
- const agentHandle = args.agentId || '@agent';
116
- registerAgent(db, { id: agentHandle, role: 'executor' });
117
- if (targetStatus === 'done' || targetStatus === 'completed') {
118
- return completeTaskWithAudit(db, args.taskId, agentHandle, { cwd, force: args.force, noTargetConfirm: args.noTargetConfirm, tokens: args.tokens });
119
- }
120
- return updateTaskStatus(db, args.taskId, targetStatus, { blockedReason: args.blockedReason || '' });
121
- }
122
- if (action === 'set-target' || action === 'target') {
123
- if (!args.taskId || !args.targetPath) return { error: 'taskId and targetPath required' };
124
- db.prepare('UPDATE tasks SET target_path = ?, updated_at = ? WHERE id = ?').run(args.targetPath, Date.now(), Number(args.taskId));
125
- return db.prepare('SELECT * FROM tasks WHERE id = ?').get(Number(args.taskId));
126
- }
127
- if (action === 'triage') {
128
- return autoGenerateTasksFromAudit(db, { cwd, maxTasks: args.maxTasks || 10 });
129
- }
130
- return { error: `Unknown task action: ${action}` };
131
- };
132
-
133
- export const handleChemxTeamLock = async (args = {}, cwd = process.cwd()) => {
134
- const db = openIndexDb(cwd);
135
- if (!db) return { error: 'sqlite_unavailable' };
136
- const action = args.action || 'status';
137
-
138
- if (action === 'acquire') {
139
- return requestFileLock(db, args.filePath, args.agentId, {
140
- purpose: args.purpose,
141
- ttlMs: args.ttlMs
142
- });
143
- }
144
- if (action === 'release') {
145
- return releaseFileLock(db, args.filePath, args.agentId);
146
- }
147
- if (action === 'status') {
148
- const status = getFileLockStatus(db, args.filePath);
149
- return {
150
- lease: status.lease,
151
- waiters: toColumnar(status.waiters, ['id', 'agent_id', 'priority', 'status', 'requested_at'])
152
- };
153
- }
154
- return { error: `Unknown lock action: ${action}` };
1
+ import { handleChemxTeamStatus, handleChemxTeamFeed, handleChemxTeamPost } from './tools-team-feed.js';
2
+ import { handleChemxTeamTask } from './tools-team-tasks.js';
3
+ import { handleChemxTeamLock, handleChemxReportIssue } from './tools-team-locks.js';
4
+ import { handleChemxTeamInbox, handleChemxTeamDm } from './tools-team-mailbox.js';
5
+
6
+ export {
7
+ handleChemxTeamStatus,
8
+ handleChemxTeamFeed,
9
+ handleChemxTeamPost,
10
+ handleChemxTeamTask,
11
+ handleChemxTeamLock,
12
+ handleChemxReportIssue,
13
+ handleChemxTeamInbox,
14
+ handleChemxTeamDm
155
15
  };
156
16
 
157
- export const handleChemxReportIssue = async (args = {}, cwd = process.cwd()) => {
158
- const errorObj = new Error(args.error || 'Unknown error');
159
- if (args.stack) errorObj.stack = args.stack;
160
-
161
- const result = await handleError(errorObj, {
162
- cwd,
163
- command: args.command,
164
- repo: args.repo,
165
- autoPost: Boolean(args.autoPost),
166
- labels: args.labels,
167
- silent: true,
168
- context: args.context,
169
- skipFileWrite: true
170
- });
171
-
172
- return {
173
- success: true,
174
- issue: {
175
- title: result.issue.title,
176
- body: result.issue.body,
177
- webUrl: result.issue.webUrl,
178
- targetRepo: result.issue.targetRepo,
179
- labels: result.issue.labels
180
- },
181
- published: result.publishResult.success,
182
- publishedUrl: result.publishResult.url,
183
- issueNumber: result.publishResult.issueNumber,
184
- savedPath: result.savedPath || null
185
- };
17
+ export const handleChemxTeam = async (args = {}, cwd = process.cwd()) => {
18
+ const isTeamAction = args.action === 'team';
19
+ const router = isTeamAction ? (args.subAction || 'status') : (args.subAction || args.action || 'status');
20
+ if (router === 'inbox') return handleChemxTeamInbox(args, cwd);
21
+ if (router === 'dm') return handleChemxTeamDm(args, cwd);
22
+ if (router === 'status') return handleChemxTeamStatus(args, cwd);
23
+ if (router === 'feed') return handleChemxTeamFeed(args, cwd);
24
+ if (router === 'post') return handleChemxTeamPost(args, cwd);
25
+ if (router === 'lock') {
26
+ const isSubAction = Boolean(args.subAction && args.subAction !== 'lock');
27
+ const lockAction = isSubAction ? args.subAction : (args.lockAction || 'status');
28
+ return handleChemxTeamLock({ ...args, action: lockAction }, cwd);
29
+ }
30
+ if (router === 'task') {
31
+ const isSubAction = Boolean(args.subAction && args.subAction !== 'task');
32
+ const taskAction = isSubAction ? args.subAction : (args.taskAction || 'list');
33
+ return handleChemxTeamTask({ ...args, action: taskAction }, cwd);
34
+ }
35
+ const isLockAction = ['acquire', 'release'].includes(router);
36
+ if (isLockAction) {
37
+ return handleChemxTeamLock({ ...args, action: router }, cwd);
38
+ }
39
+ return handleChemxTeamTask({ ...args, action: router }, cwd);
186
40
  };
@@ -0,0 +1,47 @@
1
+ import path from 'node:path';
2
+ import { runBuildAudit } from '../build.js';
3
+ import { runTypecheckAudit, runTestAudit, runProjectVerify } from '../verify.js';
4
+ import { resolveTargetCwd } from './tools-search.js';
5
+
6
+ export const handleAuditBuild = async (args = {}, cwd = process.cwd()) => {
7
+ const baseCwd = resolveTargetCwd(cwd);
8
+ const targetCwd = args.dir ? path.resolve(baseCwd, args.dir) : baseCwd;
9
+ const rawArgs = ['--json'];
10
+ if (args.command) {
11
+ rawArgs.push('--', args.command);
12
+ }
13
+ return runBuildAudit(rawArgs, false, { print: false, cwd: targetCwd });
14
+ };
15
+
16
+ export const handleChemxTypecheck = async (args = {}, cwd = process.cwd()) => {
17
+ const baseCwd = resolveTargetCwd(cwd);
18
+ const targetCwd = args.dir ? path.resolve(baseCwd, args.dir) : baseCwd;
19
+ return runTypecheckAudit([], false, {
20
+ json: true,
21
+ command: args.command,
22
+ print: false,
23
+ cwd: targetCwd
24
+ });
25
+ };
26
+
27
+ export const handleChemxTest = async (args = {}, cwd = process.cwd()) => {
28
+ const baseCwd = resolveTargetCwd(cwd);
29
+ const targetCwd = args.dir ? path.resolve(baseCwd, args.dir) : baseCwd;
30
+ return runTestAudit([], false, {
31
+ json: true,
32
+ command: args.command,
33
+ print: false,
34
+ cwd: targetCwd
35
+ });
36
+ };
37
+
38
+ export const handleChemxVerify = async (args = {}, cwd = process.cwd()) => {
39
+ const baseCwd = resolveTargetCwd(cwd);
40
+ return runProjectVerify([], false, {
41
+ json: true,
42
+ targetDir: args.dir,
43
+ includeBuild: Boolean(args.includeBuild),
44
+ print: false,
45
+ cwd: baseCwd
46
+ });
47
+ };
@@ -0,0 +1,33 @@
1
+ import path from 'node:path';
2
+ import { syncSingleFileIndex } from '../search.js';
3
+ import { writeFile } from '../patcher.js';
4
+ import { formatPatchWarnings } from './tools-patch.js';
5
+
6
+ export const handleChemxWrite = (args = {}, cwd = process.cwd()) => {
7
+ const hasPath = Boolean(args.path);
8
+ const hasContent = args.content !== undefined;
9
+ const hasRequiredArgs = hasPath && hasContent;
10
+
11
+ if (!hasRequiredArgs) {
12
+ throw new Error('chemx_write requires "path" and "content" arguments.');
13
+ }
14
+
15
+ const targetPath = path.isAbsolute(args.path) ? args.path : path.resolve(cwd, args.path);
16
+ const result = writeFile(targetPath, {
17
+ content: args.content,
18
+ cwd
19
+ });
20
+
21
+ try {
22
+ syncSingleFileIndex(targetPath, cwd);
23
+ } catch (err) {
24
+ if (process.env.CHEMX_DEBUG) {
25
+ process.stderr.write(`[write-sync] Auto-index skipped for ${targetPath}: ${err.message}\n`);
26
+ }
27
+ }
28
+
29
+ return {
30
+ ...result,
31
+ warnings: formatPatchWarnings(result)
32
+ };
33
+ };