Skip to content

Commit bd356a8

Browse files
committed
fix(kimaki): satisfy plugin lint rules
1 parent 1aca3cd commit bd356a8

2 files changed

Lines changed: 58 additions & 25 deletions

File tree

bridges/kimaki/plugins/dm-agent-sync.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
// Add to opencode.json: "plugin": ["path/to/dm-agent-sync.ts"]
1313
// Or place in .opencode/plugins/ in the project root.
1414

15+
/**
16+
* External dependencies
17+
*/
1518
import type { Plugin } from "@opencode-ai/plugin";
1619

1720
interface DmAgent {
@@ -56,17 +59,25 @@ const dmAgentSync: Plugin = async ({ $ }) => {
5659
// wp datamachine agents list appends a summary line ("Total: N agent(s).")
5760
// after the JSON array. Strip it to get valid JSON.
5861
const jsonMatch = agentsRaw.match(/\[[\s\S]*\]/);
59-
if (!jsonMatch) return;
62+
if (!jsonMatch) {
63+
return;
64+
}
6065

6166
const agents: DmAgent[] = JSON.parse(jsonMatch[0]);
62-
if (!agents.length) return;
67+
if (!agents.length) {
68+
return;
69+
}
6370

6471
// Ensure agent config object exists.
65-
if (!config.agent) config.agent = {};
72+
if (!config.agent) {
73+
config.agent = {};
74+
}
6675

6776
for (const agent of agents) {
6877
const status = agent.status || "active";
69-
if (status !== "active") continue;
78+
if (status !== "active") {
79+
continue;
80+
}
7081

7182
// Get agent file paths.
7283
let paths: DmPaths;
@@ -76,7 +87,9 @@ const dmAgentSync: Plugin = async ({ $ }) => {
7687
continue;
7788
}
7889

79-
if (!paths?.relative_files?.length) continue;
90+
if (!paths?.relative_files?.length) {
91+
continue;
92+
}
8093

8194
// Build the prompt from discovered files (layered: AGENTS.md → SITE.md → SOUL.md → MEMORY.md → USER.md).
8295
const prompt = [
@@ -104,8 +117,12 @@ const dmAgentSync: Plugin = async ({ $ }) => {
104117
prompt,
105118
mode: "primary" as const,
106119
};
107-
if (agentModel) buildEntry.model = agentModel;
108-
if (tools) buildEntry.tools = tools;
120+
if (agentModel) {
121+
buildEntry.model = agentModel;
122+
}
123+
if (tools) {
124+
buildEntry.tools = tools;
125+
}
109126

110127
// Check if this agent is already defined in the config (user override).
111128
// Don't overwrite explicit user config — only fill in missing agents.
@@ -154,6 +171,9 @@ const dmAgentSync: Plugin = async ({ $ }) => {
154171
/**
155172
* Check if an agent config entry looks like an intentional user override
156173
* (has a model set, which means the user chose something specific).
174+
*
175+
* @param {Record<string, unknown>} agent Agent configuration entry.
176+
* @return {boolean} Whether the entry looks user-configured.
157177
*/
158178
function isUserOverride(agent: Record<string, unknown>): boolean {
159179
return typeof agent.model === "string" && agent.model.length > 0;

bridges/kimaki/plugins/dm-context-filter.ts

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
// Add to opencode.json: "plugin": ["/opt/kimaki-config/plugins/dm-context-filter.ts"]
6363
// Or place in .opencode/plugins/ in the project root.
6464

65+
/**
66+
* External dependencies
67+
*/
6568
import type { Plugin } from "@opencode-ai/plugin";
6669

6770
const fleetContextFilter: Plugin = async () => {
@@ -108,7 +111,9 @@ const fleetContextFilter: Plugin = async () => {
108111
continue;
109112
}
110113
const text = (part as any).text as string;
111-
if (!text) continue;
114+
if (!text) {
115+
continue;
116+
}
112117

113118
// Remove MEMORY.md TOC injection.
114119
if (text.includes("Project memory from MEMORY.md")) {
@@ -134,22 +139,11 @@ const fleetContextFilter: Plugin = async () => {
134139
};
135140

136141
/**
137-
* Remove a markdown section from a system prompt block. Matches from the
138-
* heading to just before the next heading at the same or higher level, or
139-
* to the end of the block.
142+
* Remove a markdown section from a system prompt block.
140143
*
141-
* Supports both ## and ### headings. For ##, stops at the next ## or #.
142-
* For ###, stops at the next ###, ##, or #.
143-
*
144-
* Fence-aware: lines that look like headings but live inside fenced code
145-
* blocks (``` … ```) are NOT treated as section terminators. Bash code
146-
* examples in the kimaki system prompt routinely contain `# Comment`
147-
* lines, which a naive regex would mistake for a level-1 heading and
148-
* stop the section early — leaving the rest of the section unstripped.
149-
* The previous regex-only implementation hit this bug on every section
150-
* containing a ```bash block with `#`-prefixed comments (notably
151-
* "## waiting for a session to finish", which left a `--worktree`
152-
* reference in the filtered prompt).
144+
* @param {string} block - System prompt block.
145+
* @param {string} heading - Section heading to remove.
146+
* @return {string} System prompt block without the requested section.
153147
*/
154148
function stripSection(block: string, heading: string): string {
155149
const lines = block.split("\n");
@@ -165,7 +159,9 @@ function stripSection(block: string, heading: string): string {
165159
break;
166160
}
167161
}
168-
if (start === -1) return block;
162+
if (start === -1) {
163+
return block;
164+
}
169165

170166
// Walk forward looking for the next heading of the same or higher level
171167
// (i.e. fewer-or-equal `#` characters), tracking fenced-code-block state
@@ -178,7 +174,9 @@ function stripSection(block: string, heading: string): string {
178174
inFence = !inFence;
179175
continue;
180176
}
181-
if (inFence) continue;
177+
if (inFence) {
178+
continue;
179+
}
182180
const m = line.match(/^(#{1,6})\s+\S/);
183181
if (m && m[1].length <= level) {
184182
end = i;
@@ -203,6 +201,9 @@ function stripSection(block: string, heading: string): string {
203201
* Leaving the language in causes the agent to try `kimaki send --worktree`
204202
* or treat a Kimaki worktree as its working directory instead of using the
205203
* DM Code workspace.
204+
*
205+
* @param {string} block System prompt block.
206+
* @return {string} System prompt block without worktree inline guidance.
206207
*/
207208
function stripWorktreeInlines(block: string): string {
208209
let result = block;
@@ -267,6 +268,9 @@ function stripWorktreeInlines(block: string): string {
267268
*
268269
* We keep `${channelId}` examples untouched — those are the intended,
269270
* session-scoped forms.
271+
*
272+
* @param {string} block System prompt block.
273+
* @return {string} System prompt block without project discovery guidance.
270274
*/
271275
function stripProjectDiscoveryInlines(block: string): string {
272276
let result = block;
@@ -347,6 +351,9 @@ function stripProjectDiscoveryInlines(block: string): string {
347351
* agent. Passing `--agent <current_agent>` teaches the runtime agent to turn
348352
* the synthetic reminder value (often `opencode`) into a real session routing
349353
* override, bypassing the channel-bound Franklin agent.
354+
*
355+
* @param {string} block System prompt block.
356+
* @return {string} System prompt block without agent override examples.
350357
*/
351358
function stripAgentOverrideInlines(block: string): string {
352359
let result = block;
@@ -382,6 +389,9 @@ function stripAgentOverrideInlines(block: string): string {
382389
* use the live site and `wp`. A tunnel is still useful when the task needs an
383390
* inbound public URL, but it is not the default path for interacting with the
384391
* site.
392+
*
393+
* @param {string} block System prompt block.
394+
* @return {string} System prompt block with WordPress runtime guidance appended.
385395
*/
386396
function appendWordPressSiteRuntimeInstruction(block: string): string {
387397
const instruction = `
@@ -399,6 +409,9 @@ Use \`kimaki tunnel\` only when the task specifically needs an inbound public UR
399409

400410
/**
401411
* Append a positive Data Machine session handoff instruction.
412+
*
413+
* @param {string} block System prompt block.
414+
* @return {string} System prompt block with Data Machine handoff guidance appended.
402415
*/
403416
function appendDataMachineSessionHandoffInstruction(block: string): string {
404417
const instruction = `

0 commit comments

Comments
 (0)