swarmdo 1.11.0 → 1.12.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.
@@ -515,7 +515,7 @@ function getCostFromStdin() {
515
515
  // misses, the displayed version is meaningful (matches what the user
516
516
  // installed), not a stale hard-coded string.
517
517
  function getPkgVersion() {
518
- let ver = '1.11.0';
518
+ let ver = '1.12.0';
519
519
  try {
520
520
  const home = os.homedir();
521
521
  const pkgPaths = [
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![swarmdo](swarmdo/assets/brand/logo-full.svg)](https://swarmdo.com)
4
4
 
5
- [![npm version (swarmdo)](https://img.shields.io/badge/npx%20swarmdo-v1.11.0-cb3837?style=for-the-badge&logo=npm&logoColor=white)](https://github.com/SwarmDo/swarmdo/releases)
5
+ [![npm version (swarmdo)](https://img.shields.io/badge/npx%20swarmdo-v1.12.0-cb3837?style=for-the-badge&logo=npm&logoColor=white)](https://github.com/SwarmDo/swarmdo/releases)
6
6
  [![MIT License](https://img.shields.io/badge/License-MIT-yellow?style=for-the-badge)](https://github.com/SwarmDo/swarmdo/blob/main/LICENSE)
7
7
  [![Website](https://img.shields.io/badge/swarmdo.com-e2a33c?style=for-the-badge&logoColor=black)](https://swarmdo.com)
8
8
  [![Star on GitHub](https://img.shields.io/github/stars/SwarmDo/swarmdo?style=for-the-badge&logo=github&color=gold)](https://github.com/SwarmDo/swarmdo)
@@ -280,6 +280,7 @@ The recent release train added a full day-to-day operations layer around the swa
280
280
  | `swarmdo codegraph` (alias `cg`) | **Queryable symbol index** — `codegraph index` scans TS/JS for exported symbols; `query <name>` (with `--fuzzy`/`--kind`) and `file <path>` answer "where is X defined / what does this file export" from `.swarm/codegraph.json` instead of grep+read round-trips. `codegraph importers <file>` shows reverse deps ("what breaks if I change this"); `codegraph imports <file>` shows a file's dependencies. 1,786 symbols + import graph across 296 files in <1s. Also MCP tools (`codegraph_query`/`file`/`imports`/`importers`/`index`/`stats`) so agents query the graph in-session |
281
281
  | `swarmdo redact` | **Mask secrets before they reach an LLM/log/memory** — detect API keys, tokens, and private keys (gitleaks-style rule catalog + Shannon-entropy fallback) and redact them. Stdin filter (`cat deploy.log \| swarmdo redact`), command-wrap (`swarmdo redact -- npm run deploy`), or `--scan` to fail CI on any secret. Also MCP tools (`redact_text`/`redact_scan`). Deterministic, zero tokens |
282
282
  | `swarmdo pack` | **Bundle a repo into one AI-context blob** — walk the tree (respects `.gitignore` + glob `--include`/`--exclude`, skips binaries/node_modules), emit markdown/xml/json/plain with a directory tree and per-file + total token estimates. `swarmdo pack --tokens` for a budget breakdown; `--redact` masks secrets first. Deterministic |
283
+ | `swarmdo env` | **Catch env-var drift before deploy** — statically scan code for `process.env.X` / `import.meta.env.X` / `Deno.env.get` / `os.getenv` references and reconcile against `.env` and `.env.example`: reports **missing** (used but undeclared), **unused**, and **undocumented**. `--ci` exits 1 on missing vars. Also an MCP tool (`env_check`). Deterministic |
283
284
  | `swarmdo integrations` (alias `integrate`) | **Use swarmdo from Codex CLI, GitHub Copilot CLI, and pi** — one command wires AGENTS.md + each CLI's MCP config (idempotent, dry-run first, never touches your Claude Code setup) |
284
285
  | OpenRouter model pool | **Let swarms pick from any models you configure** — declare tier-mapped OpenRouter models in `swarmdo.config.json`; the router Thompson-samples among them per task and the execution layer dispatches the winner |
285
286
  | `swarmdo changelog` (alias `notes`) | **Release notes from conventional commits** — `--out NOTES.md` feeds `gh release create --notes-file` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swarmdo",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Swarmdo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `swarmdo env` — reconcile the env vars the code references against what
3
+ * `.env` declares (and, if present, `.env.example`). Catches deploy-breaking
4
+ * drift before it ships:
5
+ *
6
+ * swarmdo env # scan cwd vs .env / .env.example
7
+ * swarmdo env src --ci # exit 1 if any referenced var is undeclared
8
+ * swarmdo env --json # machine-readable report
9
+ *
10
+ * Engine (../env/env.ts) is pure + tested; this layer does the fs walk and
11
+ * reads the dotenv files.
12
+ */
13
+ import type { Command } from '../types.js';
14
+ export declare const envCommand: Command;
15
+ export default envCommand;
16
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1,137 @@
1
+ /**
2
+ * `swarmdo env` — reconcile the env vars the code references against what
3
+ * `.env` declares (and, if present, `.env.example`). Catches deploy-breaking
4
+ * drift before it ships:
5
+ *
6
+ * swarmdo env # scan cwd vs .env / .env.example
7
+ * swarmdo env src --ci # exit 1 if any referenced var is undeclared
8
+ * swarmdo env --json # machine-readable report
9
+ *
10
+ * Engine (../env/env.ts) is pure + tested; this layer does the fs walk and
11
+ * reads the dotenv files.
12
+ */
13
+ import * as fs from 'node:fs';
14
+ import * as path from 'node:path';
15
+ import { output } from '../output.js';
16
+ import { extractEnvRefs, parseDotenv, reconcile, formatEnvSummary } from '../env/env.js';
17
+ const SOURCE_EXT = new Set(['.ts', '.tsx', '.js', '.jsx', '.mts', '.cts', '.mjs', '.cjs', '.py', '.vue', '.svelte', '.astro']);
18
+ const SKIP_DIRS = new Set([
19
+ 'node_modules', '.git', '.swarm', 'dist', 'dist-standalone', 'build',
20
+ 'coverage', '.next', '.turbo', 'out', 'vendor', '.cache',
21
+ ]);
22
+ // Ubiquitous runtime/CI vars that are almost never declared in a project .env.
23
+ const DEFAULT_IGNORE = ['NODE_ENV', 'CI', 'PATH', 'HOME', 'PWD', 'USER', 'SHELL', 'TERM', 'TZ', 'LANG'];
24
+ function walk(root) {
25
+ const found = [];
26
+ const stack = [root];
27
+ while (stack.length) {
28
+ const dir = stack.pop();
29
+ let entries;
30
+ try {
31
+ entries = fs.readdirSync(dir, { withFileTypes: true });
32
+ }
33
+ catch {
34
+ continue;
35
+ }
36
+ for (const e of entries) {
37
+ const full = path.join(dir, e.name);
38
+ if (e.isDirectory()) {
39
+ if (SKIP_DIRS.has(e.name))
40
+ continue;
41
+ stack.push(full);
42
+ }
43
+ else if (e.isFile()) {
44
+ const ext = path.extname(e.name);
45
+ if (SOURCE_EXT.has(ext) && !e.name.endsWith('.d.ts'))
46
+ found.push(full);
47
+ }
48
+ }
49
+ }
50
+ return found;
51
+ }
52
+ function readKeys(file) {
53
+ try {
54
+ return parseDotenv(fs.readFileSync(file, 'utf8'));
55
+ }
56
+ catch {
57
+ return null;
58
+ }
59
+ }
60
+ async function run(ctx) {
61
+ const repoRoot = ctx.cwd || process.cwd();
62
+ const scanRoot = ctx.args[0] ? path.resolve(repoRoot, ctx.args[0]) : repoRoot;
63
+ const envFile = path.resolve(repoRoot, typeof ctx.flags.env === 'string' ? ctx.flags.env : '.env');
64
+ const exampleFlag = typeof ctx.flags.example === 'string' ? ctx.flags.example : '.env.example';
65
+ const exampleFile = path.resolve(repoRoot, exampleFlag);
66
+ const declared = readKeys(envFile);
67
+ if (declared === null) {
68
+ output.printError(`no env file at ${path.relative(repoRoot, envFile)} (use --env <file>)`);
69
+ return { success: false, exitCode: 1 };
70
+ }
71
+ const example = readKeys(exampleFile) ?? undefined;
72
+ const ignore = [...DEFAULT_IGNORE];
73
+ if (typeof ctx.flags.ignore === 'string')
74
+ ignore.push(...ctx.flags.ignore.split(',').map((s) => s.trim()).filter(Boolean));
75
+ const refs = [];
76
+ for (const abs of walk(scanRoot)) {
77
+ let src;
78
+ try {
79
+ src = fs.readFileSync(abs, 'utf8');
80
+ }
81
+ catch {
82
+ continue;
83
+ }
84
+ const rel = path.relative(repoRoot, abs).split(path.sep).join('/');
85
+ refs.push(...extractEnvRefs(src, rel));
86
+ }
87
+ const report = reconcile({ refs, declared, example, ignore });
88
+ const hasExample = example !== undefined;
89
+ if (ctx.flags.json === true) {
90
+ output.printJson({ ...report, envFile: path.relative(repoRoot, envFile), hasExample });
91
+ }
92
+ else {
93
+ const section = (title, keys, withSites = false) => {
94
+ if (keys.length === 0)
95
+ return;
96
+ output.writeln(output.bold(`${title} (${keys.length})`));
97
+ output.printList(keys.map((k) => {
98
+ if (!withSites)
99
+ return k;
100
+ const site = report.refs[k]?.[0];
101
+ return site ? `${k} ${output.dim(`${site.file}:${site.line}`)}` : k;
102
+ }));
103
+ };
104
+ section('Missing — referenced in code, not in .env', report.missing, true);
105
+ section('Unused — declared in .env, never referenced', report.unused);
106
+ if (hasExample)
107
+ section('Undocumented — in .env, not in .env.example', report.undocumented);
108
+ output.writeln(output.dim(formatEnvSummary(report, hasExample)));
109
+ }
110
+ // --ci gates on `missing` (the runtime-breaking bucket); --strict also gates
111
+ // on unused + undocumented.
112
+ const strict = ctx.flags.strict === true;
113
+ const bad = report.missing.length + (strict ? report.unused.length + report.undocumented.length : 0);
114
+ const gate = ctx.flags.ci === true || strict;
115
+ const code = gate && bad > 0 ? 1 : 0;
116
+ return { success: code === 0, exitCode: code };
117
+ }
118
+ export const envCommand = {
119
+ name: 'env',
120
+ description: 'Reconcile env vars referenced in code against .env / .env.example — find missing, unused, and undocumented vars',
121
+ options: [
122
+ { name: 'env', description: 'path to the env file (default .env)', type: 'string' },
123
+ { name: 'example', description: 'path to the example env file (default .env.example)', type: 'string' },
124
+ { name: 'ignore', description: 'comma-separated extra keys to ignore (NODE_ENV/CI/… already ignored)', type: 'string' },
125
+ { name: 'ci', description: 'exit 1 if any referenced var is undeclared (missing bucket)', type: 'boolean' },
126
+ { name: 'strict', description: 'exit 1 on missing OR unused OR undocumented', type: 'boolean' },
127
+ { name: 'json', description: 'machine-readable report', type: 'boolean' },
128
+ ],
129
+ examples: [
130
+ { command: 'swarmdo env', description: 'Reconcile the repo against .env / .env.example' },
131
+ { command: 'swarmdo env src --ci', description: 'Fail CI if code references an undeclared var' },
132
+ { command: 'swarmdo env --env .env.production --json', description: 'Check a specific env file, JSON out' },
133
+ ],
134
+ action: run,
135
+ };
136
+ export default envCommand;
137
+ //# sourceMappingURL=env.js.map
@@ -28,6 +28,9 @@ const commandLoaders = {
28
28
  // Repo→AI-context bundle (repomix demand) — one promptable blob with tree +
29
29
  // token counts; swarmdo's context-assembly primitive.
30
30
  pack: () => import('./pack.js'),
31
+ // Env-var drift checker (dotenv-safe/dotenv-scan demand) — reconcile code
32
+ // references against .env / .env.example (missing/unused/undocumented).
33
+ env: () => import('./env.js'),
31
34
  // Queryable exported-symbol index (codegraph demand) — where things are
32
35
  // defined without grep+read round-trips.
33
36
  codegraph: () => import('./codegraph.js'),
@@ -261,7 +264,7 @@ export async function getCommandsByCategory() {
261
264
  // three slots from 'statusline' onward (completionsCmd received the
262
265
  // statusline module, analyzeCmd received completions, …), scrambling the
263
266
  // categorized help. Every load now has a named slot.
264
- const [daemonCmd, doctorCmd, embeddingsCmd, neuralCmd, performanceCmd, securityCmd, swarmvectorCmd, hiveMindCmd, configCmd, statuslineCmd, compressCmd, efficiencyCmd, completionsCmd, migrateCmd, workflowCmd, analyzeCmd, routeCmd, progressCmd, providersCmd, pluginsCmd, deploymentCmd, claimsCmd, issuesCmd, updateCmd, processCmd, guidanceCmd, applianceCmd, cleanupCmd, autopilotCmd, demoCmd, usageCmd, repairCmd, hudCmd, compactCmd, codegraphCmd, redactCmd, packCmd,] = await Promise.all([
267
+ const [daemonCmd, doctorCmd, embeddingsCmd, neuralCmd, performanceCmd, securityCmd, swarmvectorCmd, hiveMindCmd, configCmd, statuslineCmd, compressCmd, efficiencyCmd, completionsCmd, migrateCmd, workflowCmd, analyzeCmd, routeCmd, progressCmd, providersCmd, pluginsCmd, deploymentCmd, claimsCmd, issuesCmd, updateCmd, processCmd, guidanceCmd, applianceCmd, cleanupCmd, autopilotCmd, demoCmd, usageCmd, repairCmd, hudCmd, compactCmd, codegraphCmd, redactCmd, packCmd, envCmd,] = await Promise.all([
265
268
  loadCommand('daemon'), loadCommand('doctor'), loadCommand('embeddings'), loadCommand('neural'),
266
269
  loadCommand('performance'), loadCommand('security'), loadCommand('swarmvector'), loadCommand('hive-mind'),
267
270
  loadCommand('config'), loadCommand('statusline'), loadCommand('compress'), loadCommand('efficiency'),
@@ -269,7 +272,7 @@ export async function getCommandsByCategory() {
269
272
  loadCommand('analyze'), loadCommand('route'), loadCommand('progress'), loadCommand('providers'),
270
273
  loadCommand('plugins'), loadCommand('deployment'), loadCommand('claims'), loadCommand('issues'),
271
274
  loadCommand('update'), loadCommand('process'), loadCommand('guidance'), loadCommand('appliance'),
272
- loadCommand('cleanup'), loadCommand('autopilot'), loadCommand('demo'), loadCommand('usage'), loadCommand('repair'), loadCommand('hud'), loadCommand('compact'), loadCommand('codegraph'), loadCommand('redact'), loadCommand('pack'),
275
+ loadCommand('cleanup'), loadCommand('autopilot'), loadCommand('demo'), loadCommand('usage'), loadCommand('repair'), loadCommand('hud'), loadCommand('compact'), loadCommand('codegraph'), loadCommand('redact'), loadCommand('pack'), loadCommand('env'),
273
276
  ]);
274
277
  return {
275
278
  primary: [
@@ -285,7 +288,7 @@ export async function getCommandsByCategory() {
285
288
  utility: [
286
289
  configCmd, doctorCmd, daemonCmd, completionsCmd,
287
290
  migrateCmd, workflowCmd, demoCmd,
288
- statuslineCmd, compressCmd, compactCmd, redactCmd, packCmd, efficiencyCmd,
291
+ statuslineCmd, compressCmd, compactCmd, redactCmd, packCmd, envCmd, efficiencyCmd,
289
292
  ].filter(Boolean),
290
293
  analysis: [
291
294
  analyzeCmd, routeCmd, progressCmd, usageCmd, hudCmd, codegraphCmd,
@@ -0,0 +1,49 @@
1
+ /**
2
+ * env.ts — reconcile the environment variables a codebase *references* against
3
+ * the ones a `.env` (and `.env.example`) *declares*. Catches the classic "deploy
4
+ * broke because a var was missing / stale" drift before it ships.
5
+ *
6
+ * Three buckets:
7
+ * missing — referenced in code, not declared in .env (will break at runtime)
8
+ * unused — declared in .env, never referenced in code (dead config)
9
+ * undocumented — declared in .env, absent from .env.example (onboarding gap)
10
+ *
11
+ * Pure + deterministic (regex extraction + dotenv parse + set diff), so it's
12
+ * fully fixture-testable with zero LLM calls. The fs walk + file reads live in
13
+ * ../commands/env.ts; this module just takes strings.
14
+ */
15
+ export interface EnvRef {
16
+ key: string;
17
+ file: string;
18
+ /** 1-based line */
19
+ line: number;
20
+ }
21
+ export interface EnvReport {
22
+ missing: string[];
23
+ unused: string[];
24
+ undocumented: string[];
25
+ /** every key referenced in code → the sites that reference it */
26
+ refs: Record<string, EnvRef[]>;
27
+ }
28
+ /** Extract env-var references from one source file. Pure. */
29
+ export declare function extractEnvRefs(source: string, file: string): EnvRef[];
30
+ /**
31
+ * Parse a `.env` file into an ordered list of declared keys. Handles `KEY=val`,
32
+ * `export KEY=val`, quoted values, `# comments`, and blank lines. Values are
33
+ * ignored — we only reconcile key presence. Pure.
34
+ */
35
+ export declare function parseDotenv(text: string): string[];
36
+ export interface ReconcileInput {
37
+ refs: EnvRef[];
38
+ /** keys declared in .env */
39
+ declared: string[];
40
+ /** keys declared in .env.example (optional) */
41
+ example?: string[];
42
+ /** keys to ignore in all buckets (e.g. NODE_ENV, CI) */
43
+ ignore?: string[];
44
+ }
45
+ /** Compute the missing / unused / undocumented buckets. Pure. */
46
+ export declare function reconcile(input: ReconcileInput): EnvReport;
47
+ /** One-line human summary. */
48
+ export declare function formatEnvSummary(r: EnvReport, hasExample: boolean): string;
49
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1,103 @@
1
+ /**
2
+ * env.ts — reconcile the environment variables a codebase *references* against
3
+ * the ones a `.env` (and `.env.example`) *declares*. Catches the classic "deploy
4
+ * broke because a var was missing / stale" drift before it ships.
5
+ *
6
+ * Three buckets:
7
+ * missing — referenced in code, not declared in .env (will break at runtime)
8
+ * unused — declared in .env, never referenced in code (dead config)
9
+ * undocumented — declared in .env, absent from .env.example (onboarding gap)
10
+ *
11
+ * Pure + deterministic (regex extraction + dotenv parse + set diff), so it's
12
+ * fully fixture-testable with zero LLM calls. The fs walk + file reads live in
13
+ * ../commands/env.ts; this module just takes strings.
14
+ */
15
+ /**
16
+ * Patterns that read an env var. Each capture group 1 is the var name. Covers
17
+ * Node (`process.env.X`, `process.env['X']`), Vite (`import.meta.env.X`), Deno
18
+ * (`Deno.env.get('X')`), and Python (`os.environ['X']`, `os.environ.get('X')`,
19
+ * `os.getenv('X')`). Deterministic, line-based.
20
+ */
21
+ const REF_PATTERNS = [
22
+ /process\.env\.([A-Za-z_][A-Za-z0-9_]*)/g,
23
+ /process\.env\[\s*['"`]([^'"`]+)['"`]\s*\]/g,
24
+ /import\.meta\.env\.([A-Za-z_][A-Za-z0-9_]*)/g,
25
+ /import\.meta\.env\[\s*['"`]([^'"`]+)['"`]\s*\]/g,
26
+ /Deno\.env\.get\(\s*['"`]([^'"`]+)['"`]\s*\)/g,
27
+ /os\.environ\[\s*['"]([^'"]+)['"]\s*\]/g,
28
+ /os\.environ\.get\(\s*['"]([^'"]+)['"]\s*\)/g,
29
+ /os\.getenv\(\s*['"]([^'"]+)['"]\s*\)/g,
30
+ ];
31
+ /** Non-secret prefixes on `import.meta.env` that are Vite builtins, not user vars. */
32
+ const VITE_BUILTINS = new Set(['MODE', 'BASE_URL', 'PROD', 'DEV', 'SSR']);
33
+ /** Extract env-var references from one source file. Pure. */
34
+ export function extractEnvRefs(source, file) {
35
+ const out = [];
36
+ const lines = source.split('\n');
37
+ for (let i = 0; i < lines.length; i++) {
38
+ const line = lines[i];
39
+ if (!line.includes('env') && !line.includes('getenv'))
40
+ continue;
41
+ for (const re of REF_PATTERNS) {
42
+ re.lastIndex = 0;
43
+ let m;
44
+ while ((m = re.exec(line)) !== null) {
45
+ const key = m[1];
46
+ if (VITE_BUILTINS.has(key))
47
+ continue;
48
+ out.push({ key, file, line: i + 1 });
49
+ }
50
+ }
51
+ }
52
+ return out;
53
+ }
54
+ /**
55
+ * Parse a `.env` file into an ordered list of declared keys. Handles `KEY=val`,
56
+ * `export KEY=val`, quoted values, `# comments`, and blank lines. Values are
57
+ * ignored — we only reconcile key presence. Pure.
58
+ */
59
+ export function parseDotenv(text) {
60
+ const keys = [];
61
+ const seen = new Set();
62
+ for (const raw of text.split('\n')) {
63
+ const line = raw.trim();
64
+ if (!line || line.startsWith('#'))
65
+ continue;
66
+ const m = line.match(/^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/);
67
+ if (!m)
68
+ continue;
69
+ if (seen.has(m[1]))
70
+ continue;
71
+ seen.add(m[1]);
72
+ keys.push(m[1]);
73
+ }
74
+ return keys;
75
+ }
76
+ /** Compute the missing / unused / undocumented buckets. Pure. */
77
+ export function reconcile(input) {
78
+ const ignore = new Set(input.ignore ?? []);
79
+ const refByKey = {};
80
+ for (const r of input.refs) {
81
+ if (ignore.has(r.key))
82
+ continue;
83
+ (refByKey[r.key] ??= []).push(r);
84
+ }
85
+ const referenced = new Set(Object.keys(refByKey));
86
+ const declared = new Set(input.declared.filter((k) => !ignore.has(k)));
87
+ const missing = [...referenced].filter((k) => !declared.has(k)).sort();
88
+ const unused = [...declared].filter((k) => !referenced.has(k)).sort();
89
+ let undocumented = [];
90
+ if (input.example) {
91
+ const example = new Set(input.example);
92
+ undocumented = [...declared].filter((k) => !example.has(k)).sort();
93
+ }
94
+ return { missing, unused, undocumented, refs: refByKey };
95
+ }
96
+ /** One-line human summary. */
97
+ export function formatEnvSummary(r, hasExample) {
98
+ const parts = [`${r.missing.length} missing`, `${r.unused.length} unused`];
99
+ if (hasExample)
100
+ parts.push(`${r.undocumented.length} undocumented`);
101
+ return `env: ${parts.join(', ')}`;
102
+ }
103
+ //# sourceMappingURL=env.js.map
@@ -21,6 +21,7 @@ import { workflowTools } from './mcp-tools/workflow-tools.js';
21
21
  import { analyzeTools } from './mcp-tools/analyze-tools.js';
22
22
  import { codegraphTools } from './mcp-tools/codegraph-tools.js';
23
23
  import { redactTools } from './mcp-tools/redact-tools.js';
24
+ import { envTools } from './mcp-tools/env-tools.js';
24
25
  import { progressTools } from './mcp-tools/progress-tools.js';
25
26
  import { embeddingsTools } from './mcp-tools/embeddings-tools.js';
26
27
  import { claimsTools } from './mcp-tools/claims-tools.js';
@@ -106,6 +107,7 @@ const TOOL_GROUPS = {
106
107
  analyze: () => analyzeTools,
107
108
  codegraph: () => codegraphTools,
108
109
  redact: () => redactTools,
110
+ env: () => envTools,
109
111
  progress: () => progressTools,
110
112
  embeddings: () => embeddingsTools,
111
113
  claims: () => claimsTools,
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Env MCP Tool
3
+ *
4
+ * Let an agent check env-var drift in-session before it writes code that reads
5
+ * a var, or before it green-lights a deploy: reconcile the vars referenced in
6
+ * given source against a `.env` (and optional `.env.example`). Deterministic —
7
+ * shares the pure engine in ../env/env.ts with the CLI command. String-in, so
8
+ * it works without touching the filesystem.
9
+ */
10
+ import type { MCPTool } from './types.js';
11
+ export declare const envTools: MCPTool[];
12
+ //# sourceMappingURL=env-tools.d.ts.map
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Env MCP Tool
3
+ *
4
+ * Let an agent check env-var drift in-session before it writes code that reads
5
+ * a var, or before it green-lights a deploy: reconcile the vars referenced in
6
+ * given source against a `.env` (and optional `.env.example`). Deterministic —
7
+ * shares the pure engine in ../env/env.ts with the CLI command. String-in, so
8
+ * it works without touching the filesystem.
9
+ */
10
+ import { extractEnvRefs, parseDotenv, reconcile } from '../env/env.js';
11
+ const envCheckTool = {
12
+ name: 'env_check',
13
+ description: 'Reconcile env vars referenced in source code against a .env declaration. Returns missing (referenced, not declared — will break at runtime), unused (declared, never referenced), and undocumented (in .env, not in .env.example). Use before adding a var or approving a deploy. Deterministic; pass the file contents directly.',
14
+ category: 'env',
15
+ tags: ['env', 'dotenv', 'config', 'drift', 'ci'],
16
+ inputSchema: {
17
+ type: 'object',
18
+ properties: {
19
+ sources: {
20
+ type: 'array',
21
+ description: 'source files to scan',
22
+ items: {
23
+ type: 'object',
24
+ properties: {
25
+ path: { type: 'string', description: 'file path (for reporting)' },
26
+ content: { type: 'string', description: 'file contents' },
27
+ },
28
+ required: ['path', 'content'],
29
+ },
30
+ },
31
+ env: { type: 'string', description: 'contents of the .env file (declarations)' },
32
+ example: { type: 'string', description: 'contents of .env.example (optional, enables the undocumented bucket)' },
33
+ ignore: { type: 'array', items: { type: 'string' }, description: 'extra keys to ignore' },
34
+ },
35
+ required: ['sources', 'env'],
36
+ },
37
+ handler: async (params) => {
38
+ const sources = params.sources;
39
+ if (!Array.isArray(sources))
40
+ return { error: true, message: 'sources[] is required' };
41
+ if (typeof params.env !== 'string')
42
+ return { error: true, message: 'env (string) is required' };
43
+ const refs = sources.flatMap((s) => {
44
+ const o = s;
45
+ if (typeof o.path !== 'string' || typeof o.content !== 'string')
46
+ return [];
47
+ return extractEnvRefs(o.content, o.path);
48
+ });
49
+ const declared = parseDotenv(params.env);
50
+ const example = typeof params.example === 'string' ? parseDotenv(params.example) : undefined;
51
+ const ignore = Array.isArray(params.ignore) ? params.ignore.filter((x) => typeof x === 'string') : undefined;
52
+ const report = reconcile({ refs, declared, example, ignore });
53
+ return {
54
+ clean: report.missing.length === 0 && report.unused.length === 0 && report.undocumented.length === 0,
55
+ missing: report.missing,
56
+ unused: report.unused,
57
+ undocumented: report.undocumented,
58
+ };
59
+ },
60
+ };
61
+ export const envTools = [envCheckTool];
62
+ //# sourceMappingURL=env-tools.js.map
@@ -17,6 +17,7 @@ export { coverageRouterTools } from '../swarmvector/coverage-tools.js';
17
17
  export { analyzeTools } from './analyze-tools.js';
18
18
  export { codegraphTools } from './codegraph-tools.js';
19
19
  export { redactTools } from './redact-tools.js';
20
+ export { envTools } from './env-tools.js';
20
21
  export { progressTools } from './progress-tools.js';
21
22
  export { transferTools } from './transfer-tools.js';
22
23
  export { securityTools } from './security-tools.js';
@@ -16,6 +16,7 @@ export { coverageRouterTools } from '../swarmvector/coverage-tools.js';
16
16
  export { analyzeTools } from './analyze-tools.js';
17
17
  export { codegraphTools } from './codegraph-tools.js';
18
18
  export { redactTools } from './redact-tools.js';
19
+ export { envTools } from './env-tools.js';
19
20
  export { progressTools } from './progress-tools.js';
20
21
  export { transferTools } from './transfer-tools.js';
21
22
  export { securityTools } from './security-tools.js';
@@ -24,6 +24,7 @@ const LEAN_GROUPS = [
24
24
  'embeddings', // embeddings_generate / search / compare
25
25
  'codegraph', // codegraph_query / file / index — "where is X defined?"
26
26
  'redact', // redact_text / redact_scan — secret guard on the data path
27
+ 'env', // env_check — env-var drift (missing/unused/undocumented)
27
28
  ];
28
29
  /** Balanced = lean + orchestration/session/system the average user reaches for. */
29
30
  const BALANCED_EXTRA = [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swarmdo/cli",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "type": "module",
5
5
  "description": "Swarmdo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",