smart-context-mcp 1.7.0 → 1.7.1

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.
package/README.md CHANGED
@@ -52,9 +52,9 @@ Restart your AI client. Done.
52
52
 
53
53
  ---
54
54
 
55
- ## `1.6.0` Task Runner
55
+ ## Task Runner
56
56
 
57
- `1.6.0` adds `smart-context-task`, a workflow-oriented CLI on top of the raw MCP tools.
57
+ `smart-context-task` is a workflow-oriented CLI on top of the raw MCP tools.
58
58
 
59
59
  Use it when you want a more repeatable path than “agent reads rules and hopefully picks the right flow”.
60
60
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-context-mcp",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "MCP server that reduces agent token usage by 90% with intelligent context compression, task checkpoint persistence, and workflow-aware agent guidance.",
5
5
  "author": "Francisco Caballero Portero <fcp1978@hotmail.com>",
6
6
  "type": "module",
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { runHeadlessWrapper } from '../src/orchestration/headless-wrapper.js';
3
+ import { detectClient } from '../src/utils/client-detection.js';
3
4
 
4
5
  const requireValue = (argv, index, flag) => {
5
6
  const value = argv[index + 1];
@@ -11,7 +12,7 @@ const requireValue = (argv, index, flag) => {
11
12
 
12
13
  const parseArgs = (argv) => {
13
14
  const options = {
14
- client: 'generic',
15
+ client: null,
15
16
  prompt: '',
16
17
  sessionId: undefined,
17
18
  event: undefined,
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { runTaskRunner } from '../src/task-runner.js';
3
3
  import { checkNodeVersion } from '../src/utils/runtime-check.js';
4
+ import { detectClient } from '../src/utils/client-detection.js';
4
5
 
5
6
  const runtimeCheck = checkNodeVersion();
6
7
  if (!runtimeCheck.ok) {
@@ -28,7 +29,7 @@ const parseArgs = (argv) => {
28
29
  const rest = argv[0] && !argv[0].startsWith('--') ? argv.slice(1) : argv;
29
30
  const options = {
30
31
  commandName: subcommand,
31
- client: 'generic',
32
+ client: null,
32
33
  prompt: '',
33
34
  sessionId: undefined,
34
35
  event: undefined,
@@ -7,6 +7,7 @@ import {
7
7
  resolveManagedStart,
8
8
  } from './base-orchestrator.js';
9
9
  import { normalizeWhitespace } from './policy/event-policy.js';
10
+ import { detectClient } from '../utils/client-detection.js';
10
11
 
11
12
  const runChildProcess = ({ command, args, env, stdinText, streamOutput }) => new Promise((resolve, reject) => {
12
13
  const child = spawn(command, args, {
@@ -44,7 +45,7 @@ const runChildProcess = ({ command, args, env, stdinText, streamOutput }) => new
44
45
  });
45
46
 
46
47
  export const runHeadlessWrapper = async ({
47
- client = 'generic',
48
+ client = null,
48
49
  prompt,
49
50
  command,
50
51
  args = [],
@@ -56,6 +57,8 @@ export const runHeadlessWrapper = async ({
56
57
  runCommand = runChildProcess,
57
58
  preparedStartResult = null,
58
59
  } = {}) => {
60
+ const resolvedClient = client ?? detectClient();
61
+
59
62
  if (!normalizeWhitespace(prompt)) {
60
63
  throw new Error('prompt is required');
61
64
  }
@@ -77,7 +80,7 @@ export const runHeadlessWrapper = async ({
77
80
 
78
81
  await recordAgentWrapperMetric({
79
82
  phase: 'start',
80
- client,
83
+ client: resolvedClient,
81
84
  sessionId: effectiveStart.sessionId ?? null,
82
85
  dryRun,
83
86
  overheadTokens,
@@ -89,7 +92,7 @@ export const runHeadlessWrapper = async ({
89
92
  const finalArgs = stdinPrompt ? [...args] : [...args, wrappedPrompt];
90
93
  if (dryRun) {
91
94
  return {
92
- client,
95
+ client: resolvedClient,
93
96
  dryRun: true,
94
97
  command,
95
98
  args: finalArgs,
@@ -123,7 +126,7 @@ export const runHeadlessWrapper = async ({
123
126
 
124
127
  await recordAgentWrapperMetric({
125
128
  phase: 'end',
126
- client,
129
+ client: resolvedClient,
127
130
  sessionId: effectiveStart.sessionId ?? null,
128
131
  isolatedSession: sessionResolution.isolated,
129
132
  exitCode: childResult.exitCode,
@@ -132,7 +135,7 @@ export const runHeadlessWrapper = async ({
132
135
  });
133
136
 
134
137
  return {
135
- client,
138
+ client: resolvedClient,
136
139
  command,
137
140
  args: finalArgs,
138
141
  wrappedPrompt,
@@ -27,6 +27,7 @@ import {
27
27
  buildWorkflowPrompt,
28
28
  evaluateRunnerGate,
29
29
  } from './task-runner/policy.js';
30
+ import { detectClient } from './utils/client-detection.js';
30
31
 
31
32
  const RUNNER_LOCK_RETRY_ATTEMPTS = 3;
32
33
  const RUNNER_LOCK_RETRY_DELAY_MS = 100;
@@ -414,7 +415,7 @@ const runCleanupCommand = async ({
414
415
 
415
416
  export const runTaskRunner = async ({
416
417
  commandName = 'task',
417
- client = 'generic',
418
+ client = null,
418
419
  prompt = '',
419
420
  sessionId,
420
421
  event,
@@ -436,6 +437,8 @@ export const runTaskRunner = async ({
436
437
  vacuum = false,
437
438
  update = {},
438
439
  } = {}) => {
440
+ const resolvedClient = client ?? detectClient();
441
+
439
442
  if (!RUNNER_COMMANDS.includes(commandName)) {
440
443
  throw new Error(`Unsupported task-runner command: ${commandName}`);
441
444
  }
@@ -443,7 +446,7 @@ export const runTaskRunner = async ({
443
446
  if (WORKFLOW_COMMANDS.has(commandName)) {
444
447
  return runWorkflowCommand({
445
448
  commandName,
446
- client,
449
+ client: resolvedClient,
447
450
  prompt,
448
451
  sessionId,
449
452
  event,
@@ -458,16 +461,16 @@ export const runTaskRunner = async ({
458
461
  }
459
462
 
460
463
  if (commandName === 'doctor') {
461
- return runDoctorCommand({ verifyIntegrity, client });
464
+ return runDoctorCommand({ verifyIntegrity, client: resolvedClient });
462
465
  }
463
466
 
464
467
  if (commandName === 'status') {
465
- return runStatusCommand({ format, maxItems, client });
468
+ return runStatusCommand({ format, maxItems, client: resolvedClient });
466
469
  }
467
470
 
468
471
  if (commandName === 'checkpoint') {
469
472
  return runCheckpointCommand({
470
- client,
473
+ client: resolvedClient,
471
474
  sessionId,
472
475
  event,
473
476
  update,
@@ -476,7 +479,7 @@ export const runTaskRunner = async ({
476
479
 
477
480
  if (commandName === 'cleanup') {
478
481
  return runCleanupCommand({
479
- client,
482
+ client: resolvedClient,
480
483
  cleanupMode,
481
484
  apply,
482
485
  retentionDays,
@@ -0,0 +1,33 @@
1
+ const detectClientFromEnv = () => {
2
+ if (process.env.CURSOR_AGENT === '1') {
3
+ return 'cursor';
4
+ }
5
+
6
+ if (process.env.CLAUDE_AGENT === '1') {
7
+ return 'claude';
8
+ }
9
+
10
+ if (process.env.GEMINI_AGENT === '1') {
11
+ return 'gemini';
12
+ }
13
+
14
+ if (process.env.CODEX_AGENT === '1') {
15
+ return 'codex';
16
+ }
17
+
18
+ return 'generic';
19
+ };
20
+
21
+ let cachedClient = null;
22
+
23
+ export const detectClient = () => {
24
+ if (cachedClient === null) {
25
+ cachedClient = detectClientFromEnv();
26
+ }
27
+
28
+ return cachedClient;
29
+ };
30
+
31
+ export const resetClientDetection = () => {
32
+ cachedClient = null;
33
+ };