clikit-plugin 0.2.28 → 0.2.30
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/AGENTS.md +30 -32
- package/README.md +45 -26
- package/command/create.md +37 -122
- package/command/handoff.md +45 -69
- package/command/init.md +125 -48
- package/command/plan.md +101 -159
- package/command/research.md +1 -1
- package/command/resume.md +34 -55
- package/command/vision.md +132 -64
- package/dist/.tsbuildinfo +1 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +95 -11
- package/dist/clikit.schema.json +245 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/config.d.ts +43 -43
- package/dist/config.d.ts.map +1 -1
- package/dist/hooks/git-guard.test.d.ts +2 -0
- package/dist/hooks/git-guard.test.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +3 -14
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/memory-digest.d.ts +27 -0
- package/dist/hooks/memory-digest.d.ts.map +1 -0
- package/dist/hooks/security-check.test.d.ts +2 -0
- package/dist/hooks/security-check.test.d.ts.map +1 -0
- package/dist/hooks/todo-beads-sync.d.ts +23 -0
- package/dist/hooks/todo-beads-sync.d.ts.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +740 -909
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/tools/beads-memory-sync.d.ts.map +1 -1
- package/dist/tools/context-summary.d.ts.map +1 -1
- package/dist/tools/memory-db.d.ts +12 -0
- package/dist/tools/memory-db.d.ts.map +1 -0
- package/dist/tools/memory.d.ts.map +1 -1
- package/dist/tools/observation.d.ts.map +1 -1
- package/memory/_templates/plan.md +18 -0
- package/package.json +7 -4
- package/src/agents/AGENTS.md +11 -39
- package/src/agents/build.md +152 -94
- package/src/agents/index.ts +31 -5
- package/src/agents/looker.md +5 -0
- package/src/agents/oracle.md +2 -0
- package/src/agents/plan.md +247 -44
- package/src/agents/review.md +1 -0
- package/src/agents/vision.md +251 -115
- package/dist/cli.test.d.ts +0 -2
- package/dist/cli.test.d.ts.map +0 -1
- package/dist/hooks/auto-format.d.ts +0 -30
- package/dist/hooks/auto-format.d.ts.map +0 -1
- package/dist/hooks/comment-checker.d.ts +0 -17
- package/dist/hooks/comment-checker.d.ts.map +0 -1
- package/dist/hooks/compaction.d.ts +0 -60
- package/dist/hooks/compaction.d.ts.map +0 -1
- package/dist/hooks/env-context.d.ts +0 -43
- package/dist/hooks/env-context.d.ts.map +0 -1
- package/dist/hooks/ritual-enforcer.d.ts +0 -29
- package/dist/hooks/ritual-enforcer.d.ts.map +0 -1
- package/dist/hooks/session-notification.d.ts +0 -23
- package/dist/hooks/session-notification.d.ts.map +0 -1
- package/dist/hooks/session-notification.test.d.ts +0 -2
- package/dist/hooks/session-notification.test.d.ts.map +0 -1
- package/dist/hooks/typecheck-gate.d.ts +0 -31
- package/dist/hooks/typecheck-gate.d.ts.map +0 -1
- package/memory/handoffs/2026-02-15-complete-audit.md +0 -136
- package/memory/handoffs/2026-02-15-complete-fix.md +0 -140
- package/memory/handoffs/2026-02-15-importmeta-fix.md +0 -121
- package/memory/handoffs/2026-02-15-installing.md +0 -90
- package/memory/handoffs/2026-02-15-plugin-install-fix.md +0 -140
- package/memory/handoffs/2026-02-15-runtime-fixes.md +0 -80
- package/memory/plans/2026-02-16-plugin-install.md +0 -195
- package/memory/research/2026-02-16-opencode-plugin-alignment.md +0 -128
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeCheck Gate Hook
|
|
3
|
-
*
|
|
4
|
-
* Runs TypeScript type checking after .ts/.tsx file edits.
|
|
5
|
-
* Reports type errors inline so agents can fix them immediately.
|
|
6
|
-
* Runs on tool.execute.after for edit/write tools.
|
|
7
|
-
*/
|
|
8
|
-
export interface TypeCheckConfig {
|
|
9
|
-
enabled?: boolean;
|
|
10
|
-
tsconfig?: string;
|
|
11
|
-
log?: boolean;
|
|
12
|
-
block_on_error?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface TypeDiagnostic {
|
|
15
|
-
file: string;
|
|
16
|
-
line: number;
|
|
17
|
-
column: number;
|
|
18
|
-
code: string;
|
|
19
|
-
message: string;
|
|
20
|
-
}
|
|
21
|
-
export interface TypeCheckResult {
|
|
22
|
-
clean: boolean;
|
|
23
|
-
errors: TypeDiagnostic[];
|
|
24
|
-
checkedFile: string;
|
|
25
|
-
}
|
|
26
|
-
export declare function isTypeScriptFile(filePath: unknown): boolean;
|
|
27
|
-
export declare function findTsConfig(projectDir: unknown, override?: string): string | undefined;
|
|
28
|
-
export declare function hasTscInstalled(projectDir: unknown): boolean;
|
|
29
|
-
export declare function runTypeCheck(filePath: unknown, projectDir: unknown, config?: TypeCheckConfig): TypeCheckResult;
|
|
30
|
-
export declare function formatTypeCheckWarning(result: TypeCheckResult | unknown): string;
|
|
31
|
-
//# sourceMappingURL=typecheck-gate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typecheck-gate.d.ts","sourceRoot":"","sources":["../../src/hooks/typecheck-gate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AA4BD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAG3D;AAED,wBAAgB,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgBvF;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,OAAO,GAAG,OAAO,CAY5D;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,OAAO,EACjB,UAAU,EAAE,OAAO,EACnB,MAAM,CAAC,EAAE,eAAe,GACvB,eAAe,CAiCjB;AAsCD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,GAAG,MAAM,CAgBhF"}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
date: 2026-02-15
|
|
3
|
-
phase: implementing
|
|
4
|
-
branch: main
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Handoff: CliKit Complete Type Guard Audit
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Status Summary
|
|
12
|
-
|
|
13
|
-
CliKit plugin v0.2.6 published with many type guards. Typecheck passes. However, there are still potential runtime issues where OpenCode passes non-string values that could cause `.toLowerCase()`, `.test()`, `.split()` etc. to fail.
|
|
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
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## Remaining Issues (Need Type Guards)
|
|
31
|
-
|
|
32
|
-
### 1. git-guard.ts: `checkDangerousCommand`
|
|
33
|
-
**Line 25:** `command: string` - no type guard
|
|
34
|
-
**Used:** `index.ts:221` - `toolInput.command as string | undefined`
|
|
35
|
-
**Risk:** `pattern.test(command)` fails if command is object
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
// Fix needed:
|
|
39
|
-
export function checkDangerousCommand(command: unknown, allowForceWithLease = true): GitGuardResult {
|
|
40
|
-
if (typeof command !== "string") {
|
|
41
|
-
return { blocked: false, command: "" };
|
|
42
|
-
}
|
|
43
|
-
// ... rest
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### 2. swarm-enforcer.ts: `isFileInScope`
|
|
48
|
-
**Line 33-36:** `filePath: string` - no type guard
|
|
49
|
-
**Risk:** `path.resolve(filePath)` fails if filePath is not string
|
|
50
|
-
|
|
51
|
-
```typescript
|
|
52
|
-
// Fix needed:
|
|
53
|
-
export function isFileInScope(filePath: unknown, scope: TaskScope): boolean {
|
|
54
|
-
if (typeof filePath !== "string") return false;
|
|
55
|
-
// ...
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### 3. swarm-enforcer.ts: `checkEditPermission`
|
|
60
|
-
**Line 59-62:** `filePath: string` - no type guard
|
|
61
|
-
|
|
62
|
-
### 4. index.ts: Tool input casting
|
|
63
|
-
Multiple places where `toolInput.X as string | undefined` is used but the value could be an object:
|
|
64
|
-
- Line 218: `toolInput.command`
|
|
65
|
-
- Line 269: `toolInput.prompt`
|
|
66
|
-
- Line 335: `toolInput.filePath`
|
|
67
|
-
- Line 351: `toolInput.filePath`
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
## Files Modified (Uncommitted)
|
|
72
|
-
|
|
73
|
-
| File | Status |
|
|
74
|
-
|------|--------|
|
|
75
|
-
| `.opencode/package.json` | v0.2.6 |
|
|
76
|
-
| `.opencode/src/cli.ts` | Removed backup, fixed JSONC |
|
|
77
|
-
| `.opencode/src/config.ts` | Type guard for loadCliKitConfig |
|
|
78
|
-
| `.opencode/src/index.ts` | Array.isArray for todos |
|
|
79
|
-
| `.opencode/src/hooks/auto-format.ts` | Type guards |
|
|
80
|
-
| `.opencode/src/hooks/comment-checker.ts` | Type guards |
|
|
81
|
-
| `.opencode/src/hooks/compaction.ts` | Type guards |
|
|
82
|
-
| `.opencode/src/hooks/env-context.ts` | Type guards |
|
|
83
|
-
| `.opencode/src/hooks/security-check.ts` | Type guards |
|
|
84
|
-
| `.opencode/src/hooks/session-notification.ts` | Type guards |
|
|
85
|
-
| `.opencode/src/hooks/subagent-question-blocker.ts` | Type guards |
|
|
86
|
-
| `.opencode/src/hooks/swarm-enforcer.ts` | Partial (extractFileFromToolInput only) |
|
|
87
|
-
| `.opencode/src/hooks/todo-enforcer.ts` | Type guards |
|
|
88
|
-
| `.opencode/src/hooks/truncator.ts` | Type guards |
|
|
89
|
-
| `.opencode/src/hooks/typecheck-gate.ts` | Type guards |
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
## Git State
|
|
94
|
-
|
|
95
|
-
- **Branch:** `main`
|
|
96
|
-
- **Last commit:** `31b200c` - Update README with simplified installation
|
|
97
|
-
- **Uncommitted changes:** 15 files
|
|
98
|
-
|
|
99
|
-
---
|
|
100
|
-
|
|
101
|
-
## Next Steps
|
|
102
|
-
|
|
103
|
-
1. [ ] Add type guard to `git-guard.ts:checkDangerousCommand(command: unknown)`
|
|
104
|
-
2. [ ] Add type guard to `swarm-enforcer.ts:isFileInScope(filePath: unknown)`
|
|
105
|
-
3. [ ] Add type guard to `swarm-enforcer.ts:checkEditPermission(filePath: unknown)`
|
|
106
|
-
4. [ ] Run typecheck
|
|
107
|
-
5. [ ] Publish v0.2.7
|
|
108
|
-
6. [ ] Test: `opencode` starts without errors
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
## Pattern for Type Guards
|
|
113
|
-
|
|
114
|
-
```typescript
|
|
115
|
-
// Before (breaks on non-string):
|
|
116
|
-
export function myFunc(content: string): Result {
|
|
117
|
-
return content.split("\n"); // CRASH if content is object
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// After (safe):
|
|
121
|
-
export function myFunc(content: unknown): Result {
|
|
122
|
-
if (typeof content !== "string") {
|
|
123
|
-
return defaultResult; // Safe fallback
|
|
124
|
-
}
|
|
125
|
-
return content.split("\n");
|
|
126
|
-
}
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
---
|
|
130
|
-
|
|
131
|
-
## Resume Command
|
|
132
|
-
|
|
133
|
-
To resume, use `/resume` and it will:
|
|
134
|
-
1. Load this handoff
|
|
135
|
-
2. Propose fixing remaining type guards in git-guard.ts and swarm-enforcer.ts
|
|
136
|
-
3. Publish v0.2.7
|
|
@@ -1,140 +0,0 @@
|
|
|
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
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
date: 2026-02-15
|
|
3
|
-
phase: completed
|
|
4
|
-
branch: main
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Handoff: CliKit `import.meta.dir` Path Fix (v0.2.11)
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Status Summary
|
|
12
|
-
|
|
13
|
-
Fixed critical bug where bun build inlined `__dirname` to absolute build-time paths, AND fixed incorrect relative path resolution for bundled output. Plugin now correctly resolves paths at runtime from `dist/` directory.
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Bug Description
|
|
18
|
-
|
|
19
|
-
**Problem 1:** After `bun build`, `__dirname` was inlined to absolute build-time path:
|
|
20
|
-
```javascript
|
|
21
|
-
var __dirname = "/mnt/c/Users/Kira/Desktop/clikit/.opencode/src/agents";
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
**Problem 2:** Even after fixing to `import.meta.dir`, the relative paths were wrong because the bundled code runs from `dist/` but the paths were calculated from source file locations:
|
|
25
|
-
|
|
26
|
-
| File | Source Location | Bundled Location |
|
|
27
|
-
|------|-----------------|------------------|
|
|
28
|
-
| `agents/index.ts` | `src/agents/` | `dist/index.js` |
|
|
29
|
-
| `commands/index.ts` | `src/commands/` | `dist/index.js` |
|
|
30
|
-
| `skills/index.ts` | `src/skills/` | `dist/index.js` |
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## Fix Applied
|
|
35
|
-
|
|
36
|
-
| File | v0.2.10 (Broken) | v0.2.11 (Fixed) |
|
|
37
|
-
|------|------------------|-----------------|
|
|
38
|
-
| `src/agents/index.ts` | `import.meta.dir` → `dist/` | `path.join(import.meta.dir, "../src/agents")` |
|
|
39
|
-
| `src/commands/index.ts` | `import.meta.dir + "../../command"` | `path.join(import.meta.dir, "../command")` |
|
|
40
|
-
| `src/skills/index.ts` | `import.meta.dir + "../../skill"` | `path.join(import.meta.dir, "../skill")` |
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## Path Resolution (Correct)
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
Installed: ~/.cache/opencode/node_modules/clikit-plugin/
|
|
48
|
-
|
|
49
|
-
dist/index.js ← import.meta.dir points here
|
|
50
|
-
├── ../src/agents/ ← AGENTS_DIR (agent .md files)
|
|
51
|
-
├── ../command/ ← COMMANDS_DIR (command .md files)
|
|
52
|
-
└── ../skill/ ← SKILLS_DIR (skill directories)
|
|
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` (paths still wrong) |
|
|
63
|
-
| 0.2.11 | Correct relative paths from `dist/` directory |
|
|
64
|
-
| 0.2.19 | Retry `getObservationsByType` when SQLite reports datatype mismatch |
|
|
65
|
-
| 0.2.20 | Guard `memoryRead` against non-string paths |
|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
|
|
69
|
-
## Verification
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
# Check published package
|
|
73
|
-
npm pack clikit-plugin@latest && tar -xzf clikit-plugin-0.2.11.tgz
|
|
74
|
-
|
|
75
|
-
# Verify paths in bundled code
|
|
76
|
-
grep -E "AGENTS_DIR|COMMANDS_DIR|SKILLS_DIR" package/dist/index.js
|
|
77
|
-
|
|
78
|
-
# Output (correct):
|
|
79
|
-
# var AGENTS_DIR = path.join(import.meta.dir, "../src/agents");
|
|
80
|
-
# var COMMANDS_DIR = path2.join(import.meta.dir, "../command");
|
|
81
|
-
# var SKILLS_DIR = path9.join(import.meta.dir, "../skill");
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
## Next Steps
|
|
87
|
-
|
|
88
|
-
1. [ ] User test: `rm -rf ~/.cache/opencode/node_modules/clikit-plugin`
|
|
89
|
-
2. [ ] User test: `bun x clikit-plugin@latest install`
|
|
90
|
-
3. [ ] User test: `opencode` - should start without errors
|
|
91
|
-
4. [ ] Verify `[CliKit] Loaded 10/10 agents` in logs
|
|
92
|
-
5. [ ] Verify `[CliKit] Loaded 19/19 commands` in logs
|
|
93
|
-
|
|
94
|
-
---
|
|
95
|
-
|
|
96
|
-
## Files Modified (3 files)
|
|
97
|
-
|
|
98
|
-
| File | Changes |
|
|
99
|
-
|------|---------|
|
|
100
|
-
| `src/agents/index.ts` | `import.meta.dir` → `path.join(import.meta.dir, "../src/agents")` |
|
|
101
|
-
| `src/commands/index.ts` | `../../command` → `../command` |
|
|
102
|
-
| `src/skills/index.ts` | `../../skill` → `../skill` |
|
|
103
|
-
| `package.json` | v0.2.11 |
|
|
104
|
-
| `src/cli.ts` | VERSION = "0.2.11" |
|
|
105
|
-
|
|
106
|
-
---
|
|
107
|
-
|
|
108
|
-
## Git State
|
|
109
|
-
|
|
110
|
-
- **Branch:** `main`
|
|
111
|
-
- **Uncommitted changes:** All fixes from this session
|
|
112
|
-
|
|
113
|
-
---
|
|
114
|
-
|
|
115
|
-
## Root Cause Analysis
|
|
116
|
-
|
|
117
|
-
Bun's bundler inlines `__dirname` to the build-time absolute path. However, `import.meta.dir` is preserved as a runtime expression. The key insight is that when code is bundled:
|
|
118
|
-
|
|
119
|
-
1. All source files (`src/agents/index.ts`, `src/commands/index.ts`, `src/skills/index.ts`) are combined into a single `dist/index.js`
|
|
120
|
-
2. `import.meta.dir` in the bundled code refers to the location of `dist/index.js`, not the original source files
|
|
121
|
-
3. Resource files (`.md` files) are NOT bundled - they must be found via relative paths from `dist/`
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
date: 2026-02-15
|
|
3
|
-
phase: implementing
|
|
4
|
-
branch: main
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Handoff: CliKit Plugin Installation Fix
|
|
8
|
-
|
|
9
|
-
## Status Summary
|
|
10
|
-
|
|
11
|
-
CliKit plugin fully implemented (10 agents, 19 commands, 48 skills, 14 hooks, 6 tools). Published to npm as `clikit-plugin@0.1.6`. **Critical issue**: Plugin NOT registered in `~/.config/opencode/opencode.json` — the "plugin" key is missing entirely. This means the CLI installer was either never run or failed silently.
|
|
12
|
-
|
|
13
|
-
## Task Status
|
|
14
|
-
|
|
15
|
-
### ✅ Completed
|
|
16
|
-
- [x] T-001: Create 10 agents with proper model assignments
|
|
17
|
-
- [x] T-002: Create 19 slash commands
|
|
18
|
-
- [x] T-003: Create 48 workflow skills
|
|
19
|
-
- [x] T-004: Create 14 runtime hooks
|
|
20
|
-
- [x] T-005: Create 6 custom tools
|
|
21
|
-
- [x] T-006: Publish to npm as clikit-plugin@0.1.6
|
|
22
|
-
- [x] T-007: Create CLI installer code
|
|
23
|
-
|
|
24
|
-
### 🔄 In Progress
|
|
25
|
-
- [ ] T-008: Fix plugin registration in OpenCode config
|
|
26
|
-
- **Current state:** `~/.config/opencode/opencode.json` has no "plugin" key
|
|
27
|
-
- **Next step:** Run CLI installer and debug why registration isn't persisting
|
|
28
|
-
|
|
29
|
-
### 📋 Not Started
|
|
30
|
-
- [ ] T-009: Verify plugin loads when OpenCode starts
|
|
31
|
-
- [ ] T-010: Test installation in fresh environment
|
|
32
|
-
|
|
33
|
-
## Files Modified
|
|
34
|
-
|
|
35
|
-
| File | Status | Notes |
|
|
36
|
-
|------|--------|-------|
|
|
37
|
-
| `.opencode/src/index.ts` | Complete | Main plugin entry point |
|
|
38
|
-
| `.opencode/src/cli.ts` | Complete | CLI installer script |
|
|
39
|
-
| `.opencode/src/config.ts` | Complete | Config loader |
|
|
40
|
-
| `.opencode/package.json` | Complete | npm package config |
|
|
41
|
-
|
|
42
|
-
## Git State
|
|
43
|
-
|
|
44
|
-
- **Branch:** `main`
|
|
45
|
-
- **Last commit:** `31b200c` - Update README with simplified installation
|
|
46
|
-
- **Uncommitted:** No
|
|
47
|
-
|
|
48
|
-
## Known Issues
|
|
49
|
-
|
|
50
|
-
1. **Plugin not registered** - `~/.config/opencode/opencode.json` has NO "plugin" array
|
|
51
|
-
2. **Plugin not cached** - `~/.cache/opencode/node_modules/` missing clikit-plugin
|
|
52
|
-
3. **Possible path mismatch** - snap/bun may use different config path than native bun
|
|
53
|
-
|
|
54
|
-
## Next Steps
|
|
55
|
-
|
|
56
|
-
1. [ ] Run `bun x clikit-plugin install` to test CLI
|
|
57
|
-
2. [ ] Verify output with `grep '"plugin"' ~/.config/opencode/opencode.json`
|
|
58
|
-
3. [ ] Check if snap/bun path issue: `/home/kira/snap/bun-js/87/.config/opencode/`
|
|
59
|
-
4. [ ] Restart OpenCode and check for `[CliKit]` logs
|
|
60
|
-
|
|
61
|
-
## Context for Resumption
|
|
62
|
-
|
|
63
|
-
### Key Discovery
|
|
64
|
-
The opencode.json at `~/.config/opencode/opencode.json` exists but has no "plugin" array. CLI code at `.opencode/src/cli.ts:72-84` writes to this path, but the key is missing.
|
|
65
|
-
|
|
66
|
-
### Possible Causes
|
|
67
|
-
1. CLI was never executed by user
|
|
68
|
-
2. Bun snap uses different home path: `/home/kira/snap/bun-js/87/`
|
|
69
|
-
3. Write operation failed silently
|
|
70
|
-
|
|
71
|
-
### Verification Commands
|
|
72
|
-
```bash
|
|
73
|
-
# Run installer
|
|
74
|
-
bun x clikit-plugin install
|
|
75
|
-
|
|
76
|
-
# Check registration
|
|
77
|
-
grep -A2 '"plugin"' ~/.config/opencode/opencode.json
|
|
78
|
-
|
|
79
|
-
# Check snap path
|
|
80
|
-
ls /home/kira/snap/bun-js/87/.config/opencode/
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### Reference Implementation
|
|
84
|
-
- oh-my-opencode-slim: https://github.com/alvinunreal/oh-my-opencode-slim
|
|
85
|
-
- Plugin docs: https://opencode.ai/docs/plugins/
|
|
86
|
-
|
|
87
|
-
### Key Files to Review
|
|
88
|
-
- `.opencode/src/cli.ts` — CLI installer logic (lines 55-88)
|
|
89
|
-
- `~/.config/opencode/opencode.json` — Target config file
|
|
90
|
-
- `.opencode/package.json` — Package config with `main` and `bin`
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
date: 2026-02-15
|
|
3
|
-
phase: implementing
|
|
4
|
-
branch: main
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Handoff: CliKit Plugin Installation & Runtime Fixes
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Status Summary
|
|
12
|
-
|
|
13
|
-
CliKit plugin published to npm (v0.1.9 → v0.2.0). Fixed snap/bun path detection and multiple runtime errors. **CRITICAL ISSUE IDENTIFIED**: Installer overwrites `opencode.json` instead of merging with existing config, deleting user's existing settings. Multiple `.split()`, `.substring()` errors still occurring in hooks due to non-string arguments.
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Artifacts
|
|
18
|
-
|
|
19
|
-
| Type | Path | Status |
|
|
20
|
-
|------|------|--------|
|
|
21
|
-
| Handoff | `.opencode/memory/handoffs/2026-02-15-installing.md` | 📚 Previous |
|
|
22
|
-
| Config | `~/.config/opencode/opencode.json` | ⚠️ Gets overwritten |
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## Task Status
|
|
27
|
-
|
|
28
|
-
### ✅ Completed
|
|
29
|
-
- [x] T-001-T-007: Plugin implementation (10 agents, 19 commands, 48 skills, 14 hooks, 6 tools)
|
|
30
|
-
- [x] Fix snap/bun path detection using `SNAP_REAL_HOME` and regex fallback
|
|
31
|
-
- [x] Fix `buildErrorNotification` to handle Error objects
|
|
32
|
-
- [x] Fix `buildIdleNotification` to handle non-string sessionId
|
|
33
|
-
- [x] Fix `checkCommentDensity` and `hasExcessiveAIComments` to handle non-string content
|
|
34
|
-
- [x] Published v0.1.7, v0.1.8, v0.1.9, v0.2.0 to npm
|
|
35
|
-
|
|
36
|
-
### 🔄 In Progress
|
|
37
|
-
- [ ] **CRITICAL**: Fix installer to MERGE with existing opencode.json instead of overwriting
|
|
38
|
-
- **Current state:** `parseConfig()` reads existing config, but may not preserve all keys
|
|
39
|
-
- **User report:** "nó ghi đè file opencode.json làm xóa config có sẵn của tôi"
|
|
40
|
-
- **Root cause:** Need to deep merge, not shallow overwrite
|
|
41
|
-
|
|
42
|
-
- [ ] Fix remaining runtime errors in hooks
|
|
43
|
-
- **Files needing defensive type checks:**
|
|
44
|
-
- `src/hooks/truncator.ts` - `shouldTruncate()`, `truncateOutput()`
|
|
45
|
-
- `src/hooks/security-check.ts` - `scanContentForSecrets()`
|
|
46
|
-
- `src/hooks/compaction.ts` - multiple `.substring()` calls
|
|
47
|
-
- **Pattern:** Add `if (typeof content !== "string") return defaultResult;` at function start
|
|
48
|
-
|
|
49
|
-
### 📋 Not Started
|
|
50
|
-
- [ ] T-009: Verify plugin loads when OpenCode starts
|
|
51
|
-
- [ ] T-010: Test installation in fresh environment
|
|
52
|
-
- [ ] Add automated tests for installer
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## Files Modified
|
|
57
|
-
|
|
58
|
-
| File | Status | Notes |
|
|
59
|
-
|------|--------|-------|
|
|
60
|
-
| `src/cli.ts` | Modified | Added `getRealHome()` for snap path detection |
|
|
61
|
-
| `src/hooks/session-notification.ts` | Modified | Fixed `buildIdleNotification`, `buildErrorNotification` |
|
|
62
|
-
| `src/hooks/comment-checker.ts` | Modified | Added type guards for content param |
|
|
63
|
-
| `src/index.ts` | Modified | Pass raw error to `buildErrorNotification` |
|
|
64
|
-
| `package.json` | Modified | Version bumps to 0.2.0 |
|
|
65
|
-
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
## Git State
|
|
69
|
-
|
|
70
|
-
- **Branch:** `main`
|
|
71
|
-
- **Last commit:** `31b200c` - Update README with simplified installation
|
|
72
|
-
- **Uncommitted changes:** Yes (5 modified files)
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
## Known Issues
|
|
77
|
-
|
|
78
|
-
1. **CRITICAL: Installer overwrites opencode.json** - deletes user's existing config (mcp, provider settings)
|
|
79
|
-
- Need to deep merge instead of shallow merge
|
|
80
|
-
- Should backup existing config before modifying
|
|
81
|
-
|
|
82
|
-
2. **Runtime TypeError: `.split()`, `.substring()` on undefined**
|
|
83
|
-
- Multiple hooks receive non-string arguments from OpenCode events
|
|
84
|
-
- Need defensive type checks in ALL functions that call string methods
|
|
85
|
-
|
|
86
|
-
3. **Snap/bun path mismatch** - partially fixed but user still sees wrong path
|
|
87
|
-
- `bun x` may cache old versions
|
|
88
|
-
- Need to verify `SNAP_REAL_HOME` detection works in user's environment
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## Next Steps
|
|
93
|
-
|
|
94
|
-
1. [ ] **FIX INSTALLER** - Merge with existing config, don't overwrite:
|
|
95
|
-
```typescript
|
|
96
|
-
// In cli.ts, preserve existing config keys
|
|
97
|
-
const existingConfig = parseConfig(configPath);
|
|
98
|
-
const newConfig = { ...existingConfig, plugin: filteredPlugins };
|
|
99
|
-
writeConfig(configPath, newConfig);
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
2. [ ] Add defensive type checks to all hooks that use string methods:
|
|
103
|
-
- `truncator.ts`: `shouldTruncate()`, `truncateOutput()`
|
|
104
|
-
- `security-check.ts`: `scanContentForSecrets()`
|
|
105
|
-
- `compaction.ts`: All substring calls
|
|
106
|
-
|
|
107
|
-
3. [ ] Publish v0.2.1 with fixes
|
|
108
|
-
|
|
109
|
-
4. [ ] Test: `bun x clikit-plugin@latest install` should preserve existing config
|
|
110
|
-
|
|
111
|
-
---
|
|
112
|
-
|
|
113
|
-
## Context for Resumption
|
|
114
|
-
|
|
115
|
-
### The Core Problem
|
|
116
|
-
The installer's `writeConfig()` function writes the entire config object to disk. The current code does spread, but needs to ensure `parseConfig()` returns complete existing config.
|
|
117
|
-
|
|
118
|
-
### Solution Approach
|
|
119
|
-
```typescript
|
|
120
|
-
// cli.ts - install() function:
|
|
121
|
-
const existingConfig = parseConfig(configPath) || {};
|
|
122
|
-
const plugins = Array.isArray(existingConfig.plugin) ? [...existingConfig.plugin] : [];
|
|
123
|
-
// ... modify plugins array ...
|
|
124
|
-
config.plugin = filteredPlugins;
|
|
125
|
-
// existingConfig already has all keys, we just update plugin
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### Files to Review
|
|
129
|
-
- `src/cli.ts:55-108` — Installer logic
|
|
130
|
-
- `src/hooks/truncator.ts` — Needs type guards
|
|
131
|
-
- `src/hooks/security-check.ts` — Needs type guards
|
|
132
|
-
|
|
133
|
-
---
|
|
134
|
-
|
|
135
|
-
## Resume Command
|
|
136
|
-
|
|
137
|
-
To resume, use `/resume` and it will:
|
|
138
|
-
1. Load this handoff
|
|
139
|
-
2. Check for drift
|
|
140
|
-
3. Propose fixing installer merge logic first
|