Skip to content

Commit 69a0d07

Browse files
committed
Refactor the project
1 parent 11f5a14 commit 69a0d07

File tree

114 files changed

+4109
-1338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+4109
-1338
lines changed

.github/workflows/lints.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Set up Node.js
2424
uses: actions/setup-node@v4
2525
with:
26-
node-version: "20.x"
26+
node-version: "22.x"
2727
- name: Install Dependencies
2828
run: make install
2929
- name: Run linter
@@ -37,8 +37,8 @@ jobs:
3737
- name: Set up Node.js
3838
uses: actions/setup-node@v4
3939
with:
40-
node-version: "20.x"
40+
node-version: "22.x"
4141
- name: Install Dependencies
4242
run: make install
43-
- name: Run type checks
43+
- name: Run Typechecking Checks
4444
run: make typecheck

.github/workflows/publish.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
contents: read
2727

2828
steps:
29-
- name: Checkout repository
29+
- name: Checkout Repository
3030
uses: actions/checkout@v4
3131

3232
- name: Use Node.js
@@ -36,31 +36,31 @@ jobs:
3636
registry-url: "https://registry.npmjs.org"
3737
cache: "npm"
3838

39-
- name: Show Node and npm versions
39+
- name: Show Node and npm Versions
4040
run: |
4141
node -v
4242
npm -v
4343
4444
- name: Install dependencies
4545
run: npm install --legacy-peer-deps
4646

47-
- name: Run tests
47+
- name: Run Tests
4848
run: npm test
4949

50-
- name: Build package
50+
- name: Build Package
5151
run: npm run build
5252

53-
- name: Verify package contents
53+
- name: Verify Package Content
5454
run: npm pack --dry-run
5555

56-
- name: Publish to npm
56+
- name: Publish to `npm`
5757
if: >-
5858
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
5959
(github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'false')
6060
env:
6161
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6262
run: npm publish --access public
6363

64-
- name: Dry-run publish
64+
- name: Dry-run Publish
6565
if: github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'true'
6666
run: npm publish --access public --dry-run

.github/workflows/tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ jobs:
3535
- name: Run Tests with Coverage
3636
run: make coverage
3737

38-
- name: Upload coverage reports to Codecov
38+
- name: Upload Coverage Reports to Codecov
3939
uses: codecov/codecov-action@v4
4040
with:
4141
token: ${{ secrets.CODECOV_TOKEN }}
42+
fail_ci_if_error: false

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,5 @@ BINHARIC.md
166166
AGENT.md
167167
*.tar.gz
168168
*.tgz
169+
test.txt
170+
a.out

Makefile

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,34 +37,34 @@ help: ## Show this help message
3737
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}'
3838

3939
install: ## Install project dependencies
40-
$(PACKAGE_MANAGER) install --legacy-peer-deps
40+
@$(PACKAGE_MANAGER) install --legacy-peer-deps
4141

4242
build: check-deps ## Build Binharic
43-
$(PACKAGE_MANAGER) run build
43+
@$(PACKAGE_MANAGER) run build
4444

4545
run: build ## Start Binharic in terminal
46-
$(PACKAGE_MANAGER) start
46+
@$(PACKAGE_MANAGER) start
4747

4848
clean: ## Remove build artifacts
49-
rm -rf dist $(NODE_MODULES_DIR) $(REMOVABLE_THINGS)
49+
@rm -rf dist $(NODE_MODULES_DIR) $(REMOVABLE_THINGS)
5050

5151
# ==============================================================================
5252
# DEVELOPMENT
5353
# ==============================================================================
5454
test: check-deps ## Run the test suite
55-
$(PACKAGE_MANAGER) test
55+
@$(PACKAGE_MANAGER) test
5656

5757
coverage: check-deps ## Run the test suite and generate a coverage report
58-
$(PACKAGE_MANAGER) run coverage
58+
@$(PACKAGE_MANAGER) run coverage
5959

6060
lint: check-deps ## Run linter checks
61-
$(PACKAGE_MANAGER) run lint
61+
@$(PACKAGE_MANAGER) run lint
6262

6363
typecheck: check-deps ## Run TypeScript type checks
64-
$(PACKAGE_MANAGER) run typecheck
64+
@$(PACKAGE_MANAGER) run typecheck
6565

