feat: update profile path resolution and enhance scripts for improved project adaptability
This commit is contained in:
@@ -7,7 +7,9 @@
|
||||
MATTERMOST_MIRROR_HOST_ALLOW=
|
||||
|
||||
# Output directory for raw evidence and normalized AI-readable context.
|
||||
MATTERMOST_MIRROR_DIR=ai/inbox/mattermost-mirror
|
||||
# Optional. If omitted, run-mirror.sh writes to the active profile inbox:
|
||||
# <inbox_dir from profiles/<profile>/workspace.json>/mattermost-mirror
|
||||
# MATTERMOST_MIRROR_DIR=/absolute/path/to/mattermost-mirror
|
||||
|
||||
# mitmproxy listener used by launch-mattermost.sh.
|
||||
MATTERMOST_MIRROR_LISTEN_HOST=127.0.0.1
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Local read-only Mattermost Desktop mirror for AI workspace context.
|
||||
|
||||
This is for **raw evidence only**. It writes under `ai/inbox/mattermost-mirror/`; durable project memory still belongs in `project-knowledge/` after normal promotion rules.
|
||||
This is for **raw evidence only**. By default it writes under the active profile inbox at `<inbox_dir>/mattermost-mirror/`; durable project memory still belongs in the profile's canonical project knowledge vault after normal promotion rules.
|
||||
|
||||
## Why this exists
|
||||
|
||||
@@ -48,7 +48,7 @@ missing.
|
||||
## Output layout
|
||||
|
||||
```text
|
||||
ai/inbox/mattermost-mirror/
|
||||
<profile inbox>/mattermost-mirror/
|
||||
latest.jsonl # bounded AI-readable window
|
||||
latest.md # bounded Markdown view
|
||||
state.json # last seen by channel and user cache
|
||||
@@ -138,7 +138,7 @@ Each line in the normalized JSONL contains:
|
||||
## Useful environment variables
|
||||
|
||||
- `MATTERMOST_MIRROR_HOST_ALLOW`: exact host or parent domain to capture.
|
||||
- `MATTERMOST_MIRROR_DIR`: output directory, default `ai/inbox/mattermost-mirror`.
|
||||
- `MATTERMOST_MIRROR_DIR`: optional output directory. If omitted, `run-mirror.sh` uses `<inbox_dir from profiles/<profile>/workspace.json>/mattermost-mirror`.
|
||||
- `MATTERMOST_MIRROR_LATEST_LIMIT`: number of messages in `latest.*`, default `200`.
|
||||
- `MATTERMOST_MIRROR_CHANNEL_IDS`: optional comma-separated channel ID allowlist.
|
||||
- `MATTERMOST_MIRROR_WRITE_RAW`: set to `1` to save compact raw REST/WebSocket evidence.
|
||||
@@ -170,7 +170,7 @@ do not create message files. Open a channel, open a thread, scroll slightly in
|
||||
history, or wait for/send a new message. Then check:
|
||||
|
||||
```text
|
||||
ai/inbox/mattermost-mirror/latest.md
|
||||
ai/inbox/mattermost-mirror/channels/<channel-name>/YYYY/MM/YYYY-MM-DD.jsonl
|
||||
ai/inbox/mattermost-mirror/by-date/YYYY/MM/YYYY-MM-DD.jsonl
|
||||
<profile inbox>/mattermost-mirror/latest.md
|
||||
<profile inbox>/mattermost-mirror/channels/<channel-name>/YYYY/MM/YYYY-MM-DD.jsonl
|
||||
<profile inbox>/mattermost-mirror/by-date/YYYY/MM/YYYY-MM-DD.jsonl
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@ This addon is intentionally narrow:
|
||||
- redact secrets
|
||||
- normalize posts into date-rotated JSONL files for AI context
|
||||
|
||||
The output under ai/inbox/ is raw evidence, not canonical project memory.
|
||||
The output under the profile inbox is raw evidence, not canonical project memory.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -23,7 +23,7 @@ from urllib.parse import urlparse
|
||||
from mitmproxy import http
|
||||
|
||||
|
||||
DEFAULT_OUT_DIR = "ai/inbox/mattermost-mirror"
|
||||
DEFAULT_OUT_DIR = "mattermost-mirror"
|
||||
POST_ID_RE = re.compile(r"^[a-z0-9]{26}$")
|
||||
SAFE_NAME_RE = re.compile(r"[^a-zA-Z0-9._-]+")
|
||||
|
||||
|
||||
@@ -13,17 +13,29 @@ import argparse
|
||||
import json
|
||||
import os
|
||||
import shlex
|
||||
import sys
|
||||
from datetime import date, datetime, timedelta
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
MIRROR_DIR = ROOT / "ai" / "inbox" / "mattermost-mirror"
|
||||
LEGACY_LATEST = ROOT / "ai" / "inbox" / "mattermost-latest.md"
|
||||
sys.path.insert(0, str(ROOT / "scripts" / "aiw"))
|
||||
import profile as aiw_profile # noqa: E402
|
||||
|
||||
DEFAULT_PROFILE = os.getenv("AIW_PROJECT_PROFILE", "fidelity")
|
||||
MIRROR_DIR = aiw_profile.inbox_dir(DEFAULT_PROFILE, root=ROOT) / "mattermost-mirror"
|
||||
LEGACY_LATEST = aiw_profile.inbox_dir(DEFAULT_PROFILE, root=ROOT) / "mattermost-latest.md"
|
||||
LEGACY_GENERATED = ROOT / "scripts" / "mattermost" / "generated" / "mattermost_context.jsonl"
|
||||
LOCAL_ENV = Path(__file__).resolve().parent / ".env"
|
||||
|
||||
|
||||
def configure_profile_paths(profile: str) -> None:
|
||||
global MIRROR_DIR, LEGACY_LATEST
|
||||
inbox = aiw_profile.inbox_dir(profile, root=ROOT)
|
||||
MIRROR_DIR = inbox / "mattermost-mirror"
|
||||
LEGACY_LATEST = inbox / "mattermost-latest.md"
|
||||
|
||||
|
||||
def load_local_env(path: Path = LOCAL_ENV) -> None:
|
||||
"""Load simple KEY=VALUE pairs from the connector-local .env.
|
||||
|
||||
@@ -201,6 +213,7 @@ def main() -> None:
|
||||
load_local_env()
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--profile", default=DEFAULT_PROFILE)
|
||||
parser.add_argument("--mode", choices=["latest", "previous-workday", "standup", "focused"], default="latest")
|
||||
parser.add_argument("--today", default="")
|
||||
parser.add_argument(
|
||||
@@ -210,6 +223,7 @@ def main() -> None:
|
||||
)
|
||||
parser.add_argument("--limit", type=int, default=80, help="Max records per section; use 0 for no limit.")
|
||||
args = parser.parse_args()
|
||||
configure_profile_paths(args.profile)
|
||||
channels = parse_channels(args.channels or None)
|
||||
limit = args.limit if args.limit > 0 else None
|
||||
|
||||
|
||||
@@ -11,7 +11,9 @@ if [ -f "$SCRIPT_DIR/.env" ]; then
|
||||
set +a
|
||||
fi
|
||||
|
||||
export MATTERMOST_MIRROR_DIR="${MATTERMOST_MIRROR_DIR:-$WORKSPACE_ROOT/ai/inbox/mattermost-mirror}"
|
||||
PROFILE="${AIW_PROJECT_PROFILE:-fidelity}"
|
||||
PROFILE_INBOX_DIR="$(python3 "$WORKSPACE_ROOT/scripts/aiw/profile.py" path inbox --profile "$PROFILE")"
|
||||
export MATTERMOST_MIRROR_DIR="${MATTERMOST_MIRROR_DIR:-$PROFILE_INBOX_DIR/mattermost-mirror}"
|
||||
export MATTERMOST_MIRROR_LISTEN_HOST="${MATTERMOST_MIRROR_LISTEN_HOST:-127.0.0.1}"
|
||||
export MATTERMOST_MIRROR_LISTEN_PORT="${MATTERMOST_MIRROR_LISTEN_PORT:-8080}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user