activating-expertise 0.1.0.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- activating_expertise-0.1.0.dev0.dist-info/METADATA +28 -0
- activating_expertise-0.1.0.dev0.dist-info/RECORD +61 -0
- activating_expertise-0.1.0.dev0.dist-info/WHEEL +5 -0
- activating_expertise-0.1.0.dev0.dist-info/entry_points.txt +2 -0
- activating_expertise-0.1.0.dev0.dist-info/licenses/LICENSE-DOCS +29 -0
- activating_expertise-0.1.0.dev0.dist-info/licenses/LICENSE-SOFTWARE +661 -0
- activating_expertise-0.1.0.dev0.dist-info/top_level.txt +1 -0
- ae/__init__.py +0 -0
- ae/analysis.py +193 -0
- ae/cli.py +496 -0
- ae/concept_server.py +209 -0
- ae/concept_viewer.py +640 -0
- ae/concepts.py +155 -0
- ae/core.py +1303 -0
- ae/dspy_xp.py +894 -0
- ae/graph.py +733 -0
- ae/guides/__init__.py +0 -0
- ae/guides/debugging.md +434 -0
- ae/guides/design_maturation.md +141 -0
- ae/guides/hygienator.md +334 -0
- ae/guides/landscape_review.md +175 -0
- ae/guides/model_evaluation.md +313 -0
- ae/guides/model_onboarding.md +386 -0
- ae/guides/operational_guide.md +869 -0
- ae/guides/process_improvement.md +296 -0
- ae/guides/quick_start.md +123 -0
- ae/guides/roadmap.md +443 -0
- ae/guides/synergistic_xp.md +416 -0
- ae/seed_concepts/__init__.py +1 -0
- ae/seed_concepts/ae-concept-context.jsonld +62 -0
- ae/seed_concepts/ai-keeping-up.jsonld +121 -0
- ae/seed_concepts/bc-activities.jsonld +97 -0
- ae/seed_concepts/bounded-rationality.jsonld +88 -0
- ae/seed_concepts/collaborative-agent.jsonld +91 -0
- ae/seed_concepts/coming-to-know.jsonld +123 -0
- ae/seed_concepts/complement.jsonld +360 -0
- ae/seed_concepts/comprehensibility-as-participation.jsonld +101 -0
- ae/seed_concepts/constellation-architecture.jsonld +136 -0
- ae/seed_concepts/decision-network.jsonld +120 -0
- ae/seed_concepts/design-maturation.jsonld +71 -0
- ae/seed_concepts/discourse-ontology.jsonld +126 -0
- ae/seed_concepts/divergence-regimes.jsonld +94 -0
- ae/seed_concepts/dominator-pattern.jsonld +103 -0
- ae/seed_concepts/emergent-paradigm-adoption.jsonld +107 -0
- ae/seed_concepts/epistemic-integrity.jsonld +102 -0
- ae/seed_concepts/human-universe.jsonld +154 -0
- ae/seed_concepts/kinship.jsonld +122 -0
- ae/seed_concepts/override-safety.jsonld +97 -0
- ae/seed_concepts/partnership.jsonld +136 -0
- ae/seed_concepts/persona-activation-as-ceremony.jsonld +130 -0
- ae/seed_concepts/process-as-medium.jsonld +102 -0
- ae/seed_concepts/process-selection.jsonld +71 -0
- ae/seed_concepts/tangent-as-signal.jsonld +85 -0
- ae/serve.py +192 -0
- ae/session_server.py +305 -0
- ae/sync.py +134 -0
- ae/teams/__init__.py +0 -0
- ae/teams/problem_solving.md +34 -0
- ae/teams/problem_solving_complete.md +735 -0
- ae/view.py +1357 -0
- ae/work.py +815 -0
ae/analysis.py
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"""Session quality analysis — AI-powered analysis of session transcripts.
|
|
2
|
+
|
|
3
|
+
Uses subagents to analyze Claude JSONL transcripts against:
|
|
4
|
+
1. Simon's five structural predictions (from Session 24)
|
|
5
|
+
2. Synergy instruments (from Session 22, Sawyer)
|
|
6
|
+
3. Corbin's qualitative dimensions (from Session 22)
|
|
7
|
+
4. Diderot fidelity check (from Session 24)
|
|
8
|
+
|
|
9
|
+
Design constraints (Session 22):
|
|
10
|
+
- No composite scores (Goodhart safeguard)
|
|
11
|
+
- Data streams shown separately
|
|
12
|
+
- Dashboard is mirror, not scorecard
|
|
13
|
+
- Calibrated to session, not universal
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import os
|
|
18
|
+
import re
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# --- Transcript extraction ---
|
|
23
|
+
|
|
24
|
+
def extract_conversation(jsonl_path: Path) -> list[dict]:
|
|
25
|
+
"""Extract user/assistant conversation turns from a Claude JSONL file.
|
|
26
|
+
|
|
27
|
+
Returns list of {"role": "user"|"assistant", "text": str} dicts.
|
|
28
|
+
Skips tool calls, progress messages, and file snapshots.
|
|
29
|
+
"""
|
|
30
|
+
turns = []
|
|
31
|
+
for line in jsonl_path.open():
|
|
32
|
+
try:
|
|
33
|
+
d = json.loads(line)
|
|
34
|
+
except json.JSONDecodeError:
|
|
35
|
+
continue
|
|
36
|
+
|
|
37
|
+
msg_type = d.get("type", "")
|
|
38
|
+
if msg_type not in ("user", "assistant"):
|
|
39
|
+
continue
|
|
40
|
+
|
|
41
|
+
message = d.get("message", {})
|
|
42
|
+
content = message.get("content", "")
|
|
43
|
+
|
|
44
|
+
if isinstance(content, str):
|
|
45
|
+
text = content.strip()
|
|
46
|
+
elif isinstance(content, list):
|
|
47
|
+
# Extract text blocks, skip tool_use/tool_result
|
|
48
|
+
text_parts = []
|
|
49
|
+
for block in content:
|
|
50
|
+
if isinstance(block, dict) and block.get("type") == "text":
|
|
51
|
+
text_parts.append(block.get("text", ""))
|
|
52
|
+
text = "\n".join(text_parts).strip()
|
|
53
|
+
else:
|
|
54
|
+
continue
|
|
55
|
+
|
|
56
|
+
if text:
|
|
57
|
+
turns.append({"role": msg_type, "text": text})
|
|
58
|
+
|
|
59
|
+
return turns
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def conversation_to_text(turns: list[dict], max_chars: int = 200_000) -> str:
|
|
63
|
+
"""Convert conversation turns to readable text for analysis.
|
|
64
|
+
|
|
65
|
+
Truncates to max_chars to fit in subagent context windows.
|
|
66
|
+
"""
|
|
67
|
+
lines = []
|
|
68
|
+
total = 0
|
|
69
|
+
for turn in turns:
|
|
70
|
+
role = "STUART" if turn["role"] == "user" else "TEAM"
|
|
71
|
+
line = f"[{role}]: {turn['text']}\n"
|
|
72
|
+
if total + len(line) > max_chars:
|
|
73
|
+
lines.append(f"\n[TRANSCRIPT TRUNCATED at {total} chars — {len(turns) - len(lines)} turns remaining]")
|
|
74
|
+
break
|
|
75
|
+
lines.append(line)
|
|
76
|
+
total += len(line)
|
|
77
|
+
return "\n".join(lines)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def identify_session(turns: list[dict]) -> str | None:
|
|
81
|
+
"""Try to identify which session a transcript belongs to from the first user message."""
|
|
82
|
+
if not turns:
|
|
83
|
+
return None
|
|
84
|
+
first = turns[0]["text"][:200].lower()
|
|
85
|
+
# Look for session file references
|
|
86
|
+
match = re.search(r"session[_\s]*(\d+[dD]?)", first)
|
|
87
|
+
if match:
|
|
88
|
+
return f"session{match.group(1).lower()}"
|
|
89
|
+
return None
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# --- Analysis prompt ---
|
|
93
|
+
|
|
94
|
+
def _load_analysis_prompt() -> str:
|
|
95
|
+
"""Load the analysis prompt from the spec file."""
|
|
96
|
+
import importlib.resources
|
|
97
|
+
spec_text = importlib.resources.files("ae").parent.parent.joinpath(
|
|
98
|
+
"specs", "session_analysis_prompt.md"
|
|
99
|
+
).read_text()
|
|
100
|
+
|
|
101
|
+
# Extract the prompt section between the --- delimiters
|
|
102
|
+
parts = spec_text.split("---")
|
|
103
|
+
# The prompt is in parts[2] (between second and third ---)
|
|
104
|
+
if len(parts) >= 3:
|
|
105
|
+
prompt = parts[2].strip()
|
|
106
|
+
# Add transcript header
|
|
107
|
+
return prompt + "\n\n### Transcript\n\n"
|
|
108
|
+
|
|
109
|
+
# Fallback: return the whole spec
|
|
110
|
+
return spec_text + "\n\n### Transcript\n\n"
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
# Lazy-loaded prompt
|
|
114
|
+
_ANALYSIS_PROMPT = None
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def get_analysis_prompt() -> str:
|
|
118
|
+
"""Get the analysis prompt, loading from spec file on first call."""
|
|
119
|
+
global _ANALYSIS_PROMPT
|
|
120
|
+
if _ANALYSIS_PROMPT is None:
|
|
121
|
+
_ANALYSIS_PROMPT = _load_analysis_prompt()
|
|
122
|
+
return _ANALYSIS_PROMPT
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def build_analysis_request(transcript_text: str, session_summary: str = "") -> str:
|
|
126
|
+
"""Build the full analysis prompt with transcript and optional session summary."""
|
|
127
|
+
prompt = get_analysis_prompt() + transcript_text
|
|
128
|
+
if session_summary:
|
|
129
|
+
prompt += f"\n\n## Session Summary (for reference)\n\n{session_summary}"
|
|
130
|
+
return prompt
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
# --- Transcript-to-session mapping ---
|
|
134
|
+
|
|
135
|
+
def find_transcripts(claude_projects_dir: Path | None = None) -> list[dict]:
|
|
136
|
+
"""Find all JSONL transcripts for this project.
|
|
137
|
+
|
|
138
|
+
Returns list of {"path": Path, "session_id": str|None, "turns": int, "size": int}.
|
|
139
|
+
"""
|
|
140
|
+
if claude_projects_dir is None:
|
|
141
|
+
claude_projects_dir = Path.home() / ".claude" / "projects" / "-home-stuart-code-activating-expertise"
|
|
142
|
+
|
|
143
|
+
if not claude_projects_dir.exists():
|
|
144
|
+
return []
|
|
145
|
+
|
|
146
|
+
results = []
|
|
147
|
+
for jsonl_file in sorted(claude_projects_dir.glob("*.jsonl")):
|
|
148
|
+
size = jsonl_file.stat().st_size
|
|
149
|
+
if size < 100: # Skip empty/tiny files
|
|
150
|
+
continue
|
|
151
|
+
|
|
152
|
+
turns = extract_conversation(jsonl_file)
|
|
153
|
+
session_id = identify_session(turns)
|
|
154
|
+
|
|
155
|
+
results.append({
|
|
156
|
+
"path": jsonl_file,
|
|
157
|
+
"session_id": session_id,
|
|
158
|
+
"turns": len(turns),
|
|
159
|
+
"size": size,
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
return results
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def parse_analysis_result(text: str) -> dict | None:
|
|
166
|
+
"""Parse JSON from analysis subagent response.
|
|
167
|
+
|
|
168
|
+
Handles cases where the response includes markdown fencing or extra text.
|
|
169
|
+
"""
|
|
170
|
+
# Try direct parse first
|
|
171
|
+
text = text.strip()
|
|
172
|
+
try:
|
|
173
|
+
return json.loads(text)
|
|
174
|
+
except json.JSONDecodeError:
|
|
175
|
+
pass
|
|
176
|
+
|
|
177
|
+
# Try extracting from markdown code block
|
|
178
|
+
match = re.search(r"```(?:json)?\s*\n(.*?)```", text, re.DOTALL)
|
|
179
|
+
if match:
|
|
180
|
+
try:
|
|
181
|
+
return json.loads(match.group(1).strip())
|
|
182
|
+
except json.JSONDecodeError:
|
|
183
|
+
pass
|
|
184
|
+
|
|
185
|
+
# Try finding the first { ... } block
|
|
186
|
+
match = re.search(r"\{.*\}", text, re.DOTALL)
|
|
187
|
+
if match:
|
|
188
|
+
try:
|
|
189
|
+
return json.loads(match.group(0))
|
|
190
|
+
except json.JSONDecodeError:
|
|
191
|
+
pass
|
|
192
|
+
|
|
193
|
+
return None
|
ae/cli.py
ADDED
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
"""Activating Expertise CLI — manage AI team sessions across projects."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import importlib.resources
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from ae.core import (
|
|
10
|
+
AEHome, AEProject, find_project_root, init_project, init_project_local,
|
|
11
|
+
save_session, save_session_for, get_status, get_peer_status,
|
|
12
|
+
get_local_project_status,
|
|
13
|
+
list_sessions, list_sessions_for,
|
|
14
|
+
read_session, read_session_for,
|
|
15
|
+
configure_node, get_node_config,
|
|
16
|
+
session_uri, add_peer, remove_peer, get_peers,
|
|
17
|
+
share_project, unshare_project, get_sharing,
|
|
18
|
+
migrate_project, migrate_project_for,
|
|
19
|
+
setup_mcp,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _list_bundled(package: str) -> list[str]:
|
|
24
|
+
"""List bundled markdown files in a subpackage."""
|
|
25
|
+
files = importlib.resources.files(package)
|
|
26
|
+
return sorted(
|
|
27
|
+
f.name[:-3] # strip .md
|
|
28
|
+
for f in files.iterdir()
|
|
29
|
+
if f.name.endswith(".md")
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _read_bundled(package: str, name: str) -> str | None:
|
|
34
|
+
"""Read a bundled markdown file by name (without .md extension)."""
|
|
35
|
+
# Allow hyphens or underscores
|
|
36
|
+
candidates = [name, name.replace("-", "_"), name.replace("_", "-")]
|
|
37
|
+
files = importlib.resources.files(package)
|
|
38
|
+
for candidate in candidates:
|
|
39
|
+
ref = files.joinpath(f"{candidate}.md")
|
|
40
|
+
try:
|
|
41
|
+
return ref.read_text(encoding="utf-8")
|
|
42
|
+
except FileNotFoundError:
|
|
43
|
+
continue
|
|
44
|
+
return None
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _format_project_entry(p: dict, prefix: str = "") -> list[str]:
|
|
48
|
+
"""Format a single project entry."""
|
|
49
|
+
lines = []
|
|
50
|
+
name = p["name"]
|
|
51
|
+
count = p["session_count"]
|
|
52
|
+
peer = p.get("peer")
|
|
53
|
+
source = p.get("source", "")
|
|
54
|
+
label = f"{prefix}{name}" if not peer else f"{prefix}{name} (from {peer})"
|
|
55
|
+
if source == "local":
|
|
56
|
+
label = f"{prefix}{name} (.ae/)"
|
|
57
|
+
|
|
58
|
+
if count == 0:
|
|
59
|
+
lines.append(f" {label} (no sessions)")
|
|
60
|
+
lines.append("")
|
|
61
|
+
return lines
|
|
62
|
+
|
|
63
|
+
last = p["last_session"]
|
|
64
|
+
date_str = last[:10] if last else "unknown"
|
|
65
|
+
|
|
66
|
+
lines.append(f" {label} ({count} sessions, last: {date_str})")
|
|
67
|
+
|
|
68
|
+
summary = p["latest_summary"]
|
|
69
|
+
if summary:
|
|
70
|
+
if len(summary) > 120:
|
|
71
|
+
summary = summary[:117] + "..."
|
|
72
|
+
lines.append(f" Last: {summary}")
|
|
73
|
+
|
|
74
|
+
questions = p["open_questions"]
|
|
75
|
+
if questions:
|
|
76
|
+
lines.append(f" Open: {questions[0]}")
|
|
77
|
+
if len(questions) > 1:
|
|
78
|
+
lines.append(f" (+{len(questions) - 1} more)")
|
|
79
|
+
|
|
80
|
+
lines.append("")
|
|
81
|
+
return lines
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _format_status(projects: list[dict], peer_projects: list[dict] | None = None,
|
|
85
|
+
local_project: dict | None = None) -> str:
|
|
86
|
+
"""Format project status for terminal output."""
|
|
87
|
+
if not projects and not peer_projects and not local_project:
|
|
88
|
+
return "No projects yet. Run 'ae init' to create one."
|
|
89
|
+
|
|
90
|
+
lines = []
|
|
91
|
+
|
|
92
|
+
if local_project:
|
|
93
|
+
lines.append("Current project:")
|
|
94
|
+
lines.extend(_format_project_entry(local_project))
|
|
95
|
+
|
|
96
|
+
if projects:
|
|
97
|
+
if local_project:
|
|
98
|
+
lines.append("Global projects:")
|
|
99
|
+
for p in projects:
|
|
100
|
+
lines.extend(_format_project_entry(p))
|
|
101
|
+
|
|
102
|
+
if peer_projects:
|
|
103
|
+
lines.append("Peer sessions:")
|
|
104
|
+
for p in peer_projects:
|
|
105
|
+
lines.extend(_format_project_entry(p))
|
|
106
|
+
|
|
107
|
+
return "\n".join(lines)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def _resolve_project(args, home: AEHome):
|
|
111
|
+
"""Resolve project from args or auto-detect from .ae/ directory.
|
|
112
|
+
|
|
113
|
+
Returns (home_or_project, project_name) tuple.
|
|
114
|
+
- For .ae/ projects: (AEProject, None)
|
|
115
|
+
- For global projects: (home, project_name)
|
|
116
|
+
"""
|
|
117
|
+
project_name = getattr(args, "project", None)
|
|
118
|
+
|
|
119
|
+
if project_name:
|
|
120
|
+
# Explicit project name given — use global home
|
|
121
|
+
return home, project_name
|
|
122
|
+
|
|
123
|
+
# Try to find a .ae/ project in cwd
|
|
124
|
+
root = find_project_root()
|
|
125
|
+
if root:
|
|
126
|
+
return AEProject(root), None
|
|
127
|
+
|
|
128
|
+
# No project found
|
|
129
|
+
print("No project specified and no .ae/ directory found.", file=sys.stderr)
|
|
130
|
+
print("Run 'ae init' to create a project here, or specify a project name.", file=sys.stderr)
|
|
131
|
+
sys.exit(1)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def main():
|
|
135
|
+
parser = argparse.ArgumentParser(
|
|
136
|
+
prog="ae",
|
|
137
|
+
description="Manage AI team sessions across projects",
|
|
138
|
+
)
|
|
139
|
+
subparsers = parser.add_subparsers(dest="command")
|
|
140
|
+
|
|
141
|
+
# ae init [project] [--starter NAME]
|
|
142
|
+
init_parser = subparsers.add_parser("init", help="Initialize a new project")
|
|
143
|
+
init_parser.add_argument("project", nargs="?", help="Project name (omit to init in current directory)")
|
|
144
|
+
init_parser.add_argument("--starter", "-s", help="Load a starter session set (e.g., ai-helping-or-harming)")
|
|
145
|
+
|
|
146
|
+
# ae save [project] [--title TITLE] [--file FILE]
|
|
147
|
+
save_parser = subparsers.add_parser("save", help="Save a session summary")
|
|
148
|
+
save_parser.add_argument("project", nargs="?", help="Project name (auto-detected if in .ae/ project)")
|
|
149
|
+
save_parser.add_argument("--title", "-t", help="Session title (auto-extracted from content if omitted)")
|
|
150
|
+
save_parser.add_argument("--file", "-f", help="Read session from file instead of stdin")
|
|
151
|
+
save_parser.add_argument("--date", "-d", help="Session date (YYYY-MM-DD). Auto-extracted from content if omitted.")
|
|
152
|
+
|
|
153
|
+
# ae set-node <name> <email>
|
|
154
|
+
node_parser = subparsers.add_parser("set-node", help="Configure this node's identity")
|
|
155
|
+
node_parser.add_argument("name", help="Your display name (e.g., stuart)")
|
|
156
|
+
node_parser.add_argument("email", help="Your email (used for unique ID, not shared)")
|
|
157
|
+
|
|
158
|
+
# ae add-peer <name> <address>
|
|
159
|
+
addpeer_parser = subparsers.add_parser("add-peer", help="Add a peer node")
|
|
160
|
+
addpeer_parser.add_argument("name", help="Peer display name (e.g., briar)")
|
|
161
|
+
addpeer_parser.add_argument("address", help="Peer address (IP or hostname)")
|
|
162
|
+
|
|
163
|
+
# ae remove-peer <name>
|
|
164
|
+
rmpeer_parser = subparsers.add_parser("remove-peer", help="Remove a peer node")
|
|
165
|
+
rmpeer_parser.add_argument("name", help="Peer name to remove")
|
|
166
|
+
|
|
167
|
+
# ae peers
|
|
168
|
+
subparsers.add_parser("peers", help="List configured peers")
|
|
169
|
+
|
|
170
|
+
# ae share <project> <peer>
|
|
171
|
+
share_parser = subparsers.add_parser("share", help="Share a project with a peer")
|
|
172
|
+
share_parser.add_argument("project", help="Project name")
|
|
173
|
+
share_parser.add_argument("peer", help="Peer name")
|
|
174
|
+
|
|
175
|
+
# ae unshare <project> <peer>
|
|
176
|
+
unshare_parser = subparsers.add_parser("unshare", help="Stop sharing a project with a peer")
|
|
177
|
+
unshare_parser.add_argument("project", help="Project name")
|
|
178
|
+
unshare_parser.add_argument("peer", help="Peer name")
|
|
179
|
+
|
|
180
|
+
# ae status
|
|
181
|
+
subparsers.add_parser("status", help="Show status across all projects")
|
|
182
|
+
|
|
183
|
+
# ae sessions [project]
|
|
184
|
+
sessions_parser = subparsers.add_parser("sessions", help="List sessions for a project")
|
|
185
|
+
sessions_parser.add_argument("project", nargs="?", help="Project name (auto-detected if in .ae/ project)")
|
|
186
|
+
|
|
187
|
+
# ae read [project] <session>
|
|
188
|
+
read_parser = subparsers.add_parser("read", help="Read a session summary")
|
|
189
|
+
read_parser.add_argument("project", nargs="?", help="Project name (auto-detected if in .ae/ project)")
|
|
190
|
+
read_parser.add_argument("session", help="Session filename or partial match")
|
|
191
|
+
|
|
192
|
+
# ae serve [--port PORT]
|
|
193
|
+
serve_parser = subparsers.add_parser("serve", help="Share sessions with peers over HTTP")
|
|
194
|
+
serve_parser.add_argument("--port", "-p", type=int, default=8099, help="Port (default: 8099)")
|
|
195
|
+
|
|
196
|
+
# ae sync [--peer PEER]
|
|
197
|
+
sync_parser = subparsers.add_parser("sync", help="Pull new sessions from peers")
|
|
198
|
+
sync_parser.add_argument("--peer", help="Sync from a specific peer (default: all)")
|
|
199
|
+
|
|
200
|
+
# ae migrate [project]
|
|
201
|
+
migrate_parser = subparsers.add_parser("migrate", help="Generate JSON-LD for existing sessions")
|
|
202
|
+
migrate_parser.add_argument("project", nargs="?", help="Project name (auto-detected if in .ae/ project)")
|
|
203
|
+
|
|
204
|
+
# ae view [project]
|
|
205
|
+
view_parser = subparsers.add_parser("view", help="Generate and open session viewer")
|
|
206
|
+
view_parser.add_argument("project", nargs="?", help="Project name (auto-detected if in .ae/ project)")
|
|
207
|
+
|
|
208
|
+
# ae guide [name]
|
|
209
|
+
guide_parser = subparsers.add_parser("guide", help="List or read bundled guides")
|
|
210
|
+
guide_parser.add_argument("name", nargs="?", help="Guide name (e.g., synergistic-xp)")
|
|
211
|
+
|
|
212
|
+
# ae team [name]
|
|
213
|
+
team_parser = subparsers.add_parser("team", help="List or read bundled starter teams")
|
|
214
|
+
team_parser.add_argument("name", nargs="?", help="Team name (e.g., problem-solving)")
|
|
215
|
+
|
|
216
|
+
# ae setup [--claude] [--goose]
|
|
217
|
+
setup_parser = subparsers.add_parser("setup",
|
|
218
|
+
help="Configure MCP servers for AI tools (Claude Code, Goose)")
|
|
219
|
+
setup_parser.add_argument("--claude", action="store_true",
|
|
220
|
+
help="Configure Claude Code (.mcp.json + .claude/settings.json)")
|
|
221
|
+
setup_parser.add_argument("--goose", action="store_true",
|
|
222
|
+
help="Configure Goose (~/.config/goose/config.yaml)")
|
|
223
|
+
|
|
224
|
+
# ae work <work_order> [options]
|
|
225
|
+
work_parser = subparsers.add_parser("work",
|
|
226
|
+
help="Run complement-checked engineering pipeline")
|
|
227
|
+
work_parser.add_argument("work_order", help="Path to work order markdown file")
|
|
228
|
+
work_parser.add_argument("--backend", choices=["goose", "claude"], default="goose",
|
|
229
|
+
help="Model backend (default: goose)")
|
|
230
|
+
work_parser.add_argument("--model", default="qwen3.5:122b-a10b",
|
|
231
|
+
help="Model name for goose backend")
|
|
232
|
+
work_parser.add_argument("--check-model", default=None,
|
|
233
|
+
help="Model for complement checking (default: same as --model)")
|
|
234
|
+
work_parser.add_argument("--host", default="http://100.77.22.113:11434",
|
|
235
|
+
help="Ollama host URL")
|
|
236
|
+
work_parser.add_argument("--auto", action="store_true",
|
|
237
|
+
help="Full automatic — skip human checkpoints")
|
|
238
|
+
work_parser.add_argument("--run-name", default=None,
|
|
239
|
+
help="Name for run directory (default: timestamp)")
|
|
240
|
+
work_parser.add_argument("--max-fix-cycles", type=int, default=3,
|
|
241
|
+
help="Maximum fix-it cycles per phase (default: 3)")
|
|
242
|
+
work_parser.add_argument("--max-phases", type=int, default=None,
|
|
243
|
+
help="Stop after N phases (default: run all)")
|
|
244
|
+
|
|
245
|
+
args = parser.parse_args()
|
|
246
|
+
|
|
247
|
+
if args.command is None:
|
|
248
|
+
parser.print_help()
|
|
249
|
+
sys.exit(1)
|
|
250
|
+
|
|
251
|
+
ae_home_env = os.environ.get("AE_HOME")
|
|
252
|
+
home = AEHome(Path(ae_home_env) if ae_home_env else None)
|
|
253
|
+
|
|
254
|
+
if args.command == "init":
|
|
255
|
+
if args.project:
|
|
256
|
+
# ae init my-project — create in global home (backward compat)
|
|
257
|
+
path = init_project(home, args.project)
|
|
258
|
+
print(f"Initialized project: {path}")
|
|
259
|
+
else:
|
|
260
|
+
# ae init — create .ae/ in cwd
|
|
261
|
+
project = init_project_local(starter=args.starter)
|
|
262
|
+
print(f"Initialized project in {project.root}/ (.ae/)")
|
|
263
|
+
if args.starter:
|
|
264
|
+
sessions = list(project.sessions_path.glob("*.md"))
|
|
265
|
+
print(f"Loaded starter set '{args.starter}': {len(sessions)} sessions")
|
|
266
|
+
print(f"Run 'ae migrate' to generate JSON-LD, then 'ae view' to see the dashboard.")
|
|
267
|
+
else:
|
|
268
|
+
from ae.core import _list_starter_sets
|
|
269
|
+
starters = _list_starter_sets()
|
|
270
|
+
if starters:
|
|
271
|
+
print(f"Tip: run 'ae init --starter {starters[0]}' to start with example sessions.")
|
|
272
|
+
|
|
273
|
+
elif args.command == "set-node":
|
|
274
|
+
home.config_dir.mkdir(parents=True, exist_ok=True)
|
|
275
|
+
config = configure_node(home, args.name, args.email)
|
|
276
|
+
print(f"Node configured: {config['node_id']}")
|
|
277
|
+
|
|
278
|
+
elif args.command == "add-peer":
|
|
279
|
+
home.config_dir.mkdir(parents=True, exist_ok=True)
|
|
280
|
+
add_peer(home, args.name, args.address)
|
|
281
|
+
print(f"Added peer: {args.name} ({args.address})")
|
|
282
|
+
|
|
283
|
+
elif args.command == "remove-peer":
|
|
284
|
+
remove_peer(home, args.name)
|
|
285
|
+
print(f"Removed peer: {args.name}")
|
|
286
|
+
|
|
287
|
+
elif args.command == "peers":
|
|
288
|
+
peers = get_peers(home)
|
|
289
|
+
if not peers:
|
|
290
|
+
print("No peers configured. Run 'ae add-peer <name> <address>'.")
|
|
291
|
+
else:
|
|
292
|
+
for name, info in peers.items():
|
|
293
|
+
print(f" {name} {info['address']}")
|
|
294
|
+
|
|
295
|
+
elif args.command == "share":
|
|
296
|
+
share_project(home, args.project, args.peer)
|
|
297
|
+
print(f"Shared {args.project} with {args.peer}")
|
|
298
|
+
|
|
299
|
+
elif args.command == "unshare":
|
|
300
|
+
unshare_project(home, args.project, args.peer)
|
|
301
|
+
print(f"Stopped sharing {args.project} with {args.peer}")
|
|
302
|
+
|
|
303
|
+
elif args.command == "save":
|
|
304
|
+
if args.file:
|
|
305
|
+
from ae.core import _read_text_safe
|
|
306
|
+
content = _read_text_safe(Path(args.file))
|
|
307
|
+
else:
|
|
308
|
+
content = sys.stdin.read()
|
|
309
|
+
|
|
310
|
+
home_or_project, project_name = _resolve_project(args, home)
|
|
311
|
+
path = save_session_for(home_or_project, project_name, content,
|
|
312
|
+
title=args.title, session_date=args.date)
|
|
313
|
+
print(f"Saved session: {path}")
|
|
314
|
+
|
|
315
|
+
elif args.command == "status":
|
|
316
|
+
projects = get_status(home)
|
|
317
|
+
peer_projects = get_peer_status(home)
|
|
318
|
+
|
|
319
|
+
# Check for a .ae/ project in cwd
|
|
320
|
+
local_project = None
|
|
321
|
+
root = find_project_root()
|
|
322
|
+
if root:
|
|
323
|
+
local_project = get_local_project_status(AEProject(root))
|
|
324
|
+
|
|
325
|
+
print(_format_status(projects, peer_projects, local_project))
|
|
326
|
+
|
|
327
|
+
elif args.command == "sessions":
|
|
328
|
+
home_or_project, project_name = _resolve_project(args, home)
|
|
329
|
+
sessions = list_sessions_for(home_or_project, project_name)
|
|
330
|
+
display_name = project_name if project_name else home_or_project.name
|
|
331
|
+
if not sessions:
|
|
332
|
+
print(f"No sessions in {display_name}.")
|
|
333
|
+
else:
|
|
334
|
+
for s in sessions:
|
|
335
|
+
print(f" {s.name}")
|
|
336
|
+
|
|
337
|
+
elif args.command == "read":
|
|
338
|
+
home_or_project, project_name = _resolve_project(args, home)
|
|
339
|
+
content = read_session_for(home_or_project, project_name, args.session)
|
|
340
|
+
print(content)
|
|
341
|
+
|
|
342
|
+
elif args.command == "serve":
|
|
343
|
+
from ae.serve import create_server
|
|
344
|
+
node_config = get_node_config(home)
|
|
345
|
+
node_name = node_config["node_id"] if node_config else "unconfigured"
|
|
346
|
+
server = create_server(home, port=args.port)
|
|
347
|
+
print(f"Serving as {node_name} on port {args.port}")
|
|
348
|
+
sharing = get_sharing(home)
|
|
349
|
+
if sharing:
|
|
350
|
+
for proj, peers in sharing.items():
|
|
351
|
+
if peers:
|
|
352
|
+
print(f" {proj} -> {', '.join(peers)}")
|
|
353
|
+
else:
|
|
354
|
+
print(" No projects shared. Run 'ae share <project> <peer>'.")
|
|
355
|
+
print("Press Ctrl+C to stop.")
|
|
356
|
+
try:
|
|
357
|
+
server.serve_forever()
|
|
358
|
+
except KeyboardInterrupt:
|
|
359
|
+
print("\nStopped.")
|
|
360
|
+
server.shutdown()
|
|
361
|
+
|
|
362
|
+
elif args.command == "sync":
|
|
363
|
+
from ae.sync import sync_from_peer, sync_all
|
|
364
|
+
node_config = get_node_config(home)
|
|
365
|
+
my_name = node_config["name"] if node_config else "unknown"
|
|
366
|
+
|
|
367
|
+
if args.peer:
|
|
368
|
+
downloaded = sync_from_peer(home, args.peer, peer_name_on_remote=my_name)
|
|
369
|
+
if downloaded and downloaded[0].startswith("NO_SHARED_PROJECTS:"):
|
|
370
|
+
name_used = downloaded[0].split(":", 1)[1]
|
|
371
|
+
print(f"No shared projects found on {args.peer} for peer name '{name_used}'.")
|
|
372
|
+
print(f" Ask {args.peer} to run: ae share <project> {name_used}")
|
|
373
|
+
elif downloaded:
|
|
374
|
+
print(f"Downloaded {len(downloaded)} sessions from {args.peer}:")
|
|
375
|
+
for p in downloaded:
|
|
376
|
+
print(f" {p}")
|
|
377
|
+
else:
|
|
378
|
+
print(f"Up to date with {args.peer}.")
|
|
379
|
+
else:
|
|
380
|
+
results = sync_all(home, my_name)
|
|
381
|
+
for peer_name, downloaded in results.items():
|
|
382
|
+
if downloaded and downloaded[0].startswith("NO_SHARED_PROJECTS:"):
|
|
383
|
+
name_used = downloaded[0].split(":", 1)[1]
|
|
384
|
+
print(f"{peer_name}: no shared projects for '{name_used}'")
|
|
385
|
+
elif downloaded and not downloaded[0].startswith("ERROR"):
|
|
386
|
+
print(f"{peer_name}: {len(downloaded)} new sessions")
|
|
387
|
+
elif downloaded and downloaded[0].startswith("ERROR"):
|
|
388
|
+
print(f"{peer_name}: {downloaded[0]}")
|
|
389
|
+
else:
|
|
390
|
+
print(f"{peer_name}: up to date")
|
|
391
|
+
|
|
392
|
+
elif args.command == "migrate":
|
|
393
|
+
home_or_project, project_name = _resolve_project(args, home)
|
|
394
|
+
created = migrate_project_for(home_or_project, project_name, home=home)
|
|
395
|
+
if created:
|
|
396
|
+
print(f"Migrated {len(created)} sessions to JSON-LD:")
|
|
397
|
+
for p in created:
|
|
398
|
+
print(f" {p.name}")
|
|
399
|
+
else:
|
|
400
|
+
print("All sessions already have JSON-LD files.")
|
|
401
|
+
|
|
402
|
+
elif args.command == "view":
|
|
403
|
+
from ae.view import generate_and_open, generate_and_open_for
|
|
404
|
+
home_or_project, project_name = _resolve_project(args, home)
|
|
405
|
+
path = generate_and_open_for(home_or_project, project_name, home=home)
|
|
406
|
+
print(f"Viewer generated: {path}")
|
|
407
|
+
|
|
408
|
+
elif args.command == "guide":
|
|
409
|
+
if args.name is None:
|
|
410
|
+
guides = _list_bundled("ae.guides")
|
|
411
|
+
print("Available guides:")
|
|
412
|
+
for g in guides:
|
|
413
|
+
print(f" {g}")
|
|
414
|
+
print(f"\nRun 'ae guide <name>' to read one.")
|
|
415
|
+
else:
|
|
416
|
+
content = _read_bundled("ae.guides", args.name)
|
|
417
|
+
if content is None:
|
|
418
|
+
print(f"Guide '{args.name}' not found. Run 'ae guide' to list available guides.")
|
|
419
|
+
sys.exit(1)
|
|
420
|
+
print(content)
|
|
421
|
+
|
|
422
|
+
elif args.command == "team":
|
|
423
|
+
if args.name is None:
|
|
424
|
+
teams = _list_bundled("ae.teams")
|
|
425
|
+
print("Available starter teams:")
|
|
426
|
+
for t in teams:
|
|
427
|
+
print(f" {t}")
|
|
428
|
+
print(f"\nRun 'ae team <name>' to read one.")
|
|
429
|
+
else:
|
|
430
|
+
content = _read_bundled("ae.teams", args.name)
|
|
431
|
+
if content is None:
|
|
432
|
+
print(f"Team '{args.name}' not found. Run 'ae team' to list available teams.")
|
|
433
|
+
sys.exit(1)
|
|
434
|
+
print(content)
|
|
435
|
+
|
|
436
|
+
elif args.command == "setup":
|
|
437
|
+
# Determine targets
|
|
438
|
+
targets = []
|
|
439
|
+
if args.claude:
|
|
440
|
+
targets.append("claude")
|
|
441
|
+
if args.goose:
|
|
442
|
+
targets.append("goose")
|
|
443
|
+
if not targets:
|
|
444
|
+
targets = None # auto-detect
|
|
445
|
+
|
|
446
|
+
# Find project root
|
|
447
|
+
root = find_project_root()
|
|
448
|
+
if not root:
|
|
449
|
+
root = Path.cwd()
|
|
450
|
+
|
|
451
|
+
written = setup_mcp(root, targets)
|
|
452
|
+
for target, path in written.items():
|
|
453
|
+
print(f" {target}: {path}")
|
|
454
|
+
if written:
|
|
455
|
+
print(f"\nMCP servers configured. Restart your AI tool to activate.")
|
|
456
|
+
else:
|
|
457
|
+
print("No configuration written.")
|
|
458
|
+
|
|
459
|
+
elif args.command == "work":
|
|
460
|
+
from ae.work import run_pipeline
|
|
461
|
+
from pathlib import Path as P
|
|
462
|
+
import time as _time
|
|
463
|
+
|
|
464
|
+
wo_path = P(args.work_order)
|
|
465
|
+
if not wo_path.exists():
|
|
466
|
+
print(f"Error: work order not found: {wo_path}")
|
|
467
|
+
sys.exit(1)
|
|
468
|
+
|
|
469
|
+
run_name = args.run_name or _time.strftime("%Y%m%d_%H%M%S")
|
|
470
|
+
run_dir = P("work") / run_name
|
|
471
|
+
run_dir.mkdir(parents=True, exist_ok=True)
|
|
472
|
+
(run_dir / "work_order.md").write_text(wo_path.read_text())
|
|
473
|
+
|
|
474
|
+
display_model = args.model if args.backend == "goose" else "claude-code"
|
|
475
|
+
print(f"ae work — Complement-Checked Pipeline")
|
|
476
|
+
print(f"Work order: {wo_path}")
|
|
477
|
+
print(f"Backend: {args.backend} / {display_model}")
|
|
478
|
+
print(f"Run dir: {run_dir}")
|
|
479
|
+
print(f"Mode: {'full auto' if args.auto else 'human-in-the-loop'}")
|
|
480
|
+
|
|
481
|
+
result = run_pipeline(
|
|
482
|
+
wo_path, run_dir, args.backend, args.model,
|
|
483
|
+
args.host, args.auto, args.check_model, args.max_fix_cycles,
|
|
484
|
+
args.max_phases
|
|
485
|
+
)
|
|
486
|
+
if result == "paused":
|
|
487
|
+
print(f"\nPipeline paused. Resume with:")
|
|
488
|
+
print(f" ae work {wo_path} --backend {args.backend}"
|
|
489
|
+
f"{' --model ' + args.model if args.backend == 'goose' else ''}"
|
|
490
|
+
f" --auto --run-name {run_name}")
|
|
491
|
+
sys.exit(2) # Distinct exit code for paused
|
|
492
|
+
sys.exit(0 if result else 1)
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
if __name__ == "__main__":
|
|
496
|
+
main()
|