Skip to content

Commit dcbbecc

Browse files
committed
Refactor plugin output generation and fix GUI CI setup
1 parent 98004f9 commit dcbbecc

12 files changed

+297
-473
lines changed

.github/workflows/pull-request.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,15 @@ jobs:
121121

122122
- uses: ./.github/actions/setup-node-pnpm
123123

124-
- uses: ./.github/actions/setup-rust
124+
- name: Read GUI version
125+
id: gui-version
126+
run: |
127+
version="$(node -p 'require("./gui/package.json").version')"
128+
echo "version=$version" >> "$GITHUB_OUTPUT"
129+
130+
- uses: ./.github/actions/setup-tauri
125131
with:
126-
cache-key: pr
132+
version: ${{ steps.gui-version.outputs.version }}
127133

128134
- name: Build native modules
129135
run: pnpm run build:native

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
],
3131
"scripts": {
3232
"build": "turbo build",
33-
"test": "turbo test --filter=!@truenine/memory-sync-gui",
33+
"test": "turbo test",
3434
"lint": "turbo lint",
3535
"lint:fix": "turbo lint:fix",
3636
"check:type": "turbo check:type",

sdk/src/plugins/CodexCLIOutputPlugin.ts

Lines changed: 16 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import type {
77
SkillPrompt
88
} from './plugin-core'
99
import {Buffer} from 'node:buffer'
10-
import * as path from 'node:path'
1110
import {
1211
AbstractOutputPlugin,
1312
filterByProjectConfig,
@@ -21,7 +20,6 @@ const PROMPTS_SUBDIR = 'prompts'
2120
const AGENTS_SUBDIR = 'agents'
2221
const SKILLS_SUBDIR = 'skills'
2322
const PRESERVED_SYSTEM_SKILL_DIR = '.system'
24-
const SKILL_FILE_NAME = 'SKILL.md'
2523
const MCP_CONFIG_FILE = 'mcp.json'
2624
const CODEX_SUBAGENT_FIELD_ORDER = ['name', 'description', 'developer_instructions'] as const
2725
const CODEX_EXCLUDED_SUBAGENT_FIELDS = ['scope', 'seriName', 'argumentHint', 'color', 'namingCase', 'model'] as const
@@ -183,66 +181,30 @@ export class CodexCLIOutputPlugin extends AbstractOutputPlugin {
183181
scope: 'project' | 'global',
184182
filteredSkills: readonly SkillPrompt[]
185183
): void => {
186-
for (const skill of filteredSkills) {
187-
const skillName = this.getSkillName(skill)
188-
const skillDir = path.join(baseDir, SKILLS_SUBDIR, skillName)
189-
190-
declarations.push({
191-
path: path.join(skillDir, SKILL_FILE_NAME),
192-
scope,
193-
source: {kind: 'skillMain', skill} satisfies CodexOutputSource
184+
this.appendSkillDeclarations(declarations, baseDir, scope, filteredSkills, {
185+
skillSubDir: SKILLS_SUBDIR,
186+
buildSkillReferenceSource: childDoc => ({
187+
kind: 'skillChildDoc',
188+
content: childDoc.content as string
194189
})
195-
196-
if (skill.childDocs != null) {
197-
for (const childDoc of skill.childDocs) {
198-
declarations.push({
199-
path: path.join(
200-
skillDir,
201-
childDoc.relativePath.replace(/\.mdx$/, '.md')
202-
),
203-
scope,
204-
source: {
205-
kind: 'skillChildDoc',
206-
content: childDoc.content as string
207-
} satisfies CodexOutputSource
208-
})
209-
}
210-
}
211-
212-
if (skill.resources != null) {
213-
for (const resource of skill.resources) {
214-
declarations.push({
215-
path: path.join(skillDir, resource.relativePath),
216-
scope,
217-
source: {
218-
kind: 'skillResource',
219-
content: resource.content,
220-
encoding: resource.encoding
221-
} satisfies CodexOutputSource
222-
})
223-
}
224-
}
225-
}
190+
})
226191
}
227192

228193
const pushSkillMcpDeclarations = (
229194
baseDir: string,
230195
scope: 'project' | 'global',
231196
filteredMcpSkills: readonly SkillPrompt[]
232197
): void => {
233-
for (const skill of filteredMcpSkills) {
234-
if (skill.mcpConfig == null) continue
235-
236-
const skillDir = path.join(baseDir, SKILLS_SUBDIR, this.getSkillName(skill))
237-
declarations.push({
238-
path: path.join(skillDir, MCP_CONFIG_FILE),
239-
scope,
240-
source: {
241-
kind: 'skillMcpConfig',
242-
rawContent: skill.mcpConfig.rawContent
243-
} satisfies CodexOutputSource
244-
})
245-
}
198+
this.appendSkillMcpDeclarations(
199+
declarations,
200+
baseDir,
201+
scope,
202+
filteredMcpSkills,
203+
{
204+
skillSubDir: SKILLS_SUBDIR,
205+
fileName: MCP_CONFIG_FILE
206+
}
207+
)
246208
}
247209

248210
if (

sdk/src/plugins/CursorOutputPlugin.ts

Lines changed: 40 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const RULES_SUBDIR = OutputSubdirectories.RULES
3131
const GLOBAL_RULE_FILE = OutputFileNames.CURSOR_GLOBAL_RULE
3232
const SKILLS_CURSOR_SUBDIR = OutputSubdirectories.CURSOR_SKILLS
3333
const SKILLS_PROJECT_SUBDIR = 'skills'
34-
const SKILL_FILE_NAME = OutputFileNames.SKILL
3534
const PRESERVED_SKILLS = PreservedSkills.CURSOR
3635

3736
type CursorOutputSource
@@ -201,47 +200,23 @@ export class CursorOutputPlugin extends AbstractOutputPlugin {
201200
): void => {
202201
const skillsSubDir
203202
= scope === 'global' ? SKILLS_CURSOR_SUBDIR : SKILLS_PROJECT_SUBDIR
204-
for (const skill of filteredSkills) {
205-
const skillName = this.getSkillName(skill)
206-
if (this.isPreservedSkill(skillName)) continue
207-
208-
const skillDir = path.join(baseDir, skillsSubDir, skillName)
209-
declarations.push({
210-
path: path.join(skillDir, SKILL_FILE_NAME),
211-
scope,
212-
source: {kind: 'skill', skill} satisfies CursorOutputSource
213-
})
214-
215-
if (skill.childDocs != null) {
216-
for (const childDoc of skill.childDocs) {
217-
declarations.push({
218-
path: path.join(
219-
skillDir,
220-
childDoc.relativePath.replace(/\.mdx$/, '.md')
221-
),
222-
scope,
223-
source: {
224-
kind: 'skillChildDoc',
225-
content: childDoc.content as string
226-
} satisfies CursorOutputSource
227-
})
228-
}
229-
}
230-
231-
if (skill.resources != null) {
232-
for (const resource of skill.resources) {
233-
declarations.push({
234-
path: path.join(skillDir, resource.relativePath),
235-
scope,
236-
source: {
237-
kind: 'skillResource',
238-
content: resource.content,
239-
encoding: resource.encoding
240-
} satisfies CursorOutputSource
241-
})
242-
}
203+
const writableSkills = filteredSkills.filter(
204+
skill => !this.isPreservedSkill(this.getSkillName(skill))
205+
)
206+
this.appendSkillDeclarations(
207+
declarations,
208+
baseDir,
209+
scope,
210+
writableSkills,
211+
{
212+
skillSubDir: skillsSubDir,
213+
buildSkillMainSource: skill => ({kind: 'skill', skill}),
214+
buildSkillReferenceSource: childDoc => ({
215+
kind: 'skillChildDoc',
216+
content: childDoc.content as string
217+
})
243218
}
244-
}
219+
)
245220
}
246221

247222
const pushSkillMcpDeclarations = (
@@ -251,23 +226,16 @@ export class CursorOutputPlugin extends AbstractOutputPlugin {
251226
): void => {
252227
const skillsSubDir
253228
= scope === 'global' ? SKILLS_CURSOR_SUBDIR : SKILLS_PROJECT_SUBDIR
254-
for (const skill of filteredMcpSkills) {
255-
if (skill.mcpConfig == null) continue
256-
257-
const skillDir = path.join(
258-
baseDir,
259-
skillsSubDir,
260-
this.getSkillName(skill)
261-
)
262-
declarations.push({
263-
path: path.join(skillDir, MCP_CONFIG_FILE),
264-
scope,
265-
source: {
266-
kind: 'skillMcpConfig',
267-
rawContent: skill.mcpConfig.rawContent
268-
} satisfies CursorOutputSource
269-
})
270-
}
229+
this.appendSkillMcpDeclarations(
230+
declarations,
231+
baseDir,
232+
scope,
233+
filteredMcpSkills,
234+
{
235+
skillSubDir: skillsSubDir,
236+
fileName: MCP_CONFIG_FILE
237+
}
238+
)
271239
}
272240

273241
const pushMcpDeclaration = (
@@ -356,17 +324,13 @@ export class CursorOutputPlugin extends AbstractOutputPlugin {
356324
project.projectConfig,
357325
'commands'
358326
)
359-
for (const command of filteredCommands) {
360-
declarations.push({
361-
path: path.join(
362-
baseDir,
363-
COMMANDS_SUBDIR,
364-
this.transformCommandName(command, transformOptions)
365-
),
366-
scope: 'project',
367-
source: {kind: 'command', command} satisfies CursorOutputSource
368-
})
369-
}
327+
this.appendCommandDeclarations(
328+
declarations,
329+
baseDir,
330+
'project',
331+
filteredCommands,
332+
transformOptions
333+
)
370334
}
371335
}
372336

@@ -376,17 +340,13 @@ export class CursorOutputPlugin extends AbstractOutputPlugin {
376340
promptSourceProjectConfig,
377341
'commands'
378342
)
379-
for (const command of filteredCommands) {
380-
declarations.push({
381-
path: path.join(
382-
globalDir,
383-
COMMANDS_SUBDIR,
384-
this.transformCommandName(command, transformOptions)
385-
),
386-
scope: 'global',
387-
source: {kind: 'command', command} satisfies CursorOutputSource
388-
})
389-
}
343+
this.appendCommandDeclarations(
344+
declarations,
345+
globalDir,
346+
'global',
347+
filteredCommands,
348+
transformOptions
349+
)
390350
}
391351

392352
if (rules != null && rules.length > 0) {

sdk/src/plugins/GenericSkillsOutputPlugin.ts

Lines changed: 25 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -87,72 +87,40 @@ export class GenericSkillsOutputPlugin extends AbstractOutputPlugin {
8787
scope: 'project' | 'global',
8888
filteredSkills: readonly SkillPrompt[]
8989
): void => {
90-
for (const skill of filteredSkills) {
91-
const skillName = this.getSkillName(skill)
92-
const skillDir = this.joinPath(baseSkillsDir, skillName)
93-
94-
declarations.push({
95-
path: this.joinPath(skillDir, SKILL_FILE_NAME),
96-
scope,
97-
source: {
98-
kind: 'skillMain',
99-
skill
100-
} satisfies GenericSkillOutputSource
101-
})
102-
103-
if (skill.childDocs != null) {
104-
for (const childDoc of skill.childDocs) {
105-
declarations.push({
106-
path: this.joinPath(
107-
skillDir,
108-
childDoc.relativePath.replace(/\.mdx$/, '.md')
109-
),
110-
scope,
111-
source: {
112-
kind: 'skillChildDoc',
113-
content: childDoc.content as string
114-
} satisfies GenericSkillOutputSource
115-
})
116-
}
90+
this.appendSkillDeclarations(
91+
declarations,
92+
baseSkillsDir,
93+
scope,
94+
filteredSkills,
95+
{
96+
skillSubDir: '',
97+
buildSkillReferenceSource: childDoc => ({
98+
kind: 'skillChildDoc',
99+
content: childDoc.content as string
100+
})
117101
}
118-
119-
if (skill.resources != null) {
120-
for (const resource of skill.resources) {
121-
declarations.push({
122-
path: this.joinPath(skillDir, resource.relativePath),
123-
scope,
124-
source: {
125-
kind: 'skillResource',
126-
content: resource.content,
127-
encoding: resource.encoding
128-
} satisfies GenericSkillOutputSource
129-
})
130-
}
131-
}
132-
}
102+
)
133103
}
134104

135105
const pushMcpDeclarations = (
136106
baseSkillsDir: string,
137107
scope: 'project' | 'global',
138108
filteredMcpSkills: readonly SkillPrompt[]
139109
): void => {
140-
for (const skill of filteredMcpSkills) {
141-
if (skill.mcpConfig == null) continue
142-
143-
declarations.push({
144-
path: this.joinPath(
145-
baseSkillsDir,
146-
this.getSkillName(skill),
147-
MCP_CONFIG_FILE
148-
),
149-
scope,
150-
source: {
110+
this.appendSkillMcpDeclarations(
111+
declarations,
112+
baseSkillsDir,
113+
scope,
114+
filteredMcpSkills,
115+
{
116+
skillSubDir: '',
117+
fileName: MCP_CONFIG_FILE,
118+
buildSkillMcpSource: skill => ({
151119
kind: 'skillMcp',
152-
rawContent: skill.mcpConfig.rawContent
153-
} satisfies GenericSkillOutputSource
154-
})
155-
}
120+
rawContent: skill.mcpConfig?.rawContent ?? ''
121+
})
122+
}
123+
)
156124
}
157125

158126
if (

0 commit comments

Comments
 (0)