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.
This commit is contained in:
2026-04-16 08:35:53 -06:00
parent 1f57597ca3
commit 8026da5719
41 changed files with 1131 additions and 42 deletions

View File

@@ -14,7 +14,9 @@ function nowIso() {
}
async function resolveSyncCommand(directory) {
const configured = process.env.FIDELITY_MATTERMOST_SYNC_CMD?.trim()
const configured =
process.env.AIW_MATTERMOST_SYNC_CMD?.trim() ||
process.env.FIDELITY_MATTERMOST_SYNC_CMD?.trim()
if (configured) return configured
const fallbackScript = path.join(directory, "scripts/mattermost/sync.sh")
@@ -96,14 +98,34 @@ function requiresFreshMattermost(promptText) {
"mensajes",
"message",
"messages",
"jeff",
"manager",
"stakeholder",
"supervisor",
"lead",
"inbox",
]
const configuredTerms = [
process.env.AIW_COMMUNICATION_FRESH_TERMS,
process.env.AIW_MANAGER_NAME,
process.env.AIW_PRIMARY_STAKEHOLDER,
process.env.FIDELITY_MANAGER_NAME,
"jeff",
"fidelity-preguntas",
]
.filter(Boolean)
.flatMap((value) => String(value).split(","))
.map((value) => value.trim().toLowerCase())
.filter(Boolean)
const sourceTerms = [
...mattermostTerms,
...configuredTerms,
]
return (
freshnessTerms.some((term) => text.includes(term)) &&
mattermostTerms.some((term) => text.includes(term))
sourceTerms.some((term) => text.includes(term))
)
}
@@ -120,7 +142,9 @@ export const MattermostInbox = async ({ $, directory, client }) => {
if (!command) return
const intervalMinutes = Number.parseInt(
process.env.FIDELITY_MATTERMOST_SYNC_INTERVAL_MINUTES || "15",
process.env.AIW_MATTERMOST_SYNC_INTERVAL_MINUTES ||
process.env.FIDELITY_MATTERMOST_SYNC_INTERVAL_MINUTES ||
"15",
10,
)
const minIntervalMs = Math.max(1, Number.isNaN(intervalMinutes) ? 15 : intervalMinutes) * 60 * 1000
@@ -133,6 +157,12 @@ export const MattermostInbox = async ({ $, directory, client }) => {
const latestPath = path.join(inboxDir, "mattermost-latest.md")
const statusPath = path.join(inboxDir, "mattermost-status.json")
const commandSource = process.env.AIW_MATTERMOST_SYNC_CMD?.trim()
? "aiw-env"
: process.env.FIDELITY_MATTERMOST_SYNC_CMD?.trim()
? "fidelity-env"
: "workspace-default"
try {
await mkdir(inboxDir, { recursive: true })
const stdoutText = await $`bash -lc ${command}`.text()
@@ -153,7 +183,7 @@ export const MattermostInbox = async ({ $, directory, client }) => {
forced: Boolean(options.force),
changed: previous !== `${output}\n` && previous !== output,
commandConfigured: true,
commandSource: process.env.FIDELITY_MATTERMOST_SYNC_CMD?.trim() ? "env" : "workspace-default",
commandSource,
})
} else {
await writeStatus(statusPath, {
@@ -162,7 +192,7 @@ export const MattermostInbox = async ({ $, directory, client }) => {
forced: Boolean(options.force),
changed: false,
commandConfigured: true,
commandSource: process.env.FIDELITY_MATTERMOST_SYNC_CMD?.trim() ? "env" : "workspace-default",
commandSource,
note: "Sync command returned no output.",
})
}
@@ -173,7 +203,7 @@ export const MattermostInbox = async ({ $, directory, client }) => {
forced: Boolean(options.force),
changed: false,
commandConfigured: true,
commandSource: process.env.FIDELITY_MATTERMOST_SYNC_CMD?.trim() ? "env" : "workspace-default",
commandSource,
error: error instanceof Error ? error.message : String(error),
})