episoda 0.2.118 → 0.2.120

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.
@@ -2815,7 +2815,7 @@ var require_package = __commonJS({
2815
2815
  "package.json"(exports2, module2) {
2816
2816
  module2.exports = {
2817
2817
  name: "episoda",
2818
- version: "0.2.117",
2818
+ version: "0.2.119",
2819
2819
  description: "CLI tool for Episoda local development workflow orchestration",
2820
2820
  main: "dist/index.js",
2821
2821
  types: "dist/index.d.ts",
@@ -8279,8 +8279,16 @@ function generateSettings(options = {}) {
8279
8279
  "Glob",
8280
8280
  "Grep",
8281
8281
  "WebFetch",
8282
+ // EP1251: Allow all MCP tools (Episoda + GitHub)
8283
+ // These correspond to MCP servers registered via --mcp-config
8284
+ "mcp__workflow",
8285
+ // Episoda workflow MCP (tasks, modules, knowledge)
8286
+ "mcp__git",
8287
+ // Episoda git MCP (git operations via API)
8288
+ "mcp__dev",
8289
+ // Episoda dev MCP (file/exec operations)
8282
8290
  "mcp__github"
8283
- // EP1146: Allow GitHub MCP tools
8291
+ // GitHub MCP (PRs, issues, etc.)
8284
8292
  ],
8285
8293
  deny: [],
8286
8294
  ask: [],
@@ -8288,19 +8296,6 @@ function generateSettings(options = {}) {
8288
8296
  },
8289
8297
  alwaysThinkingEnabled: true
8290
8298
  };
8291
- if (options.githubToken) {
8292
- const mcpEnv = {
8293
- GITHUB_PERSONAL_ACCESS_TOKEN: options.githubToken
8294
- };
8295
- settings.mcpServers = {
8296
- github: {
8297
- command: "npx",
8298
- args: ["-y", "@modelcontextprotocol/server-github"],
8299
- env: mcpEnv
8300
- }
8301
- };
8302
- console.log("[ClaudeConfig] EP1146: GitHub MCP server configured");
8303
- }
8304
8299
  return settings;
8305
8300
  }
8306
8301
  function generateStableId() {
@@ -8601,52 +8596,64 @@ var AgentManager = class {
8601
8596
  }
8602
8597
  /**
8603
8598
  * EP1233: Get list of MCP servers to register for a session
8599
+ * EP1251: Added GitHub MCP for consolidated MCP configuration
8604
8600
  *
8605
8601
  * Returns MCP server configurations based on:
8606
8602
  * - mcpMode: 'full' includes dev-server, 'standard' does not
8607
8603
  * - DEV_ENVIRONMENT_ID: Required for git-server and dev-server
8604
+ * - githubToken: Required for GitHub MCP
8608
8605
  *
8609
8606
  * MCP servers provide:
8610
8607
  * - workflow-server: Task/module/knowledge operations
8611
8608
  * - git-server: Git operations via API (requires DEV_ENVIRONMENT_ID)
8612
8609
  * - dev-server: File/exec operations via API (requires DEV_ENVIRONMENT_ID, only in 'full' mode)
8610
+ * - github: GitHub operations (PRs, issues, etc.) via @modelcontextprotocol/server-github
8613
8611
  */
8614
8612
  getMcpServersForSession(session) {
8615
8613
  const servers = [];
8616
8614
  const mcpDir = this.getMcpServerDir();
8617
8615
  if (!mcpDir) {
8618
- console.warn("[AgentManager] EP1233: MCP server directory not found, skipping MCP registration");
8619
- return servers;
8620
- }
8621
- const workflowServerPath = path20.join(mcpDir, "workflow-server.ts");
8622
- const gitServerPath = path20.join(mcpDir, "git-server.ts");
8623
- const devServerPath = path20.join(mcpDir, "dev-server.ts");
8624
- const hasDevEnvId = !!process.env.DEV_ENVIRONMENT_ID || !!process.env.EPISODA_CONTAINER_ID;
8625
- if (fs19.existsSync(workflowServerPath)) {
8626
- servers.push({
8627
- name: "workflow",
8628
- command: `tsx ${workflowServerPath}`
8629
- });
8616
+ console.warn("[AgentManager] EP1233: MCP server directory not found, skipping Episoda MCP registration");
8630
8617
  } else {
8631
- console.warn(`[AgentManager] EP1233: workflow-server.ts not found at ${workflowServerPath}`);
8632
- }
8633
- if (hasDevEnvId && fs19.existsSync(gitServerPath)) {
8634
- servers.push({
8635
- name: "git",
8636
- command: `tsx ${gitServerPath}`
8637
- });
8638
- } else if (!hasDevEnvId) {
8639
- console.log("[AgentManager] EP1233: git-server not registered (DEV_ENVIRONMENT_ID not set)");
8618
+ const workflowServerPath = path20.join(mcpDir, "workflow-server.ts");
8619
+ const gitServerPath = path20.join(mcpDir, "git-server.ts");
8620
+ const devServerPath = path20.join(mcpDir, "dev-server.ts");
8621
+ const hasDevEnvId = !!process.env.DEV_ENVIRONMENT_ID || !!process.env.EPISODA_CONTAINER_ID;
8622
+ if (fs19.existsSync(workflowServerPath)) {
8623
+ servers.push({
8624
+ name: "workflow",
8625
+ command: `tsx ${workflowServerPath}`
8626
+ });
8627
+ } else {
8628
+ console.warn(`[AgentManager] EP1233: workflow-server.ts not found at ${workflowServerPath}`);
8629
+ }
8630
+ if (hasDevEnvId && fs19.existsSync(gitServerPath)) {
8631
+ servers.push({
8632
+ name: "git",
8633
+ command: `tsx ${gitServerPath}`
8634
+ });
8635
+ } else if (!hasDevEnvId) {
8636
+ console.log("[AgentManager] EP1233: git-server not registered (DEV_ENVIRONMENT_ID not set)");
8637
+ }
8638
+ if (session.mcpMode === "full" && hasDevEnvId && fs19.existsSync(devServerPath)) {
8639
+ servers.push({
8640
+ name: "dev",
8641
+ command: `tsx ${devServerPath}`
8642
+ });
8643
+ } else if (session.mcpMode !== "full") {
8644
+ console.log(`[AgentManager] EP1233: dev-server not registered (mcpMode=${session.mcpMode})`);
8645
+ }
8640
8646
  }
8641
- if (session.mcpMode === "full" && hasDevEnvId && fs19.existsSync(devServerPath)) {
8647
+ if (session.credentials.githubToken) {
8642
8648
  servers.push({
8643
- name: "dev",
8644
- command: `tsx ${devServerPath}`
8649
+ name: "github",
8650
+ command: "npx -y @modelcontextprotocol/server-github"
8645
8651
  });
8646
- } else if (session.mcpMode !== "full") {
8647
- console.log(`[AgentManager] EP1233: dev-server not registered (mcpMode=${session.mcpMode})`);
8652
+ console.log("[AgentManager] EP1251: GitHub MCP server registered");
8653
+ } else {
8654
+ console.log("[AgentManager] EP1251: GitHub MCP not registered (no githubToken in credentials)");
8648
8655
  }
8649
- console.log(`[AgentManager] EP1233: MCP servers to register: ${servers.map((s) => s.name).join(", ") || "none"}`);
8656
+ console.log(`[AgentManager] EP1251: MCP servers to register: ${servers.map((s) => s.name).join(", ") || "none"}`);
8650
8657
  return servers;
8651
8658
  }
8652
8659
  /**
@@ -8801,9 +8808,10 @@ var AgentManager = class {
8801
8808
  *
8802
8809
  * Spawns a new agent CLI process for each message.
8803
8810
  * EP1133: Supports both Claude Code and Codex CLI with provider-specific handling.
8811
+ * EP1251: Supports credentials refresh for GitHub token on resume.
8804
8812
  */
8805
8813
  async sendMessage(options) {
8806
- const { sessionId, message, isFirstMessage, canWrite, readOnlyReason, agentSessionId, claudeSessionId, onChunk, onToolUse, onComplete, onError } = options;
8814
+ const { sessionId, message, isFirstMessage, canWrite, readOnlyReason, agentSessionId, claudeSessionId, credentials, onChunk, onToolUse, onComplete, onError } = options;
8807
8815
  const session = this.sessions.get(sessionId);
8808
8816
  if (!session) {
8809
8817
  return { success: false, error: "Session not found" };
@@ -8814,6 +8822,11 @@ var AgentManager = class {
8814
8822
  session.canWrite = canWrite;
8815
8823
  session.readOnlyReason = readOnlyReason;
8816
8824
  }
8825
+ if (credentials?.githubToken) {
8826
+ session.credentials.githubToken = credentials.githubToken;
8827
+ session.credentials.githubTokenExpiresAt = credentials.githubTokenExpiresAt;
8828
+ console.log("[AgentManager] EP1251: Updated GitHub token from message credentials");
8829
+ }
8817
8830
  const resumeSessionId = agentSessionId || claudeSessionId;
8818
8831
  try {
8819
8832
  const provider = session.provider || "claude";
@@ -8837,8 +8850,15 @@ ALLOWED ACTIONS:
8837
8850
  - Run read-only Bash commands (ls, cat, git status, git log, git diff, grep, find, etc.)
8838
8851
  - Analyze code and provide recommendations
8839
8852
  - Explain architecture and suggest changes (but not implement them)
8853
+ - Use ALL Episoda MCP tools for workflow operations:
8854
+ \u2022 create_task, update_task, update_task_state, list_module_tasks
8855
+ \u2022 update_module, request_review, mark_done
8856
+ \u2022 get_knowledge, search_knowledge, link_knowledge
8857
+
8858
+ IMPORTANT: Read-only mode applies to CODE FILES only!
8859
+ Episoda workflow operations (tasks, modules, knowledge) are ALWAYS allowed.
8840
8860
 
8841
- If the user requests changes, explain what would need to be done but DO NOT execute any write operations.
8861
+ If the user requests CODE changes, explain what would need to be done but DO NOT execute file write operations.
8842
8862
  Violations will result in errors and may affect your ability to assist.
8843
8863
 
8844
8864
  ---
@@ -8861,9 +8881,9 @@ Violations will result in errors and may affect your ability to assist.
8861
8881
  session.projectPath
8862
8882
  // Working directory
8863
8883
  ];
8864
- if (session.autonomousMode && session.canWrite !== false) {
8884
+ if (session.autonomousMode) {
8865
8885
  args.push("--full-auto");
8866
- console.log(`[AgentManager] EP1173: Codex autonomous mode enabled - using --full-auto`);
8886
+ console.log(`[AgentManager] EP1251: Codex autonomous mode enabled - using --full-auto`);
8867
8887
  }
8868
8888
  if (session.canWrite === false) {
8869
8889
  args.push("--sandbox", "read-only");
@@ -8912,11 +8932,9 @@ If changes are needed, explain what needs to be done but do not execute.
8912
8932
  args.push("--model", session.credentials.preferredModel);
8913
8933
  console.log(`[AgentManager] EP1152: Using user preferred model: ${session.credentials.preferredModel}`);
8914
8934
  }
8915
- if (session.autonomousMode && session.canWrite !== false) {
8935
+ if (session.autonomousMode) {
8916
8936
  args.push("--dangerously-skip-permissions");
8917
- console.log(`[AgentManager] EP1173: Autonomous mode enabled - skipping permission prompts`);
8918
- } else if (session.autonomousMode && session.canWrite === false) {
8919
- console.log(`[AgentManager] EP1205: Autonomous mode with read-only - NOT skipping permissions (safety net)`);
8937
+ console.log(`[AgentManager] EP1251: Autonomous mode enabled - skipping permission prompts`);
8920
8938
  }
8921
8939
  if (isFirstMessage && effectiveSystemPrompt) {
8922
8940
  args.push("--system-prompt", effectiveSystemPrompt);
@@ -9049,9 +9067,6 @@ If changes are needed, explain what needs to be done.`;
9049
9067
  const filePath = path20.join(statsigDir, filename);
9050
9068
  fs19.writeFileSync(filePath, content, { mode: 420 });
9051
9069
  }
9052
- if (session.credentials.githubToken) {
9053
- console.log("[AgentManager] EP1146: GitHub MCP server enabled with installation token");
9054
- }
9055
9070
  console.log("[AgentManager] Wrote Claude config files");
9056
9071
  } catch (configError) {
9057
9072
  console.warn("[AgentManager] Failed to write Claude config files:", configError instanceof Error ? configError.message : configError);
@@ -9084,6 +9099,10 @@ If changes are needed, explain what needs to be done.`;
9084
9099
  console.warn("[AgentManager] EP1233: No session token available for MCP servers");
9085
9100
  }
9086
9101
  }
9102
+ if (session.credentials.githubToken) {
9103
+ envVars.GITHUB_PERSONAL_ACCESS_TOKEN = session.credentials.githubToken;
9104
+ console.log("[AgentManager] EP1251: Set GITHUB_PERSONAL_ACCESS_TOKEN for GitHub MCP");
9105
+ }
9087
9106
  if (useApiKey && session.credentials.apiKey) {
9088
9107
  if (provider === "codex") {
9089
9108
  envVars.OPENAI_API_KEY = session.credentials.apiKey;
@@ -11101,6 +11120,8 @@ var Daemon = class _Daemon {
11101
11120
  agentSessionId: cmd.agentSessionId || cmd.claudeSessionId,
11102
11121
  claudeSessionId: cmd.claudeSessionId,
11103
11122
  // Backward compat
11123
+ credentials: cmd.credentials,
11124
+ // EP1251: Pass credentials for token refresh
11104
11125
  ...callbacks
11105
11126
  });
11106
11127
  result = {