claude-flow 3.5.70 → 3.5.71

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 (87) hide show
  1. package/package.json +1 -1
  2. package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-tools.js +35 -1
  3. package/v3/@claude-flow/cli/dist/src/mcp-tools/agentdb-tools.js +81 -0
  4. package/v3/@claude-flow/cli/dist/src/mcp-tools/analyze-tools.js +29 -0
  5. package/v3/@claude-flow/cli/dist/src/mcp-tools/autopilot-tools.js +4 -0
  6. package/v3/@claude-flow/cli/dist/src/mcp-tools/browser-tools.js +146 -0
  7. package/v3/@claude-flow/cli/dist/src/mcp-tools/claims-tools.js +116 -0
  8. package/v3/@claude-flow/cli/dist/src/mcp-tools/coordination-tools.js +31 -0
  9. package/v3/@claude-flow/cli/dist/src/mcp-tools/daa-tools.js +61 -0
  10. package/v3/@claude-flow/cli/dist/src/mcp-tools/embeddings-tools.js +26 -0
  11. package/v3/@claude-flow/cli/dist/src/mcp-tools/github-tools.js +96 -0
  12. package/v3/@claude-flow/cli/dist/src/mcp-tools/guidance-tools.js +21 -0
  13. package/v3/@claude-flow/cli/dist/src/mcp-tools/hive-mind-tools.js +56 -0
  14. package/v3/@claude-flow/cli/dist/src/mcp-tools/hooks-tools.js +176 -0
  15. package/v3/@claude-flow/cli/dist/src/mcp-tools/memory-tools.js +18 -2
  16. package/v3/@claude-flow/cli/dist/src/mcp-tools/neural-tools.js +51 -0
  17. package/v3/@claude-flow/cli/dist/src/mcp-tools/performance-tools.js +11 -0
  18. package/v3/@claude-flow/cli/dist/src/mcp-tools/ruvllm-tools.js +31 -0
  19. package/v3/@claude-flow/cli/dist/src/mcp-tools/security-tools.js +36 -0
  20. package/v3/@claude-flow/cli/dist/src/mcp-tools/system-tools.js +6 -0
  21. package/v3/@claude-flow/cli/dist/src/mcp-tools/transfer-tools.js +51 -0
  22. package/v3/@claude-flow/cli/dist/src/mcp-tools/wasm-agent-tools.js +61 -0
  23. package/v3/@claude-flow/cli/package.json +1 -1
  24. package/v3/@claude-flow/guidance/dist/adversarial.d.ts +284 -0
  25. package/v3/@claude-flow/guidance/dist/adversarial.js +572 -0
  26. package/v3/@claude-flow/guidance/dist/analyzer.d.ts +530 -0
  27. package/v3/@claude-flow/guidance/dist/analyzer.js +2518 -0
  28. package/v3/@claude-flow/guidance/dist/artifacts.d.ts +283 -0
  29. package/v3/@claude-flow/guidance/dist/artifacts.js +356 -0
  30. package/v3/@claude-flow/guidance/dist/authority.d.ts +290 -0
  31. package/v3/@claude-flow/guidance/dist/authority.js +558 -0
  32. package/v3/@claude-flow/guidance/dist/capabilities.d.ts +209 -0
  33. package/v3/@claude-flow/guidance/dist/capabilities.js +485 -0
  34. package/v3/@claude-flow/guidance/dist/coherence.d.ts +233 -0
  35. package/v3/@claude-flow/guidance/dist/coherence.js +372 -0
  36. package/v3/@claude-flow/guidance/dist/compiler.d.ts +87 -0
  37. package/v3/@claude-flow/guidance/dist/compiler.js +419 -0
  38. package/v3/@claude-flow/guidance/dist/conformance-kit.d.ts +225 -0
  39. package/v3/@claude-flow/guidance/dist/conformance-kit.js +629 -0
  40. package/v3/@claude-flow/guidance/dist/continue-gate.d.ts +214 -0
  41. package/v3/@claude-flow/guidance/dist/continue-gate.js +353 -0
  42. package/v3/@claude-flow/guidance/dist/crypto-utils.d.ts +17 -0
  43. package/v3/@claude-flow/guidance/dist/crypto-utils.js +24 -0
  44. package/v3/@claude-flow/guidance/dist/evolution.d.ts +282 -0
  45. package/v3/@claude-flow/guidance/dist/evolution.js +500 -0
  46. package/v3/@claude-flow/guidance/dist/gates.d.ts +79 -0
  47. package/v3/@claude-flow/guidance/dist/gates.js +302 -0
  48. package/v3/@claude-flow/guidance/dist/gateway.d.ts +206 -0
  49. package/v3/@claude-flow/guidance/dist/gateway.js +452 -0
  50. package/v3/@claude-flow/guidance/dist/generators.d.ts +153 -0
  51. package/v3/@claude-flow/guidance/dist/generators.js +682 -0
  52. package/v3/@claude-flow/guidance/dist/headless.d.ts +177 -0
  53. package/v3/@claude-flow/guidance/dist/headless.js +342 -0
  54. package/v3/@claude-flow/guidance/dist/hooks.d.ts +109 -0
  55. package/v3/@claude-flow/guidance/dist/hooks.js +347 -0
  56. package/v3/@claude-flow/guidance/dist/index.d.ts +205 -0
  57. package/v3/@claude-flow/guidance/dist/index.js +321 -0
  58. package/v3/@claude-flow/guidance/dist/ledger.d.ts +162 -0
  59. package/v3/@claude-flow/guidance/dist/ledger.js +375 -0
  60. package/v3/@claude-flow/guidance/dist/manifest-validator.d.ts +289 -0
  61. package/v3/@claude-flow/guidance/dist/manifest-validator.js +838 -0
  62. package/v3/@claude-flow/guidance/dist/memory-gate.d.ts +222 -0
  63. package/v3/@claude-flow/guidance/dist/memory-gate.js +382 -0
  64. package/v3/@claude-flow/guidance/dist/meta-governance.d.ts +265 -0
  65. package/v3/@claude-flow/guidance/dist/meta-governance.js +348 -0
  66. package/v3/@claude-flow/guidance/dist/optimizer.d.ts +104 -0
  67. package/v3/@claude-flow/guidance/dist/optimizer.js +329 -0
  68. package/v3/@claude-flow/guidance/dist/persistence.d.ts +189 -0
  69. package/v3/@claude-flow/guidance/dist/persistence.js +464 -0
  70. package/v3/@claude-flow/guidance/dist/proof.d.ts +185 -0
  71. package/v3/@claude-flow/guidance/dist/proof.js +238 -0
  72. package/v3/@claude-flow/guidance/dist/retriever.d.ts +116 -0
  73. package/v3/@claude-flow/guidance/dist/retriever.js +394 -0
  74. package/v3/@claude-flow/guidance/dist/ruvbot-integration.d.ts +370 -0
  75. package/v3/@claude-flow/guidance/dist/ruvbot-integration.js +738 -0
  76. package/v3/@claude-flow/guidance/dist/temporal.d.ts +426 -0
  77. package/v3/@claude-flow/guidance/dist/temporal.js +658 -0
  78. package/v3/@claude-flow/guidance/dist/trust.d.ts +283 -0
  79. package/v3/@claude-flow/guidance/dist/trust.js +473 -0
  80. package/v3/@claude-flow/guidance/dist/truth-anchors.d.ts +276 -0
  81. package/v3/@claude-flow/guidance/dist/truth-anchors.js +488 -0
  82. package/v3/@claude-flow/guidance/dist/types.d.ts +378 -0
  83. package/v3/@claude-flow/guidance/dist/types.js +10 -0
  84. package/v3/@claude-flow/guidance/dist/uncertainty.d.ts +372 -0
  85. package/v3/@claude-flow/guidance/dist/uncertainty.js +619 -0
  86. package/v3/@claude-flow/guidance/dist/wasm-kernel.d.ts +48 -0
  87. package/v3/@claude-flow/guidance/dist/wasm-kernel.js +158 -0
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @module @claude-flow/cli/mcp-tools/claims
8
8
  */
