@artyfacts/claude 1.3.0 → 1.3.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/dist/cli.js +58 -0
- package/dist/cli.mjs +58 -0
- package/package.json +1 -1
- package/src/cli.ts +73 -0
package/dist/cli.js
CHANGED
|
@@ -25,6 +25,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
|
|
26
26
|
// src/cli.ts
|
|
27
27
|
var import_commander = require("commander");
|
|
28
|
+
var import_child_process2 = require("child_process");
|
|
28
29
|
|
|
29
30
|
// src/auth.ts
|
|
30
31
|
var fs = __toESM(require("fs"));
|
|
@@ -771,6 +772,62 @@ function createListener(config) {
|
|
|
771
772
|
// src/cli.ts
|
|
772
773
|
var VERSION = "0.1.0";
|
|
773
774
|
var DEFAULT_BASE_URL3 = "https://artyfacts.dev/api/v1";
|
|
775
|
+
function isMcpConfigured() {
|
|
776
|
+
try {
|
|
777
|
+
const result = (0, import_child_process2.spawnSync)("claude", ["mcp", "get", "artyfacts"], {
|
|
778
|
+
encoding: "utf-8",
|
|
779
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
780
|
+
});
|
|
781
|
+
return result.status === 0;
|
|
782
|
+
} catch {
|
|
783
|
+
return false;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
function configureMcp(apiKey, baseUrl) {
|
|
787
|
+
console.log("\u{1F527} Configuring Artyfacts tools for Claude Code...");
|
|
788
|
+
try {
|
|
789
|
+
const result = (0, import_child_process2.spawnSync)("claude", [
|
|
790
|
+
"mcp",
|
|
791
|
+
"add",
|
|
792
|
+
"--transport",
|
|
793
|
+
"stdio",
|
|
794
|
+
"--scope",
|
|
795
|
+
"user",
|
|
796
|
+
// Available across all projects
|
|
797
|
+
"--env",
|
|
798
|
+
`ARTYFACTS_API_KEY=${apiKey}`,
|
|
799
|
+
"--env",
|
|
800
|
+
`ARTYFACTS_BASE_URL=${baseUrl}`,
|
|
801
|
+
"artyfacts",
|
|
802
|
+
"--",
|
|
803
|
+
"npx",
|
|
804
|
+
"-y",
|
|
805
|
+
"@artyfacts/mcp-server"
|
|
806
|
+
], {
|
|
807
|
+
encoding: "utf-8",
|
|
808
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
809
|
+
});
|
|
810
|
+
if (result.status === 0) {
|
|
811
|
+
console.log("\u2705 MCP tools configured! Claude Code now has access to Artyfacts.");
|
|
812
|
+
return true;
|
|
813
|
+
} else {
|
|
814
|
+
console.log("\u26A0\uFE0F Could not configure MCP:", result.stderr || result.stdout);
|
|
815
|
+
console.log(" You can manually add it with:");
|
|
816
|
+
console.log(` claude mcp add --transport stdio artyfacts -- npx -y @artyfacts/mcp-server`);
|
|
817
|
+
return false;
|
|
818
|
+
}
|
|
819
|
+
} catch (error) {
|
|
820
|
+
console.log("\u26A0\uFE0F Could not configure MCP:", error instanceof Error ? error.message : error);
|
|
821
|
+
return false;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
function ensureMcpConfigured(apiKey, baseUrl) {
|
|
825
|
+
if (isMcpConfigured()) {
|
|
826
|
+
console.log("\u2705 Artyfacts MCP tools already configured");
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
configureMcp(apiKey, baseUrl);
|
|
830
|
+
}
|
|
774
831
|
var program = new import_commander.Command();
|
|
775
832
|
program.name("artyfacts-claude").description("Claude adapter for Artyfacts - Execute tasks using Claude API").version(VERSION);
|
|
776
833
|
program.command("run", { isDefault: true }).description("Start listening for and executing tasks").option("--base-url <url>", "Artyfacts API base URL", DEFAULT_BASE_URL3).option("--dry-run", "Print tasks but do not execute", false).action(async (options) => {
|
|
@@ -924,6 +981,7 @@ async function runAgent(options) {
|
|
|
924
981
|
console.error("\u274C Authentication failed:", error instanceof Error ? error.message : error);
|
|
925
982
|
process.exit(1);
|
|
926
983
|
}
|
|
984
|
+
ensureMcpConfigured(credentials.apiKey, options.baseUrl);
|
|
927
985
|
let executor = null;
|
|
928
986
|
if (!options.dryRun) {
|
|
929
987
|
executor = createExecutor({
|
package/dist/cli.mjs
CHANGED
|
@@ -10,8 +10,65 @@ import {
|
|
|
10
10
|
|
|
11
11
|
// src/cli.ts
|
|
12
12
|
import { Command } from "commander";
|
|
13
|
+
import { spawnSync } from "child_process";
|
|
13
14
|
var VERSION = "0.1.0";
|
|
14
15
|
var DEFAULT_BASE_URL = "https://artyfacts.dev/api/v1";
|
|
16
|
+
function isMcpConfigured() {
|
|
17
|
+
try {
|
|
18
|
+
const result = spawnSync("claude", ["mcp", "get", "artyfacts"], {
|
|
19
|
+
encoding: "utf-8",
|
|
20
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
21
|
+
});
|
|
22
|
+
return result.status === 0;
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function configureMcp(apiKey, baseUrl) {
|
|
28
|
+
console.log("\u{1F527} Configuring Artyfacts tools for Claude Code...");
|
|
29
|
+
try {
|
|
30
|
+
const result = spawnSync("claude", [
|
|
31
|
+
"mcp",
|
|
32
|
+
"add",
|
|
33
|
+
"--transport",
|
|
34
|
+
"stdio",
|
|
35
|
+
"--scope",
|
|
36
|
+
"user",
|
|
37
|
+
// Available across all projects
|
|
38
|
+
"--env",
|
|
39
|
+
`ARTYFACTS_API_KEY=${apiKey}`,
|
|
40
|
+
"--env",
|
|
41
|
+
`ARTYFACTS_BASE_URL=${baseUrl}`,
|
|
42
|
+
"artyfacts",
|
|
43
|
+
"--",
|
|
44
|
+
"npx",
|
|
45
|
+
"-y",
|
|
46
|
+
"@artyfacts/mcp-server"
|
|
47
|
+
], {
|
|
48
|
+
encoding: "utf-8",
|
|
49
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
50
|
+
});
|
|
51
|
+
if (result.status === 0) {
|
|
52
|
+
console.log("\u2705 MCP tools configured! Claude Code now has access to Artyfacts.");
|
|
53
|
+
return true;
|
|
54
|
+
} else {
|
|
55
|
+
console.log("\u26A0\uFE0F Could not configure MCP:", result.stderr || result.stdout);
|
|
56
|
+
console.log(" You can manually add it with:");
|
|
57
|
+
console.log(` claude mcp add --transport stdio artyfacts -- npx -y @artyfacts/mcp-server`);
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.log("\u26A0\uFE0F Could not configure MCP:", error instanceof Error ? error.message : error);
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function ensureMcpConfigured(apiKey, baseUrl) {
|
|
66
|
+
if (isMcpConfigured()) {
|
|
67
|
+
console.log("\u2705 Artyfacts MCP tools already configured");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
configureMcp(apiKey, baseUrl);
|
|
71
|
+
}
|
|
15
72
|
var program = new Command();
|
|
16
73
|
program.name("artyfacts-claude").description("Claude adapter for Artyfacts - Execute tasks using Claude API").version(VERSION);
|
|
17
74
|
program.command("run", { isDefault: true }).description("Start listening for and executing tasks").option("--base-url <url>", "Artyfacts API base URL", DEFAULT_BASE_URL).option("--dry-run", "Print tasks but do not execute", false).action(async (options) => {
|
|
@@ -165,6 +222,7 @@ async function runAgent(options) {
|
|
|
165
222
|
console.error("\u274C Authentication failed:", error instanceof Error ? error.message : error);
|
|
166
223
|
process.exit(1);
|
|
167
224
|
}
|
|
225
|
+
ensureMcpConfigured(credentials.apiKey, options.baseUrl);
|
|
168
226
|
let executor = null;
|
|
169
227
|
if (!options.dryRun) {
|
|
170
228
|
executor = createExecutor({
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { Command } from 'commander';
|
|
13
|
+
import { execSync, spawnSync } from 'child_process';
|
|
13
14
|
import { getCredentials, clearCredentials, loadCredentials, promptForApiKey } from './auth';
|
|
14
15
|
import { ClaudeExecutor, createExecutor, TaskContext } from './executor';
|
|
15
16
|
import { ArtyfactsListener, createListener, TaskAssignedEvent } from './listener';
|
|
@@ -21,6 +22,75 @@ import { ArtyfactsListener, createListener, TaskAssignedEvent } from './listener
|
|
|
21
22
|
const VERSION = '0.1.0';
|
|
22
23
|
const DEFAULT_BASE_URL = 'https://artyfacts.dev/api/v1';
|
|
23
24
|
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// MCP Configuration
|
|
27
|
+
// ============================================================================
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Check if Artyfacts MCP server is already configured in Claude Code
|
|
31
|
+
*/
|
|
32
|
+
function isMcpConfigured(): boolean {
|
|
33
|
+
try {
|
|
34
|
+
const result = spawnSync('claude', ['mcp', 'get', 'artyfacts'], {
|
|
35
|
+
encoding: 'utf-8',
|
|
36
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
37
|
+
});
|
|
38
|
+
// If exit code is 0, MCP is already configured
|
|
39
|
+
return result.status === 0;
|
|
40
|
+
} catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Configure Artyfacts MCP server in Claude Code
|
|
47
|
+
*/
|
|
48
|
+
function configureMcp(apiKey: string, baseUrl: string): boolean {
|
|
49
|
+
console.log('🔧 Configuring Artyfacts tools for Claude Code...');
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
// Add MCP server with environment variables
|
|
53
|
+
const result = spawnSync('claude', [
|
|
54
|
+
'mcp', 'add',
|
|
55
|
+
'--transport', 'stdio',
|
|
56
|
+
'--scope', 'user', // Available across all projects
|
|
57
|
+
'--env', `ARTYFACTS_API_KEY=${apiKey}`,
|
|
58
|
+
'--env', `ARTYFACTS_BASE_URL=${baseUrl}`,
|
|
59
|
+
'artyfacts',
|
|
60
|
+
'--',
|
|
61
|
+
'npx', '-y', '@artyfacts/mcp-server',
|
|
62
|
+
], {
|
|
63
|
+
encoding: 'utf-8',
|
|
64
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (result.status === 0) {
|
|
68
|
+
console.log('✅ MCP tools configured! Claude Code now has access to Artyfacts.');
|
|
69
|
+
return true;
|
|
70
|
+
} else {
|
|
71
|
+
console.log('⚠️ Could not configure MCP:', result.stderr || result.stdout);
|
|
72
|
+
console.log(' You can manually add it with:');
|
|
73
|
+
console.log(` claude mcp add --transport stdio artyfacts -- npx -y @artyfacts/mcp-server`);
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.log('⚠️ Could not configure MCP:', error instanceof Error ? error.message : error);
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Ensure MCP is configured, configure if needed
|
|
84
|
+
*/
|
|
85
|
+
function ensureMcpConfigured(apiKey: string, baseUrl: string): void {
|
|
86
|
+
if (isMcpConfigured()) {
|
|
87
|
+
console.log('✅ Artyfacts MCP tools already configured');
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
configureMcp(apiKey, baseUrl);
|
|
92
|
+
}
|
|
93
|
+
|
|
24
94
|
// ============================================================================
|
|
25
95
|
// CLI Setup
|
|
26
96
|
// ============================================================================
|
|
@@ -284,6 +354,9 @@ async function runAgent(options: {
|
|
|
284
354
|
process.exit(1);
|
|
285
355
|
}
|
|
286
356
|
|
|
357
|
+
// Configure MCP tools (auto-configures if needed)
|
|
358
|
+
ensureMcpConfigured(credentials.apiKey, options.baseUrl);
|
|
359
|
+
|
|
287
360
|
// Create executor (uses Claude Code CLI + Artyfacts context API)
|
|
288
361
|
let executor: ClaudeExecutor | null = null;
|
|
289
362
|
if (!options.dryRun) {
|