overarch-linux-x64 0.8.0

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 (127) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +214 -0
  3. package/dist/bin/overarch.d.ts +2 -0
  4. package/dist/bin/overarch.js +178 -0
  5. package/dist/src/agent/context.d.ts +14 -0
  6. package/dist/src/agent/context.js +200 -0
  7. package/dist/src/agent/context_compressor.d.ts +21 -0
  8. package/dist/src/agent/context_compressor.js +90 -0
  9. package/dist/src/agent/manifest.d.ts +22 -0
  10. package/dist/src/agent/manifest.js +131 -0
  11. package/dist/src/agent/planner.d.ts +38 -0
  12. package/dist/src/agent/planner.js +118 -0
  13. package/dist/src/agent/runtime.d.ts +59 -0
  14. package/dist/src/agent/runtime.js +400 -0
  15. package/dist/src/cli/approval.d.ts +13 -0
  16. package/dist/src/cli/approval.js +71 -0
  17. package/dist/src/cli/args.d.ts +15 -0
  18. package/dist/src/cli/args.js +47 -0
  19. package/dist/src/cli/commands/audit.d.ts +10 -0
  20. package/dist/src/cli/commands/audit.js +79 -0
  21. package/dist/src/cli/commands/companion.d.ts +1 -0
  22. package/dist/src/cli/commands/companion.js +143 -0
  23. package/dist/src/cli/commands/config.d.ts +1 -0
  24. package/dist/src/cli/commands/config.js +135 -0
  25. package/dist/src/cli/commands/doctor.d.ts +1 -0
  26. package/dist/src/cli/commands/doctor.js +217 -0
  27. package/dist/src/cli/commands/init.d.ts +1 -0
  28. package/dist/src/cli/commands/init.js +134 -0
  29. package/dist/src/cli/commands/memory.d.ts +2 -0
  30. package/dist/src/cli/commands/memory.js +98 -0
  31. package/dist/src/cli/commands/onboarding.d.ts +3 -0
  32. package/dist/src/cli/commands/onboarding.js +223 -0
  33. package/dist/src/cli/commands/sessions.d.ts +1 -0
  34. package/dist/src/cli/commands/sessions.js +22 -0
  35. package/dist/src/cli/commands/status.d.ts +1 -0
  36. package/dist/src/cli/commands/status.js +37 -0
  37. package/dist/src/cli/commands/update.d.ts +9 -0
  38. package/dist/src/cli/commands/update.js +105 -0
  39. package/dist/src/cli/repl.d.ts +3 -0
  40. package/dist/src/cli/repl.js +821 -0
  41. package/dist/src/cli/ui.d.ts +53 -0
  42. package/dist/src/cli/ui.js +215 -0
  43. package/dist/src/companion/petdex_adapter.d.ts +31 -0
  44. package/dist/src/companion/petdex_adapter.js +171 -0
  45. package/dist/src/companion/petdex_bridge.d.ts +65 -0
  46. package/dist/src/companion/petdex_bridge.js +356 -0
  47. package/dist/src/companion/types.d.ts +57 -0
  48. package/dist/src/companion/types.js +11 -0
  49. package/dist/src/config/index.d.ts +24 -0
  50. package/dist/src/config/index.js +237 -0
  51. package/dist/src/config/types.d.ts +58 -0
  52. package/dist/src/config/types.js +7 -0
  53. package/dist/src/core/diagnostics.d.ts +48 -0
  54. package/dist/src/core/diagnostics.js +115 -0
  55. package/dist/src/core/index.d.ts +23 -0
  56. package/dist/src/core/index.js +23 -0
  57. package/dist/src/core/mission.d.ts +55 -0
  58. package/dist/src/core/mission.js +173 -0
  59. package/dist/src/index.d.ts +1 -0
  60. package/dist/src/index.js +1 -0
  61. package/dist/src/learning/memory_manager.d.ts +26 -0
  62. package/dist/src/learning/memory_manager.js +211 -0
  63. package/dist/src/learning/types.d.ts +54 -0
  64. package/dist/src/learning/types.js +1 -0
  65. package/dist/src/mcp/registry.d.ts +17 -0
  66. package/dist/src/mcp/registry.js +97 -0
  67. package/dist/src/mcp/types.d.ts +13 -0
  68. package/dist/src/mcp/types.js +1 -0
  69. package/dist/src/providers/anthropic.d.ts +10 -0
  70. package/dist/src/providers/anthropic.js +95 -0
  71. package/dist/src/providers/base.d.ts +15 -0
  72. package/dist/src/providers/base.js +108 -0
  73. package/dist/src/providers/factory.d.ts +28 -0
  74. package/dist/src/providers/factory.js +142 -0
  75. package/dist/src/providers/gemini.d.ts +10 -0
  76. package/dist/src/providers/gemini.js +97 -0
  77. package/dist/src/providers/openai.d.ts +9 -0
  78. package/dist/src/providers/openai.js +85 -0
  79. package/dist/src/providers/openrouter.d.ts +5 -0
  80. package/dist/src/providers/openrouter.js +14 -0
  81. package/dist/src/providers/registry.d.ts +19 -0
  82. package/dist/src/providers/registry.js +209 -0
  83. package/dist/src/providers/types.d.ts +59 -0
  84. package/dist/src/providers/types.js +1 -0
  85. package/dist/src/providers/validator.d.ts +24 -0
  86. package/dist/src/providers/validator.js +161 -0
  87. package/dist/src/security/audit.d.ts +56 -0
  88. package/dist/src/security/audit.js +154 -0
  89. package/dist/src/security/guardrails.d.ts +9 -0
  90. package/dist/src/security/guardrails.js +32 -0
  91. package/dist/src/security/permissions.d.ts +12 -0
  92. package/dist/src/security/permissions.js +68 -0
  93. package/dist/src/security/policy.d.ts +220 -0
  94. package/dist/src/security/policy.js +720 -0
  95. package/dist/src/session/manager.d.ts +22 -0
  96. package/dist/src/session/manager.js +172 -0
  97. package/dist/src/session/types.d.ts +36 -0
  98. package/dist/src/session/types.js +1 -0
  99. package/dist/src/tools/checkpoint.d.ts +26 -0
  100. package/dist/src/tools/checkpoint.js +160 -0
  101. package/dist/src/tools/diagnostics.d.ts +2 -0
  102. package/dist/src/tools/diagnostics.js +125 -0
  103. package/dist/src/tools/diff.d.ts +14 -0
  104. package/dist/src/tools/diff.js +124 -0
  105. package/dist/src/tools/filesystem.d.ts +2 -0
  106. package/dist/src/tools/filesystem.js +224 -0
  107. package/dist/src/tools/git.d.ts +2 -0
  108. package/dist/src/tools/git.js +138 -0
  109. package/dist/src/tools/markdown.d.ts +33 -0
  110. package/dist/src/tools/markdown.js +190 -0
  111. package/dist/src/tools/project.d.ts +2 -0
  112. package/dist/src/tools/project.js +63 -0
  113. package/dist/src/tools/registry.d.ts +14 -0
  114. package/dist/src/tools/registry.js +230 -0
  115. package/dist/src/tools/search.d.ts +2 -0
  116. package/dist/src/tools/search.js +136 -0
  117. package/dist/src/tools/shell.d.ts +2 -0
  118. package/dist/src/tools/shell.js +74 -0
  119. package/dist/src/tools/symbols.d.ts +30 -0
  120. package/dist/src/tools/symbols.js +155 -0
  121. package/dist/src/tools/types.d.ts +28 -0
  122. package/dist/src/tools/types.js +1 -0
  123. package/dist/src/tools/web_search.d.ts +14 -0
  124. package/dist/src/tools/web_search.js +154 -0
  125. package/install.sh +29 -0
  126. package/overarch +15 -0
  127. package/package.json +28 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yatharth Roy, The Thursday AI Company of New Delhi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,214 @@
