Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 35 additions & 26 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Repository Guidelines

**Generated:** 2026-01-04 | **Commit:** 649f42a | **Branch:** main

## Project Structure

```
Expand Down Expand Up @@ -102,12 +104,12 @@ Location: `~/.local/bin/<variant>`

### Provider Auth Modes

| Provider | Auth Mode | Key Variable |
|----------|-----------|--------------|
| zai, minimax, custom | API Key | `ANTHROPIC_API_KEY` |
| openrouter | Auth Token | `ANTHROPIC_AUTH_TOKEN` |
| ccrouter | Optional | placeholder token |
| mirror | None | user authenticates normally |
| Provider | Auth Mode | Key Variable |
| -------------------- | ---------- | --------------------------- |
| zai, minimax, custom | API Key | `ANTHROPIC_API_KEY` |
| openrouter | Auth Token | `ANTHROPIC_AUTH_TOKEN` |
| ccrouter | Optional | placeholder token |
| mirror | None | user authenticates normally |

### Model Mapping (env vars)

Expand All @@ -118,14 +120,18 @@ Location: `~/.local/bin/<variant>`

## Team Mode

Team mode patches `cli.js` to enable Task* tools for multi-agent collaboration.
Team mode patches `cli.js` to enable Task\* tools for multi-agent collaboration.

### How It Works

```javascript
// Target function in cli.js
function sU() { return !1; } // disabled (default)
function sU() { return !0; } // enabled (patched)
function sU() {
return !1;
} // disabled (default)
function sU() {
return !0;
} // enabled (patched)
```

- Backup stored at `cli.js.backup` before patching
Expand All @@ -140,31 +146,33 @@ function sU() { return !0; } // enabled (patched)

### Agent Identity Env Vars

| Variable | Purpose |
|----------|---------|
| `CLAUDE_CODE_TEAM_NAME` | Team namespace for task storage |
| `CLAUDE_CODE_AGENT_ID` | Unique identifier for this agent |
| Variable | Purpose |
| ------------------------ | ----------------------------------- |
| `CLAUDE_CODE_TEAM_NAME` | Team namespace for task storage |
| `CLAUDE_CODE_AGENT_ID` | Unique identifier for this agent |
| `CLAUDE_CODE_AGENT_TYPE` | Agent role: `team-lead` or `worker` |

## Provider Blocked Tools

Providers can block tools via TweakCC toolsets. Defined in `src/brands/*.ts`.

**zai blocked tools:**

```typescript
export const ZAI_BLOCKED_TOOLS = [
'mcp__4_5v_mcp__analyze_image', // Server-injected
'mcp__4_5v_mcp__analyze_image', // Server-injected
'mcp__milk_tea_server__claim_milk_tea_coupon',
'mcp__web_reader__webReader',
'WebSearch', // Use zai-cli search
'WebFetch', // Use zai-cli read
'WebSearch', // Use zai-cli search
'WebFetch', // Use zai-cli read
];
```

**minimax blocked tools:**

```typescript
export const MINIMAX_BLOCKED_TOOLS = [
'WebSearch', // Use mcp__MiniMax__web_search
'WebSearch', // Use mcp__MiniMax__web_search
];
```

Expand All @@ -179,15 +187,15 @@ export const MINIMAX_BLOCKED_TOOLS = [

## Common Development Tasks

| Task | Location |
|------|----------|
| Add/update provider | `src/providers/index.ts` |
| Add/update brand theme | `src/brands/*.ts` |
| Add blocked tools | `src/brands/zai.ts` or `minimax.ts` → `*_BLOCKED_TOOLS` |
| Modify prompt pack overlays | `src/core/prompt-pack/providers/*.ts` |
| Add build step | `src/core/variant-builder/steps/` |
| Add TUI screen | `src/tui/screens/` + `app.tsx` + `router/routes.ts` |
| Add team pack prompt | `src/team-pack/*.md` + `TEAM_PACK_FILES` in `index.ts` |
| Task | Location |
| --------------------------- | ------------------------------------------------------- |
| Add/update provider | `src/providers/index.ts` |
| Add/update brand theme | `src/brands/*.ts` |
| Add blocked tools | `src/brands/zai.ts` or `minimax.ts` → `*_BLOCKED_TOOLS` |
| Modify prompt pack overlays | `src/core/prompt-pack/providers/*.ts` |
| Add build step | `src/core/variant-builder/steps/` |
| Add TUI screen | `src/tui/screens/` + `app.tsx` + `router/routes.ts` |
| Add team pack prompt | `src/team-pack/*.md` + `TEAM_PACK_FILES` in `index.ts` |

## Debugging & Verification

Expand Down Expand Up @@ -277,6 +285,7 @@ npm test -- --test-name-pattern="TUI" # TUI tests only
```

Key test files:

- `test/e2e/creation.test.ts` - Variant creation for all providers
- `test/e2e/team-mode.test.ts` - Team mode + team pack
- `test/e2e/blocked-tools.test.ts` - Provider blocked tools
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions src/core/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Core Module

Public API for variant management. All CLI/TUI operations flow through `index.ts`.

## Public API

| Export | Purpose |
| ------------------------------------------ | -------------------------------------------------------- |
| `createVariant()` / `createVariantAsync()` | Build new variant (sync for CLI, async for TUI progress) |
| `updateVariant()` / `updateVariantAsync()` | Reinstall npm + reapply config |
| `removeVariant()` | Delete variant directory |
| `doctor()` | Health check all variants |
| `listVariants()` | Enumerate `~/.cc-mirror/` |
| `tweakVariant()` | Launch tweakcc UI |

## Module Map

| File | Role |
| ------------------ | -------------------------------------------------- |
| `constants.ts` | `DEFAULT_ROOT`, `DEFAULT_BIN_DIR`, `DEFAULT_NPM_*` |
| `paths.ts` | `expandTilde()` helper |
| `fs.ts` | `ensureDir()`, `writeJsonFile()` |
| `variants.ts` | Load/list variant metadata |
| `wrapper.ts` | Generate wrapper shell scripts |
| `tweakcc.ts` | TweakCC config management |
| `claude-config.ts` | `.claude.json` generation |
| `install.ts` | npm package installation |
| `prompt-pack.ts` | Provider prompt overlay resolution |
| `skills.ts` | Skill installation (dev-browser) |
| `shell-env.ts` | Write API keys to shell profile |

## Subdirectories

- `variant-builder/` - Step-based build orchestration (see its AGENTS.md)
- `prompt-pack/` - Per-provider system prompt overlays

## Conventions

- Sync functions for CLI, async variants for TUI (yields to event loop)
- All paths resolved via `expandTilde()` before use
- Errors thrown as `Error` with descriptive message
2 changes: 2 additions & 0 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import type {

export { DEFAULT_ROOT, DEFAULT_BIN_DIR, DEFAULT_NPM_PACKAGE, DEFAULT_NPM_VERSION };
export { expandTilde } from './paths.js';
export { syncVariants, syncVariantsAsync, createConfigBackup, restoreConfigBackup } from './sync.js';
export type { SyncItem, SyncOptions, SyncResult, SyncItemResult } from './sync.js';

export const createVariant = (params: CreateVariantParams): CreateVariantResult => {
return new VariantBuilder(false).build(params);
Expand Down
Loading