|
|
|
@@ -35,7 +35,7 @@ zcode(options)
|
|
|
|
### 1.1 `src/zcode.js`
|
|
|
|
### 1.1 `src/zcode.js`
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/zcode.js` |
|
|
|
|
| **Path** | `src/zcode.js` |
|
|
|
|
| **Exported API** | `async function zcode(options)` |
|
|
|
|
| **Exported API** | `async function zcode(options)` |
|
|
|
|
| **Init** | Called from `bin/zcode.js` via `import { zcode } from '../src/zcode.js'` |
|
|
|
|
| **Init** | Called from `bin/zcode.js` via `import { zcode } from '../src/zcode.js'` |
|
|
|
|
| **Options** | `{ bot: boolean, cli: boolean }` |
|
|
|
|
| **Options** | `{ bot: boolean, cli: boolean }` |
|
|
|
|
@@ -44,7 +44,7 @@ zcode(options)
|
|
|
|
### 1.2 `src/utils/env.js`
|
|
|
|
### 1.2 `src/utils/env.js`
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/utils/env.js` |
|
|
|
|
| **Path** | `src/utils/env.js` |
|
|
|
|
| **Exported API** | `function checkEnv()` |
|
|
|
|
| **Exported API** | `function checkEnv()` |
|
|
|
|
| **Returns** | `{ valid, missing, ZAI_API_KEY, GLM_BASE_URL, TELEGRAM_BOT_TOKEN, TELEGRAM_ALLOWED_USERS }` |
|
|
|
|
| **Returns** | `{ valid, missing, ZAI_API_KEY, GLM_BASE_URL, TELEGRAM_BOT_TOKEN, TELEGRAM_ALLOWED_USERS }` |
|
|
|
|
| **Init** | `checkEnv()` — no constructor, stateless |
|
|
|
|
| **Init** | `checkEnv()` — no constructor, stateless |
|
|
|
|
@@ -53,7 +53,7 @@ zcode(options)
|
|
|
|
### 1.3 `src/config/index.js`
|
|
|
|
### 1.3 `src/config/index.js`
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/config/index.js` |
|
|
|
|
| **Path** | `src/config/index.js` |
|
|
|
|
| **Exported API** | `async function initConfig()` |
|
|
|
|
| **Exported API** | `async function initConfig()` |
|
|
|
|
| **Returns** | Config object: `{ api, telegram, tools, skills, agents, logging }` |
|
|
|
|
| **Returns** | Config object: `{ api, telegram, tools, skills, agents, logging }` |
|
|
|
|
| **Init** | `const config = await initConfig()` |
|
|
|
|
| **Init** | `const config = await initConfig()` |
|
|
|
|
@@ -62,7 +62,7 @@ zcode(options)
|
|
|
|
### 1.4 `src/api/index.js`
|
|
|
|
### 1.4 `src/api/index.js`
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/api/index.js` |
|
|
|
|
| **Path** | `src/api/index.js` |
|
|
|
|
| **Exported API** | `async function initAPI()` — returns `{ config, client }` |
|
|
|
|
| **Exported API** | `async function initAPI()` — returns `{ config, client }` |
|
|
|
|
| | `class ZAIProvider` — `constructor(api)`, `chat(messages, opts)`, `complete(prompt, opts)` |
|
|
|
|
| | `class ZAIProvider` — `constructor(api)`, `chat(messages, opts)`, `complete(prompt, opts)` |
|
|
|
|
| | `function createZAIProvider(api)` — factory |
|
|
|
|
| | `function createZAIProvider(api)` — factory |
|
|
|
|
@@ -73,7 +73,7 @@ zcode(options)
|
|
|
|
### 1.5 `src/tools/index.js`
|
|
|
|
### 1.5 `src/tools/index.js`
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/tools/index.js` |
|
|
|
|
| **Path** | `src/tools/index.js` |
|
|
|
|
| **Exported API** | `async function initTools()` — returns `tools[]` |
|
|
|
|
| **Exported API** | `async function initTools()` — returns `tools[]` |
|
|
|
|
| | `class BashTool` — `.execute(command, options)` |
|
|
|
|
| | `class BashTool` — `.execute(command, options)` |
|
|
|
|
| | `class FileEditTool` — `.read(path)`, `.write(path, content)`, `.append(path, content)`, `.edit(path, oldText, newText)` |
|
|
|
|
| | `class FileEditTool` — `.read(path)`, `.write(path, content)`, `.append(path, content)`, `.edit(path, oldText, newText)` |
|
|
|
|
@@ -85,7 +85,7 @@ zcode(options)
|
|
|
|
### 1.6 `src/skills/index.js`
|
|
|
|
### 1.6 `src/skills/index.js`
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/skills/index.js` |
|
|
|
|
| **Path** | `src/skills/index.js` |
|
|
|
|
| **Exported API** | `async function initSkills()` — returns `skills[]` of `{ name, description, version, category }` |
|
|
|
|
| **Exported API** | `async function initSkills()` — returns `skills[]` of `{ name, description, version, category }` |
|
|
|
|
| **Init** | `const skills = await initSkills()` |
|
|
|
|
| **Init** | `const skills = await initSkills()` |
|
|
|
|
| **Sources** | (1) `.json`/`.js` files in `skills/` dir in CWD, (2) 5 built-in skills hardcoded |
|
|
|
|
| **Sources** | (1) `.json`/`.js` files in `skills/` dir in CWD, (2) 5 built-in skills hardcoded |
|
|
|
|
@@ -94,7 +94,7 @@ zcode(options)
|
|
|
|
### 1.7 `src/agents/index.js`
|
|
|
|
### 1.7 `src/agents/index.js`
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/agents/index.js` |
|
|
|
|
| **Path** | `src/agents/index.js` |
|
|
|
|
| **Exported API** | `async function initAgents()` — returns `agents[]` of `{ id, name, description, capabilities, enabled }` |
|
|
|
|
| **Exported API** | `async function initAgents()` — returns `agents[]` of `{ id, name, description, capabilities, enabled }` |
|
|
|
|
| | `class AgentOrchestrator` — `constructor(agents)`, `execute(agentId, task, context)`, `getAgent(id)`, `listAgents()` |
|
|
|
|
| | `class AgentOrchestrator` — `constructor(agents)`, `execute(agentId, task, context)`, `getAgent(id)`, `listAgents()` |
|
|
|
|
| **Init** | `const agents = await initAgents()` |
|
|
|
|
| **Init** | `const agents = await initAgents()` |
|
|
|
|
@@ -103,7 +103,7 @@ zcode(options)
|
|
|
|
### 1.8 `src/bot/index.js`
|
|
|
|
### 1.8 `src/bot/index.js`
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/bot/index.js` |
|
|
|
|
| **Path** | `src/bot/index.js` |
|
|
|
|
| **Exported API** | `async function initBot(config, api, tools, skills)` — returns `{ send, ws, waitForMessages, getConnections }` |
|
|
|
|
| **Exported API** | `async function initBot(config, api, tools, skills)` — returns `{ send, ws, waitForMessages, getConnections }` |
|
|
|
|
| **Init** | `const bot = await import('./bot/index.js').then(m => m.initBot(config, api, tools, skills))` |
|
|
|
|
| **Init** | `const bot = await import('./bot/index.js').then(m => m.initBot(config, api, tools, skills))` |
|
|
|
|
| **Current state** | THIN: creates Express+WebSocket server, handles webhook POSTs, routes messages through ZAIProvider directly. Does NOT use tools/skills/agents params. |
|
|
|
|
| **Current state** | THIN: creates Express+WebSocket server, handles webhook POSTs, routes messages through ZAIProvider directly. Does NOT use tools/skills/agents params. |
|
|
|
|
@@ -112,7 +112,7 @@ zcode(options)
|
|
|
|
### 1.9 `src/utils/logger.js`
|
|
|
|
### 1.9 `src/utils/logger.js`
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/utils/logger.js` |
|
|
|
|
| **Path** | `src/utils/logger.js` |
|
|
|
|
| **Exported API** | `export const logger` — winston logger instance |
|
|
|
|
| **Exported API** | `export const logger` — winston logger instance |
|
|
|
|
| **Init** | Import and use directly: `import { logger } from '../utils/logger.js'` |
|
|
|
|
| **Init** | Import and use directly: `import { logger } from '../utils/logger.js'` |
|
|
|
|
| **Features** | Console transport (colorized), optional file transport via `LOG_FILE` env var |
|
|
|
|
| **Features** | Console transport (colorized), optional file transport via `LOG_FILE` env var |
|
|
|
|
@@ -120,7 +120,7 @@ zcode(options)
|
|
|
|
### 1.10 `src/utils/rtk.js`
|
|
|
|
### 1.10 `src/utils/rtk.js`
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/utils/rtk.js` |
|
|
|
|
| **Path** | `src/utils/rtk.js` |
|
|
|
|
| **Exported API** | `class RTKIntegration` — `init()`, `isCommandSupported(cmd)`, `optimizeCommand(command, args)`, `getTrackingStats()`, `listSupportedCommands()` |
|
|
|
|
| **Exported API** | `class RTKIntegration` — `init()`, `isCommandSupported(cmd)`, `optimizeCommand(command, args)`, `getTrackingStats()`, `listSupportedCommands()` |
|
|
|
|
| | `function getRTK()` — singleton factory |
|
|
|
|
| | `function getRTK()` — singleton factory |
|
|
|
|
| **Init** | `const rtk = getRTK(); await rtk.init()` |
|
|
|
|
| **Init** | `const rtk = getRTK(); await rtk.init()` |
|
|
|
|
@@ -135,7 +135,7 @@ These services exist in the Claude Code fork but are **not imported or used by t
|
|
|
|
### 2.1 Voice Service
|
|
|
|
### 2.1 Voice Service
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/services/voice.ts` |
|
|
|
|
| **Path** | `src/services/voice.ts` |
|
|
|
|
| **Exported API** | `startRecording(fallbackToSoX?)`, `stopRecording()`, `checkRecordingAvailability()` (need full export list) |
|
|
|
|
| **Exported API** | `startRecording(fallbackToSoX?)`, `stopRecording()`, `checkRecordingAvailability()` (need full export list) |
|
|
|
|
| **Init** | `import { startRecording, stopRecording } from '../services/voice.ts'` — no init, module-level state |
|
|
|
|
| **Init** | `import { startRecording, stopRecording } from '../services/voice.ts'` — no init, module-level state |
|
|
|
|
| **Dependencies** | `audio-capture-napi` (native), falls back to SoX/arecord on Linux |
|
|
|
|
| **Dependencies** | `audio-capture-napi` (native), falls back to SoX/arecord on Linux |
|
|
|
|
@@ -143,7 +143,7 @@ These services exist in the Claude Code fork but are **not imported or used by t
|
|
|
|
### 2.2 Cron Scheduler
|
|
|
|
### 2.2 Cron Scheduler
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/utils/cronScheduler.ts` |
|
|
|
|
| **Path** | `src/utils/cronScheduler.ts` |
|
|
|
|
| **Exported API** | `class CronScheduler` with options `{ onFire, isLoading, assistantMode }`, `start()`, `stop()` |
|
|
|
|
| **Exported API** | `class CronScheduler` with options `{ onFire, isLoading, assistantMode }`, `start()`, `stop()` |
|
|
|
|
| | `isRecurringTaskAged(t, nowMs, maxAgeMs)` |
|
|
|
|
| | `isRecurringTaskAged(t, nowMs, maxAgeMs)` |
|
|
|
|
| | `getSchedulerCheckDelayMs(nextFireAtMs, nowMs, options)` |
|
|
|
|
| | `getSchedulerCheckDelayMs(nextFireAtMs, nowMs, options)` |
|
|
|
|
@@ -153,7 +153,7 @@ These services exist in the Claude Code fork but are **not imported or used by t
|
|
|
|
### 2.3 MCP Validation
|
|
|
|
### 2.3 MCP Validation
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/utils/mcpValidation.ts` |
|
|
|
|
| **Path** | `src/utils/mcpValidation.ts` |
|
|
|
|
| **Exported API** | `getMaxMcpOutputTokens()`, `getContentSizeEstimate(content)`, `MCPToolResult` type |
|
|
|
|
| **Exported API** | `getMaxMcpOutputTokens()`, `getContentSizeEstimate(content)`, `MCPToolResult` type |
|
|
|
|
| | Internal: `truncateContentBlocks(blocks, maxChars)`, `truncateString(content, maxChars)` |
|
|
|
|
| | Internal: `truncateContentBlocks(blocks, maxChars)`, `truncateString(content, maxChars)` |
|
|
|
|
| **Init** | Import functions directly |
|
|
|
|
| **Init** | Import functions directly |
|
|
|
|
@@ -162,26 +162,26 @@ These services exist in the Claude Code fork but are **not imported or used by t
|
|
|
|
### 2.4 Memory System
|
|
|
|
### 2.4 Memory System
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/utils/memoryFileDetection.ts` |
|
|
|
|
| **Path** | `src/utils/memoryFileDetection.ts` |
|
|
|
|
| | `/home/uroma2/zcode-cli-x/src/memdir/memoryTypes.ts` |
|
|
|
|
| | `src/memdir/memoryTypes.ts` |
|
|
|
|
| | `/home/uroma2/zcode-cli-x/src/memdir/memoryScan.ts` |
|
|
|
|
| | `src/memdir/memoryScan.ts` |
|
|
|
|
| | `/home/uroma2/zcode-cli-x/src/memdir/memoryAge.ts` |
|
|
|
|
| | `src/memdir/memoryAge.ts` |
|
|
|
|
| **Exported API (memoryTypes.ts)** | `MEMORY_TYPES` (`['user', 'feedback', 'project', 'reference']`), `parseMemoryType(raw)` |
|
|
|
|
| **Exported API (memoryTypes.ts)** | `MEMORY_TYPES` (`['user', 'feedback', 'project', 'reference']`), `parseMemoryType(raw)` |
|
|
|
|
| | `TYPES_SECTION_COMBINED` (system prompt text), `TYPES_SECTION_PRIVATE` |
|
|
|
|
| | `TYPES_SECTION_COMBINED` (system prompt text), `TYPES_SECTION_PRIVATE` |
|
|
|
|
|
|
|
|
|
|
|
|
### 2.5 Context Compression (Compact)
|
|
|
|
### 2.5 Context Compression (Compact)
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/services/compact/compact.ts` (1706 lines) |
|
|
|
|
| **Path** | `src/services/compact/compact.ts` (1706 lines) |
|
|
|
|
| | `/home/uroma2/zcode-cli-x/src/services/compact/cachedMicrocompact.ts` |
|
|
|
|
| | `src/services/compact/cachedMicrocompact.ts` |
|
|
|
|
| | `/home/uroma2/zcode-cli-x/src/services/compact/apiMicrocompact.ts` |
|
|
|
|
| | `src/services/compact/apiMicrocompact.ts` |
|
|
|
|
| | `/home/uroma2/zcode-cli-x/src/services/compact/compactWarningState.ts` |
|
|
|
|
| | `src/services/compact/compactWarningState.ts` |
|
|
|
|
| **Init** | Deeply integrated into the main loop (`main.tsx`/`query.ts`). Not standalone. |
|
|
|
|
| **Init** | Deeply integrated into the main loop (`main.tsx`/`query.ts`). Not standalone. |
|
|
|
|
|
|
|
|
|
|
|
|
### 2.6 Tool Orchestration
|
|
|
|
### 2.6 Tool Orchestration
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/services/tools/toolOrchestration.ts` |
|
|
|
|
| **Path** | `src/services/tools/toolOrchestration.ts` |
|
|
|
|
| **Exported API** | `runTools(toolUseMessages, assistantMessages, canUseTool, toolUseContext)` — async generator |
|
|
|
|
| **Exported API** | `runTools(toolUseMessages, assistantMessages, canUseTool, toolUseContext)` — async generator |
|
|
|
|
| | `DEFAULT_MAX_TOOL_USE_CONCURRENCY`, `getMaxToolUseConcurrency()` |
|
|
|
|
| | `DEFAULT_MAX_TOOL_USE_CONCURRENCY`, `getMaxToolUseConcurrency()` |
|
|
|
|
| **Dependencies** | `toolExecution.ts`, `toolConcurrency.ts`, `StreamingToolExecutor.ts`, `toolHooks.ts` |
|
|
|
|
| **Dependencies** | `toolExecution.ts`, `toolConcurrency.ts`, `StreamingToolExecutor.ts`, `toolHooks.ts` |
|
|
|
|
@@ -189,7 +189,7 @@ These services exist in the Claude Code fork but are **not imported or used by t
|
|
|
|
### 2.7 Team Memory Sync
|
|
|
|
### 2.7 Team Memory Sync
|
|
|
|
| Field | Value |
|
|
|
|
| Field | Value |
|
|
|
|
|-------|-------|
|
|
|
|
|-------|-------|
|
|
|
|
| **Path** | `/home/uroma2/zcode-cli-x/src/services/teamMemorySync/index.ts` |
|
|
|
|
| **Path** | `src/services/teamMemorySync/index.ts` |
|
|
|
|
| **Exported API** | Sync service for team memory files between local FS and server API |
|
|
|
|
| **Exported API** | Sync service for team memory files between local FS and server API |
|
|
|
|
| **Dependencies** | Axios, OAuth, git remote, secret scanner |
|
|
|
|
| **Dependencies** | Axios, OAuth, git remote, secret scanner |
|
|
|
|
|
|
|
|
|
|
|
|
|