6666
format: check-deps ## Format code with Prettier
67-
$(PACKAGE_MANAGER) run format
67+
@$(PACKAGE_MANAGER) run format
6868

6969
# ==============================================================================
7070
# GIT HOOKS
@@ -87,28 +87,28 @@ test-hooks: ## Test Git hooks on all files
8787
# PUBLISHING
8888
# ==============================================================================
8989
npm-login: ## Log in to npm registry
90-
$(PACKAGE_MANAGER) login
90+
@$(PACKAGE_MANAGER) login
9191

9292
npm-whoami: ## Show current npm user (if logged in)
93-
-$(PACKAGE_MANAGER) whoami
93+
@-$(PACKAGE_MANAGER) whoami
9494

9595
pack: build ## Create npm tarball (binharic-cli-<version>.tgz)
96-
$(PACKAGE_MANAGER) pack
96+
@$(PACKAGE_MANAGER) pack
9797

9898
pack-dry-run: build ## Preview files that would be packed
99-
$(PACKAGE_MANAGER) pack --dry-run
99+
@$(PACKAGE_MANAGER) pack --dry-run
100100

101101
publish-dry-run: ## Simulate npm publish (no registry changes)
102-
$(PACKAGE_MANAGER) publish --dry-run
102+
@$(PACKAGE_MANAGER) publish --access public --dry-run
103103

104104
publish: ## Publish the package to npm (runs build via prepublishOnly)
105-
$(PACKAGE_MANAGER) publish
105+
@$(PACKAGE_MANAGER) publish --access public
106106

107107
version-patch: ## Bump patch version (x.y.z -> x.y.(z+1))
108-
$(PACKAGE_MANAGER) version patch
108+
@$(PACKAGE_MANAGER) version patch
109109

110110
version-minor: ## Bump minor version (x.y.z -> x.(y+1).0)
111-
$(PACKAGE_MANAGER) version minor
111+
@$(PACKAGE_MANAGER) version minor
112112

