gitdone-agent 0.6.4 → 0.6.5
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/index.js +36 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import { randomUUID } from 'node:crypto'
|
|
|
27
27
|
// Reported to the server on every sync so the web UI can flag outdated agents.
|
|
28
28
|
// Keep in lockstep with packages/agent/package.json "version" AND
|
|
29
29
|
// src/lib/agentVersion.ts LATEST_AGENT_VERSION.
|
|
30
|
-
const AGENT_VERSION = '0.6.
|
|
30
|
+
const AGENT_VERSION = '0.6.5'
|
|
31
31
|
|
|
32
32
|
const AGENT_DIR = join(homedir(), '.gitdone-agent')
|
|
33
33
|
const CONFIG_PATH = join(AGENT_DIR, 'config.json')
|
|
@@ -675,6 +675,32 @@ function ensureAiSessionHookFiles() {
|
|
|
675
675
|
return AI_SESSION_SETTINGS_PATH
|
|
676
676
|
}
|
|
677
677
|
|
|
678
|
+
// gitdone MCP config for headless sessions (gd-308). We provide it ourselves —
|
|
679
|
+
// with an X-Gitdone-Machine-Id header — so the server can attribute the AI agents
|
|
680
|
+
// this session registers (ai_agent_start) to THIS computer, and the „АИ Агенти"
|
|
681
|
+
// panel shows one sub-panel per machine instead of a single „Локален агент".
|
|
682
|
+
// Used with --strict-mcp-config so the session uses exactly this server. The
|
|
683
|
+
// agent's own key (a gdo_ key) authenticates the MCP endpoint.
|
|
684
|
+
const AI_MCP_CONFIG_PATH = join(AGENT_DIR, 'ai-mcp-config.json')
|
|
685
|
+
|
|
686
|
+
function ensureAiMcpConfig(cfg) {
|
|
687
|
+
ensureAgentDir()
|
|
688
|
+
const config = {
|
|
689
|
+
mcpServers: {
|
|
690
|
+
gitdone: {
|
|
691
|
+
type: 'http',
|
|
692
|
+
url: `${cfg.url}/api/mcp`,
|
|
693
|
+
headers: {
|
|
694
|
+
Authorization: `Bearer ${cfg.key}`,
|
|
695
|
+
'X-Gitdone-Machine-Id': cfg.machineId,
|
|
696
|
+
},
|
|
697
|
+
},
|
|
698
|
+
},
|
|
699
|
+
}
|
|
700
|
+
writeFileSync(AI_MCP_CONFIG_PATH, JSON.stringify(config, null, 2), 'utf8')
|
|
701
|
+
return AI_MCP_CONFIG_PATH
|
|
702
|
+
}
|
|
703
|
+
|
|
678
704
|
// Run a headless Claude Code session for an `ai_run` command and stream its
|
|
679
705
|
// output back. Long-running and fire-and-forget: it wires up async handlers and
|
|
680
706
|
// returns immediately so the agent's snapshot loop is never blocked.
|
|
@@ -698,6 +724,8 @@ function runAiCommand(cfg, cmd, repoPath) {
|
|
|
698
724
|
|
|
699
725
|
let settingsPath
|
|
700
726
|
try { settingsPath = ensureAiHookFiles() } catch (e) { log(`✗ ai hook setup failed: ${e.message}`) }
|
|
727
|
+
let mcpConfigPath
|
|
728
|
+
try { mcpConfigPath = ensureAiMcpConfig(cfg) } catch (e) { log(`✗ ai mcp config setup failed: ${e.message}`) }
|
|
701
729
|
|
|
702
730
|
// The prompt is delivered on STDIN, not as a `-p <arg>` command-line value.
|
|
703
731
|
// A multi-line, non-ASCII (Cyrillic) prompt passed as an argv element gets
|
|
@@ -714,6 +742,8 @@ function runAiCommand(cfg, cmd, repoPath) {
|
|
|
714
742
|
// Block git commit/push unless this repo opted in (per-repo aiAutoCommit).
|
|
715
743
|
...(allowCommit ? [] : ['--disallowedTools', 'Bash(git commit *),Bash(git push *)']),
|
|
716
744
|
...(settingsPath ? ['--settings', settingsPath] : []),
|
|
745
|
+
// Our own gitdone MCP, tagged with this machine (gd-308).
|
|
746
|
+
...(mcpConfigPath ? ['--mcp-config', mcpConfigPath, '--strict-mcp-config'] : []),
|
|
717
747
|
]
|
|
718
748
|
|
|
719
749
|
// The PostToolUse hook reads these from its env to post raw tool output.
|
|
@@ -850,6 +880,8 @@ async function runAiChat(cfg, cmd, repoPath) {
|
|
|
850
880
|
|
|
851
881
|
let settingsPath
|
|
852
882
|
try { settingsPath = ensureAiSessionHookFiles() } catch (e) { log(`✗ ai session hook setup failed: ${e.message}`) }
|
|
883
|
+
let mcpConfigPath
|
|
884
|
+
try { mcpConfigPath = ensureAiMcpConfig(cfg) } catch (e) { log(`✗ ai mcp config setup failed: ${e.message}`) }
|
|
853
885
|
|
|
854
886
|
const args = [
|
|
855
887
|
'-p',
|
|
@@ -864,6 +896,9 @@ async function runAiChat(cfg, cmd, repoPath) {
|
|
|
864
896
|
...(allowCommit ? [] : ['--disallowedTools', 'Bash(git commit *),Bash(git push *)']),
|
|
865
897
|
...(claudeSessionId ? ['--resume', claudeSessionId] : []),
|
|
866
898
|
...(settingsPath ? ['--settings', settingsPath] : []),
|
|
899
|
+
// Our own gitdone MCP, tagged with this machine so ai_agent_start attributes
|
|
900
|
+
// the agents to this computer (gd-308). --strict = use exactly this server.
|
|
901
|
+
...(mcpConfigPath ? ['--mcp-config', mcpConfigPath, '--strict-mcp-config'] : []),
|
|
867
902
|
]
|
|
868
903
|
|
|
869
904
|
const childEnv = { ...process.env, GITDONE_URL: cfg.url, GITDONE_KEY: cfg.key, GITDONE_SESSION_ID: sessionId }
|