1
+ # Overarch CLI v0.5.0
2
+
3
+ > **The Learning Agent for Autonomous Software Engineering**
4
+ > *Understand • Investigate • Plan • Execute • Verify • Learn*
5
+ > **2026 Made By Yatharth Roy, From The Thursday AI Company of New Delhi**
6
+
7
+ Overarch CLI is an autonomous, terminal-native AI coding agent built for real-world software engineering. Designed with senior-developer minimalism and strict human control, Overarch operates directly inside your terminal, learning from its mistakes and compounding engineering knowledge over time.
8
+
9
+ ---
10
+
11
+ ## What's New in v0.5.0 ("The Learning Agent")
12
+
13
+ - **Terminal-Native Focus**: All web servers and webviews have been eliminated. Overarch CLI is 100% focused on the terminal developer experience.
14
+ - **Persistent Learning Engine (`src/learning/`)**:
15
+ - **Project Memory (`.overarch/memory/project.json`)**: Tracks architecture notes, conventions, build/test commands, and tech stacks.
16
+ - **User Memory (`~/.overarch/user_memory.json`)**: Remembers user coding preferences, workflows, and stylistic rules.
17
+ - **Episodic Lessons (`.overarch/memory/lessons.json`)**: Automatically captures problem ➔ investigation ➔ resolution ➔ lesson whenever self-corrections or user insights occur.
18
+ - **Selective Prompt Injection**: Never blindly dumps memory. Retrieves token-budgeted, query-relevant context for each task.
19
+ - **Learning Commands**: `overarch memory show`, `overarch memory search <query>`, `overarch memory forget <id>`, `overarch learn "<lesson>"`.
20
+ - **Claude-Like Contextual Thinking**:
21
+ - Dynamic thinking spinner with progressive adjectives:
22
+ `*Analyzing repository architecture...*`, `*Synthesizing change impact...*`, `*Investigating code paths...*`, `*Deliberating implementation plan...*`, `*Distilling project memory...*`
23
+ - **Streamlined Status & Reduced Noise**:
24
+ - Eliminated redundant turn reports and mission cards during read-only interactions.
25
+ - Clean, minimal diffs and one-line summaries only when modifications occur.
26
+ - **Petdex Floating Desktop Companion (`OverarchCompanion.exe`)**:
27
+ - **Zero Focus Stealing**: Transparent, frameless, always-on-top desktop companion built in native C# WPF using `WS_EX_NOACTIVATE`, `WS_EX_TOPMOST`, and `WS_EX_TOOLWINDOW` to ensure it never interrupts typing or terminal work.
28
+ - **Petdex Ecosystem Integration**: Directly discovers, loads, and switches pets from `~/.petdex/pets/` and `~/.codex/pets/` (supports 8×9 and 8×11 sprite grids, WebP and PNG formats).
29
+ - **Real-Time Agent State Reactions**: Visually reflects Overarch agent operations: `idle` (row 0), `thinking`/`inspecting` (row 8), `editing`/`executing` (row 7), `waiting`/`approval` (row 6), `success` (row 4), and `error`/`warning` (row 5).
30
+ - **Interactive Companion Controls**: Right-click context menu to switch installed pets, install from Petdex, open terminal, or reposition. Left-click drag with edge snapping and position persistence (`~/.overarch/companion_state.json`).
31
+ - **Bundled Offline Default**: Includes the official `savage-codex-hacker` pet definition and spritesheet for immediate out-of-the-box operation.
32
+ - **Windows Native Integration**:
33
+ - **Custom GUI Installer (`dist-desktop/Overarch-Setup.exe`)**: 10-step animated installer matching custom specifications (dark navy `#081842`, burgundy titlebar `#5c1122`, elapsed timer, collapsible log, Start Menu, Desktop, and PATH registration).
34
+ - **Console Launcher (`dist-desktop/Overarch.exe`)**: Lightweight C# native binary (< 75KB) launching Overarch CLI directly in Windows Terminal or cmd.
35
+ - **Companion Launcher (`dist-desktop/OverarchCompanion.exe`)**: Ultra-lightweight native WPF companion runner (84.5 KB).
36
+ - **Global Command**: `overarch` available anywhere in Windows terminal.
37
+
38
+ ---
39
+
40
+ ## Core Capabilities
41
+
42
+ - **7-Stage Epistemic Loop**:
43
+ 1. `Understand`: Parse goal and establish epistemic tracking.
44
+ 2. `Inspect`: Discover repository structure and run parallel read-only inspections.
45
+ 3. `Plan`: Structure actionable roadmaps with clear milestones.
46
+ 4. `Approve`: CCHCFAI human control gating and pre-mutation checkpointing.
47
+ 5. `Execute`: Sequential deterministic tool mutations with loop prevention.
48
+ 6. `Verify`: Autonomous verification of modifications against test suites.
49
+ 7. `Learn`: Record lessons learned from self-correction and user feedback.
50
+ - **CCSS 5.0 Orchestration**:
51
+ - `/ccss auto`: Balanced autonomy for standard feature engineering.
52
+ - `/ccss master`: Exhaustive planning and checkpoint validation.
53
+ - `/ccss god`: End-to-end full autonomy for major refactors.
54
+ - `/ccss control`: Supervised execution requiring explicit human approval.
55
+ - **CCHCFAI Human Control Guardrails**:
56
+ - `Tier 0 (Read-Only)`: File inspection, symbol discovery, and directory listings.
57
+ - `Tier 1 (Safe Mutation)`: Non-destructive local modifications.
58
+ - `Tier 2 (State-Mutating)`: Shell execution and file creation with notification and approval gates.
59
+ - `Tier 3 (High-Impact)`: Mandatory explicit confirmation for deletions or out-of-scope actions.
60
+ - **Emergency Stop**: Instant halt via `Ctrl+C` or `/halt`.
61
+ - **BYOK (Bring Your Own Key)**:
62
+ - Supports OpenAI (`gpt-4o`), Anthropic Claude (`claude-3-5-sonnet`), Google Gemini (`gemini-2.5-flash`), OpenRouter (`openrouter/auto`), and local/custom OpenAI-compatible endpoints.
63
+ - **Ponytail Senior Dev Minimalism**:
64
+ - Zero third-party runtime dependencies. Built strictly on standard Node.js built-ins (`node:fs/promises`, `node:child_process`, `node:readline/promises`, `node:util.styleText`, `node:test`) and the native Windows C# compiler (`csc.exe`).
65
+
66
+ ---
67
+
68
+ ## Installation & Setup
69
+
70
+ ### Option 1: Custom Windows Installer (GUI)
71
+ Run `dist-desktop/Overarch-Setup.exe` to install Overarch CLI, create desktop and Start Menu shortcuts, and register `overarch` in your system PATH.
72
+
73
+ ### Option 2: Run via Node.js
74
+ ```bash
75
+ cd overarch
76
+ npm install
77
+ npm run build
78
+ npm start
79
+ ```
80
+
81
+ ### Option 3: Global Terminal Command
82
+ ```bash
83
+ overarch
84
+ ```
85
+
86
+ ---
87
+
88
+ ## CLI Commands
89
+
90
+ | Command | Description |
91
+ |---|---|
92
+ | `overarch` | Launch interactive terminal agent session |
93
+ | `overarch memory show` | Display project memory and learned episodic lessons |
94
+ | `overarch memory search <query>` | Search memory for specific patterns, conventions, or lessons |
95
+ | `overarch memory forget <id>` | Remove a specific learned memory by ID |
96
+ | `overarch learn "<lesson>"` | Teach Overarch an engineering insight or rule |
97
+ | `overarch companion start` | Launch the floating Petdex desktop companion |
98
+ | `overarch companion status` | Inspect companion status, active pet, and event bridge |
99
+ | `overarch companion pets` | List all discovered Petdex pets |
100
+ | `overarch companion select <slug>` | Switch active companion pet |
101
+ | `overarch companion install <slug>` | Install a pet from Petdex library via official CLI |
102
+ | `overarch setup` | Run interactive onboarding wizard (providers, keys, models) |
103
+ | `overarch doctor` | Health check: Node environment, Git status, provider keys |
104
+ | `overarch init` | Initialize `.overarch/` directory with project config and instructions |
105
+ | `overarch status` | Display workspace status card (project, model, git branch) |
106
+ | `overarch models` | List available models across supported providers |
107
+ | `overarch config` | Inspect active hierarchical configuration |
108
+ | `overarch sessions` | List saved sessions with timestamps and message summaries |
109
+ | `overarch resume [id]` | Resume previous session or specific session by prefix |
110
+
111
+ ---
112
+
113
+ ## In-Session Slash Commands
114
+
115
+ Inside the interactive REPL:
116
+
117
+ ```text
118
+ PERSISTENT LEARNING & MEMORY
119
+ /memory [show] Display project memory & learned episodic lessons
120
+ /memory search <q> Search lessons, conventions, and architectural decisions
121
+ /memory forget <id> Remove a specific learned memory
122
+ /learn "<lesson>" Record a new engineering insight into memory
123
+
124
+ SESSION
125
+ /status Display diagnostic dashboard card
126
+ /new Start a fresh session in current project
127
+ /resume [id] Resume past session by ID or prefix
128
+ /sessions List saved sessions with summaries
129
+ /clear Clear conversation history
130
+ /exit, /quit Save session and exit cleanly
131
+
132
+ PROJECT & REPOSITORY
133
+ /project [dir] Inspect current workspace or switch directory
134
+ /project recent List recently accessed projects
135
+ /init Initialize .overarch subsystem for this project
136
+ /context Deep inspection of files, stack, and tokens
137
+ /reload Re-scan workspace context and instructions
138
+ /checkpoint [name] Create an instant git/snapshot checkpoint
139
+ /checkpoints List all saved checkpoints
140
+ /rollback [id] Revert repository to a previous checkpoint
141
+ /diff, /changes Inspect uncommitted git working tree changes
142
+
143
+ AI & AGENT
144
+ /model [name] List available models or switch active model
145
+ /plan [on|off] Toggle Plan Mode (roadmap before changes)
146
+ /retry Re-execute last prompt with updated approach
147
+ /ponytail [level] Set Ponytail minimalism: lite | full | ultra
148
+ /ccss [mode] Set CCSS mission orchestration: auto | master | god | control
149
+ /cchcfai [action] Human control layer: gate | audit | halt | status
150
+ /companion [action] Floating desktop companion: start | stop | status | pets | select
151
+ /petdex [action] Alias for /companion (Petdex integration)
152
+ /tools List available tools, permission tiers, and MCP
153
+ /abort, /halt Emergency stop current agent operation
154
+ ```
155
+
156
+ ---
157
+
158
+ ## Architecture
159
+
160
+ ```text
161
+ Overarch CLI Architecture
162
+ ├── bin/overarch.ts # CLI entry point, subcommands & argument dispatch
163
+ ├── src/cli/
164
+ │ ├── repl.ts # Terminal REPL, Claude-like spinner & command routing
165
+ │ ├── ui.ts # Pixel logo, ANSI diff formatting & thinking adjectives
166
+ │ └── commands/ # Subcommands (memory, doctor, setup, companion, status, etc.)
167
+ ├── src/companion/ # Petdex Desktop Companion Integration
168
+ │ ├── petdex_adapter.ts # Multi-directory pet discovery & spritesheet mapping
169
+ │ ├── petdex_bridge.ts # HTTP/SSE event server & desktop process manager
170
+ │ └── types.ts # Petdex schemas & AgentState animation row mappings
171
+ ├── src/learning/ # Persistent Learning Architecture
172
+ │ ├── memory_manager.ts # Disk persistence, selective retrieval & token bounding
173
+ │ └── types.ts # EpisodicLesson, ProjectMemory, UserMemory schemas
174
+ ├── src/agent/
175
+ │ ├── runtime.ts # 7-stage epistemic agent pipeline & self-correction
176
+ │ ├── planner.ts # CCSS modes (auto, master, god, control) & roadmaps
177
+ │ ├── manifest.ts # AST symbol extractor & repository intelligence
178
+ │ ├── context.ts # Workspace discovery & instruction loader
179
+ │ └── context_compressor.ts # Token-efficient context compression
180
+ ├── src/security/
181
+ │ ├── permissions.ts # CCHCFAI Tier 0-3 permission checker
182
+ │ └── guardrails.ts # Path traversal defense & emergency stop
183
+ ├── src/tools/
184
+ │ ├── filesystem.ts # Precision slice reader, diff-aware writer & patcher
185
+ │ ├── git.ts # Git operations & branch inspection
186
+ │ ├── checkpoint.ts # Snapshot & rollback engine
187
+ │ ├── symbols.ts # Symbol search & reference tracking
188
+ │ └── registry.ts # Tool registry & OpenAI tool-calling schema export
189
+ ├── src/desktop/
190
+ │ ├── launcher.cs # Native Windows console launcher (< 75KB)
191
+ │ ├── companion.cs # Native WPF floating desktop companion (84.5 KB)
192
+ │ └── installer.cs # Custom WinForms GUI installer (100 KB)
193
+ └── src/providers/
194
+ ├── factory.ts # BYOK provider factory (OpenRouter, Anthropic, OpenAI, Gemini)
195
+ └── validator.ts # OpenRouter tool_call_id healing & pre-flight integrity
196
+ ```
197
+
198
+ ---
199
+
200
+ ## Testing & Verification
201
+
202
+ Run the full automated test suite:
203
+
204
+ ```bash
205
+ npm test
206
+ ```
207
+
208
+ Runs **93 automated tests** across **24 suites** with 100% pass rate using Node.js's built-in `node:test` runner.
209
+
210
+ ---
211
+
212
+ ## Credits
213
+
214
+ 2026 Made By Yatharth Roy, From The Thursday AI Company of New Delhi
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,178 @@
1
+ #!/usr/bin/env node
2
+ import { parseCliArgs } from '../src/cli/args.js';
3
+ import * as ui from '../src/cli/ui.js';
4
+ import { doctor } from '../src/cli/commands/doctor.js';
5
+ import { init } from '../src/cli/commands/init.js';
6
+ import { status } from '../src/cli/commands/status.js';
7
+ import { listSessions } from '../src/cli/commands/sessions.js';
8
+ import { handleConfigCommand } from '../src/cli/commands/config.js';
9
+ import { startRepl } from '../src/cli/repl.js';
10
+ import { loadConfig } from '../src/config/index.js';
11
+ import { listModels } from '../src/providers/factory.js';
12
+ import { runOnboarding, runSetup } from '../src/cli/commands/onboarding.js';
13
+ import { handleMemoryCommand, handleLearnCommand } from '../src/cli/commands/memory.js';
14
+ import { handleCompanionCommand } from '../src/cli/commands/companion.js';
15
+ import { handleAuditCommand } from '../src/cli/commands/audit.js';
16
+ import { handleUpdateCommand } from '../src/cli/commands/update.js';
17
+ import { policyEngine } from '../src/security/policy.js';
18
+ const USAGE = `
19
+ ${ui.bold('Overarch CLI')} — The Learning Agent for Autonomous Software Engineering (v0.8.0)
20
+
21
+ ${ui.bold('Usage')}
22
+ overarch Start interactive session
23
+ overarch "fix failing tests" One-shot prompt
24
+ overarch <command> Run a command
25
+
26
+ ${ui.bold('Commands')}
27
+ doctor Check environment, Git, and configuration
28
+ init Initialize project config & instructions
29
+ setup Run interactive setup / onboarding
30
+ audit [opts] View, filter, or export CCHCFAI policy audit log
31
+ update [--check] Check packages and verify SHA-256 integrity
32
+ memory [show|search] Inspect project and episodic memory
33
+ learn "<insight>" Record a persistent engineering lesson
34
+ companion [start|pets] Floating Petdex desktop companion
35
+ config [get|set] Inspect or modify configuration
36
+ status Show active project, model, and git status
37
+ models List available models across BYOK providers
38
+ sessions List saved sessions with summaries
39
+ resume [id] Resume last session or specific session by ID
40
+
41
+ ${ui.bold('Options')}
42
+ --model <id> Use specific model (e.g. gpt-4o, claude-sonnet-4-20250514)
43
+ --folder, -f Specify workspace directory to operate in
44
+ --compact Compact terminal output mode
45
+ --setup Run setup before starting
46
+ --safe-only Run in SAFE-ONLY mode (blocks destructive shell or file mutations)
47
+ --resume, -r Resume last session
48
+ --yes, -y Auto-approve all actions
49
+ --verbose Show detailed output
50
+ --version, -v Print version
51
+ --help, -h Print this help
52
+
53
+ ${ui.dim('2026 Made By Yatharth Roy, From The Thursday AI Company of New Delhi')}
54
+ `;
55
+ process.on('SIGINT', () => {
56
+ policyEngine.terminateAllProcesses();
57
+ process.exit(130);
58
+ });
59
+ async function main() {
60
+ try {
61
+ const args = parseCliArgs();
62
+ if (args.safeOnly) {
63
+ policyEngine.setSafeOnly(true);
64
+ }
65
+ if (args.version) {
66
+ console.log('overarch-cli 0.8.0\n2026 Made By Yatharth Roy, From The Thursday AI Company of New Delhi');
67
+ return;
68
+ }
69
+ if (args.help) {
70
+ console.log(USAGE);
71
+ return;
72
+ }
73
+ if (args.folder) {
74
+ process.chdir(args.folder);
75
+ }
76
+ let config = await loadConfig();
77
+ // Apply accent and avatar globally
78
+ if (config.ui?.accentColor) {
79
+ ui.setAccent(config.ui.accentColor);
80
+ }
81
+ if (config.ui?.avatar) {
82
+ ui.setAvatar(config.ui.avatar);
83
+ }
84
+ if (args.setup || args.command === 'setup') {
85
+ await runSetup();
86
+ return;
87
+ }
88
+ if (!args.command) {
89
+ await runOnboarding();
90
+ config = await loadConfig();
91
+ await startRepl(config, args);
92
+ return;
93
+ }
94
+ switch (args.command) {
95
+ case 'doctor':
96
+ await doctor();
97
+ break;
98
+ case 'init':
99
+ await init();
100
+ break;
101
+ case 'audit':
102
+ await handleAuditCommand(process.argv.slice(3));
103
+ break;
104
+ case 'update':
105
+ await handleUpdateCommand(process.argv.slice(3));
106
+ break;
107
+ case 'models': {
108
+ ui.heading('Available Models');
109
+ const models = listModels();
110
+ for (const m of models) {
111
+ const ctx = m.contextWindow >= 1_000_000
112
+ ? `${(m.contextWindow / 1_000_000).toFixed(1)}M`
113
+ : `${(m.contextWindow / 1_000).toFixed(0)}K`;
114
+ const tools = m.supportsTools ? ui.green('✓ tools') : ui.dim('✗ tools');
115
+ console.log(` ${ui.bold(m.id)} ${ui.dim(`(${m.provider}, ${ctx}, ${tools})`)}`);
116
+ }
117
+ console.log(`\n${ui.dim('Use provider/model format for unlisted models: e.g. openai/gpt-4.5-preview')}`);
118
+ break;
119
+ }
120
+ case 'config': {
121
+ const rawArgs = process.argv.slice(3);
122
+ const sub = rawArgs[0];
123
+ const key = rawArgs[1];
124
+ const val = rawArgs[2];
125
+ await handleConfigCommand(sub, key, val);
126
+ break;
127
+ }
128
+ case 'status':
129
+ await status();
130
+ break;
131
+ case 'sessions':
132
+ await listSessions();
133
+ break;
134
+ case 'memory': {
135
+ const rawArgs = process.argv.slice(3);
136
+ await handleMemoryCommand(rawArgs[0], rawArgs[1], rawArgs[2]);
137
+ break;
138
+ }
139
+ case 'learn': {
140
+ const rawArgs = process.argv.slice(3);
141
+ await handleLearnCommand(rawArgs.join(' '));
142
+ break;
143
+ }
144
+ case 'companion':
145
+ case 'petdex': {
146
+ const rawArgs = process.argv.slice(3);
147
+ await handleCompanionCommand(rawArgs[0], rawArgs[1], rawArgs[2]);
148
+ break;
149
+ }
150
+ case 'desktop':
151
+ case 'gui': {
152
+ await runOnboarding();
153
+ config = await loadConfig();
154
+ await startRepl(config, args);
155
+ break;
156
+ }
157
+ case 'resume':
158
+ await runOnboarding();
159
+ config = await loadConfig();
160
+ await startRepl(config, { ...args, resume: true });
161
+ break;
162
+ case 'chat':
163
+ await runOnboarding();
164
+ config = await loadConfig();
165
+ await startRepl(config, args);
166
+ break;
167
+ default:
168
+ ui.error(`Unknown command: ${args.command}`);
169
+ console.log(USAGE);
170
+ process.exit(1);
171
+ }
172
+ }
173
+ catch (err) {
174
+ ui.error(err.message || String(err));
175
+ process.exit(1);
176
+ }
177
+ }
178
+ main();
@@ -0,0 +1,14 @@
1
+ import { OverarchConfig } from '../config/types.js';
2
+ export interface ProjectContextInspection {
3
+ cwd: string;
4
+ projectTypes: string[];
5
+ gitBranch: string;
6
+ gitStatus: string;
7
+ filesDiscovered: number;
8
+ filesSample: string[];
9
+ instructionsSource?: string;
10
+ memoryEntriesCount: number;
11
+ estimatedTokens: number;
12
+ }
13
+ export declare function inspectProjectContext(cwd: string): Promise<ProjectContextInspection>;
14
+ export declare function buildContext(cwd: string, config?: Partial<OverarchConfig>): Promise<string>;
@@ -0,0 +1,200 @@
1
+ import * as fs from 'node:fs/promises';
2
+ import * as path from 'node:path';
3
+ import { exec } from 'node:child_process';
4
+ import { promisify } from 'node:util';
5
+ import { buildRepoManifest } from './manifest.js';
6
+ const execAsync = promisify(exec);
7
+ export async function inspectProjectContext(cwd) {
8
+ const result = {
9
+ cwd,
10
+ projectTypes: [],
11
+ gitBranch: 'unknown',
12
+ gitStatus: 'clean',
13
+ filesDiscovered: 0,
14
+ filesSample: [],
15
+ memoryEntriesCount: 0,
16
+ estimatedTokens: 0
17
+ };
18
+ // Git
19
+ try {
20
+ const { stdout: branch } = await execAsync('git branch --show-current', { cwd });
21
+ result.gitBranch = branch.trim() || 'HEAD';
22
+ const { stdout: status } = await execAsync('git status --porcelain', { cwd });
23
+ result.gitStatus = status.trim() ? `${status.trim().split('\n').length} modified files` : 'Clean';
24
+ }
25
+ catch {
26
+ result.gitBranch = 'Not a git repo';
27
+ }
28
+ // Language & Framework
29
+ try {
30
+ const pkg = JSON.parse(await fs.readFile(path.join(cwd, 'package.json'), 'utf8'));
31
+ result.projectTypes.push(`Node.js (${pkg.name || 'unnamed'})`);
32
+ }
33
+ catch { }
34
+ try {
35
+ await fs.readFile(path.join(cwd, 'Cargo.toml'), 'utf8');
36
+ result.projectTypes.push('Rust (Cargo)');
37
+ }
38
+ catch { }
39
+ try {
40
+ await fs.readFile(path.join(cwd, 'pyproject.toml'), 'utf8');
41
+ result.projectTypes.push('Python (pyproject.toml)');
42
+ }
43
+ catch {
44
+ try {
45
+ await fs.readFile(path.join(cwd, 'requirements.txt'), 'utf8');
46
+ result.projectTypes.push('Python (requirements.txt)');
47
+ }
48
+ catch { }
49
+ }
50
+ try {
51
+ await fs.readFile(path.join(cwd, 'go.mod'), 'utf8');
52
+ result.projectTypes.push('Go');
53
+ }
54
+ catch { }
55
+ // File discovery
56
+ try {
57
+ const ignoreList = new Set(['node_modules', '.git', 'dist', 'build', '.next', '.turbo', '.cache']);
58
+ const entries = await fs.readdir(cwd, { withFileTypes: true });
59
+ for (const e of entries) {
60
+ if (ignoreList.has(e.name))
61
+ continue;
62
+ result.filesDiscovered++;
63
+ if (result.filesSample.length < 12) {
64
+ result.filesSample.push(`${e.name}${e.isDirectory() ? '/' : ''}`);
65
+ }
66
+ }
67
+ }
68
+ catch { }
69
+ // Instructions check
70
+ const candidateInstructions = [
71
+ { p: path.join(cwd, '.overarch', 'instructions.md'), name: '.overarch/instructions.md' },
72
+ { p: path.join(cwd, 'CLAUDE.md'), name: 'CLAUDE.md' },
73
+ { p: path.join(cwd, 'OVERARCH.md'), name: 'OVERARCH.md' },
74
+ { p: path.join(cwd, 'AGENTS.md'), name: 'AGENTS.md' }
75
+ ];
76
+ for (const item of candidateInstructions) {
77
+ try {
78
+ await fs.access(item.p);
79
+ result.instructionsSource = item.name;
80
+ break;
81
+ }
82
+ catch { }
83
+ }
84
+ // Memory count
85
+ try {
86
+ const mem = await fs.readFile(path.join(cwd, '.overarch', 'memory.md'), 'utf8');
87
+ const lines = mem.split('\n').filter(l => l.trim().startsWith('-'));
88
+ result.memoryEntriesCount = lines.length;
89
+ }
90
+ catch { }
91
+ const fullContext = await buildContext(cwd);
92
+ result.estimatedTokens = Math.round(fullContext.length / 4);
93
+ return result;
94
+ }
95
+ export async function buildContext(cwd, config) {
96
+ const parts = [];
97
+ // 1. Identity & Operating Model
98
+ parts.push(`You are Overarch, an autonomous terminal-native AI coding agent.`);
99
+ parts.push(`Working directory: ${cwd}`);
100
+ parts.push(`Operating Rules:`);
101
+ parts.push(`- Be concise, fast, and action-oriented.`);
102
+ parts.push(`- Always read files before modifying to verify exact contents.`);
103
+ parts.push(`- Make minimal, surgical diffs. Follow existing codebase patterns.`);
104
+ parts.push(`- Destructive actions (deleting files, force pushes) require explicit human confirmation.`);
105
+ // Ponytail tuning if active
106
+ const ponytail = config?.ponytail || 'full';
107
+ if (ponytail === 'ultra' || ponytail === 'full') {
108
+ parts.push(`\n[Ponytail ${ponytail.toUpperCase()} Active]: Enforce YAGNI ladder. Standard library before custom code; shortest working diff wins; zero unnecessary abstractions or unrequested boilerplate.`);
109
+ }
110
+ // CCSS mode tuning
111
+ const ccss = config?.ccss || 'auto';
112
+ parts.push(`\n[CCSS ${ccss.toUpperCase()} Mode]: Discover capabilities, orchestrate verified work, confirm key milestones, and deliver concrete results.`);
113
+ // CCHCFAI Human Control Protocol
114
+ parts.push(`\n[CCHCFAI Protocol]: Autonomy is bounded and interruptible. Classify actions into Tier 0 (Read-only), Tier 1 (Reversible local), Tier 2 (State-mutating), Tier 3 (Destructive). Halt immediately if user types /halt or Ctrl+C.`);
115
+ // 2. Git Status
116
+ try {
117
+ const { stdout: gitBranch } = await execAsync('git branch --show-current', { cwd });
118
+ const { stdout: gitStatus } = await execAsync('git status -s', { cwd });
119
+ let gitInfo = `Git Branch: ${gitBranch.trim() || 'HEAD (detached)'}\n`;
120
+ if (gitStatus.trim()) {
121
+ const changedFiles = gitStatus.trim().split('\n');
122
+ gitInfo += `Git Status: ${changedFiles.length} changed file(s):\n${changedFiles.slice(0, 8).join('\n')}`;
123
+ if (changedFiles.length > 8) {
124
+ gitInfo += `\n... and ${changedFiles.length - 8} more`;
125
+ }
126
+ }
127
+ else {
128
+ gitInfo += `Git Status: Clean working tree`;
129
+ }
130
+ try {
131
+ const { stdout: gitLog } = await execAsync('git log -n 3 --oneline', { cwd });
132
+ if (gitLog.trim()) {
133
+ gitInfo += `\nRecent commits:\n${gitLog.trim()}`;
134
+ }
135
+ }
136
+ catch { }
137
+ parts.push(`\n## Version Control\n${gitInfo}`);
138
+ }
139
+ catch {
140
+ parts.push(`\n## Version Control\nGit: Not a git repository or git unavailable.`);
141
+ }
142
+ // 3. Project Manifest & Architecture Map
143
+ const manifest = await buildRepoManifest(cwd);
144
+ if (manifest.projectTypes.length > 0) {
145
+ parts.push(`\n## Project Architecture\nType: ${manifest.projectTypes.join(', ')}`);
146
+ if (manifest.entryPoints.length > 0) {
147
+ parts.push(`Entry Points: ${manifest.entryPoints.join(', ')}`);
148
+ }
149
+ if (manifest.buildSystems.length > 0) {
150
+ parts.push(`Build Systems: ${manifest.buildSystems.join(', ')}`);
151
+ }
152
+ if (manifest.testDirectories.length > 0) {
153
+ parts.push(`Test Directories: ${manifest.testDirectories.join(', ')}`);
154
+ }
155
+ }
156
+ // 4. Workspace Structure
157
+ if (manifest.keyDirectories.length > 0) {
158
+ parts.push(`\n## Key Directories\n${manifest.keyDirectories.join(' ')}`);
159
+ }
160
+ // 5. Project Instructions (.overarch/instructions.md authoritative, or CLAUDE.md / OVERARCH.md / AGENTS.md fallback)
161
+ let instructionsFound = false;
162
+ try {
163
+ const instructions = await fs.readFile(path.join(cwd, '.overarch', 'instructions.md'), 'utf-8');
164
+ if (instructions.trim()) {
165
+ parts.push(`\n## Project Instructions (.overarch/instructions.md)\n${instructions.trim()}`);
166
+ instructionsFound = true;
167
+ }
168
+ }
169
+ catch { }
170
+ if (!instructionsFound) {
171
+ const candidates = ['CLAUDE.md', 'OVERARCH.md', 'AGENTS.md'];
172
+ for (const file of candidates) {
173
+ try {
174
+ const content = await fs.readFile(path.join(cwd, file), 'utf-8');
175
+ if (content.trim()) {
176
+ parts.push(`\n## Project Instructions (${file})\n${content.trim()}`);
177
+ break;
178
+ }
179
+ }
180
+ catch { }
181
+ }
182
+ }
183
+ // 6. Project Memory (.overarch/memory.md)
184
+ try {
185
+ const memory = await fs.readFile(path.join(cwd, '.overarch', 'memory.md'), 'utf-8');
186
+ if (memory.trim()) {
187
+ parts.push(`\n## Project Memory (.overarch/memory.md)\n${memory.trim()}`);
188
+ }
189
+ }
190
+ catch { }
191
+ // 7. README Snippet
192
+ try {
193
+ const readme = await fs.readFile(path.join(cwd, 'README.md'), 'utf-8');
194
+ if (readme.trim()) {
195
+ parts.push(`\n## README (overview)\n${readme.substring(0, 1200).trim()}`);
196
+ }
197
+ }
198
+ catch { }
199
+ return parts.join('\n');
200
+ }
@@ -0,0 +1,21 @@
1
+ import { Message } from '../providers/types.js';
2
+ export interface CompressionResult {
3
+ messages: Message[];
4
+ originalTokens: number;
5
+ compressedTokens: number;
6
+ didCompress: boolean;
7
+ }
8
+ /**
9
+ * Estimates token count from text using standard ~4 characters per token heuristic
10
+ */
11
+ export declare function estimateTokens(text: string): number;
12
+ /**
13
+ * Estimates token count for an array of messages
14
+ */
15
+ export declare function estimateMessagesTokens(messages: Message[]): number;
16
+ /**
17
+ * Compresses conversation history to stay within a configured token budget,
18
+ * preserving critical goals, plans, recent file diffs, and verification evidence
19
+ * while summarizing verbose intermediate tool executions.
20
+ */
21
+ export declare function compressContext(messages: Message[], maxTokens?: number): CompressionResult;