9
+ import { validateIdentifier, validateText } from './validate-input.js';
9
10
  // File-based persistence
10
11
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
11
12
  import { join, resolve } from 'path';
@@ -78,6 +79,21 @@ export const claimsTools = [
78
79
  const issueId = input.issueId;
79
80
  const claimantStr = input.claimant;
80
81
  const context = input.context;
82
+ {
83
+ const v = validateIdentifier(issueId, 'issueId');
84
+ if (!v.valid)
85
+ return { success: false, error: v.error };
86
+ }
87
+ {
88
+ const v = validateText(claimantStr, 'claimant');
89
+ if (!v.valid)
90
+ return { success: false, error: v.error };
91
+ }
92
+ if (context) {
93
+ const v = validateText(context, 'context');
94
+ if (!v.valid)
95
+ return { success: false, error: v.error };
96
+ }
81
97
  const claimant = parseClaimant(claimantStr);
82
98
  if (!claimant) {
83
99
  return { success: false, error: 'Invalid claimant format. Use "human:userId:name" or "agent:agentId:agentType"' };
@@ -137,6 +153,21 @@ export const claimsTools = [
137
153
  const issueId = input.issueId;
138
154
  const claimantStr = input.claimant;
139
155
  const reason = input.reason;
156
+ {
157
+ const v = validateIdentifier(issueId, 'issueId');
158
+ if (!v.valid)
159
+ return { success: false, error: v.error };
160
+ }
161
+ {
162
+ const v = validateText(claimantStr, 'claimant');
163
+ if (!v.valid)
164
+ return { success: false, error: v.error };
165
+ }
166
+ if (reason) {
167
+ const v = validateText(reason, 'reason');
168
+ if (!v.valid)
169
+ return { success: false, error: v.error };
170
+ }
140
171
  const claimant = parseClaimant(claimantStr);
141
172
  if (!claimant) {
142
173
  return { success: false, error: 'Invalid claimant format' };
@@ -197,6 +228,26 @@ export const claimsTools = [
197
228
  const toStr = input.to;
198
229
  const reason = input.reason;
199
230
  const progress = input.progress || 0;
231
+ {
232
+ const v = validateIdentifier(issueId, 'issueId');
233
+ if (!v.valid)
234
+ return { success: false, error: v.error };
235
+ }
236
+ {
237
+ const v = validateText(fromStr, 'from');
238
+ if (!v.valid)
239
+ return { success: false, error: v.error };
240
+ }
241
+ {
242
+ const v = validateText(toStr, 'to');
243
+ if (!v.valid)
244
+ return { success: false, error: v.error };
245
+ }
246
+ if (reason) {
247
+ const v = validateText(reason, 'reason');
248
+ if (!v.valid)
249
+ return { success: false, error: v.error };
250
+ }
200
251
  const from = parseClaimant(fromStr);
201
252
  const to = parseClaimant(toStr);
202
253
  if (!from || !to) {
@@ -246,6 +297,16 @@ export const claimsTools = [
246
297
  handler: async (input) => {
247
298
  const issueId = input.issueId;
248
299
  const claimantStr = input.claimant;
300
+ {
301
+ const v = validateIdentifier(issueId, 'issueId');
302
+ if (!v.valid)
303
+ return { success: false, error: v.error };
304
+ }
305
+ {
306
+ const v = validateText(claimantStr, 'claimant');
307
+ if (!v.valid)
308
+ return { success: false, error: v.error };
309
+ }
249
310
  const claimant = parseClaimant(claimantStr);
250
311
  if (!claimant) {
251
312
  return { success: false, error: 'Invalid claimant format' };
@@ -310,6 +371,16 @@ export const claimsTools = [
310
371
  const status = input.status;
311
372
  const note = input.note;
312
373
  const progress = input.progress;
374
+ {
375
+ const v = validateIdentifier(issueId, 'issueId');
376
+ if (!v.valid)
377
+ return { success: false, error: v.error };
378
+ }
379
+ if (note) {
380
+ const v = validateText(note, 'note');
381
+ if (!v.valid)
382
+ return { success: false, error: v.error };
383
+ }
313
384
  const store = loadClaims();
314
385
  const claim = store.claims[issueId];
315
386
  if (!claim) {
@@ -359,6 +430,16 @@ export const claimsTools = [
359
430
  const status = input.status;
360
431
  const claimantFilter = input.claimant;
361
432
  const agentType = input.agentType;
433
+ if (claimantFilter) {
434
+ const v = validateText(claimantFilter, 'claimant');
435
+ if (!v.valid)
436
+ return { success: false, error: v.error };
437
+ }
438
+ if (agentType) {
439
+ const v = validateIdentifier(agentType, 'agentType');
440
+ if (!v.valid)
441
+ return { success: false, error: v.error };
442
+ }
362
443
  const store = loadClaims();
363
444
  let claims = Object.values(store.claims);
364
445
  if (status && status !== 'all') {
@@ -411,6 +492,16 @@ export const claimsTools = [
411
492
  const reason = input.reason;
412
493
  const preferredTypes = input.preferredTypes;
413
494
  const context = input.context;
495
+ {
496
+ const v = validateIdentifier(issueId, 'issueId');
497
+ if (!v.valid)
498
+ return { success: false, error: v.error };
499
+ }
500
+ if (context) {
501
+ const v = validateText(context, 'context');
502
+ if (!v.valid)
503
+ return { success: false, error: v.error };
504
+ }
414
505
  const store = loadClaims();
415
506
  const claim = store.claims[issueId];
416
507
  if (!claim) {
@@ -457,6 +548,16 @@ export const claimsTools = [
457
548
  handler: async (input) => {
458
549
  const issueId = input.issueId;
459
550
  const stealerStr = input.stealer;
551
+ {
552
+ const v = validateIdentifier(issueId, 'issueId');
553
+ if (!v.valid)
554
+ return { success: false, error: v.error };
555
+ }
556
+ {
557
+ const v = validateText(stealerStr, 'stealer');
558
+ if (!v.valid)
559
+ return { success: false, error: v.error };
560
+ }
460
561
  const stealer = parseClaimant(stealerStr);
461
562
  if (!stealer) {
462
563
  return { success: false, error: 'Invalid claimant format' };
@@ -512,6 +613,11 @@ export const claimsTools = [
512
613
  },
513
614
  handler: async (input) => {
514
615
  const agentType = input.agentType;
616
+ if (agentType) {
617
+ const v = validateIdentifier(agentType, 'agentType');
618
+ if (!v.valid)
619
+ return { success: false, error: v.error };
620
+ }
515
621
  const store = loadClaims();
516
622
  let stealableIssues = Object.entries(store.stealable).map(([issueId, info]) => ({
517
623
  issueId,
@@ -548,6 +654,16 @@ export const claimsTools = [
548
654
  handler: async (input) => {
549
655
  const agentId = input.agentId;
550
656
  const agentType = input.agentType;
657
+ if (agentId) {
658
+ const v = validateIdentifier(agentId, 'agentId');
659
+ if (!v.valid)
660
+ return { success: false, error: v.error };
661
+ }
662
+ if (agentType) {
663
+ const v = validateIdentifier(agentType, 'agentType');
664
+ if (!v.valid)
665
+ return { success: false, error: v.error };
666
+ }
551
667
  const store = loadClaims();
552
668
  const claims = Object.values(store.claims);
553
669
  // Group claims by agent
@@ -9,6 +9,7 @@
9
9
  * - Useful for single-machine workflow orchestration
10
10
  */
11
11
  import { getProjectCwd } from './types.js';
12
+ import { validateIdentifier, validateText } from './validate-input.js';
12
13
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
13
14
  import { join } from 'node:path';
14
15
  // Storage paths
@@ -147,6 +148,11 @@ export const coordinationTools = [
147
148
  },
148
149
  },
149
150
  handler: async (input) => {
151
+ if (input.task) {
152
+ const vTask = validateText(input.task, 'task');
153
+ if (!vTask.valid)
154
+ return { success: false, error: vTask.error };
155
+ }
150
156
  const store = loadCoordStore();
151
157
  const action = input.action || 'get';
152
158
  if (action === 'get') {
@@ -286,6 +292,11 @@ export const coordinationTools = [
286
292
  },
287
293
  },
288
294
  handler: async (input) => {
295
+ if (input.nodeId) {
296
+ const vNode = validateIdentifier(input.nodeId, 'nodeId');
297
+ if (!vNode.valid)
298
+ return { success: false, error: vNode.error };
299
+ }
289
300
  const store = loadCoordStore();
290
301
  const action = input.action || 'list';
291
302
  if (action === 'list') {
@@ -367,6 +378,16 @@ export const coordinationTools = [
367
378
  },
368
379
  },
369
380
  handler: async (input) => {
381
+ if (input.proposalId) {
382
+ const vProp = validateIdentifier(input.proposalId, 'proposalId');
383
+ if (!vProp.valid)
384
+ return { success: false, error: vProp.error };
385
+ }
386
+ if (input.voterId) {
387
+ const vVoter = validateIdentifier(input.voterId, 'voterId');
388
+ if (!vVoter.valid)
389
+ return { success: false, error: vVoter.error };
390
+ }
370
391
  const store = loadCoordStore();
371
392
  const action = input.action || 'status';
372
393
  const strategy = input.strategy || 'raft';
@@ -598,6 +619,16 @@ export const coordinationTools = [
598
619
  required: ['task'],
599
620
  },
600
621
  handler: async (input) => {
622
+ const vTask = validateText(input.task, 'task');
623
+ if (!vTask.valid)
624
+ return { success: false, error: vTask.error };
625
+ if (input.agents && Array.isArray(input.agents)) {
626
+ for (const a of input.agents) {
627
+ const vA = validateIdentifier(a, 'agents[]');
628
+ if (!vA.valid)
629
+ return { success: false, error: vA.error };
630
+ }
631
+ }
601
632
  const store = loadCoordStore();
602
633
  const task = input.task;
603
634
  const agents = input.agents || Object.keys(store.nodes);
@@ -9,6 +9,7 @@
9
9
  * - Useful for workflow orchestration and state tracking
10
10
  */
11
11
  import { getProjectCwd } from './types.js';
12
+ import { validateIdentifier, validateText } from './validate-input.js';
12
13
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
13
14
  import { join } from 'node:path';
14
15
  // Storage paths
@@ -62,6 +63,19 @@ export const daaTools = [
62
63
  required: ['id'],
63
64
  },
64
65
  handler: async (input) => {
66
+ const vId = validateIdentifier(input.id, 'id');
67
+ if (!vId.valid)
68
+ return { success: false, error: vId.error };
69
+ if (input.name) {
70
+ const vName = validateText(input.name, 'name');
71
+ if (!vName.valid)
72
+ return { success: false, error: vName.error };
73
+ }
74
+ if (input.type) {
75
+ const vType = validateIdentifier(input.type, 'type');
76
+ if (!vType.valid)
77
+ return { success: false, error: vType.error };
78
+ }
65
79
  const store = loadDAAStore();
66
80
  const id = input.id;
67
81
  const agent = {
@@ -123,6 +137,14 @@ export const daaTools = [
123
137
  required: ['agentId'],
124
138
  },
125
139
  handler: async (input) => {
140
+ const vAgentId = validateIdentifier(input.agentId, 'agentId');
141
+ if (!vAgentId.valid)
142
+ return { success: false, error: vAgentId.error };
143
+ if (input.feedback) {
144
+ const vFeedback = validateText(input.feedback, 'feedback');
145
+ if (!vFeedback.valid)
146
+ return { success: false, error: vFeedback.error };
147
+ }
126
148
  const store = loadDAAStore();
127
149
  const agentId = input.agentId;
128
150
  const agent = store.agents[agentId];
@@ -179,6 +201,12 @@ export const daaTools = [
179
201
  required: ['id', 'name'],
180
202
  },
181
203
  handler: async (input) => {
204
+ const vId = validateIdentifier(input.id, 'id');
205
+ if (!vId.valid)
206
+ return { success: false, error: vId.error };
207
+ const vName = validateText(input.name, 'name');
208
+ if (!vName.valid)
209
+ return { success: false, error: vName.error };
182
210
  const store = loadDAAStore();
183
211
  const id = input.id;
184
212
  const workflow = {
@@ -218,6 +246,9 @@ export const daaTools = [
218
246
  required: ['workflowId'],
219
247
  },
220
248
  handler: async (input) => {
249
+ const vWorkflowId = validateIdentifier(input.workflowId, 'workflowId');
250
+ if (!vWorkflowId.valid)
251
+ return { success: false, error: vWorkflowId.error };
221
252
  const store = loadDAAStore();
222
253
  const workflowId = input.workflowId;
223
254
  const workflow = store.workflows[workflowId];
@@ -265,6 +296,21 @@ export const daaTools = [
265
296
  required: ['sourceAgentId', 'targetAgentIds'],
266
297
  },
267
298
  handler: async (input) => {
299
+ const vSourceId = validateIdentifier(input.sourceAgentId, 'sourceAgentId');
300
+ if (!vSourceId.valid)
301
+ return { success: false, error: vSourceId.error };
302
+ if (input.targetAgentIds && Array.isArray(input.targetAgentIds)) {
303
+ for (const t of input.targetAgentIds) {
304
+ const vT = validateIdentifier(t, 'targetAgentIds[]');
305
+ if (!vT.valid)
306
+ return { success: false, error: vT.error };
307
+ }
308
+ }
309
+ if (input.knowledgeDomain) {
310
+ const vDomain = validateIdentifier(input.knowledgeDomain, 'knowledgeDomain');
311
+ if (!vDomain.valid)
312
+ return { success: false, error: vDomain.error };
313
+ }
268
314
  const store = loadDAAStore();
269
315
  const sourceId = input.sourceAgentId;
270
316
  const targetIds = input.targetAgentIds;
@@ -319,6 +365,11 @@ export const daaTools = [
319
365
  },
320
366
  },
321
367
  handler: async (input) => {
368
+ if (input.agentId) {
369
+ const vAgentId = validateIdentifier(input.agentId, 'agentId');
370
+ if (!vAgentId.valid)
371
+ return { success: false, error: vAgentId.error };
372
+ }
322
373
  const store = loadDAAStore();
323
374
  const agentId = input.agentId;
324
375
  if (agentId) {
@@ -371,6 +422,16 @@ export const daaTools = [
371
422
  },
372
423
  },
373
424
  handler: async (input) => {
425
+ if (input.agentId) {
426
+ const vAgentId = validateIdentifier(input.agentId, 'agentId');
427
+ if (!vAgentId.valid)
428
+ return { success: false, error: vAgentId.error };
429
+ }
430
+ if (input.pattern) {
431
+ const vPattern = validateIdentifier(input.pattern, 'pattern');
432
+ if (!vPattern.valid)
433
+ return { success: false, error: vPattern.error };
434
+ }
374
435
  const store = loadDAAStore();
375
436
  const agentId = input.agentId;
376
437
  const action = input.action || 'analyze';
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
8
8
  import { join, resolve } from 'path';
9
+ import { validateIdentifier, validateText } from './validate-input.js';
9
10
  // Configuration paths
10
11
  const CONFIG_DIR = '.claude-flow';
11
12
  const EMBEDDINGS_CONFIG = 'embeddings.json';
@@ -230,6 +231,11 @@ export const embeddingsTools = [
230
231
  };
231
232
  }
232
233
  const text = input.text;
234
+ {
235
+ const v = validateText(text, 'text');
236
+ if (!v.valid)
237
+ return { success: false, error: v.error };
238
+ }
233
239
  const useHyperbolic = input.hyperbolic === true && config.hyperbolic.enabled;
234
240
  // Generate real ONNX embedding
235
241
  const embedding = await generateRealEmbedding(text, config.dimension);
@@ -292,6 +298,16 @@ export const embeddingsTools = [
292
298
  const text1 = input.text1;
293
299
  const text2 = input.text2;
294
300
  const metric = input.metric || 'cosine';
301
+ {
302
+ const v = validateText(text1, 'text1');
303
+ if (!v.valid)
304
+ return { success: false, error: v.error };
305
+ }
306
+ {
307
+ const v = validateText(text2, 'text2');
308
+ if (!v.valid)
309
+ return { success: false, error: v.error };
310
+ }
295
311
  // Generate real ONNX embeddings for both texts
296
312
  const [emb1, emb2] = await Promise.all([
297
313
  generateRealEmbedding(text1, config.dimension),
@@ -376,6 +392,16 @@ export const embeddingsTools = [
376
392
  const topK = input.topK || 5;
377
393
  const threshold = input.threshold || 0.5;
378
394
  const namespace = input.namespace;
395
+ {
396
+ const v = validateText(query, 'query');
397
+ if (!v.valid)
398
+ return { success: false, error: v.error };
399
+ }
400
+ if (namespace) {
401
+ const v = validateIdentifier(namespace, 'namespace');
402
+ if (!v.valid)
403
+ return { success: false, error: v.error };
404
+ }
379
405
  const startTime = performance.now();
380
406
  // Generate real ONNX embedding for query
381
407
  const queryEmbedding = await generateRealEmbedding(query, config.dimension);
@@ -5,6 +5,7 @@
5
5
  * Falls back to local state management when CLI tools are unavailable.
6
6
  */
7
7
  import { getProjectCwd } from './types.js';
8
+ import { validateIdentifier, validateText } from './validate-input.js';
8
9
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
9
10
  import { join } from 'node:path';
10
11
  import { execSync } from 'node:child_process';
@@ -68,6 +69,21 @@ export const githubTools = [
68
69
  },
69
70
  },
70
71
  handler: async (input) => {
72
+ if (input.owner) {
73
+ const v = validateIdentifier(input.owner, 'owner');
74
+ if (!v.valid)
75
+ return { success: false, error: v.error };
76
+ }
77
+ if (input.repo) {
78
+ const v = validateIdentifier(input.repo, 'repo');
79
+ if (!v.valid)
80
+ return { success: false, error: v.error };
81
+ }
82
+ if (input.branch) {
83
+ const v = validateIdentifier(input.branch, 'branch');
84
+ if (!v.valid)
85
+ return { success: false, error: v.error };
86
+ }
71
87
  const store = loadGitHubStore();
72
88
  const branch = input.branch || 'main';
73
89
  const cwd = getProjectCwd();
@@ -150,6 +166,36 @@ export const githubTools = [
150
166
  },
151
167
  },
152
168
  handler: async (input) => {
169
+ if (input.owner) {
170
+ const v = validateIdentifier(input.owner, 'owner');
171
+ if (!v.valid)
172
+ return { success: false, error: v.error };
173
+ }
174
+ if (input.repo) {
175
+ const v = validateIdentifier(input.repo, 'repo');
176
+ if (!v.valid)
177
+ return { success: false, error: v.error };
178
+ }
179
+ if (input.title) {
180
+ const v = validateText(input.title, 'title');
181
+ if (!v.valid)
182
+ return { success: false, error: v.error };
183
+ }
184
+ if (input.body) {
185
+ const v = validateText(input.body, 'body');
186
+ if (!v.valid)
187
+ return { success: false, error: v.error };
188
+ }
189
+ if (input.branch) {
190
+ const v = validateIdentifier(input.branch, 'branch');
191
+ if (!v.valid)
192
+ return { success: false, error: v.error };
193
+ }
194
+ if (input.baseBranch) {
195
+ const v = validateIdentifier(input.baseBranch, 'baseBranch');
196
+ if (!v.valid)
197
+ return { success: false, error: v.error };
198
+ }
153
199
  const store = loadGitHubStore();
154
200
  const action = input.action || 'list';
155
201
  const gh = hasGhCli();
@@ -250,6 +296,26 @@ export const githubTools = [
250
296
  },
251
297
  },
252
298
  handler: async (input) => {
299
+ if (input.owner) {
300
+ const v = validateIdentifier(input.owner, 'owner');
301
+ if (!v.valid)
302
+ return { success: false, error: v.error };
303
+ }
304
+ if (input.repo) {
305
+ const v = validateIdentifier(input.repo, 'repo');
306
+ if (!v.valid)
307
+ return { success: false, error: v.error };
308
+ }
309
+ if (input.title) {
310
+ const v = validateText(input.title, 'title');
311
+ if (!v.valid)
312
+ return { success: false, error: v.error };
313
+ }
314
+ if (input.body) {
315
+ const v = validateText(input.body, 'body');
316
+ if (!v.valid)
317
+ return { success: false, error: v.error };
318
+ }
253
319
  const store = loadGitHubStore();
254
320
  const action = input.action || 'list';
255
321
  const gh = hasGhCli();
@@ -340,6 +406,26 @@ export const githubTools = [
340
406
  },
341
407
  },
342
408
  handler: async (input) => {
409
+ if (input.owner) {
410
+ const v = validateIdentifier(input.owner, 'owner');
411
+ if (!v.valid)
412
+ return { success: false, error: v.error };
413
+ }
414
+ if (input.repo) {
415
+ const v = validateIdentifier(input.repo, 'repo');
416
+ if (!v.valid)
417
+ return { success: false, error: v.error };
418
+ }
419
+ if (input.workflowId) {
420
+ const v = validateIdentifier(input.workflowId, 'workflowId');
421
+ if (!v.valid)
422
+ return { success: false, error: v.error };
423
+ }
424
+ if (input.ref) {
425
+ const v = validateIdentifier(input.ref, 'ref');
426
+ if (!v.valid)
427
+ return { success: false, error: v.error };
428
+ }
343
429
  const action = input.action || 'list';
344
430
  const gh = hasGhCli();
345
431
  if (!gh) {
@@ -417,6 +503,16 @@ export const githubTools = [
417
503
  },
418
504
  },
419
505
  handler: async (input) => {
506
+ if (input.owner) {
507
+ const v = validateIdentifier(input.owner, 'owner');
508
+ if (!v.valid)
509
+ return { success: false, error: v.error };
510
+ }
511
+ if (input.repo) {
512
+ const v = validateIdentifier(input.repo, 'repo');
513
+ if (!v.valid)
514
+ return { success: false, error: v.error };
515
+ }
420
516
  const metric = input.metric || 'all';
421
517
  const timeRange = input.timeRange || '30d';
422
518
  const cwd = getProjectCwd();
@@ -7,6 +7,7 @@
7
7
  * @module @claude-flow/cli/mcp-tools/guidance
8
8
  */
9
9
  import { getProjectCwd } from './types.js';
10
+ import { validateIdentifier, validateText } from './validate-input.js';
10
11
  import { existsSync, readFileSync, readdirSync } from 'node:fs';
11
12
  import { join, dirname } from 'node:path';
12
13
  import { fileURLToPath } from 'node:url';
@@ -348,6 +349,11 @@ const guidanceCapabilities = {
348
349
  handler: async (params) => {
349
350
  const area = params.area;
350
351
  const format = params.format || 'summary';
352
+ if (area) {
353
+ const v = validateIdentifier(area, 'area');
354
+ if (!v.valid)
355
+ return { content: [{ type: 'text', text: JSON.stringify({ error: v.error }, null, 2) }], isError: true };
356
+ }
351
357
  if (area) {
352
358
  const cap = CAPABILITY_CATALOG[area];
353
359
  if (!cap) {
@@ -386,6 +392,11 @@ const guidanceRecommend = {
386
392
  },
387
393
  handler: async (params) => {
388
394
  const task = params.task;
395
+ {
396
+ const v = validateText(task, 'task');
397
+ if (!v.valid)
398
+ return { content: [{ type: 'text', text: JSON.stringify({ error: v.error }, null, 2) }], isError: true };
399
+ }
389
400
  const matches = [];
390
401
  for (const route of TASK_ROUTES) {
391
402
  if (route.pattern.test(task)) {
@@ -492,6 +503,11 @@ const guidanceWorkflow = {
492
503
  },
493
504
  handler: async (params) => {
494
505
  const type = params.type;
506
+ {
507
+ const v = validateIdentifier(type, 'type');
508
+ if (!v.valid)
509
+ return { content: [{ type: 'text', text: JSON.stringify({ error: v.error }, null, 2) }], isError: true };
510
+ }
495
511
  const template = WORKFLOW_TEMPLATES[type];
496
512
  if (!template) {
497
513
  return {
@@ -538,6 +554,11 @@ const guidanceQuickRef = {
538
554
  },
539
555
  handler: async (params) => {
540
556
  const domain = params.domain;
557
+ {
558
+ const v = validateIdentifier(domain, 'domain');
559
+ if (!v.valid)
560
+ return { content: [{ type: 'text', text: JSON.stringify({ error: v.error }, null, 2) }], isError: true };
561
+ }
541
562
  const refs = {
542
563
  'getting-started': {
543
564
  title: 'Getting Started',