feat: refactor work item file retrieval to use Python script for improved error handling and readability

This commit is contained in:
2026-05-04 09:45:28 -06:00
parent 541c9b43de
commit ff4ed6a759
12 changed files with 195 additions and 143 deletions

View File

@@ -19,7 +19,28 @@ Read active profile, if present:
Relevant active work item files, if available:
!`if [ -d project-knowledge/02-work-items ]; then for f in project-knowledge/02-work-items/*.md; do case "$f" in *README.md|*index.md) continue;; esac; echo "\n### $f"; cat "$f"; done; else echo "No work item files available."; fi`
!`python3 - <<'PY'
import re
from pathlib import Path
summary = Path("project-knowledge/01-current/work-items.md")
if not summary.is_file():
print("No work item files available.")
raise SystemExit(0)
text = summary.read_text()
paths = re.findall(r"Detail: `(project-knowledge/02-work-items/[^`]+)`", text)
if not paths:
print("No work item files available.")
raise SystemExit(0)
for rel in paths:
path = Path(rel)
if not path.is_file():
continue
print(f"\n### {rel}")
print(path.read_text())
PY`
User request:

View File

@@ -24,7 +24,28 @@ Active profile, if present:
Detailed active work item files, if available:
!`if [ -d project-knowledge/02-work-items ]; then for f in project-knowledge/02-work-items/*.md; do case "$f" in *README.md|*index.md) continue;; esac; echo "\n### $f"; cat "$f"; done; else echo "No work item files available."; fi`
!`python3 - <<'PY'
import re
from pathlib import Path
summary = Path("project-knowledge/01-current/work-items.md")
if not summary.is_file():
print("No work item files available.")
raise SystemExit(0)
text = summary.read_text()
paths = re.findall(r"Detail: `(project-knowledge/02-work-items/[^`]+)`", text)
if not paths:
print("No work item files available.")
raise SystemExit(0)
for rel in paths:
path = Path(rel)
if not path.is_file():
continue
print(f"\n### {rel}")
print(path.read_text())
PY`
User request:

View File

@@ -6,34 +6,17 @@ Load and internalize the active context for this Fidelity workspace before answe
Use these files as the baseline context:
@README.md
@core/README.md
@core/memory/operational-memory.md
@core/integrations/memory-vault-model.md
@core/integrations/communication-model.md
@profiles/fidelity/profile.md
@agent-memory/README.md
@agent-memory/behavior/agent-behavior.md
@agent-memory/behavior/learning-sessions.md
@agent-memory/behavior/self-maintenance.md
@agent-memory/memory/operational-memory.md
@agent-memory/integrations/memory-interface.md
@agent-memory/integrations/obsidian.md
@agent-memory/integrations/communication-sources.md
@agent-memory/memory/promotion-rules.md
@agent-memory/integrations/technical-verification.md
@project-knowledge/00-start/start-here.md
@project-knowledge/01-current/current-work.md
@project-knowledge/01-current/work-items.md
@project-knowledge/07-maps/current-work.md
@project-knowledge/07-maps/fidelity-domain.md
@project-knowledge/07-maps/work-items.md
@project-knowledge/07-maps/people.md
@project-knowledge/03-context/project.md
@project-knowledge/03-context/process/communication.md
@agent-memory/integrations/technical-verification.md
@agent-memory/workflows/ai-to-ai-prompting.md
@project-knowledge/03-context/process/jira-story-rules.md
@agent-memory/workflows/workspace-model.md
@agent-memory/behavior/agent-behavior.md
@agent-memory/memory/promotion-rules.md
@project-knowledge/03-context/ios/index.md
@project-knowledge/04-people/manager.md
@project-knowledge/04-people/index.md
@@ -45,13 +28,34 @@ Today's canonical daily note, if present:
!`if [ -f project-knowledge/06-daily/$(date +%F).md ]; then cat project-knowledge/06-daily/$(date +%F).md; else echo "No daily note exists for today yet."; fi`
Recent daily notes available:
Latest daily notes available:
!`if [ -d project-knowledge/06-daily ]; then ls -1 project-knowledge/06-daily 2>/dev/null | sort | tail -n 5; else echo "No daily notes directory available."; fi`
!`if [ -d project-knowledge/06-daily ]; then ls -1 project-knowledge/06-daily 2>/dev/null | sort | tail -n 3; else echo "No daily notes directory available."; fi`
Detailed active work item files, if available:
!`if [ -d project-knowledge/02-work-items ]; then for f in project-knowledge/02-work-items/*.md; do case "$f" in *README.md|*index.md) continue;; esac; echo "\n### $f"; cat "$f"; done; else echo "No work item files available."; fi`
!`python3 - <<'PY'
import re
from pathlib import Path
summary = Path("project-knowledge/01-current/work-items.md")
if not summary.is_file():
print("No work item files available.")
raise SystemExit(0)
text = summary.read_text()
paths = re.findall(r"Detail: `(project-knowledge/02-work-items/[^`]+)`", text)
if not paths:
print("No work item files available.")
raise SystemExit(0)
for rel in paths:
path = Path(rel)
if not path.is_file():
continue
print(f"\n### {rel}")
print(path.read_text())
PY`
Latest Mattermost context, if available:

View File

@@ -12,7 +12,6 @@ Read:
@project-knowledge/01-current/current-work.md
@project-knowledge/01-current/work-items.md
@project-knowledge/03-context/project.md
@project-knowledge/03-context/workstreams/index.md
@project-knowledge/03-context/process/communication.md
@project-knowledge/04-people/manager.md
@project-knowledge/04-people/index.md
@@ -27,7 +26,28 @@ Latest Mattermost context, if available:
Detailed active work item files, if available:
!`if [ -d project-knowledge/02-work-items ]; then for f in project-knowledge/02-work-items/*.md; do case "$f" in *README.md|*index.md) continue;; esac; echo "\n### $f"; cat "$f"; done; else echo "No work item files available."; fi`
!`python3 - <<'PY'
import re
from pathlib import Path
summary = Path("project-knowledge/01-current/work-items.md")
if not summary.is_file():
print("No work item files available.")
raise SystemExit(0)
text = summary.read_text()
paths = re.findall(r"Detail: `(project-knowledge/02-work-items/[^`]+)`", text)
if not paths:
print("No work item files available.")
raise SystemExit(0)
for rel in paths:
path = Path(rel)
if not path.is_file():
continue
print(f"\n### {rel}")
print(path.read_text())
PY`
User draft or rough notes:

View File

@@ -4,18 +4,24 @@ description: Draft a standup from the latest Fidelity workspace context
Generate a standup update using the latest workspace state.
First, refresh Mattermost context before drafting:
First, refresh previous-workday Mattermost context before drafting:
!`python3 - <<'PY'
import os
import subprocess
from pathlib import Path
from datetime import date
cmd = os.environ.get("AIW_MATTERMOST_SYNC_CMD") or os.environ.get("FIDELITY_MATTERMOST_SYNC_CMD")
if cmd:
today = date.today().isoformat()
if Path("scripts/mattermost/sync.sh").is_file():
result = subprocess.run(
["bash", "scripts/mattermost/sync.sh", "--previous-workday", "--today", today],
capture_output=True,
text=True,
)
elif cmd:
result = subprocess.run(["bash", "-lc", cmd], capture_output=True, text=True)
elif Path("scripts/mattermost/sync.sh").is_file():
result = subprocess.run(["bash", "scripts/mattermost/sync.sh"], capture_output=True, text=True)
else:
print("No Mattermost sync command configured.")
raise SystemExit(0)
@@ -34,28 +40,17 @@ PY`
Read:
@prompts/standup.md
@project-knowledge/00-start/start-here.md
@project-knowledge/01-current/current-work.md
@project-knowledge/01-current/work-items.md
@project-knowledge/03-context/project.md
@project-knowledge/03-context/workstreams/index.md
@project-knowledge/03-context/workstreams/flow-page-references.md
@project-knowledge/03-context/process/communication.md
@project-knowledge/03-context/process/jira-story-rules.md
@project-knowledge/04-people/manager.md
Previous workday Mattermost context, if present:
!`bash scripts/mattermost/sync.sh --previous-workday --today "$(date +%F)"`
Today's log, if present:
!`if [ -f project-knowledge/06-daily/$(date +%F).md ]; then cat project-knowledge/06-daily/$(date +%F).md; else echo "No daily note exists for today yet."; fi`
Latest Mattermost context, preferring inbox and falling back to generated JSONL:
!`if [ -s ai/inbox/mattermost-latest.md ]; then cat ai/inbox/mattermost-latest.md; elif [ -s scripts/mattermost/generated/mattermost_context.jsonl ]; then cat scripts/mattermost/generated/mattermost_context.jsonl; else echo "No Mattermost context available."; fi`
Detailed active work item files, if available:
!`python3 - <<'PY'

View File

@@ -40,7 +40,28 @@ Latest Mattermost context, if available:
Detailed active work item files, if available:
!`if [ -d project-knowledge/02-work-items ]; then for f in project-knowledge/02-work-items/*.md; do case "$f" in *README.md|*index.md) continue;; esac; echo "\n### $f"; cat "$f"; done; else echo "No work item files available."; fi`
!`python3 - <<'PY'
import re
from pathlib import Path
summary = Path("project-knowledge/01-current/work-items.md")
if not summary.is_file():
print("No work item files available.")
raise SystemExit(0)
text = summary.read_text()
paths = re.findall(r"Detail: `(project-knowledge/02-work-items/[^`]+)`", text)
if not paths:
print("No work item files available.")
raise SystemExit(0)
for rel in paths:
path = Path(rel)
if not path.is_file():
continue
print(f"\n### {rel}")
print(path.read_text())
PY`
Requirements:

View File

@@ -6,37 +6,20 @@ Load and internalize the reusable workspace core and the active project context
Read core:
@core/README.md
@core/memory/operational-memory.md
@core/integrations/memory-vault-model.md
@core/integrations/communication-model.md
@core/profiles/create-project-profile.md
@agent-memory/README.md
@profiles/fidelity/profile.md
@agent-memory/behavior/agent-behavior.md
@agent-memory/behavior/learning-sessions.md
@agent-memory/behavior/self-maintenance.md
@agent-memory/memory/operational-memory.md
@agent-memory/integrations/memory-interface.md
@agent-memory/integrations/obsidian.md
@agent-memory/integrations/communication-sources.md
@agent-memory/memory/promotion-rules.md
@agent-memory/integrations/technical-verification.md
Read active workspace memory:
@README.md
@project-knowledge/00-start/start-here.md
@project-knowledge/00-start/onboarding.md
@project-knowledge/01-current/current-work.md
@project-knowledge/01-current/work-items.md
@project-knowledge/07-maps/current-work.md
@project-knowledge/07-maps/fidelity-domain.md
@project-knowledge/07-maps/work-items.md
@project-knowledge/07-maps/people.md
@project-knowledge/03-context/project.md
@project-knowledge/03-context/process/communication.md
@agent-memory/integrations/technical-verification.md
@agent-memory/memory/context-maintenance.md
@agent-memory/workflows/workspace-model.md
@agent-memory/behavior/agent-behavior.md
@agent-memory/memory/promotion-rules.md
@project-knowledge/03-context/ios/index.md
@project-knowledge/04-people/manager.md
@project-knowledge/04-people/index.md
@@ -52,13 +35,34 @@ Today's canonical daily note, if present:
!`if [ -f project-knowledge/06-daily/$(date +%F).md ]; then cat project-knowledge/06-daily/$(date +%F).md; else echo "No daily note exists for today yet."; fi`
Recent daily notes available:
Latest daily notes available:
!`if [ -d project-knowledge/06-daily ]; then ls -1 project-knowledge/06-daily 2>/dev/null | sort | tail -n 5; else echo "No daily notes directory available."; fi`
!`if [ -d project-knowledge/06-daily ]; then ls -1 project-knowledge/06-daily 2>/dev/null | sort | tail -n 3; else echo "No daily notes directory available."; fi`
Detailed active work item files, if available:
!`if [ -d project-knowledge/02-work-items ]; then for f in project-knowledge/02-work-items/*.md; do case "$f" in *README.md|*index.md) continue;; esac; echo "\n### $f"; cat "$f"; done; else echo "No work item files available."; fi`
!`python3 - <<'PY'
import re
from pathlib import Path
summary = Path("project-knowledge/01-current/work-items.md")
if not summary.is_file():
print("No work item files available.")
raise SystemExit(0)
text = summary.read_text()
paths = re.findall(r"Detail: `(project-knowledge/02-work-items/[^`]+)`", text)
if not paths:
print("No work item files available.")
raise SystemExit(0)
for rel in paths:
path = Path(rel)
if not path.is_file():
continue
print(f"\n### {rel}")
print(path.read_text())
PY`
Latest communication inbox, if available: