clikit-plugin 0.2.9 → 0.2.11
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.
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as fs from "fs";
|
|
|
6
6
|
import * as path from "path";
|
|
7
7
|
import * as os from "os";
|
|
8
8
|
var PLUGIN_NAME = "clikit-plugin";
|
|
9
|
-
var VERSION = "0.2.
|
|
9
|
+
var VERSION = "0.2.11";
|
|
10
10
|
function getRealHome() {
|
|
11
11
|
if (process.env.SNAP_REAL_HOME) {
|
|
12
12
|
return process.env.SNAP_REAL_HOME;
|
package/dist/index.js
CHANGED
|
@@ -3495,8 +3495,7 @@ var require_gray_matter = __commonJS((exports, module) => {
|
|
|
3495
3495
|
var import_gray_matter = __toESM(require_gray_matter(), 1);
|
|
3496
3496
|
import * as fs from "fs";
|
|
3497
3497
|
import * as path from "path";
|
|
3498
|
-
var
|
|
3499
|
-
var AGENTS_DIR = __dirname;
|
|
3498
|
+
var AGENTS_DIR = path.join(import.meta.dir, "../src/agents");
|
|
3500
3499
|
function parseAgentMarkdown(filePath) {
|
|
3501
3500
|
try {
|
|
3502
3501
|
const content = fs.readFileSync(filePath, "utf-8");
|
|
@@ -3549,8 +3548,7 @@ function getBuiltinAgents() {
|
|
|
3549
3548
|
var import_gray_matter2 = __toESM(require_gray_matter(), 1);
|
|
3550
3549
|
import * as fs2 from "fs";
|
|
3551
3550
|
import * as path2 from "path";
|
|
3552
|
-
var
|
|
3553
|
-
var COMMANDS_DIR = path2.join(__dirname, "../../command");
|
|
3551
|
+
var COMMANDS_DIR = path2.join(import.meta.dir, "../command");
|
|
3554
3552
|
function parseCommandMarkdown(filePath) {
|
|
3555
3553
|
try {
|
|
3556
3554
|
const content = fs2.readFileSync(filePath, "utf-8");
|
|
@@ -4791,8 +4789,7 @@ var RITUAL_FILE = path8.join(process.cwd(), ".opencode", "memory", "ritual-state
|
|
|
4791
4789
|
var import_gray_matter3 = __toESM(require_gray_matter(), 1);
|
|
4792
4790
|
import * as fs8 from "fs";
|
|
4793
4791
|
import * as path9 from "path";
|
|
4794
|
-
var
|
|
4795
|
-
var SKILLS_DIR = path9.join(__dirname, "..", "..", "skill");
|
|
4792
|
+
var SKILLS_DIR = path9.join(import.meta.dir, "../skill");
|
|
4796
4793
|
function getBuiltinSkills() {
|
|
4797
4794
|
const skills = {};
|
|
4798
4795
|
if (!fs8.existsSync(SKILLS_DIR)) {
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
---
|
|
2
|
+
date: 2026-02-15
|
|
3
|
+
phase: implementing
|
|
4
|
+
branch: main
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Handoff: CliKit Complete Type Guard & SQLite Fix
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Status Summary
|
|
12
|
+
|
|
13
|
+
CliKit plugin v0.2.1 → v0.2.9 published with comprehensive type guards across all hooks and tools. Fixed SQLite schema migration issues, removed backup logic, and added defensive programming patterns throughout the codebase. Plugin should now handle all edge cases where OpenCode passes unexpected data types.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Version History
|
|
18
|
+
|
|
19
|
+
| Version | Fix |
|
|
20
|
+
|---------|-----|
|
|
21
|
+
| 0.2.1 | Type guards in hooks (truncator, security-check, compaction) |
|
|
22
|
+
| 0.2.2 | Abort on JSON parse error |
|
|
23
|
+
| 0.2.3 | Fix JSONC comment stripping breaking URLs |
|
|
24
|
+
| 0.2.4 | Remove backup logic, fix `todos.filter` error |
|
|
25
|
+
| 0.2.5 | Fix `path.join` error - guards for projectDir/cwd params |
|
|
26
|
+
| 0.2.6 | Fix `text.toLowerCase` error in subagent-question-blocker |
|
|
27
|
+
| 0.2.7 | Fix remaining type guards (git-guard, swarm-enforcer) |
|
|
28
|
+
| 0.2.8 | SQLite migration - add missing columns |
|
|
29
|
+
| 0.2.9 | Type guards for ALL tool functions |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Task Status
|
|
34
|
+
|
|
35
|
+
### ✅ Completed
|
|
36
|
+
- [x] Fix installer to MERGE with existing opencode.json
|
|
37
|
+
- [x] Remove backup creation from cli.ts
|
|
38
|
+
- [x] Add type guards to all hooks (14 hooks)
|
|
39
|
+
- [x] Add type guards to all tools (6 tool files)
|
|
40
|
+
- [x] Fix SQLite schema migration with ALTER TABLE
|
|
41
|
+
- [x] Publish v0.2.1 → v0.2.9 to npm
|
|
42
|
+
|
|
43
|
+
### 📋 Not Started
|
|
44
|
+
- [ ] Test: `opencode` starts without errors
|
|
45
|
+
- [ ] Test: Plugin loads correctly after fresh install
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Files Modified (22 files)
|
|
50
|
+
|
|
51
|
+
| File | Changes |
|
|
52
|
+
|------|---------|
|
|
53
|
+
| `package.json` | v0.2.9 |
|
|
54
|
+
| `cli.ts` | Removed backup, fixed JSONC parsing |
|
|
55
|
+
| `config.ts` | Type guard for loadCliKitConfig |
|
|
56
|
+
| `index.ts` | Array.isArray for todos |
|
|
57
|
+
| `hooks/auto-format.ts` | Type guards for filePath, projectDir |
|
|
58
|
+
| `hooks/comment-checker.ts` | Type guard for content |
|
|
59
|
+
| `hooks/compaction.ts` | Type guards for projectDir, raw content |
|
|
60
|
+
| `hooks/env-context.ts` | Type guard for cwd |
|
|
61
|
+
| `hooks/git-guard.ts` | Type guard for command |
|
|
62
|
+
| `hooks/security-check.ts` | Type guard for content |
|
|
63
|
+
| `hooks/session-notification.ts` | Type guards for sessionId, error |
|
|
64
|
+
| `hooks/subagent-question-blocker.ts` | Type guards for text, toolName |
|
|
65
|
+
| `hooks/swarm-enforcer.ts` | Type guards for filePath, toolName |
|
|
66
|
+
| `hooks/todo-enforcer.ts` | Type guard for todos array |
|
|
67
|
+
| `hooks/truncator.ts` | Type guard for content |
|
|
68
|
+
| `hooks/typecheck-gate.ts` | Type guards for filePath, projectDir, output |
|
|
69
|
+
| `tools/observation.ts` | Type guard + SQLite migration |
|
|
70
|
+
| `tools/memory.ts` | Type guards + SQLite migration |
|
|
71
|
+
| `tools/beads-memory-sync.ts` | Type guard + SQLite migration |
|
|
72
|
+
| `tools/context-summary.ts` | Type guard + SQLite migration |
|
|
73
|
+
| `tools/quick-research.ts` | Type guard for params |
|
|
74
|
+
| `tools/swarm.ts` | Type guard for params |
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Git State
|
|
79
|
+
|
|
80
|
+
- **Branch:** `main`
|
|
81
|
+
- **Last commit:** `31b200c` - Update README with simplified installation
|
|
82
|
+
- **Uncommitted changes:** 22 modified files, 5 handoff files
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Known Issues
|
|
87
|
+
|
|
88
|
+
None - all reported runtime errors have been addressed with type guards.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Next Steps
|
|
93
|
+
|
|
94
|
+
1. [ ] User test: `rm -rf ~/.cache/opencode/node_modules/clikit-plugin`
|
|
95
|
+
2. [ ] User test: `bun x clikit-plugin@latest install`
|
|
96
|
+
3. [ ] User test: `opencode` - should start without errors
|
|
97
|
+
4. [ ] If errors persist, check error message and add appropriate type guard
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Context for Resumption
|
|
102
|
+
|
|
103
|
+
### Type Guard Pattern Used Throughout
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
export function myFunc(params: unknown): Result | null {
|
|
107
|
+
if (!params || typeof params !== "object") {
|
|
108
|
+
return defaultResult;
|
|
109
|
+
}
|
|
110
|
+
const p = params as Partial<Params>;
|
|
111
|
+
if (!p.requiredField) {
|
|
112
|
+
return defaultResult;
|
|
113
|
+
}
|
|
114
|
+
// ... rest of function
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### SQLite Migration Pattern
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// Create table with all columns
|
|
122
|
+
db.exec(`CREATE TABLE IF NOT EXISTS observations (...)`);
|
|
123
|
+
|
|
124
|
+
// Migration: add missing columns if they don't exist
|
|
125
|
+
try { db.exec(`ALTER TABLE observations ADD COLUMN new_col TEXT`); } catch {}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Key Files to Review
|
|
129
|
+
- `.opencode/src/hooks/*.ts` — All hooks have type guards
|
|
130
|
+
- `.opencode/src/tools/*.ts` — All tools have type guards + SQLite migration
|
|
131
|
+
- `.opencode/src/cli.ts` — Installer logic, JSONC parsing
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Resume Command
|
|
136
|
+
|
|
137
|
+
To resume, use `/resume` and it will:
|
|
138
|
+
1. Load this handoff
|
|
139
|
+
2. Check for new runtime errors
|
|
140
|
+
3. Propose adding appropriate type guards if needed
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
---
|
|
2
|
+
date: 2026-02-15
|
|
3
|
+
phase: verifying
|
|
4
|
+
branch: main
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Handoff: CliKit `import.meta.dir` Path Fix (v0.2.10)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Status Summary
|
|
12
|
+
|
|
13
|
+
Fixed critical bug where bun build inlined `__dirname` to absolute build-time paths, causing plugin to fail on user machines. Replaced with `import.meta.dir` which is preserved as runtime expression.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Bug Description
|
|
18
|
+
|
|
19
|
+
**Problem:** After `bun build`, the bundled code had hardcoded paths:
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
// Before (broken):
|
|
23
|
+
var __dirname = "/mnt/c/Users/Kira/Desktop/clikit/.opencode/src/agents";
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
When users installed via npm, the plugin looked for files at the BUILD machine's path, not the installed location.
|
|
27
|
+
|
|
28
|
+
**Root Cause:** Bun bundler inlines `__dirname` to the build-time absolute path. `import.meta.dir` is preserved as a runtime expression.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Fix Applied
|
|
33
|
+
|
|
34
|
+
| File | Before | After |
|
|
35
|
+
|------|--------|-------|
|
|
36
|
+
| `src/agents/index.ts:6` | `const AGENTS_DIR = __dirname;` | `const AGENTS_DIR = import.meta.dir;` |
|
|
37
|
+
| `src/commands/index.ts:6` | `path.join(__dirname, "../../command")` | `path.join(import.meta.dir, "../../command")` |
|
|
38
|
+
| `src/skills/index.ts:5` | `path.join(__dirname, "..", "..", "skill")` | `path.join(import.meta.dir, "../../skill")` |
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Verification
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Published package shows runtime expressions (not inlined):
|
|
46
|
+
npm pack clikit-plugin@latest && tar -xzf clikit-plugin-0.2.10.tgz
|
|
47
|
+
grep import.meta.dir package/dist/index.js
|
|
48
|
+
|
|
49
|
+
# Output:
|
|
50
|
+
# var AGENTS_DIR = import.meta.dir;
|
|
51
|
+
# var COMMANDS_DIR = path2.join(import.meta.dir, "../../command");
|
|
52
|
+
# var SKILLS_DIR = path9.join(import.meta.dir, "../../skill");
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Version History
|
|
58
|
+
|
|
59
|
+
| Version | Fix |
|
|
60
|
+
|---------|-----|
|
|
61
|
+
| 0.2.1-0.2.9 | Type guards for hooks/tools |
|
|
62
|
+
| 0.2.10 | `__dirname` → `import.meta.dir` path fix |
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Next Steps
|
|
67
|
+
|
|
68
|
+
1. [ ] User test: `rm -rf ~/.cache/opencode/node_modules/clikit-plugin`
|
|
69
|
+
2. [ ] User test: `bun x clikit-plugin@latest install`
|
|
70
|
+
3. [ ] User test: `opencode` - should start without errors
|
|
71
|
+
4. [ ] Verify agents/commands/skills load correctly
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Files Modified (3 files)
|
|
76
|
+
|
|
77
|
+
| File | Changes |
|
|
78
|
+
|------|---------|
|
|
79
|
+
| `src/agents/index.ts` | `__dirname` → `import.meta.dir` |
|
|
80
|
+
| `src/commands/index.ts` | `__dirname` → `import.meta.dir` |
|
|
81
|
+
| `src/skills/index.ts` | `__dirname` → `import.meta.dir` |
|
|
82
|
+
| `package.json` | v0.2.10 |
|
|
83
|
+
| `src/cli.ts` | VERSION = "0.2.10" |
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Git State
|
|
88
|
+
|
|
89
|
+
- **Branch:** `main`
|
|
90
|
+
- **Uncommitted changes:** All previous fixes + this fix
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Context for Resumption
|
|
95
|
+
|
|
96
|
+
### Why `import.meta.dir` Works
|
|
97
|
+
|
|
98
|
+
Bun's bundler treats `import.meta.dir` specially - it's preserved as a runtime expression that evaluates to the actual file's directory at runtime, not build time. This is standard ESM behavior.
|
|
99
|
+
|
|
100
|
+
### Path Resolution After Fix
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
Installed location: ~/.cache/opencode/node_modules/clikit-plugin/
|
|
104
|
+
|
|
105
|
+
dist/index.js
|
|
106
|
+
├── import.meta.dir → ~/.cache/opencode/node_modules/clikit-plugin/dist/
|
|
107
|
+
├── AGENTS_DIR = import.meta.dir → ~/.cache/.../dist/ (contains compiled index.js)
|
|
108
|
+
│ └── Resolved from src/agents/*.md via package.json "files": ["src/agents"]
|
|
109
|
+
├── COMMANDS_DIR = import.meta.dir + "../../command" → ~/.cache/.../command/
|
|
110
|
+
└── SKILLS_DIR = import.meta.dir + "../../skill" → ~/.cache/.../skill/
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Note: `AGENTS_DIR` points to `dist/` which doesn't contain `.md` files directly. The `src/agents` directory IS included in package.json `files` array, but the path resolution may need adjustment.
|
|
114
|
+
|
|
115
|
+
### Potential Issue
|
|
116
|
+
|
|
117
|
+
Looking at the package structure:
|
|
118
|
+
- `dist/index.js` is the entry point
|
|
119
|
+
- `import.meta.dir` in `dist/index.js` evaluates to `.../clikit-plugin/dist/`
|
|
120
|
+
- But `src/agents/*.md` files are at `.../clikit-plugin/src/agents/`
|
|
121
|
+
|
|
122
|
+
The agents directory resolution may need adjustment. Check if agents load correctly after install.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Resume Command
|
|
127
|
+
|
|
128
|
+
To resume, use `/resume` and verify:
|
|
129
|
+
1. Plugin starts without errors
|
|
130
|
+
2. Agents load (check `[CliKit] Loaded X agents` log)
|
|
131
|
+
3. Commands load (check `[CliKit] Loaded X commands` log)
|
package/package.json
CHANGED
package/src/agents/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as fs from "fs";
|
|
|
3
3
|
import * as path from "path";
|
|
4
4
|
import matter from "gray-matter";
|
|
5
5
|
|
|
6
|
-
const AGENTS_DIR =
|
|
6
|
+
const AGENTS_DIR = path.join(import.meta.dir, "../src/agents");
|
|
7
7
|
|
|
8
8
|
function parseAgentMarkdown(filePath: string): AgentConfig | null {
|
|
9
9
|
try {
|