Files
fidelity-ai-workspace/.opencode/plugins/fidelity-compaction.js
david.delagneau 8026da5719 Refactor AI workspace for improved context management and communication integration
- Introduced new commands and skills for workspace memory curation, professional communication, and status reporting.
- Updated existing commands to utilize new skills and improve clarity in instructions.
- Created a new workspace context command to load reusable core and active project profile.
- Enhanced Mattermost inbox integration with support for generic environment variables.
- Established a clear separation between project-independent core logic and project-specific profiles.
- Improved documentation across various files to reflect changes in workflow and command usage.
- Added operational memory management rules to ensure accurate context promotion and correction.
- Updated README and workflow documents to guide users in utilizing the new structure effectively.
2026-04-16 08:35:53 -06:00

81 lines
2.4 KiB
JavaScript

import { readdir, readFile } from "node:fs/promises"
import path from "node:path"
async function safeRead(filePath) {
try {
return await readFile(filePath, "utf8")
} catch {
return null
}
}
export const FidelityCompaction = async ({ directory }) => {
return {
"experimental.session.compacting": async (_input, output) => {
const baseFiles = [
"README.md",
"core/README.md",
"core/memory/operational-memory.md",
"core/integrations/communication-model.md",
"profiles/fidelity/profile.md",
"ai/context/index.md",
"ai/context/project.md",
"ai/context/ios/index.md",
"ai/context/ios/current-practices.md",
"ai/context/ios/project-swift-guidance.md",
"ai/context/systems/index.md",
"ai/context/workstreams/index.md",
"ai/context/process/communication.md",
"ai/context/process/ai-to-ai-prompting.md",
"ai/context/people/manager.md",
"ai/context/people/index.md",
"ai/work-items/index.md",
"ai/state/current.md",
"ai/state/work-items.md",
"ai/context/decisions/rest-vs-graphql.md",
"ai/context/decisions/discourse-handling.md",
"knowledge/workspace-model.md",
"knowledge/communication-rules.md",
]
const sections = []
for (const relPath of baseFiles) {
const content = await safeRead(path.join(directory, relPath))
if (content) {
sections.push(`### ${relPath}\n${content.trim()}`)
}
}
try {
const logsDir = path.join(directory, "ai/logs")
const logs = (await readdir(logsDir))
.filter((name) => name.endsWith(".md"))
.sort()
.slice(-2)
for (const logName of logs) {
const content = await safeRead(path.join(logsDir, logName))
if (content) {
sections.push(`### ai/logs/${logName}\n${content.trim()}`)
}
}
} catch {
// No logs available yet.
}
if (sections.length > 0) {
output.context.push(
[
"## AI Workspace Persistent Context",
"Preserve this operational memory across compaction.",
"If later messages introduced corrections or durable facts, prefer the corrected view over stale summaries.",
"",
sections.join("\n\n"),
].join("\n"),
)
}
},
}
}