zerg-ztc 0.1.11 → 0.1.12

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.
Files changed (122) hide show
  1. package/bin/ztc-audio-darwin-arm64 +0 -0
  2. package/dist/utils/dictation_native.d.ts.map +1 -1
  3. package/dist/utils/dictation_native.js +43 -23
  4. package/dist/utils/dictation_native.js.map +1 -1
  5. package/package.json +5 -4
  6. package/packages/ztc-dictation/Cargo.toml +0 -43
  7. package/packages/ztc-dictation/README.md +0 -65
  8. package/packages/ztc-dictation/index.d.ts +0 -16
  9. package/packages/ztc-dictation/index.js +0 -74
  10. package/packages/ztc-dictation/package.json +0 -41
  11. package/packages/ztc-dictation/src/main.rs +0 -430
  12. package/src/App.tsx +0 -910
  13. package/src/agent/agent.ts +0 -534
  14. package/src/agent/backends/anthropic.ts +0 -86
  15. package/src/agent/backends/gemini.ts +0 -119
  16. package/src/agent/backends/inception.ts +0 -23
  17. package/src/agent/backends/index.ts +0 -17
  18. package/src/agent/backends/openai.ts +0 -23
  19. package/src/agent/backends/openai_compatible.ts +0 -143
  20. package/src/agent/backends/types.ts +0 -83
  21. package/src/agent/commands/clipboard.ts +0 -77
  22. package/src/agent/commands/config.ts +0 -204
  23. package/src/agent/commands/debug.ts +0 -23
  24. package/src/agent/commands/dictation.ts +0 -11
  25. package/src/agent/commands/emulation.ts +0 -80
  26. package/src/agent/commands/execution.ts +0 -9
  27. package/src/agent/commands/help.ts +0 -20
  28. package/src/agent/commands/history.ts +0 -13
  29. package/src/agent/commands/index.ts +0 -48
  30. package/src/agent/commands/input_mode.ts +0 -22
  31. package/src/agent/commands/keybindings.ts +0 -40
  32. package/src/agent/commands/model.ts +0 -11
  33. package/src/agent/commands/models.ts +0 -116
  34. package/src/agent/commands/permissions.ts +0 -64
  35. package/src/agent/commands/retry.ts +0 -9
  36. package/src/agent/commands/shell.ts +0 -68
  37. package/src/agent/commands/skills.ts +0 -54
  38. package/src/agent/commands/status.ts +0 -19
  39. package/src/agent/commands/types.ts +0 -88
  40. package/src/agent/commands/update.ts +0 -32
  41. package/src/agent/factory.ts +0 -60
  42. package/src/agent/index.ts +0 -20
  43. package/src/agent/runtime/capabilities.ts +0 -7
  44. package/src/agent/runtime/memory.ts +0 -23
  45. package/src/agent/runtime/policy.ts +0 -48
  46. package/src/agent/runtime/session.ts +0 -18
  47. package/src/agent/runtime/tracing.ts +0 -23
  48. package/src/agent/tools/file.ts +0 -178
  49. package/src/agent/tools/index.ts +0 -52
  50. package/src/agent/tools/screenshot.ts +0 -821
  51. package/src/agent/tools/search.ts +0 -138
  52. package/src/agent/tools/shell.ts +0 -69
  53. package/src/agent/tools/skills.ts +0 -28
  54. package/src/agent/tools/types.ts +0 -14
  55. package/src/agent/tools/zerg.ts +0 -50
  56. package/src/cli.tsx +0 -163
  57. package/src/components/ActivityLine.tsx +0 -23
  58. package/src/components/FullScreen.tsx +0 -79
  59. package/src/components/Header.tsx +0 -27
  60. package/src/components/InputArea.tsx +0 -1660
  61. package/src/components/MessageList.tsx +0 -71
  62. package/src/components/SingleMessage.tsx +0 -298
  63. package/src/components/StatusBar.tsx +0 -55
  64. package/src/components/index.tsx +0 -8
  65. package/src/config/types.ts +0 -19
  66. package/src/config.ts +0 -186
  67. package/src/debug/logger.ts +0 -14
  68. package/src/emulation/README.md +0 -24
  69. package/src/emulation/catalog.ts +0 -82
  70. package/src/emulation/trace_style.ts +0 -8
  71. package/src/emulation/types.ts +0 -7
  72. package/src/skills/index.ts +0 -36
  73. package/src/skills/loader.ts +0 -135
  74. package/src/skills/registry.ts +0 -6
  75. package/src/skills/types.ts +0 -10
  76. package/src/types.ts +0 -84
  77. package/src/ui/README.md +0 -44
  78. package/src/ui/core/factory.ts +0 -9
  79. package/src/ui/core/index.ts +0 -4
  80. package/src/ui/core/input.ts +0 -38
  81. package/src/ui/core/input_segments.ts +0 -410
  82. package/src/ui/core/input_state.ts +0 -17
  83. package/src/ui/core/layout_yoga.ts +0 -122
  84. package/src/ui/core/style.ts +0 -38
  85. package/src/ui/core/types.ts +0 -54
  86. package/src/ui/ink/index.tsx +0 -1
  87. package/src/ui/ink/render.tsx +0 -60
  88. package/src/ui/views/activity_line.ts +0 -33
  89. package/src/ui/views/app.ts +0 -111
  90. package/src/ui/views/header.ts +0 -44
  91. package/src/ui/views/input_area.ts +0 -255
  92. package/src/ui/views/message_list.ts +0 -443
  93. package/src/ui/views/status_bar.ts +0 -114
  94. package/src/ui/vue/index.ts +0 -53
  95. package/src/ui/web/frame_render.tsx +0 -148
  96. package/src/ui/web/index.tsx +0 -1
  97. package/src/ui/web/render.tsx +0 -41
  98. package/src/utils/clipboard.ts +0 -39
  99. package/src/utils/clipboard_image.ts +0 -40
  100. package/src/utils/dictation.ts +0 -467
  101. package/src/utils/dictation_native.ts +0 -258
  102. package/src/utils/diff.ts +0 -52
  103. package/src/utils/image_preview.ts +0 -36
  104. package/src/utils/models.ts +0 -98
  105. package/src/utils/path_complete.ts +0 -173
  106. package/src/utils/path_format.ts +0 -99
  107. package/src/utils/shell.ts +0 -72
  108. package/src/utils/spinner_frames.ts +0 -1
  109. package/src/utils/spinner_verbs.ts +0 -23
  110. package/src/utils/table.ts +0 -171
  111. package/src/utils/tool_summary.ts +0 -56
  112. package/src/utils/tool_trace.ts +0 -346
  113. package/src/utils/update.ts +0 -44
  114. package/src/utils/version.ts +0 -15
  115. package/src/web/index.html +0 -352
  116. package/src/web/mirror-favicon.svg +0 -4
  117. package/src/web/mirror.html +0 -641
  118. package/src/web/mirror_hook.ts +0 -25
  119. package/src/web/mirror_server.ts +0 -204
  120. package/tsconfig.json +0 -22
  121. package/vite.config.ts +0 -363
  122. /package/{packages/ztc-dictation/bin → bin}/.gitkeep +0 -0
