Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
471 commits
Select commit Hold shift + click to select a range
9d324d8
Remove undici, @sentry/node; move @types/ws to devDependencies
remorses Apr 1, 2026
f1c24ed
remove undici use
remorses Apr 1, 2026
5b7c911
Delete bin.sh
remorses Apr 2, 2026
61c9ab1
Update package.json
remorses Apr 2, 2026
1e2b032
auto enable auto-restart
remorses Apr 2, 2026
6b17623
Update bin.ts
remorses Apr 2, 2026
b433e57
Fix pending question handling for voice follow-ups
remorses Apr 4, 2026
c378ec7
Add multi-account Anthropic OAuth rotation
remorses Apr 4, 2026
8270941
Replace `e as Error` casts with proper Error wrapping using cause chains
remorses Apr 4, 2026
7bf9e9d
Update test snapshots
remorses Apr 4, 2026
d3ac34e
Update goke to ^6.3.2
remorses Apr 4, 2026
dd8baa3
worktree merge: opencode/kimaki-see-that-right-now-voice-messages-hav…
remorses Apr 4, 2026
00d713b
feat: show detected agent indicator after voice transcription
remorses Apr 4, 2026
b4def07
Rewrite new-skill SKILL.md as a best-practices guide for creating skills
remorses Apr 4, 2026
f3423af
Update new-skill: synced skills warning, better README example, singu…
remorses Apr 4, 2026
dd91aaa
fix: scope /worktrees to the current project
remorses Apr 4, 2026
f693f2f
feat: run dependency install after worktree creation, queue messages …
remorses Apr 4, 2026
6382370
fix main CI queue recovery and plugin loading
remorses Apr 4, 2026
6402ebd
refactor: use single root prepare script with --filter instead of per…
remorses Apr 4, 2026
b003557
fix plugin logger compatibility on Node 22
remorses Apr 4, 2026
ae14be3
remove terminal styling deps from shared logger
remorses Apr 4, 2026
47c8c5f
fix anthropic plugin lockfile import for plugin startup
remorses Apr 4, 2026
c3fc19e
update voice question queue snapshots
remorses Apr 4, 2026
14b96f7
stabilize voice question session assertions
remorses Apr 4, 2026
072ba86
relax flaky voice question thread snapshot
remorses Apr 4, 2026
5911d60
feat: auto-rename Discord threads from OpenCode session titles
remorses Apr 5, 2026
602d19b
Merge branch 'main' of https://github.com/remorses/kimaki
remorses Apr 5, 2026
480e96c
fix: avoid duplicating markdown task list markers after marked upgrade
remorses Apr 5, 2026
1272059
/merge-worktree: rebase instead of squash
remorses Apr 5, 2026
c79fbc4
feat: detect leading /command in user prompts and route to opencode c…
remorses Apr 5, 2026
171f5ac
Update package.json
remorses Apr 5, 2026
0ed31a0
Update pnpm-lock.yaml
remorses Apr 5, 2026
0b57189
fix: keep Kimaki system prompt stable across a session
remorses Apr 5, 2026
28a2ad1
refactor: detect /command on any line instead of stripping prefixes
remorses Apr 5, 2026
381a641
fix: keep stable channel context in the session prompt
remorses Apr 5, 2026
1675426
docs: add MEMORY.md with session learnings
remorses Apr 5, 2026
9c12471
refactor: simplify MEMORY reminder to latest assistant reply
remorses Apr 5, 2026
eec27eb
feat: add image optimizer plugin to prevent oversized image API errors
remorses Apr 5, 2026
c97da78
refactor: tighten MEMORY.md prompt instructions for conciseness
remorses Apr 6, 2026
5870579
docs: add session learnings on thread rename rate limits, session tit…
remorses Apr 6, 2026
622612b
chore: bump traforo submodule
remorses Apr 6, 2026
6f676bc
rename discord/ folder to cli/
remorses Apr 6, 2026
9a10bbb
docs: add worktree base branch instructions to system message
remorses Apr 6, 2026
0b411f5
chore: update pnpm-lock.yaml
remorses Apr 6, 2026
584dc38
chore: bump traforo submodule to dae3518
remorses Apr 6, 2026
5980311
fix lockfile
remorses Apr 6, 2026
3f739a5
Update anthropic-auth-plugin.ts
remorses Apr 6, 2026
2ba3d6b
docs: use rimraf in npm-package skill build example
remorses Apr 6, 2026
6b6e0a4
feat: add --cwd option to kimaki send for reusing existing worktree d…
remorses Apr 6, 2026
53ef283
restore: bring back colored clack logger output
remorses Apr 6, 2026
a15e5fc
fix: keep stable --user examples in Kimaki send prompts
remorses Apr 6, 2026
1cadbcc
fix: skip restart wrapper only for --help
remorses Apr 6, 2026
022e63f
fix: always log opencode server warnings
remorses Apr 6, 2026
325cfc8
fix: drop opencode server log prefixes
remorses Apr 6, 2026
f523b00
add Discord reply context to prompt ingress
remorses Apr 6, 2026
6bd8b07
fix: isolate opencode plugin logging from clack
remorses Apr 6, 2026
1a7ed06
fix: remove final clack import from plugin startup path
remorses Apr 6, 2026
efd8511
fix: replay interrupted queued prompts instead of resuming empty sess…
remorses Apr 6, 2026
142bc63
refactor anthropic auth state handling
remorses Apr 6, 2026
7fc7cb4
sync bundled skill docs
remorses Apr 6, 2026
647dd56
fix external sync session discovery
remorses Apr 6, 2026
c347998
reduce external sync log noise
remorses Apr 6, 2026
6fa7ed6
refactor: remove automatic Kimaki Discord role reconciliation
remorses Apr 6, 2026
2ca0840
release: kimaki@0.4.91
remorses Apr 6, 2026
dd0db6c
docs: add plugin fix and opencode log forwarding to 0.4.91 changelog
remorses Apr 6, 2026
c6013b0
ignore subagent sessions in external sync
remorses Apr 6, 2026
24859ec
truncate folder and branch names to 15 chars in footer
remorses Apr 6, 2026
96b3179
fix: route /command-cmd prompts via session.command when registeredUs…
remorses Apr 6, 2026
746d19a
release: kimaki@0.4.92
remorses Apr 6, 2026
5d7c684
increase footer truncation limit to 30 chars
remorses Apr 7, 2026
db5c603
document running opencode commands and switching agents via kimaki send
remorses Apr 7, 2026
25ef55f
clarify agent switches apply on the next thread message
remorses Apr 7, 2026
b0fe92e
docs: move npm-package cleanup to prepublishOnly
remorses Apr 7, 2026
bd65727
show toast notification on Claude account rotation
remorses Apr 7, 2026
3412ee6
improve merge-worktree conflict resolution guidance
remorses Apr 7, 2026
67eaec1
release: kimaki@0.4.93
remorses Apr 7, 2026
a70aba3
soften worktree directory reminder wording
remorses Apr 7, 2026
639f040
add system prompt drift detector plugin
remorses Apr 8, 2026
89b39a8
refine system prompt drift toast
remorses Apr 8, 2026
9484cef
Update system-prompt-drift-plugin.ts
remorses Apr 8, 2026
620cb70
Fix Anthropic Max Subscription third party detection. Max subscription
remorses Apr 8, 2026
cfb502c
Truncate log args to 1000 chars to prevent giant log output
remorses Apr 8, 2026
c3a3f1d
release: kimaki@0.4.94
remorses Apr 8, 2026
a9c77e3
fix: use namespace import for discord.js CJS interop in plugin chain
remorses Apr 8, 2026
8721ba5
fix: fix max subscription by removing OpenCode identity section inste…
remorses Apr 8, 2026
c9a9b71
release: kimaki@0.4.95
remorses Apr 8, 2026
fcd86ee
refine system prompt drift toast copy
remorses Apr 8, 2026
66f30d3
simplify saved system prompt filenames
remorses Apr 8, 2026
f027811
scope marked toasts to the matching session
remorses Apr 8, 2026
7ea763f
release: kimaki@0.4.96
remorses Apr 8, 2026
efb7937
scope anthropic plugin toasts to the active session
remorses Apr 8, 2026
d2e4ace
expose anthropic account CLI commands
remorses Apr 8, 2026
f478d71
disable gateway onboarding mode. fucking discord verification process
remorses Apr 8, 2026
35cdff6
persist anthropic account identity across oauth rotation
remorses Apr 8, 2026
635ae81
normalize generated agents markdown whitespace
remorses Apr 8, 2026
f63f7bb
simplify worktree base selection to HEAD
remorses Apr 8, 2026
e505109
refine agentmap scope for initial kimaki context
remorses Apr 8, 2026
32540e3
release: kimaki@0.4.97
remorses Apr 8, 2026
88e0799
Update anthropic-auth-plugin.ts
remorses Apr 8, 2026
6f8be07
remove latestPromptPath
remorses Apr 8, 2026
075d600
delay system prompt drift detection
remorses Apr 8, 2026
d79b3e7
Add /vscode browser workspace tunnel
remorses Apr 8, 2026
da3ef1c
Prefer current-agent kimaki send examples
remorses Apr 8, 2026
75b4e5b
switch website defaults to kimaki.dev with xyz fallback
remorses Apr 9, 2026
378b385
use kimaki.dev as CLI and onboarding default domain
remorses Apr 9, 2026
4b3dd11
update bridge and onboarding docs to kimaki.dev
remorses Apr 9, 2026
18ae413
bump gateway-proxy submodule for kimaki.dev defaults
remorses Apr 9, 2026
ef09153
regenerate AGENTS.md after kimaki.dev instruction updates
remorses Apr 9, 2026
94deb87
bump traforo submodule to kimaki.dev routing commit
remorses Apr 9, 2026
f111529
remove downlevelIteration from shared tsconfig
remorses Apr 9, 2026
571017f
release: kimaki@0.4.98
remorses Apr 9, 2026
5003776
migrate stored gateway proxy urls from xyz to dev
remorses Apr 9, 2026
db1f7f7
release: kimaki@0.4.99
remorses Apr 9, 2026
766e306
release: kimaki@0.4.100
remorses Apr 9, 2026
494e637
test: refresh cli send thread command snapshot
remorses Apr 9, 2026
2fb9e4b
test: remove brittle opencode command snapshots
remorses Apr 9, 2026
9fd92d4
remove lintcn. I will use my global config instead
remorses Apr 9, 2026
0e7c449
Update traforo
remorses Apr 9, 2026
88eb69b
nn
remorses Apr 9, 2026
66ca176
Extract frozen memory overview plugin
remorses Apr 9, 2026
1038bf6
add opencode go to providers for login
remorses Apr 9, 2026
b3f9bbc
fix anthropic third party app detection
remorses Apr 9, 2026
8d0b4d1
refactor anthropic prompt rewriting
remorses Apr 9, 2026
65f1c97
release: kimaki@0.4.101
remorses Apr 9, 2026
4f53052
allow opensrc directory in opencode defaults
remorses Apr 9, 2026
faeafb3
fix: load the built OpenCode plugin from dist in published kimaki
remorses Apr 10, 2026
7288139
release: kimaki@0.4.102
remorses Apr 10, 2026
9fc1b11
add anthropic current account command
remorses Apr 10, 2026
58e4ee4
add positional clear-queue support
remorses Apr 10, 2026
61661f3
improve skill sync reliability and refresh skill docs
remorses Apr 10, 2026
f638e7b
update traforo submodule
remorses Apr 10, 2026
2992e34
dedupe repeated question tool requests
remorses Apr 10, 2026
07984ab
extract GenAI bash tool and cache remote skills
remorses Apr 10, 2026
dd1b0f8
revert GenAI bash tool extraction
remorses Apr 10, 2026
6caab5c
make /new-worktree use the current local HEAD by default
remorses Apr 10, 2026
06eeed0
clarify scheduled task no-op cleanup
remorses Apr 10, 2026
acb48e8
sync skills: add profano skill and update npm-package skill
remorses Apr 10, 2026
9a50af3
Add BTW message shortcut for side-question forks
remorses Apr 10, 2026
e635856
show model in /xx-agent quick-switch reply
remorses Apr 10, 2026
daf10a2
fix queue drain after dropdown answers
remorses Apr 11, 2026
d5ed00d
test sync /plan-agent model snapshot
remorses Apr 11, 2026
dfa2b01
docs tighten skill authoring guidance
remorses Apr 11, 2026
278ce0f
chore(deps): bump goke to ^6.5.2 across cli, profano, traforo
remorses Apr 11, 2026
768e968
chore(deps): bump goke to ^6.6.0 and simplify option handling
remorses Apr 11, 2026
cecfcd2
docs(npm-package): add section on package.json imports map types cond…
remorses Apr 11, 2026
e1e5c49
feat(cli): add --enable-skill / --disable-skill to filter injected sk…
remorses Apr 11, 2026
852a8c3
delete betterstack thing
remorses Apr 11, 2026
fbd5fd7
fix(cli): append trailing newline to synthetic user message parts
remorses Apr 11, 2026
2b69ab6
fix(cli): mention pwd change and forbid writes to previous folder in …
remorses Apr 11, 2026
2be0b75
fix(cli): drop confusing 'worktree reminders emitted only on change' …
remorses Apr 11, 2026
06a0183
feat(cli): shorten worktree paths and folder names
remorses Apr 11, 2026
15065dd
fix(cli): use MUST wording and cite overriding other changes in workt…
remorses Apr 11, 2026
df425e6
remove profano
remorses Apr 12, 2026
33aa932
agents
remorses Apr 12, 2026
b99eef8
Update pnpm-lock.yaml
remorses Apr 12, 2026
aa6c97b
fix(cli): re-inject process cwd into Anthropic sanitized system prompt
remorses Apr 12, 2026
a339d71
support punctuation separators in btw prefix detection
remorses Apr 12, 2026
5428c0e
feat(worktrees): use git worktree list as source of truth for /worktr…
remorses Apr 12, 2026
294a6b8
add pnpm workspaces and CI sections to npm-package skill
remorses Apr 12, 2026
8dfb6d5
preserve btw: and Fork: prefixes during OpenCode session title renames
remorses Apr 12, 2026
0f44467
fix ~/.config/opencode/skills/<skill-name>/SKILL.md
remorses Apr 12, 2026
900fb64
fix anthropic again? I am such a genius
remorses Apr 12, 2026
e5314de
fix(discord): dedupe task start messages
remorses Apr 12, 2026
0ba5cb1
release: kimaki@0.4.103
remorses Apr 12, 2026
2ea18fa
fix queued question handoff and update goke
remorses Apr 13, 2026
fee15d1
release: kimaki@0.4.104
remorses Apr 13, 2026
0063899
fix system prompt drift toast diff display
remorses Apr 14, 2026
58fa5e1
fix opencode log chunking for readable output
remorses Apr 15, 2026
0cc4387
add /add-dir session permission updates
remorses Apr 15, 2026
3f68e72
simplify /add-dir permission updates
remorses Apr 15, 2026
a0a6ebe
fix opencode directory resolution and speed up e2e failures
remorses Apr 15, 2026
5a08b3c
update opencode-injection-guard submodule for CI
remorses Apr 15, 2026
3d8b9c4
update traforo submodule for frozen lockfile installs
remorses Apr 15, 2026
9fe2c10
prevent worktree sessions from editing the main checkout
remorses Apr 16, 2026
d3bf952
docs: add TRAFORO_URL usage examples to tunnel system prompt instruct…
remorses Apr 16, 2026
c8d8d27
release: kimaki@0.5.0
remorses Apr 16, 2026
1981598
add subagent rate-limit model fallback plugin
remorses Apr 16, 2026
8e65c55
simplify subagent rate-limit fallback plugin
remorses Apr 17, 2026
a3f094b
docs: clarify root-level skill location
remorses Apr 17, 2026
ddfa550
abort rate-limited subagent sessions
remorses Apr 17, 2026
e343f4f
ignore unscoped Discord toasts
remorses Apr 17, 2026
470dc16
remove openc0de thing
remorses Apr 17, 2026
f78f1d6
replace gitchamber with opensrc
remorses Apr 17, 2026
58b637a
nn
remorses Apr 17, 2026
03a6e1c
allow common home toolchain caches by default
remorses Apr 17, 2026
2e63571
chore: update traforo submodule to proxy-aware WebSocket agent commit
remorses Apr 17, 2026
45bbef4
Rebrand opencode → openc0de in Anthropic system prompt and allow ~/.c…
remorses Apr 18, 2026
7aa2b81
fix anthropic again. very picky
remorses Apr 18, 2026
89fe70c
Update anthropic-auth-plugin.ts
remorses Apr 18, 2026
68871eb
fix homedir bug
remorses Apr 18, 2026
9736252
Update anthropic-auth-plugin.ts
remorses Apr 18, 2026
ebe3b61
fix interrupt plugin infinite abort→replay loop on large contexts
remorses Apr 18, 2026
80c3c46
centralize appendToastSessionMarker so plugin toasts route to Discord
remorses Apr 18, 2026
bfe6ea5
add bash tool for GenAI worker with remote skill loading
remorses Apr 18, 2026
d691f35
release: kimaki@0.6.0
remorses Apr 18, 2026
ee9111d
Revert "add bash tool for GenAI worker with remote skill loading"
remorses Apr 18, 2026
bff02e9
Fix vitest OpenCode startup paths
remorses Apr 18, 2026
a14e1ed
Fix CI-only permission and plugin loading tests
remorses Apr 18, 2026
041eabc
Relax queue e2e hook timeouts for CI
remorses Apr 18, 2026
a2c4ef9
Track OpenAI transcription requests in Kimaki
remorses Apr 18, 2026
9768966
Make /add-dir default to all directories
remorses Apr 19, 2026
4312572
Update new-skill and npm-package skills: prefer root README in worksp…
remorses Apr 19, 2026
1c3fef8
readme info for npm packages
remorses Apr 19, 2026
299c9c1
support queue as a standalone final line
remorses Apr 19, 2026
3f9de54
Update SKILL.md
remorses Apr 19, 2026
b69f3eb
Update SKILL.md
remorses Apr 19, 2026
9a0e399
sync upstream terminal and automation skills
remorses Apr 19, 2026
d7ac01c
replace tmux guidance with bunx tuistory flows
remorses Apr 19, 2026
8c8389d
fix website dev restart loop from doppler mount
remorses Apr 19, 2026
8268919
Update AGENTS.md
remorses Apr 20, 2026
d07da7e
docs(goke-skill): add @clack/prompts TTY guard rules and agent-safe p…
remorses Apr 20, 2026
8a6b270
Add callout containers to Discord markdown rendering
remorses Apr 20, 2026
3cee3cc
Simplify callout color guidance in the system prompt
remorses Apr 20, 2026
d4706e0
fix(anthropic-plugin): extract per-session cwd from stripped OpenCode…
remorses Apr 22, 2026
b8c06a2
Improve callout guidance in the system prompt
remorses Apr 22, 2026
8daf53e
add /fork-subagent thread for subagent sessions
remorses Apr 22, 2026
b51b23f
remove system prompt drift toast plugin
remorses Apr 22, 2026
c7d592e
sync skill docs from upstream repos
remorses Apr 22, 2026
1d6f141
docs: restore goke prompt guidance and tuistory docs
remorses Apr 22, 2026
0fda27f
refactor: make root skills the canonical source
remorses Apr 22, 2026
238990e
build: inline skill copy into package scripts
remorses Apr 22, 2026
114d660
refactor: assume bundled skills always exist in cli
remorses Apr 22, 2026
aa715b8
add sigillo skill
remorses Apr 22, 2026
c8ff029
skills: sync spiceflow skill with typed fetch rules
remorses Apr 23, 2026
410a4e8
avoid SIGKILL during hrana eviction
remorses Apr 23, 2026
814c2f5
poll hrana eviction for up to 10 seconds
remorses Apr 23, 2026
905dcde
fix fork-subagent replay formatting
remorses Apr 23, 2026
9074da0
chore: update model-variant description and errore submodule pointer
remorses Apr 23, 2026
81dc8d5
release: kimaki@0.7.0
remorses Apr 23, 2026
9272821
chore: update lockfile after kimaki@0.7.0 publish
remorses Apr 23, 2026
e77f0ae
fix callout rendering: skip ⬥ prefix for <callout> tags
remorses Apr 23, 2026
d83adc5
fix: update cwd extraction regex in anthropic plugin for new opencode…
remorses Apr 24, 2026
5e50b86
fix: handle subagent prompts in anthropic system text sanitization
remorses Apr 24, 2026
a19c8f6
release: kimaki@0.7.1
remorses Apr 24, 2026
50a31ca
show model and agent as first message when creating a new session thread
remorses Apr 25, 2026
b4f62b4
fix: pass resolved model to opencode commands
remorses Apr 26, 2026
abc14e1
show model and agent banner for opencode commands
remorses Apr 26, 2026
98a0bd2
Add last-sessions command
remorses Apr 29, 2026
1ffb922
Keep synced skills out of root skills
remorses Apr 29, 2026
45fd3c0
Document root skills folder
remorses Apr 29, 2026
33fd411
Simplify agent instructions source
remorses Apr 29, 2026
b7ab645
Update errore submodule instructions
remorses Apr 29, 2026
07f73e1
Apply add-dir permissions to busy sessions immediately
remorses Apr 29, 2026
12937c1
Document skill repository frontmatter
remorses Apr 30, 2026
78e70d0
Require Kimaki callouts for important notices
remorses Apr 30, 2026
123d43d
Keep CLI JSON output pipe-safe
remorses Apr 30, 2026
c2bb7d4
Use single quotes in kimaki send examples
remorses Apr 30, 2026
c11d4d4
Fix Bun dev startup isolation
remorses May 1, 2026
501b116
Update gateway proxy for Bun startup
remorses May 1, 2026
ddfabdf
Use tsx for CLI development
remorses May 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 22 additions & 0 deletions .agentmapignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Exclude low-signal generated, scratch, and reference folders from agentmap.
opensrc/**
betterstack/**
slop/**
plans/**
discord/**
discord-digital-twin/**
discord-slack-bridge/**
slack-digital-twin/**
fly-admin/**
libsqlproxy/**
errore/**
traforo/**
gateway-proxy/**
opencode-injection-guard/**
opencode-deterministic-provider/**
profano/**
usecomputer/**
tmp/**
cli/src/**/*.e2e.test.ts
cli/src/session-handler/event-stream-fixtures/**
cli/src/forum-sync/**
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
name: Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: pnpm/action-setup@v4
with:
version: 9

- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- name: Install opencode CLI
run: curl -fsSL https://opencode.ai/install | bash

- name: Add opencode to PATH
run: echo "$HOME/.opencode/bin" >> $GITHUB_PATH

- name: Verify opencode
run: opencode --version

- name: Install dependencies
run: pnpm install

# Submodules have dist/ gitignored so they need to be built after checkout.
# libsqlproxy is a workspace package that also needs building (exports from dist/).
- name: Build workspace packages with dist/ exports
run: |
pnpm --filter errore run build
pnpm --filter traforo run build
pnpm --filter opencode-injection-guard run build
pnpm --filter libsqlproxy run build

- name: Generate Prisma + SQL (discord-digital-twin)
run: pnpm generate
working-directory: discord-digital-twin

- name: Generate Prisma + SQL (cli)
run: pnpm generate
working-directory: cli

- name: Build discord-digital-twin
run: pnpm build
working-directory: discord-digital-twin

# --retry 3: some e2e tests have timing sensitivity on CI hardware
# (question tool cleanup races, reply ordering under slower I/O).
- name: Run tests
run: pnpm test -- --run --retry 3
working-directory: cli
env:
NODE_ENV: test
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ useraudio
*.wav
discord-audio-logs
tmp
/cli/skills

# opensrc - source code for packages
opensrc/
/opensrc
__snapshots__
traforo/dist/
skills/jitter/dist/
Expand All @@ -24,3 +25,6 @@ app.log
generated
.zig-cache
zig-out
website/.wrangler/
.wrangler
betterstack
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
path = gateway-proxy
url = https://github.com/remorses/gateway-proxy.git
branch = multi-client-support
[submodule "opencode-injection-guard"]
path = opencode-injection-guard
url = https://github.com/remorses/opencode-injection-guard.git
5 changes: 0 additions & 5 deletions .prettierignore

This file was deleted.

8 changes: 0 additions & 8 deletions .prettierrc.json

This file was deleted.

615 changes: 61 additions & 554 deletions AGENTS.md

Large diffs are not rendered by default.

598 changes: 0 additions & 598 deletions KIMAKI_AGENTS.md

This file was deleted.

140 changes: 140 additions & 0 deletions MEMORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Session learnings

## Prompt ingress architecture

All user prompts funnel through `ThreadSessionRuntime.enqueueIncoming` in
`cli/src/session-handler/thread-session-runtime.ts`. This is the single
centralized injection point for any cross-cutting prompt transformation
(command detection, prefix stripping, etc). The 6 sources that funnel here:

1. Discord chat messages → `discord-bot.ts` MessageCreate → `preprocess*Message` → `enqueueWithPreprocess`
2. `/new-session` slash → `commands/session.ts` → `enqueueIncoming` directly
3. `/queue` slash → posts Discord message with `» **user:** ...` prefix → path #1
4. `kimaki send --thread` (existing thread) → posts `» **kimaki-cli:** <prompt>` → path #1
5. `kimaki send --channel` (new thread) → raw starter message → bot `ThreadCreate` handler → `enqueueIncoming` with preprocess callback
6. Scheduled tasks (`task-runner.ts`) → posts Discord messages like #4/#5

Prefix conventions: `» **<username>:** ` is used for queued reposts and
CLI-injected messages in existing threads. New-thread flows (channel-level
`kimaki send` and channel scheduled tasks) post the raw prompt without
prefix and rely on an embed marker (`ThreadStartMarker` YAML) for metadata.

## Cross-cutting transformations — do them in two places

When adding a prompt-level transformation (like leading `/command` detection):
- Call the transformer inside `enqueueIncoming()` for sources that provide
a ready `prompt`.
- ALSO call it inside `enqueueWithPreprocess()` after the preprocess callback
resolves — otherwise preprocess-based inputs (including `ThreadCreate` flow
and Discord chat messages) skip the transformation.
- No double-conversion risk: `enqueueIncoming` returns early to
`enqueueWithPreprocess` when `input.preprocess` is set.

## preprocessNewSessionMessage wraps prompts

`preprocessNewSessionMessage()` wraps the user prompt with
`Context from thread:\n${starterText}\n\nUser request:\n${prompt}` when the
starter message differs from the current message. This breaks any
prefix-based detection (leading `/command`, etc) because the command is no
longer at the start of the prompt.

**Fix pattern**: run the detector on the raw prompt BEFORE wrapping and
skip the wrapping when detection succeeds.

## Prefer line-based detection over prefix stripping

When adding a transformation that needs to match a user-intent pattern in
prompts that sometimes carry programmatic prefixes (`» **kimaki-cli:** ...`,
`» **user:** ...`, `Context from thread: ...`), do NOT try to regex-strip
every possible prefix before matching. That creates maintenance burden
(new prefix formats silently break detection) and gets the semantics
wrong when usernames contain regex metacharacters.

Instead:
1. Split the prompt by `\n` and check each line
2. Always put programmatic prefixes on their OWN line (separated by `\n`
from the user's content), so the user's text starts at a fresh line
3. Detection only scans each line's first non-whitespace token

This makes detection oblivious to prefix format — it Just Works for any
current or future prefix line.

## Discord display names can contain `*`

When writing regexes to match markdown-formatted names like `**<name>:**`,
use non-greedy `[\s\S]+?` instead of `[^*]+`. Discord display names can
(rarely) contain `*`. Better long-term fix: escape usernames at render
time or pass structured metadata instead of parsing markdown.

## Commit only your own files when other agents are editing concurrently

`git status` frequently shows modifications from other agents running in
parallel on the same repo. Never `git add -A` or `git add .`. Always
enumerate your files explicitly:

```bash
git commit path/to/file1 path/to/file2 -m "message"
```

Before committing, run `git status -s` and `git diff <file>` on any file
you don't remember touching. If it's unrelated to your task, leave it out
of the commit.

## Discord thread rename is heavily rate-limited

Discord rate-limits channel/thread renames to ~2 per 10 minutes per thread,
and the limit is **undocumented** in headers — `setName()` will silently
block on the 3rd attempt rather than returning 429. See
discord/discord-api-docs#1900 and discordjs/discord.js#6651.

Design rules for any code that calls `thread.setName()`:

- Rename at most once per distinct new value (dedup via a runtime-local field).
- Race `setName()` against `AbortSignal.timeout(...)` (discord.js doesn't
take a signal directly, so wrap in `Promise.race`).
- Fail soft on timeout/429/error — log and continue, never retry.
- Don't let a blocked rename block queue draining, typing, or event handling.

Reference implementation: `handleSessionUpdated` in
`cli/src/session-handler/thread-session-runtime.ts`.

## OpenCode permission.reply cannot widen/change scope — patterns are fixed by permission.asked

`client.permission.reply({ requestID, directory, workspace, reply, message })`
is the only SDK method to answer a `permission.asked` event. The body only
accepts `reply: "once" | "always" | "reject"` plus an optional `message`.
There is **no** field to override the directory/path/patterns of the
permission. The `directory` and `workspace` query params are just routing
hints to identify which OpenCode server context the reply belongs to —
they do NOT change what the "always" rule covers.

The scope of "always" is determined entirely by `PermissionRequest.patterns`
set by OpenCode when it emitted `permission.asked`. If you want a broader
rule (e.g. grant permission for a parent directory instead of a single
file), the user must configure permission rules in OpenCode config / via
per-session `permissions` option (see `parsePermissionRules` and the
`--permission "tool:pattern:action"` CLI flag in
`cli/src/session-handler/thread-session-runtime.ts`), not via
`permission.reply`.

There is also a legacy `PermissionRespond` endpoint
(`POST /session/{sessionID}/permissions/{permissionID}`) with the same
body shape — no scope override there either.

## undici is a devDependency but easy to miss-install

`cli/package.json` lists `undici: ^8.0.2` as a devDependency (used by
`gateway-proxy-reconnect.e2e.test.ts` for `setGlobalDispatcher`). If you
see `Cannot find package 'undici'` from that test, just run `pnpm install`
inside `cli/`. Do NOT assume it's a transitive dep — the comment in
`discord-bot.ts:125` saying "undici is a transitive dep from discord.js"
is misleading for the test file which needs the explicit dependency.

## Worktree folder name ≠ branch name

`getManagedWorktreeDirectory` strips the `opencode/kimaki-` prefix from the
on-disk folder basename but the git branch name still keeps it. Two format
helpers exist: `formatWorktreeName` (verbatim, for user-provided names) and
`formatAutoWorktreeName` (vowel-compressed if >20 chars, for auto-derived
names from thread titles/prompts). Worktrees now live under
`<kimakiDataDir>/worktrees/<8charProjectHash>/<basename>`.
Loading