113113
version-major: ## Bump major version ((x+1).0.0)
114-
$(PACKAGE_MANAGER) version major
114+
@$(PACKAGE_MANAGER) version major

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[![Tests](https://img.shields.io/github/actions/workflow/status/CogitatorTech/binharic-cli/tests.yml?label=tests&style=flat&labelColor=333333&logo=github&logoColor=white)](https://github.com/CogitatorTech/binharic-cli/actions/workflows/tests.yml)
1010
[![Code Coverage](https://img.shields.io/codecov/c/github/CogitatorTech/binharic-cli?style=flat&label=coverage&labelColor=333333&logo=codecov&logoColor=white)](https://codecov.io/gh/CogitatorTech/binharic-cli)
1111
[![Code Quality](https://img.shields.io/codefactor/grade/github/CogitatorTech/binharic-cli?style=flat&label=code%20quality&labelColor=333333&logo=codefactor&logoColor=white)](https://www.codefactor.io/repository/github/CogitatorTech/binharic-cli)
12-
[![npm](https://img.shields.io/npm/v/binharic-cli?style=flat&labelColor=333333&logo=npm&logoColor=white)](https://www.npmjs.com/package/binharic-cli)
12+
[![npm](https://img.shields.io/npm/v/%40cogitator%2Fbinharic-cli?style=flat&labelColor=333333&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cogitator/binharic-cli)
1313
[![Documentation](https://img.shields.io/badge/docs-latest-8ca0d7?style=flat&labelColor=333333&logo=read-the-docs&logoColor=white)](docs)
1414
[![License](https://img.shields.io/badge/license-MIT-00acc1?style=flat&labelColor=333333&logo=open-source-initiative&logoColor=white)](LICENSE)
1515

ROADMAP.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ It includes planned features, improvements, and their current implementation sta
1919
- [x] Token-based context window management
2020
- [x] Automatic context trimming for long conversations
2121
- [x] History preservation across sessions
22-
- [x] Adaptive context management with prepareStep callbacks
22+
- [ ] Adaptive context management with prepareStep callbacks
2323
- [x] Tool result summarization for longer agentic loops
2424
- [ ] Intelligent context compression
2525
- [ ] Semantic context pruning
2626
- **Multi-Step Execution**
2727
- [x] Multi-step tool calling with retry logic
2828
- [x] Transient error handling with exponential backoff
2929
- [x] Tool execution confirmation flow
30-
- [x] AI SDK 5 Agent class integration
31-
- [x] Automatic loop control with stopWhen conditions**
32-
- [x] Budget-based stopping conditions
30+
- [ ] AI SDK 5 Agent class integration (currently using AI SDK streaming + tool calling directly)
31+
- [ ] Automatic loop control with stopWhen conditions
32+
- [ ] Budget-based stopping conditions
3333
- [x] Error threshold conditions
34-
- [x] Validation-based stopping
34+
- [ ] Validation-based stopping
3535
- [x] Completion detection conditions
3636
- [ ] Parallel tool execution for independent operations
3737
- [ ] Automatic tool dependency resolution
@@ -54,11 +54,11 @@ It includes planned features, improvements, and their current implementation sta
5454
- [x] Smart file editing with diff application
5555
- [x] List directory contents
5656
- [x] File search capabilities
57-
- [x] Integrated with AI SDK Agent class
57+
- [x] Integrated with AI SDK tool calling
5858
- [x] Automatic file tracking for edits (no manual read required)
5959
- [x] File staleness detection
6060
- [x] Memory-efficient file tracking (1000 file limit)
61-
- [ ] File comparison and diffing
61+
- [x] File comparison and diffing
6262
- [ ] Bulk file operations
6363
- [ ] File watching for changes
6464
- **Code Intelligence**
@@ -78,7 +78,7 @@ It includes planned features, improvements, and their current implementation sta
7878
- [ ] Interactive shell support
7979
- [ ] Command history and replay
8080
- [ ] Environment variable management
81-
- **Web & Network**
81+
- **Web and Network**
8282
- [x] URL fetching with HTML-to-text conversion
8383
- [x] Content markup stripping
8484
- [ ] API integration templates
@@ -103,7 +103,7 @@ It includes planned features, improvements, and their current implementation sta
103103
- [x] File search with @ mention
104104
- [x] Non-blocking UI during LLM responses
105105
- [x] Command syntax highlighting (partial match in yellow, full match in cyan)
106-
- [x] Colored help menu items**
106+
- [x] Colored help menu items\*\*
107107
- [x] Clean message display (no "Binharic:" prefix)
108108
- [x] Dynamic username from system (not hardcoded)
109109
- [x] Tool results hidden from UI (only failures shown)
@@ -122,7 +122,7 @@ It includes planned features, improvements, and their current implementation sta
122122
- [ ] Undo/redo for file operations
123123
- [ ] Session saving and loading
124124

125-
### 4. Configuration & Customization
125+
### 4. Configuration and Customization
126126

127127
- **Configuration Management**
128128
- [x] JSON5 configuration format
@@ -131,16 +131,16 @@ It includes planned features, improvements, and their current implementation sta
131131
- [x] API key management
132132
- [x] History size limits
133133
- [ ] Configuration profiles (development, production, etc.)
134-
- [ ] Configuration validation with detailed error messages
134+
- [x] Configuration validation with detailed error messages
135135
- [ ] Hot-reload configuration changes
136-
- **Personality & Behavior**
136+
- **Personality and Behavior**
137137
- [x] Adeptus Mechanicus character and terminology
138138
- [x] Customizable system prompts
139139
- [ ] Multiple personality presets
140140
- [ ] Conversation style customization
141141
- [ ] Output verbosity levels
142142

143-
### 5. Performance & Reliability
143+
### 5. Performance and Reliability
144144

145145
- **Error Handling**
146146
- [x] Categorized errors (Fatal, Transient, Tool)
@@ -173,7 +173,7 @@ It includes planned features, improvements, and their current implementation sta
173173
- [ ] Usage analytics (tokens, costs)
174174
- [ ] Health checks and diagnostics
175175

176-
### 6. Testing & Quality
176+
### 6. Testing and Quality
177177

178178
- **Test Coverage**
179179
- [x] Unit tests for core functionality
@@ -213,7 +213,7 @@ It includes planned features, improvements, and their current implementation sta
213213
- [ ] Plugin development guide
214214
- [ ] Deployment guide
215215

216-
### 8. Distribution & Deployment
216+
### 8. Distribution and Deployment
217217

218218
- **Package Management**
219219
- [x] NPM package structure
@@ -227,7 +227,7 @@ It includes planned features, improvements, and their current implementation sta
227227
- [ ] Chocolatey package (Windows)
228228
- [ ] Docker image
229229
- [ ] Standalone binary releases
230-
- **Cloud & Remote**
230+
- **Cloud and Remote**
231231
- [ ] Remote execution support
232232
- [ ] Multi-user deployments
233233
- [ ] Cloud provider integrations
@@ -238,12 +238,12 @@ It includes planned features, improvements, and their current implementation sta
238238
- [x] Autonomous task execution
239239
- [x] Tool chaining
240240
- [x] File tracking for safe edits
241-
- [x] AI SDK 5 Agent class for reusable configurations
241+
- [ ] AI SDK 5 Agent class for reusable configurations
242242
- [x] Multi-step tool execution with automatic loop control
243243
- [x] Specialized agents with distinct personalities
244-
- [x] onStepFinish callbacks for monitoring
245-
- [x] prepareStep callbacks for dynamic configuration**
246-
- [x] Multiple stopping conditions (step count, budget, errors, validation, completion)
244+
- [ ] onStepFinish callbacks for monitoring
245+
- [ ] prepareStep callbacks for dynamic configuration\*\*
246+
- [ ] Multiple stopping conditions (step count, budget, errors, validation, completion)
247247
- [ ] Goal-oriented planning
248248
- [ ] Task decomposition
249249
- [ ] Long-term memory
@@ -255,14 +255,14 @@ It includes planned features, improvements, and their current implementation sta
255255
- [ ] Code review assistance
256256
- [ ] Pull request analysis
257257
- [ ] Multi-agent collaboration
258-
- **Extensions & Plugins**
258+
- **Extensions and Plugins**
259259
- [ ] Plugin system architecture
260260
- [ ] Custom tool registration
261261
- [ ] Language-specific plugins
262262
- [ ] Framework-specific assistants
263263
- [ ] Custom agent templates
264264

265-
### 10. Security & Privacy
265+
### 10. Security and Privacy
266266

267267
- **Security**
268268
- [x] API key environment variable support

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "binharic-cli",
2+
"name": "@cogitator/binharic-cli",
33
"version": "0.1.0-alpha.1",
44
"description": "A coding agent with the persona of a Tech-Priest of the Adeptus Mechanicus",
55
"main": "dist/cli.js",
@@ -13,6 +13,9 @@
1313
"README.md",
1414
"LICENSE"
1515
],
16+
"publishConfig": {
17+
"access": "public"
18+
},
1619
"scripts": {
1720
"start": "node dist/cli.js",
1821
"dev": "nodemon",
@@ -28,10 +31,13 @@
2831
},
2932
"keywords": [
3033
"ai",
34+
"coding-agent",
35+
"ai-assistant",
3136
"typescript",
32-
"cli"
37+
"cli",
38+
"llm"
3339
],
34-
"author": "",
40+
"author": "Hassan Abedi",
3541
"license": "MIT",
3642
"dependencies": {
3743
"@ai-sdk/anthropic": "^2.0.4",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function getMessageTokenCount(message: ModelMessage): number {
3737
}
3838
} else if ("toolName" in part && typeof part.toolName === "string") {
3939
tokens += getTokenCount(part.toolName);
40+
tokens += 10;
4041
if ("args" in part && part.args) {
4142
tokens += getTokenCount(serializeContent(part.args));
4243
}
@@ -50,6 +51,10 @@ function getMessageTokenCount(message: ModelMessage): number {
5051

5152
tokens += 4;
5253

54+
if (message.role === "tool") {
55+
tokens += 15;
56+
}
57+
5358
return tokens;
5459
}
5560

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { AssistantContent } from "ai";
2-
import type { ToolCall } from "./types.js";
2+
import type { ToolCall } from "../core/types.js";
33

44
export type UserMessageItem = {
55
id: string;

0 commit comments

Comments
 (0)