@@ -1,82 +0,0 @@
1
- import { readFileSync, existsSync } from 'fs';
2
- import { resolve, join } from 'path';
3
- import { fileURLToPath } from 'url';
4
- import { homedir } from 'os';
5
- import { EmulationProfile } from './types.js';
6
-
7
- interface EmulationSource {
8
- id: string;
9
- name: string;
10
- description: string;
11
- promptPath: string;
12
- toolsPath?: string;
13
- }
14
-
15
- const sources: EmulationSource[] = [
16
- {
17
- id: 'claude-code',
18
- name: 'Claude Code',
19
- description: 'Anthropic Claude Code CLI emulation',
20
- promptPath: 'Anthropic/Claude Code/Prompt.txt',
21
- toolsPath: 'Anthropic/Claude Code/Tools.json'
22
- },
23
- {
24
- id: 'codex-cli-system',
25
- name: 'Codex CLI (System Prompt 2025-08-20)',
26
- description: 'OpenAI Codex CLI system prompt emulation',
27
- promptPath: 'Open Source prompts/Codex CLI/openai-codex-cli-system-prompt-20250820.txt'
28
- },
29
- {
30
- id: 'codex-cli',
31
- name: 'Codex CLI (Prompt)',
32
- description: 'OpenAI Codex CLI prompt emulation',
33
- promptPath: 'Open Source prompts/Codex CLI/Prompt.txt'
34
- }
35
- ];
36
-
37
- function resolveBaseDir(): string {
38
- const override = process.env.ZTC_EMULATION_DIR;
39
- if (override && override.trim().length > 0) {
40
- return resolve(override);
41
- }
42
- const candidates = [
43
- join(homedir(), '.ztc', 'emulations', 'x1xhlol'),
44
- resolve(process.cwd(), 'emulations/x1xhlol'),
45
- resolve(process.cwd(), 'ztc/emulations/x1xhlol'),
46
- resolve(fileURLToPath(new URL('../../emulations/x1xhlol', import.meta.url)))
47
- ];
48
- for (const candidate of candidates) {
49
- if (existsSync(candidate)) {
50
- return candidate;
51
- }
52
- }
53
- return candidates[0];
54
- }
55
-
56
- export function loadEmulationProfiles(): EmulationProfile[] {
57
- const baseDir = resolveBaseDir();
58
-
59
- return sources.flatMap(source => {
60
- const promptFile = resolve(baseDir, source.promptPath);
61
- if (!existsSync(promptFile)) {
62
- return [];
63
- }
64
- const prompt = readFileSync(promptFile, 'utf-8');
65
- const toolsFile = source.toolsPath ? resolve(baseDir, source.toolsPath) : undefined;
66
- const tools = toolsFile && existsSync(toolsFile)
67
- ? JSON.parse(readFileSync(toolsFile, 'utf-8'))
68
- : undefined;
69
-
70
- return [{
71
- id: source.id,
72
- name: source.name,
73
- description: source.description,
74
- systemPrompt: prompt,
75
- tools
76
- }];
77
- });
78
- }
79
-
80
- export function getEmulationProfile(id: string): EmulationProfile | undefined {
81
- return loadEmulationProfiles().find(profile => profile.id === id);
82
- }
@@ -1,8 +0,0 @@
1
- export type TraceStyle = 'claude_code' | 'codex' | 'plain';
2
-
3
- export function getTraceStyle(emulationId?: string): TraceStyle {
4
- if (!emulationId) return 'plain';
5
- if (emulationId === 'claude-code') return 'claude_code';
6
- if (emulationId.startsWith('codex')) return 'codex';
7
- return 'plain';
8
- }
@@ -1,7 +0,0 @@
1
- export interface EmulationProfile {
2
- id: string;
3
- name: string;
4
- description: string;
5
- systemPrompt: string;
6
- tools?: Record<string, unknown>;
7
- }
@@ -1,36 +0,0 @@
1
- import { Skill } from './types.js';
2
-
3
- export function buildSkillPrompt(skills: Skill[]): string {
4
- if (skills.length === 0) return '';
5
- const blocks = skills.map(skill => {
6
- const header = `Skill: ${skill.name}`;
7
- const description = skill.description ? `Description: ${skill.description}` : '';
8
- const instructions = skill.instructions.trim();
9
- return [header, description, instructions].filter(Boolean).join('\n');
10
- });
11
- return ['# Skills', ...blocks].join('\n\n');
12
- }
13
-
14
- export function autoActivateSkills(message: string, skills: Skill[]): Skill[] {
15
- const haystack = message.toLowerCase();
16
- return skills.filter(skill => {
17
- const name = skill.name.toLowerCase();
18
- const id = skill.id.toLowerCase();
19
- if (haystack.includes(name) || haystack.includes(id)) return true;
20
- if (skill.keywords) {
21
- return skill.keywords.some(keyword => haystack.includes(keyword.toLowerCase()));
22
- }
23
- return false;
24
- });
25
- }
26
-
27
- export function formatSkillList(skills: Skill[]): string {
28
- if (skills.length === 0) return 'No skills found.';
29
- const lines = skills
30
- .sort((a, b) => a.name.localeCompare(b.name))
31
- .map(skill => {
32
- const source = skill.sourceRoot.includes('.claude') ? 'claude' : 'ztc';
33
- return ` ${skill.id} - ${skill.name}${skill.description ? `: ${skill.description}` : ''} (${source})`;
34
- });
35
- return ['Available skills:', ...lines].join('\n');
36
- }
@@ -1,135 +0,0 @@
1
- import { homedir } from 'os';
2
- import { join, resolve, basename } from 'path';
3
- import { readdir, readFile, stat } from 'fs/promises';
4
-
5
- import { Skill } from './types.js';
6
-
7
- const MAX_DEPTH = 4;
8
-
9
- function defaultRoots(): string[] {
10
- const home = homedir();
11
- return [
12
- join(home, '.ztc', 'skills'),
13
- join(home, '.claude', 'skills'),
14
- join(process.cwd(), '.ztc', 'skills'),
15
- join(process.cwd(), '.claude', 'skills')
16
- ];
17
- }
18
-
19
- async function walk(dir: string, depth = 0): Promise<string[]> {
20
- if (depth > MAX_DEPTH) return [];
21
- try {
22
- const entries = await readdir(dir, { withFileTypes: true });
23
- const results: string[] = [];
24
- for (const entry of entries) {
25
- if (entry.name.startsWith('.')) continue;
26
- const full = join(dir, entry.name);
27
- if (entry.isDirectory()) {
28
- results.push(...await walk(full, depth + 1));
29
- } else if (entry.isFile() && entry.name.toLowerCase() === 'skill.md') {
30
- results.push(full);
31
- }
32
- }
33
- return results;
34
- } catch {
35
- return [];
36
- }
37
- }
38
-
39
- function parseFrontmatter(content: string): { meta: Record<string, unknown>; body: string } {
40
- if (!content.startsWith('---')) {
41
- return { meta: {}, body: content };
42
- }
43
- const end = content.indexOf('\n---', 3);
44
- if (end === -1) return { meta: {}, body: content };
45
-
46
- const metaBlock = content.slice(3, end).trim();
47
- const body = content.slice(end + 4).trim();
48
- const meta: Record<string, unknown> = {};
49
- let currentKey: string | null = null;
50
-
51
- for (const line of metaBlock.split('\n')) {
52
- if (!line.trim()) continue;
53
- if (line.startsWith(' -') || line.startsWith('- ')) {
54
- if (!currentKey) continue;
55
- const value = line.replace(/^(\s*-)\s*/, '').trim();
56
- const list = Array.isArray(meta[currentKey]) ? meta[currentKey] as string[] : [];
57
- list.push(value);
58
- meta[currentKey] = list;
59
- continue;
60
- }
61
- const idx = line.indexOf(':');
62
- if (idx === -1) continue;
63
- const key = line.slice(0, idx).trim();
64
- let value = line.slice(idx + 1).trim();
65
- if (value.startsWith('[') && value.endsWith(']')) {
66
- value = value.slice(1, -1);
67
- meta[key] = value.split(',').map(item => item.trim()).filter(Boolean);
68
- } else if (value) {
69
- meta[key] = value;
70
- } else {
71
- meta[key] = [];
72
- currentKey = key;
73
- continue;
74
- }
75
- currentKey = key;
76
- }
77
-
78
- return { meta, body };
79
- }
80
-
81
- function normalizeList(value?: unknown): string[] | undefined {
82
- if (!value) return undefined;
83
- if (Array.isArray(value)) {
84
- return value.map(item => String(item)).filter(Boolean);
85
- }
86
- if (typeof value === 'string') {
87
- return value.split(',').map(item => item.trim()).filter(Boolean);
88
- }
89
- return undefined;
90
- }
91
-
92
- function deriveSkillId(path: string, meta: Record<string, unknown>): string {
93
- const explicit = meta.id ? String(meta.id) : '';
94
- if (explicit) return explicit;
95
- const name = meta.name ? String(meta.name) : '';
96
- if (name) return name.toLowerCase().replace(/\s+/g, '-');
97
- return basename(resolve(path, '..')) || 'skill';
98
- }
99
-
100
- export async function loadSkills(roots: string[] = defaultRoots()): Promise<Skill[]> {
101
- const files = new Set<string>();
102
- for (const root of roots) {
103
- const paths = await walk(root);
104
- for (const path of paths) files.add(path);
105
- }
106
-
107
- const skills: Skill[] = [];
108
- for (const filePath of files) {
109
- try {
110
- const content = await readFile(filePath, 'utf-8');
111
- const { meta, body } = parseFrontmatter(content);
112
- const id = deriveSkillId(filePath, meta);
113
- const name = meta.name ? String(meta.name) : id;
114
- const description = meta.description ? String(meta.description) : undefined;
115
- const allowedTools = normalizeList(meta['allowed-tools'] || meta.allowed_tools || meta.allowedTools);
116
- const keywords = normalizeList(meta.keywords);
117
- const root = roots.find(r => filePath.startsWith(resolve(r))) || resolve(filePath, '..');
118
- await stat(filePath);
119
- skills.push({
120
- id,
121
- name,
122
- description,
123
- instructions: body.trim(),
124
- allowedTools,
125
- keywords,
126
- sourcePath: filePath,
127
- sourceRoot: root
128
- });
129
- } catch {
130
- // skip unreadable skills
131
- }
132
- }
133
-
134
- return skills;
135
- }
@@ -1,6 +0,0 @@
1
- import { loadSkills } from './loader.js';
2
- import { Skill } from './types.js';
3
-
4
- export async function getSkillRegistry(): Promise<Skill[]> {
5
- return loadSkills();
6
- }
@@ -1,10 +0,0 @@
1
- export interface Skill {
2
- id: string;
3
- name: string;
4
- description?: string;
5
- instructions: string;
6
- allowedTools?: string[];
7
- keywords?: string[];
8
- sourcePath: string;
9
- sourceRoot: string;
10
- }
package/src/types.ts DELETED
@@ -1,84 +0,0 @@
1
- // ==========================================
2
- // ZTC Type Definitions
3
- // ==========================================
4
-
5
- export type MessageRole = 'user' | 'assistant' | 'tool' | 'system';
6
-
7
- export type ToolStatus = 'pending' | 'running' | 'complete' | 'error';
8
-
9
- export type AgentStatus = 'idle' | 'thinking' | 'tool_use' | 'streaming' | 'error';
10
- export type InputMode = 'queue' | 'interrupt';
11
-
12
- export interface ToolCall {
13
- id: string;
14
- name: string;
15
- args: Record<string, unknown>;
16
- status: ToolStatus;
17
- result?: string;
18
- error?: string;
19
- startedAt?: Date;
20
- completedAt?: Date;
21
- }
22
-
23
- export interface Message {
24
- id: string;
25
- role: MessageRole;
26
- content: string;
27
- timestamp: Date;
28
- toolCalls?: ToolCall[];
29
- isStreaming?: boolean;
30
- metadata?: Record<string, unknown>;
31
- }
32
-
33
- export interface AgentState {
34
- status: AgentStatus;
35
- currentTool?: string;
36
- tokensUsed?: number;
37
- contextTokens?: number;
38
- tokensEstimated?: boolean;
39
- authError?: boolean;
40
- error?: string;
41
- startedAt?: Date;
42
- }
43
-
44
- export interface Session {
45
- id: string;
46
- createdAt: Date;
47
- messages: Message[];
48
- metadata?: Record<string, unknown>;
49
- }
50
-
51
- export interface ZTCConfig {
52
- zergEndpoint?: string;
53
- maxTokens?: number;
54
- timeout?: number;
55
- tools?: string[];
56
- }
57
-
58
- // Tool definition for the agent
59
- export interface ToolDefinition {
60
- name: string;
61
- description: string;
62
- parameters: {
63
- type: 'object';
64
- properties: Record<string, {
65
- type: string;
66
- description: string;
67
- enum?: string[];
68
- }>;
69
- required?: string[];
70
- };
71
- }
72
-
73
- // Events emitted during agent execution
74
- export type AgentEvent =
75
- | { type: 'thinking_start' }
76
- | { type: 'thinking_end' }
77
- | { type: 'tool_start'; tool: string; args: Record<string, unknown> }
78
- | { type: 'tool_end'; tool: string; result: string }
79
- | { type: 'tool_error'; tool: string; error: string }
80
- | { type: 'stream_start' }
81
- | { type: 'stream_delta'; content: string }
82
- | { type: 'stream_end' }
83
- | { type: 'token_usage'; usage: { inputTokens: number; outputTokens: number; totalTokens: number; estimated?: boolean } }
84
- | { type: 'error'; error: string };
package/src/ui/README.md DELETED
@@ -1,44 +0,0 @@
1
- ## UI Architecture (Renderer-Agnostic)
2
-
3
- This directory defines a shared, renderer-agnostic UI tree for ZTC and thin adapters for Ink (CLI), Web (React DOM), and Vue.
4
-
5
- ### Goals
6
- - Single source of truth for layout and UI structure.
7
- - Pixel-aligned monospace rendering in the browser.
8
- - Optional Yoga integration for layout parity with Ink.
9
-
10
- ### Structure
11
- - `core/`: layout tree types + helpers
12
- - `ink/`: Ink renderer adapter
13
- - `web/`: React DOM renderer adapter
14
- - `vue/`: Vue adapter (no Vue dependency; pass `h()` from your app)
15
-
16
- ### Core Tree
17
- The UI is expressed as a `LayoutNode` tree:
18
- - `box` nodes with flex and spacing styles
19
- - `text` nodes with basic text styles
20
-
21
- This keeps the model portable across Ink/DOM/Vue.
22
-
23
- ### Renderers
24
- - **Ink** uses `Box`/`Text` directly.
25
- - **Web** renders to `div`/`span` with strict monospace styles to match terminal layout.
26
- - **Vue** uses a tiny helper `renderToVue(h, node)` that returns VNodes.
27
-
28
- ### Nuxt/Vue Integration
29
- Because `vue/` does not import Vue directly, you can pass Nuxt's `h`:
30
-
31
- ```ts
32
- import { renderToVue } from '~/ui/vue';
33
-
34
- export default {
35
- render() {
36
- return renderToVue(this.$createElement, nodeTree);
37
- }
38
- };
39
- ```
40
-
41
- ### Next Steps
42
- - Add Yoga-backed layout engine in `core/` for exact Ink parity.
43
- - Move existing Ink UI components to build `LayoutNode` trees.
44
- - Create a web mirror route that renders the same tree for debugging.
@@ -1,9 +0,0 @@
1
- import { BoxNode, LayoutNode, TextNode } from './types.js';
2
-
3
- export function box(children: LayoutNode[] = [], style?: BoxNode['style']): BoxNode {
4
- return { type: 'box', children, style };
5
- }
6
-
7
- export function text(content: string, style?: TextNode['style']): TextNode {
8
- return { type: 'text', text: content, style };
9
- }
@@ -1,4 +0,0 @@
1
- export type { LayoutNode, BoxNode, TextNode, Style, TextStyle } from './types.js';
2
- export { box, text } from './factory.js';
3
- export { toCssStyle } from './style.js';
4
- export { computeLayout, type LayoutFrame } from './layout_yoga.js';
@@ -1,38 +0,0 @@
1
- export interface InputKey {
2
- return?: boolean;
3
- shift?: boolean;
4
- upArrow?: boolean;
5
- downArrow?: boolean;
6
- leftArrow?: boolean;
7
- rightArrow?: boolean;
8
- ctrl?: boolean;
9
- meta?: boolean;
10
- backspace?: boolean;
11
- delete?: boolean;
12
- }
13
-
14
- export interface InputEvent {
15
- input: string;
16
- key: InputKey;
17
- }
18
-
19
- export interface InputBus {
20
- subscribe(handler: (event: InputEvent) => void): () => void;
21
- emit(event: InputEvent): void;
22
- }
23
-
24
- export function createInputBus(): InputBus {
25
- const handlers = new Set<(event: InputEvent) => void>();
26
-
27
- return {
28
- subscribe(handler) {
29
- handlers.add(handler);
30
- return () => handlers.delete(handler);
31
- },
32
- emit(event) {
33
- for (const handler of handlers) {
34
- handler(event);
35
- }
36
- }
37
- };
38
- }