akm-opencode 0.4.3 → 0.5.1

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # akm-opencode
2
2
 
3
- OpenCode plugin for the [AKM](https://github.com/itlackey/akm) CLI. Registers tools that let your AI agent **search**, **show**, and **manage** extension assets from stash directories and registries — plus **agentic hooks** that auto-load relevant assets into each turn, record feedback when assets are used, and harvest session memories so the stash improves with every session.
3
+ OpenCode plugin for the [AKM](https://github.com/itlackey/akm) CLI (v0.5.0+). Registers tools that let your AI agent **search**, **show**, and **manage** stash assets — skills, commands, agents, knowledge, memories, scripts, workflows, vaults, and wikis — plus **agentic hooks** that auto-load relevant assets into each turn, record feedback when assets are used, and harvest session memories so the stash improves with every session.
4
4
 
5
5
  ## Installation
6
6
 
@@ -14,27 +14,24 @@ Add to your OpenCode config (`opencode.json`):
14
14
 
15
15
  ## Tools
16
16
 
17
+ The plugin exposes a trimmed surface of **14 high-value tools**. Long-tail verbs (`add`, `save`, `import`, `clone`, `update`, `remove`, `list`-sources, `registry-search`, `index`-reindex, `config`, `upgrade`, ad-hoc `run`) are reachable via `akm_help` plus the raw `akm` CLI through the `bash` tool.
18
+
17
19
  | Tool | Description |
18
20
  |------|-------------|
19
- | `akm_search` | Search the local stash, the registry, or both for scripts, skills, commands, agents, and knowledge |
20
- | `akm_registry_search` | Search configured registries for installable kits and optional asset-level hits |
21
+ | `akm_search` | Search the local stash, the registry, or both. Type filter accepts `skill`, `command`, `agent`, `knowledge`, `memory`, `script`, `workflow`, `vault`, `wiki`, `any` |
21
22
  | `akm_show` | Show a stash asset by its ref |
22
- | `akm_index` | Build or rebuild the search index |
23
23
  | `akm_agent` | Dispatch a stash `agent:*` into OpenCode using the stash prompt and metadata |
24
24
  | `akm_cmd` | Execute a stash `command:*` template in OpenCode via SDK session prompting |
25
- | `akm_add` | Install kits from npm, GitHub, git URLs, or local directories |
26
- | `akm_list` | List configured AKM sources |
27
- | `akm_remove` | Remove a configured AKM source and reindex |
28
- | `akm_update` | Update one managed source or all managed sources |
29
- | `akm_clone` | Clone an asset into the working stash or a custom destination for editing |
30
25
  | `akm_remember` | Record a memory in the default stash |
31
- | `akm_feedback` | Record positive or negative feedback for a stash asset |
32
- | `akm_config` | Get, set, unset, list, or inspect akm configuration (including `config path --all`) |
33
- | `akm_run` | Execute a stash script using its `run` field |
34
- | `akm_sources` | Backward-compatible alias that lists configured AKM sources |
35
- | `akm_upgrade` | Check for or install akm CLI updates |
26
+ | `akm_feedback` | Record positive or negative feedback for a stash asset (skipped automatically for `memory:` and `vault:` refs) |
36
27
  | `akm_curate` | Curate the stash for a task or topic and return ranked matches the agent can use |
37
- | `akm_evolve` | Dispatch the AKM curator agent to review recent session activity and propose stash improvements |
28
+ | `akm_evolve` | Dispatch the AKM curator subagent into a child session, capture the report as a memory, and seed the curator-context cache so it survives compaction |
29
+ | `akm_parent_messages` | Summarize the parent OpenCode session so dispatched stash subagents can inherit upstream context |
30
+ | `akm_session_messages` | Summarize a specific OpenCode session (arbitrary IDs restricted to `akm-curator`) |
31
+ | `akm_vault` | Vault `list` / `show` (key names) / `create` / `set` / `unset` / `load` (opaque shell-eval text). **Values never surface** through `list`/`show`; `load` output is meant for `eval` and must not be displayed back |
32
+ | `akm_wiki` | Manage wikis (`create`, `register`, `list`, `show`, `pages`, `search`, `stash`, `lint`, `ingest`, `remove`) |
33
+ | `akm_workflow` | Drive workflow runs (`start`, `next`, `complete`, `status`, `list`, `create`, `template`, `resume`) |
34
+ | `akm_help` | Discover the right `akm` CLI invocation for non-first-class verbs. Returns a curated quick-reference table plus live `akm <subcommand> --help` output |
38
35
 
39
36
  ## Compound-engineering hooks
40
37
 
@@ -44,10 +41,13 @@ fails silently when `akm` is not on PATH — the TUI is never affected.
44
41
 
45
42
  | Event | What happens |
46
43
  | --- | --- |
47
- | **`session.created`** (event hook) | Warms the stash index in the background and caches `akm hints` for the next system transform so the agent knows the CLI surface area at turn 0. |
44
+ | **`session.created`** (event hook) | Warms the stash index in the background and caches `akm hints` plus active workflow status for the next system transform so the agent knows the CLI surface area at turn 0. |
48
45
  | **`chat.message`** | Runs `akm curate "<prompt>"` on each user message (prompts shorter than `AKM_CURATE_MIN_CHARS` are skipped). The top matches are stored for injection. Memory intents (prompts mentioning "remember" / "memory") are tracked in the session buffer. |
49
- | **`experimental.chat.system.transform`** | Appends the cached hints (once per session) and the curated context (once per turn) to the model's system prompt so the agent sees relevant stash assets before answering. |
50
- | **`tool.execute.after`** (`akm_*` tools) | Logs asset usage, accumulates refs into the session buffer, and records `akm feedback <ref> --positive` / `--negative` automatically based on whether the tool succeeded or failed. Never recurses into `akm_feedback` and skips `memory:` refs. |
46
+ | **`experimental.chat.system.transform`** | Appends cached hints, active workflow state, the last curator report, and the current prompt's curated context to the model's system prompt. Hints and workflow state are re-injected after transcript compaction. |
47
+ | **`tool.execute.before`** (`akm_*` tools) | Blocks destructive or sensitive operations until `confirm:true` is provided. |
48
+ | **`tool.execute.after`** (`akm_*` tools) | Logs asset usage, accumulates refs into the session buffer, records `akm feedback <ref> --positive` / `--negative` asynchronously with per-call dedupe, checkpoints memories every `AKM_MEMORY_CHECKPOINT_EVERY` successful asset-touching tool calls, and scans child-agent free text for additional refs. |
49
+ | **`experimental.session.compacting`** | Pushes hints, curated context, active workflows, and the last curator report into the compaction prompt so they survive transcript shrinking. |
50
+ | **`shell.env`** | Exposes `AKM_STASH_DIR`, `AKM_PROJECT`, and `AKM_PLUGIN_VERSION` to shell tools so plain `akm` calls inherit the right context. |
51
51
  | **`stop`** / **`session.idle`** / **`session.compacted`** / **`session.deleted`** | Flushes the per-session buffer into a `memory:opencode-session-YYYYMMDD-<sid>` memory so every meaningful session contributes durable context for future searches. Requires at least two observations before persisting. |
52
52
 
53
53
  ### Environment overrides
@@ -61,24 +61,22 @@ fails silently when `akm` is not on PATH — the TUI is never affected.
61
61
  | `AKM_CURATE_LIMIT` | `5` | Max curated results injected into context per prompt. |
62
62
  | `AKM_CURATE_MIN_CHARS` | `16` | Minimum prompt length before curation runs. |
63
63
  | `AKM_CURATE_TIMEOUT` | `8` | Wall-clock seconds for `akm` invocations inside hooks. |
64
+ | `AKM_CURATOR_CONTEXT_MAX_CHARS` | `4000` | Max cached curator-report characters re-injected into system/compaction context; the full report is still persisted as memory. |
65
+ | `AKM_MEMORY_CHECKPOINT_EVERY` | `8` | Number of successful asset-touching tool calls between mid-session checkpoint memories. |
66
+ | `AKM_RETROSPECTIVE_FEEDBACK_PATTERN` | `\b(thanks|perfect|worked)\b` | Case-insensitive regex used for lightweight positive retrospective feedback on the most recent refs. |
64
67
 
65
68
  ### Curator agent
66
69
 
67
- `akm_evolve` dispatches a child OpenCode session running a built-in curator
68
- prompt that reviews recent AKM activity (OpenCode app logs, session-summary
69
- memories, live stash) and produces a prioritized action list: hot assets to
70
- promote, cold ones to investigate, coverage gaps to draft, duplicates to
71
- consolidate. The curator never applies destructive changes without explicit
72
- user approval.
70
+ `akm_evolve` dispatches the native `akm-curator` OpenCode subagent when it is
71
+ available, falling back to `general` with the same curator prompt when needed.
72
+ The curator reviews recent AKM activity (OpenCode app logs, session-summary
73
+ memories, parent-session context, live stash), produces a prioritized action
74
+ list, and persists its latest report as `memory:akm-curator-YYYYMMDD-<sid>` so
75
+ future curator runs can build on it.
73
76
 
74
77
  ### Registry discovery
75
78
 
76
- Use either:
77
-
78
- - `akm_search` with `source: "registry"` or `source: "both"`
79
- - `akm_registry_search` when you only want installable community kits
80
-
81
- Registry hits include `id`, `installRef`, and `action` fields. Use `installRef` when passing a result into `akm_add`; registry-specific IDs are not installable refs. Use `assets: true` when you also want asset-level matches from registry v2 indexes.
79
+ Search registries with `akm_search` using `source: "registry"` or `source: "both"`. Registry hits include `id`, `installRef`, and `action` fields. Use `installRef` when feeding a result into `akm add` (run via `akm_help` topic="add" or directly through bash); registry-specific IDs are not installable refs.
82
80
 
83
81
  ## Agent Dispatch
84
82
 
@@ -142,10 +140,30 @@ stash/
142
140
  ├── skills/ # skill directories containing SKILL.md
143
141
  ├── commands/ # markdown files
144
142
  ├── agents/ # markdown files
145
- └── knowledge/ # markdown files
143
+ ├── knowledge/ # markdown files
144
+ ├── memories/ # markdown memory files (akm remember)
145
+ ├── workflows/ # multi-step procedures (workflow:<name>)
146
+ ├── vaults/ # .env secret stores (vault:<name>) — values never surface through structured output
147
+ └── wikis/ # per-wiki directories <name>/{schema,index,log}.md + raw/ + pages
146
148
  ```
147
149
 
148
- Assets are resolved from three source types: **working** (local stash), **search paths** (additional dirs via `searchPaths` config), and **installed** (registry kits via `akm add`).
150
+ ## Vaults
151
+
152
+ `akm_vault` is the one tool in this plugin with a hard contract on output. The
153
+ AKM CLI itself guarantees vault values never appear in JSON, the search index,
154
+ `.stash.json`, or any structured output channel. This plugin mirrors that:
155
+
156
+ - `action: "list"` / `"show"` return key names and comments only.
157
+ - `action: "set"` / `"unset"` never echo the value.
158
+ - `action: "load"` wraps `akm vault load` and returns the raw shell text
159
+ as-is. Treat it as opaque and hand it straight to a shell via
160
+ `eval "$(…)"` — do not log it, do not pass it through another tool, and do
161
+ not let the agent inspect it.
162
+
163
+ Automatic feedback recording (`tool.execute.after`) skips `vault:*` refs so
164
+ that usage signals can't leak which vault was touched.
165
+
166
+ Assets are resolved from three source types: **working** (local stash), **search paths** (additional dirs via `searchPaths` config), and **installed** (registry kits via `akm add` — see `akm_help` topic="add").
149
167
 
150
168
  ## Docs
151
169
 
@@ -0,0 +1,58 @@
1
+ ---
2
+ mode: subagent
3
+ description: AKM stash curator. Reviews session activity and proposes stash improvements.
4
+ permission:
5
+ task: deny
6
+ tools:
7
+ akm_vault: deny
8
+ write: deny
9
+ bash: deny
10
+ ---
11
+
12
+ You are the AKM curator — a compound-engineering agent that keeps the user's AKM stash improving every time the main agent finishes a task.
13
+
14
+ Inputs you should inspect:
15
+ 1. OpenCode app logs that include the "akm-opencode" service (feedback, memory, tool invocations).
16
+ 2. Session-summary memories named memory:opencode-session-*.
17
+ 3. The live stash: call akm_search "" --limit 50 and akm_show <ref> to enumerate assets; use akm_help topic="list sources" when you need the configured-sources view.
18
+ 4. Parent-session context via akm_parent_messages when this session was dispatched as a child.
19
+
20
+ Signals to act on:
21
+ - Hot refs: assets repeatedly appearing in positive tool outcomes. Call akm_feedback <ref> positive --note "curator: consistently useful" to reinforce.
22
+ - Cold refs: assets tied to failures or user complaints. Record akm_feedback <ref> negative --note "<excerpt>" and open the asset for review.
23
+ - Missing coverage: recurring user prompts with no matching asset. Draft a new skill, command, knowledge doc, wiki page, or workflow in the working stash and reindex via the akm CLI (see akm_help topic="reindex").
24
+ - Duplicates / drift: near-identical descriptions or overlapping responsibilities. Propose a consolidation.
25
+ - Stale memories: session summaries that never get recalled. Propose removal (see akm_help topic="remove") once distilled into a durable knowledge doc or wiki page.
26
+ - Wiki hygiene: for each wiki returned by akm_wiki list, run akm_wiki lint <name> and report orphans, broken xrefs, uncited raws, and stale indexes as fix candidates.
27
+ - Stuck workflows: run akm_workflow list --active and surface any runs in blocked or failed state with their step ids. Propose whether to resume or escalate.
28
+ - Never touch vaults: do not call akm_vault show or load unless the user explicitly asks. Vault values must never appear in reports.
29
+
30
+ Rules of engagement:
31
+ - Never apply destructive changes without explicit user approval.
32
+ - Report findings as a prioritized action list of concrete akm_* tool calls the user can run.
33
+ - Prefer small, reversible edits: promote via positive feedback, draft a candidate skill, or clone and tweak.
34
+ - When drafting new assets, write them into the working stash directory under skills/, commands/, agents/, knowledge/, or scripts/. Use akm_help (topic="config" / topic="reindex") to look up the right CLI invocation when you need the stash path or want to force a reindex.
35
+ - When finished, persist your own summary with akm_remember (name: curator-run-<timestamp>) so the next curator run can build on yours.
36
+
37
+ Output shape: end every run with a markdown report that has these sections:
38
+
39
+ ## Hot assets (promote)
40
+ - <ref> — why it helped — command to run
41
+
42
+ ## Cold assets (investigate)
43
+ - <ref> — failure signal — proposed fix
44
+
45
+ ## Coverage gaps
46
+ - <theme> — proposed asset (type, name, one-line description)
47
+
48
+ ## Duplicates / drift
49
+ - <ref a> vs <ref b> — consolidation proposal
50
+
51
+ ## Wiki health
52
+ - <wiki> — lint findings (orphan, broken-xref, uncited-raw, stale-index) with suggested fix
53
+
54
+ ## Workflow health
55
+ - <workflow|runId> — blocked/failed state — resume or escalate
56
+
57
+ ## Housekeeping
58
+ - stale memories, reindex needs, config tweaks