@mindfoldhq/trellis 0.5.0-beta.8 → 0.5.0-rc.0
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.
- package/README.md +60 -95
- package/dist/cli/index.js +7 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/init.d.ts +13 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +474 -210
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +295 -54
- package/dist/commands/update.js.map +1 -1
- package/dist/configurators/antigravity.d.ts.map +1 -1
- package/dist/configurators/antigravity.js +2 -8
- package/dist/configurators/antigravity.js.map +1 -1
- package/dist/configurators/claude.d.ts.map +1 -1
- package/dist/configurators/claude.js +4 -10
- package/dist/configurators/claude.js.map +1 -1
- package/dist/configurators/codebuddy.d.ts.map +1 -1
- package/dist/configurators/codebuddy.js +3 -3
- package/dist/configurators/codebuddy.js.map +1 -1
- package/dist/configurators/codex.d.ts.map +1 -1
- package/dist/configurators/codex.js +5 -13
- package/dist/configurators/codex.js.map +1 -1
- package/dist/configurators/copilot.d.ts.map +1 -1
- package/dist/configurators/copilot.js +5 -19
- package/dist/configurators/copilot.js.map +1 -1
- package/dist/configurators/cursor.d.ts.map +1 -1
- package/dist/configurators/cursor.js +3 -3
- package/dist/configurators/cursor.js.map +1 -1
- package/dist/configurators/droid.d.ts.map +1 -1
- package/dist/configurators/droid.js +3 -3
- package/dist/configurators/droid.js.map +1 -1
- package/dist/configurators/gemini.d.ts.map +1 -1
- package/dist/configurators/gemini.js +3 -5
- package/dist/configurators/gemini.js.map +1 -1
- package/dist/configurators/index.d.ts.map +1 -1
- package/dist/configurators/index.js +44 -55
- package/dist/configurators/index.js.map +1 -1
- package/dist/configurators/kilo.d.ts.map +1 -1
- package/dist/configurators/kilo.js +2 -8
- package/dist/configurators/kilo.js.map +1 -1
- package/dist/configurators/kiro.d.ts.map +1 -1
- package/dist/configurators/kiro.js +3 -3
- package/dist/configurators/kiro.js.map +1 -1
- package/dist/configurators/opencode.d.ts.map +1 -1
- package/dist/configurators/opencode.js +7 -4
- package/dist/configurators/opencode.js.map +1 -1
- package/dist/configurators/pi.d.ts +3 -0
- package/dist/configurators/pi.d.ts.map +1 -0
- package/dist/configurators/pi.js +44 -0
- package/dist/configurators/pi.js.map +1 -0
- package/dist/configurators/qoder.d.ts +7 -6
- package/dist/configurators/qoder.d.ts.map +1 -1
- package/dist/configurators/qoder.js +18 -12
- package/dist/configurators/qoder.js.map +1 -1
- package/dist/configurators/shared.d.ts +30 -6
- package/dist/configurators/shared.d.ts.map +1 -1
- package/dist/configurators/shared.js +65 -15
- package/dist/configurators/shared.js.map +1 -1
- package/dist/configurators/windsurf.d.ts.map +1 -1
- package/dist/configurators/windsurf.js +2 -8
- package/dist/configurators/windsurf.js.map +1 -1
- package/dist/constants/paths.d.ts +2 -0
- package/dist/constants/paths.d.ts.map +1 -1
- package/dist/constants/paths.js +2 -0
- package/dist/constants/paths.js.map +1 -1
- package/dist/migrations/manifests/0.5.0-beta.0.json +2 -0
- package/dist/migrations/manifests/0.5.0-beta.10.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.11.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.12.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.13.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.14.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.15.json +116 -0
- package/dist/migrations/manifests/0.5.0-beta.16.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.17.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.18.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.19.json +9 -0
- package/dist/migrations/manifests/0.5.0-beta.5.json +2 -0
- package/dist/migrations/manifests/0.5.0-beta.9.json +48 -0
- package/dist/migrations/manifests/0.5.0-rc.0.json +9 -0
- package/dist/templates/claude/agents/trellis-research.md +1 -1
- package/dist/templates/claude/settings.json +0 -4
- package/dist/templates/codebuddy/agents/trellis-research.md +1 -1
- package/dist/templates/codex/agents/trellis-research.toml +3 -2
- package/dist/templates/codex/hooks/session-start.py +126 -26
- package/dist/templates/codex/skills/finish-work/SKILL.md +41 -109
- package/dist/templates/codex/skills/start/SKILL.md +12 -9
- package/dist/templates/common/bundled-skills/trellis-meta/SKILL.md +73 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/add-project-local-conventions.md +83 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-agents.md +54 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-context-loading.md +81 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-hooks.md +57 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-skills-or-commands.md +78 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-spec-structure.md +83 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-task-lifecycle.md +90 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-workflow.md +64 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/overview.md +55 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/context-injection.md +68 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/generated-files.md +80 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/overview.md +51 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/spec-system.md +102 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/task-system.md +101 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/workflow.md +75 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/workspace-memory.md +71 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/agents.md +79 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/hooks-and-settings.md +69 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/overview.md +59 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md +74 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/skills-and-commands.md +83 -0
- package/dist/templates/common/commands/continue.md +9 -5
- package/dist/templates/common/commands/finish-work.md +34 -10
- package/dist/templates/common/index.d.ts +22 -2
- package/dist/templates/common/index.d.ts.map +1 -1
- package/dist/templates/common/index.js +53 -4
- package/dist/templates/common/index.js.map +1 -1
- package/dist/templates/common/skills/brainstorm.md +50 -4
- package/dist/templates/copilot/hooks/session-start.py +127 -30
- package/dist/templates/copilot/prompts/finish-work.prompt.md +44 -112
- package/dist/templates/copilot/prompts/start.prompt.md +12 -9
- package/dist/templates/cursor/agents/trellis-check.md +1 -1
- package/dist/templates/cursor/agents/trellis-implement.md +1 -1
- package/dist/templates/cursor/agents/trellis-research.md +2 -2
- package/dist/templates/cursor/hooks.json +7 -1
- package/dist/templates/droid/droids/trellis-research.md +1 -1
- package/dist/templates/extract.d.ts +6 -0
- package/dist/templates/extract.d.ts.map +1 -1
- package/dist/templates/extract.js +14 -0
- package/dist/templates/extract.js.map +1 -1
- package/dist/templates/gemini/agents/trellis-research.md +1 -1
- package/dist/templates/kiro/agents/trellis-research.json +1 -1
- package/dist/templates/markdown/agents.md +19 -12
- package/dist/templates/markdown/gitignore.txt +3 -0
- package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +24 -0
- package/dist/templates/opencode/agents/trellis-check.md +1 -1
- package/dist/templates/opencode/agents/trellis-implement.md +7 -4
- package/dist/templates/opencode/agents/trellis-research.md +2 -2
- package/dist/templates/opencode/lib/trellis-context.js +100 -13
- package/dist/templates/opencode/plugins/inject-subagent-context.js +70 -5
- package/dist/templates/opencode/plugins/inject-workflow-state.js +38 -44
- package/dist/templates/opencode/plugins/session-start.js +76 -31
- package/dist/templates/pi/agents/trellis-check.md +28 -0
- package/dist/templates/pi/agents/trellis-implement.md +33 -0
- package/dist/templates/pi/agents/trellis-research.md +25 -0
- package/dist/templates/pi/extensions/trellis/index.ts.txt +997 -0
- package/dist/templates/pi/index.d.ts +5 -0
- package/dist/templates/pi/index.d.ts.map +1 -0
- package/dist/templates/pi/index.js +12 -0
- package/dist/templates/pi/index.js.map +1 -0
- package/dist/templates/pi/settings.json +12 -0
- package/dist/templates/qoder/agents/trellis-research.md +1 -1
- package/dist/templates/shared-hooks/index.d.ts +31 -0
- package/dist/templates/shared-hooks/index.d.ts.map +1 -1
- package/dist/templates/shared-hooks/index.js +59 -0
- package/dist/templates/shared-hooks/index.js.map +1 -1
- package/dist/templates/shared-hooks/inject-shell-session-context.py +180 -0
- package/dist/templates/shared-hooks/inject-subagent-context.py +156 -27
- package/dist/templates/shared-hooks/inject-workflow-state.py +85 -92
- package/dist/templates/shared-hooks/session-start.py +232 -36
- package/dist/templates/trellis/config.yaml +6 -0
- package/dist/templates/trellis/gitignore.txt +3 -0
- package/dist/templates/trellis/index.d.ts +1 -1
- package/dist/templates/trellis/index.d.ts.map +1 -1
- package/dist/templates/trellis/index.js +2 -2
- package/dist/templates/trellis/index.js.map +1 -1
- package/dist/templates/trellis/scripts/common/__init__.py +8 -0
- package/dist/templates/trellis/scripts/common/active_task.py +593 -0
- package/dist/templates/trellis/scripts/common/cli_adapter.py +72 -14
- package/dist/templates/trellis/scripts/common/paths.py +61 -58
- package/dist/templates/trellis/scripts/common/session_context.py +12 -0
- package/dist/templates/trellis/scripts/common/task_context.py +27 -194
- package/dist/templates/trellis/scripts/common/task_store.py +102 -26
- package/dist/templates/trellis/scripts/common/tasks.py +4 -1
- package/dist/templates/trellis/scripts/common/types.py +0 -2
- package/dist/templates/trellis/scripts/common/workflow_phase.py +15 -3
- package/dist/templates/trellis/scripts/task.py +99 -34
- package/dist/templates/trellis/workflow.md +332 -64
- package/dist/types/ai-tools.d.ts +12 -3
- package/dist/types/ai-tools.d.ts.map +1 -1
- package/dist/types/ai-tools.js +29 -0
- package/dist/types/ai-tools.js.map +1 -1
- package/dist/utils/file-writer.d.ts.map +1 -1
- package/dist/utils/file-writer.js +7 -2
- package/dist/utils/file-writer.js.map +1 -1
- package/dist/utils/posix.d.ts +13 -0
- package/dist/utils/posix.d.ts.map +1 -0
- package/dist/utils/posix.js +15 -0
- package/dist/utils/posix.js.map +1 -0
- package/dist/utils/project-detector.d.ts +2 -0
- package/dist/utils/project-detector.d.ts.map +1 -1
- package/dist/utils/project-detector.js +120 -11
- package/dist/utils/project-detector.js.map +1 -1
- package/dist/utils/task-json.d.ts +46 -0
- package/dist/utils/task-json.d.ts.map +1 -0
- package/dist/utils/task-json.js +49 -0
- package/dist/utils/task-json.js.map +1 -0
- package/dist/utils/template-fetcher.d.ts +22 -6
- package/dist/utils/template-fetcher.d.ts.map +1 -1
- package/dist/utils/template-fetcher.js +405 -27
- package/dist/utils/template-fetcher.js.map +1 -1
- package/dist/utils/template-hash.d.ts +22 -3
- package/dist/utils/template-hash.d.ts.map +1 -1
- package/dist/utils/template-hash.js +99 -19
- package/dist/utils/template-hash.js.map +1 -1
- package/package.json +7 -7
- package/dist/templates/markdown/spec/backend/directory-structure.md +0 -292
- package/dist/templates/markdown/spec/backend/index.md +0 -40
- package/dist/templates/markdown/spec/backend/script-conventions.md +0 -742
- package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md +0 -118
- package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md +0 -394
- package/dist/templates/shared-hooks/statusline.py +0 -218
- package/dist/templates/trellis/scripts/create_bootstrap.py +0 -298
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
"""
|
|
4
|
-
Trellis StatusLine — project-level status display for Claude Code.
|
|
5
|
-
|
|
6
|
-
Reads Claude Code session JSON from stdin + Trellis task data from filesystem.
|
|
7
|
-
Outputs 1-2 lines:
|
|
8
|
-
With active task: [P1] Task title (status) + info line
|
|
9
|
-
Without task: info line only
|
|
10
|
-
Info line: model · ctx% · branch · duration · developer · tasks · rate limits
|
|
11
|
-
"""
|
|
12
|
-
from __future__ import annotations
|
|
13
|
-
|
|
14
|
-
import io
|
|
15
|
-
import json
|
|
16
|
-
import re
|
|
17
|
-
import subprocess
|
|
18
|
-
import sys
|
|
19
|
-
from pathlib import Path
|
|
20
|
-
|
|
21
|
-
# Fix: Windows Python defaults to GBK encoding, which corrupts UTF-8
|
|
22
|
-
# characters like the middle dot (·). Wrap stdout/stderr with UTF-8.
|
|
23
|
-
if sys.platform == "win32":
|
|
24
|
-
sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding="utf-8")
|
|
25
|
-
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding="utf-8")
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def _read_text(path: Path) -> str:
|
|
29
|
-
try:
|
|
30
|
-
return path.read_text(encoding="utf-8").strip()
|
|
31
|
-
except (FileNotFoundError, PermissionError, OSError):
|
|
32
|
-
return ""
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def _read_json(path: Path) -> dict:
|
|
36
|
-
text = _read_text(path)
|
|
37
|
-
if not text:
|
|
38
|
-
return {}
|
|
39
|
-
try:
|
|
40
|
-
return json.loads(text)
|
|
41
|
-
except (json.JSONDecodeError, ValueError):
|
|
42
|
-
return {}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def _normalize_task_ref(task_ref: str) -> str:
|
|
46
|
-
normalized = task_ref.strip()
|
|
47
|
-
if not normalized:
|
|
48
|
-
return ""
|
|
49
|
-
|
|
50
|
-
path_obj = Path(normalized)
|
|
51
|
-
if path_obj.is_absolute():
|
|
52
|
-
return str(path_obj)
|
|
53
|
-
|
|
54
|
-
normalized = normalized.replace("\\", "/")
|
|
55
|
-
while normalized.startswith("./"):
|
|
56
|
-
normalized = normalized[2:]
|
|
57
|
-
|
|
58
|
-
if normalized.startswith("tasks/"):
|
|
59
|
-
return f".trellis/{normalized}"
|
|
60
|
-
|
|
61
|
-
return normalized
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def _resolve_task_dir(trellis_dir: Path, task_ref: str) -> Path:
|
|
65
|
-
normalized = _normalize_task_ref(task_ref)
|
|
66
|
-
path_obj = Path(normalized)
|
|
67
|
-
if path_obj.is_absolute():
|
|
68
|
-
return path_obj
|
|
69
|
-
if normalized.startswith(".trellis/"):
|
|
70
|
-
return trellis_dir.parent / path_obj
|
|
71
|
-
return trellis_dir / "tasks" / path_obj
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def _find_trellis_dir() -> Path | None:
|
|
75
|
-
"""Walk up from cwd to find .trellis/ directory."""
|
|
76
|
-
current = Path.cwd()
|
|
77
|
-
for parent in [current, *current.parents]:
|
|
78
|
-
candidate = parent / ".trellis"
|
|
79
|
-
if candidate.is_dir():
|
|
80
|
-
return candidate
|
|
81
|
-
return None
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
def _get_current_task(trellis_dir: Path) -> dict | None:
|
|
85
|
-
"""Load current task info. Returns dict with title/status/priority or None."""
|
|
86
|
-
task_ref = _normalize_task_ref(_read_text(trellis_dir / ".current-task"))
|
|
87
|
-
if not task_ref:
|
|
88
|
-
return None
|
|
89
|
-
|
|
90
|
-
# Resolve task directory
|
|
91
|
-
task_path = _resolve_task_dir(trellis_dir, task_ref)
|
|
92
|
-
task_data = _read_json(task_path / "task.json")
|
|
93
|
-
if not task_data:
|
|
94
|
-
return None
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
"title": task_data.get("title") or task_data.get("name") or "unknown",
|
|
98
|
-
"status": task_data.get("status", "unknown"),
|
|
99
|
-
"priority": task_data.get("priority", "P2"),
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
def _count_active_tasks(trellis_dir: Path) -> int:
|
|
104
|
-
"""Count non-archived task directories with valid task.json."""
|
|
105
|
-
tasks_dir = trellis_dir / "tasks"
|
|
106
|
-
if not tasks_dir.is_dir():
|
|
107
|
-
return 0
|
|
108
|
-
count = 0
|
|
109
|
-
for d in tasks_dir.iterdir():
|
|
110
|
-
if d.is_dir() and d.name != "archive" and (d / "task.json").is_file():
|
|
111
|
-
count += 1
|
|
112
|
-
return count
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
def _get_developer(trellis_dir: Path) -> str:
|
|
116
|
-
content = _read_text(trellis_dir / ".developer")
|
|
117
|
-
if not content:
|
|
118
|
-
return "unknown"
|
|
119
|
-
for line in content.splitlines():
|
|
120
|
-
if line.startswith("name="):
|
|
121
|
-
return line[5:].strip()
|
|
122
|
-
return content.splitlines()[0].strip() or "unknown"
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
def _get_git_branch() -> str:
|
|
126
|
-
try:
|
|
127
|
-
result = subprocess.run(
|
|
128
|
-
["git", "branch", "--show-current"],
|
|
129
|
-
capture_output=True, text=True, timeout=3,
|
|
130
|
-
)
|
|
131
|
-
return result.stdout.strip() if result.returncode == 0 else ""
|
|
132
|
-
except (FileNotFoundError, subprocess.TimeoutExpired):
|
|
133
|
-
return ""
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
def _format_ctx_size(size: int) -> str:
|
|
137
|
-
if size >= 1_000_000:
|
|
138
|
-
return f"{size // 1_000_000}M"
|
|
139
|
-
if size >= 1_000:
|
|
140
|
-
return f"{size // 1_000}K"
|
|
141
|
-
return str(size)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
def _format_duration(ms: int) -> str:
|
|
145
|
-
secs = ms // 1000
|
|
146
|
-
hours, remainder = divmod(secs, 3600)
|
|
147
|
-
mins = remainder // 60
|
|
148
|
-
if hours > 0:
|
|
149
|
-
return f"{hours}h{mins}m"
|
|
150
|
-
return f"{mins}m"
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
def main() -> None:
|
|
154
|
-
# Read Claude Code session JSON from stdin
|
|
155
|
-
try:
|
|
156
|
-
cc_data = json.loads(sys.stdin.read())
|
|
157
|
-
except (json.JSONDecodeError, ValueError):
|
|
158
|
-
cc_data = {}
|
|
159
|
-
|
|
160
|
-
trellis_dir = _find_trellis_dir()
|
|
161
|
-
SEP = " \033[90m·\033[0m "
|
|
162
|
-
|
|
163
|
-
# --- Trellis data ---
|
|
164
|
-
task = _get_current_task(trellis_dir) if trellis_dir else None
|
|
165
|
-
dev = _get_developer(trellis_dir) if trellis_dir else ""
|
|
166
|
-
task_count = _count_active_tasks(trellis_dir) if trellis_dir else 0
|
|
167
|
-
|
|
168
|
-
# --- CC session data ---
|
|
169
|
-
model = cc_data.get("model", {}).get("display_name", "?")
|
|
170
|
-
ctx_pct = int(cc_data.get("context_window", {}).get("used_percentage") or 0)
|
|
171
|
-
ctx_size = _format_ctx_size(cc_data.get("context_window", {}).get("context_window_size") or 0)
|
|
172
|
-
duration = _format_duration(cc_data.get("cost", {}).get("total_duration_ms") or 0)
|
|
173
|
-
branch = _get_git_branch()
|
|
174
|
-
|
|
175
|
-
# Avoid "Opus 4.6 (1M context) (1M)"
|
|
176
|
-
if re.search(r"\d+[KMG]\b", model, re.IGNORECASE):
|
|
177
|
-
model_label = model
|
|
178
|
-
else:
|
|
179
|
-
model_label = f"{model} ({ctx_size})"
|
|
180
|
-
|
|
181
|
-
# Context % with color
|
|
182
|
-
if ctx_pct >= 90:
|
|
183
|
-
ctx_color = "\033[31m"
|
|
184
|
-
elif ctx_pct >= 70:
|
|
185
|
-
ctx_color = "\033[33m"
|
|
186
|
-
else:
|
|
187
|
-
ctx_color = "\033[32m"
|
|
188
|
-
|
|
189
|
-
# Build info line: model · ctx · branch · duration · dev · tasks [· rate limits]
|
|
190
|
-
parts = [
|
|
191
|
-
model_label,
|
|
192
|
-
f"ctx {ctx_color}{ctx_pct}%\033[0m",
|
|
193
|
-
]
|
|
194
|
-
if branch:
|
|
195
|
-
parts.append(f"\033[35m{branch}\033[0m")
|
|
196
|
-
parts.append(duration)
|
|
197
|
-
if dev:
|
|
198
|
-
parts.append(f"\033[32m{dev}\033[0m")
|
|
199
|
-
if task_count:
|
|
200
|
-
parts.append(f"{task_count} task(s)")
|
|
201
|
-
|
|
202
|
-
five_hr = cc_data.get("rate_limits", {}).get("five_hour", {}).get("used_percentage")
|
|
203
|
-
if five_hr is not None:
|
|
204
|
-
parts.append(f"5h {int(five_hr)}%")
|
|
205
|
-
seven_day = cc_data.get("rate_limits", {}).get("seven_day", {}).get("used_percentage")
|
|
206
|
-
if seven_day is not None:
|
|
207
|
-
parts.append(f"7d {int(seven_day)}%")
|
|
208
|
-
|
|
209
|
-
info_line = SEP.join(parts)
|
|
210
|
-
|
|
211
|
-
# Output: task line (only if active) + info line
|
|
212
|
-
if task:
|
|
213
|
-
print(f"\033[36m[{task['priority']}]\033[0m {task['title']} \033[33m({task['status']})\033[0m")
|
|
214
|
-
print(info_line)
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
if __name__ == "__main__":
|
|
218
|
-
main()
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
Create Bootstrap Task for First-Time Setup.
|
|
4
|
-
|
|
5
|
-
Creates a guided task to help users fill in project guidelines
|
|
6
|
-
after initializing Trellis for the first time.
|
|
7
|
-
|
|
8
|
-
Usage:
|
|
9
|
-
python3 create_bootstrap.py [project-type]
|
|
10
|
-
|
|
11
|
-
Arguments:
|
|
12
|
-
project-type: frontend | backend | fullstack (default: fullstack)
|
|
13
|
-
|
|
14
|
-
Prerequisites:
|
|
15
|
-
- .trellis/.developer must exist (run init_developer.py first)
|
|
16
|
-
|
|
17
|
-
Creates:
|
|
18
|
-
.trellis/tasks/00-bootstrap-guidelines/
|
|
19
|
-
- task.json # Task metadata
|
|
20
|
-
- prd.md # Task description and guidance
|
|
21
|
-
"""
|
|
22
|
-
|
|
23
|
-
from __future__ import annotations
|
|
24
|
-
|
|
25
|
-
import json
|
|
26
|
-
import sys
|
|
27
|
-
from datetime import datetime
|
|
28
|
-
from pathlib import Path
|
|
29
|
-
|
|
30
|
-
from common.paths import (
|
|
31
|
-
DIR_WORKFLOW,
|
|
32
|
-
DIR_SCRIPTS,
|
|
33
|
-
DIR_TASKS,
|
|
34
|
-
get_repo_root,
|
|
35
|
-
get_developer,
|
|
36
|
-
get_tasks_dir,
|
|
37
|
-
set_current_task,
|
|
38
|
-
)
|
|
39
|
-
from common.config import get_spec_base, resolve_package
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
# =============================================================================
|
|
43
|
-
# Constants
|
|
44
|
-
# =============================================================================
|
|
45
|
-
|
|
46
|
-
TASK_NAME = "00-bootstrap-guidelines"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
# =============================================================================
|
|
50
|
-
# PRD Content
|
|
51
|
-
# =============================================================================
|
|
52
|
-
|
|
53
|
-
def write_prd_header() -> str:
|
|
54
|
-
"""Write PRD header section."""
|
|
55
|
-
return """# Bootstrap: Fill Project Development Guidelines
|
|
56
|
-
|
|
57
|
-
## Purpose
|
|
58
|
-
|
|
59
|
-
Welcome to Trellis! This is your first task.
|
|
60
|
-
|
|
61
|
-
AI agents use `.trellis/spec/` to understand YOUR project's coding conventions.
|
|
62
|
-
**Starting from scratch = AI writes generic code that doesn't match your project style.**
|
|
63
|
-
|
|
64
|
-
Filling these guidelines is a one-time setup that pays off for every future AI session.
|
|
65
|
-
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
## Your Task
|
|
69
|
-
|
|
70
|
-
Fill in the guideline files based on your **existing codebase**.
|
|
71
|
-
"""
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def write_prd_backend_section(spec_base: str) -> str:
|
|
75
|
-
"""Write PRD backend section."""
|
|
76
|
-
return f"""
|
|
77
|
-
|
|
78
|
-
### Backend Guidelines
|
|
79
|
-
|
|
80
|
-
| File | What to Document |
|
|
81
|
-
|------|------------------|
|
|
82
|
-
| `.trellis/{spec_base}/backend/directory-structure.md` | Where different file types go (routes, services, utils) |
|
|
83
|
-
| `.trellis/{spec_base}/backend/database-guidelines.md` | ORM, migrations, query patterns, naming conventions |
|
|
84
|
-
| `.trellis/{spec_base}/backend/error-handling.md` | How errors are caught, logged, and returned |
|
|
85
|
-
| `.trellis/{spec_base}/backend/logging-guidelines.md` | Log levels, format, what to log |
|
|
86
|
-
| `.trellis/{spec_base}/backend/quality-guidelines.md` | Code review standards, testing requirements |
|
|
87
|
-
"""
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
def write_prd_frontend_section(spec_base: str) -> str:
|
|
91
|
-
"""Write PRD frontend section."""
|
|
92
|
-
return f"""
|
|
93
|
-
|
|
94
|
-
### Frontend Guidelines
|
|
95
|
-
|
|
96
|
-
| File | What to Document |
|
|
97
|
-
|------|------------------|
|
|
98
|
-
| `.trellis/{spec_base}/frontend/directory-structure.md` | Component/page/hook organization |
|
|
99
|
-
| `.trellis/{spec_base}/frontend/component-guidelines.md` | Component patterns, props conventions |
|
|
100
|
-
| `.trellis/{spec_base}/frontend/hook-guidelines.md` | Custom hook naming, patterns |
|
|
101
|
-
| `.trellis/{spec_base}/frontend/state-management.md` | State library, patterns, what goes where |
|
|
102
|
-
| `.trellis/{spec_base}/frontend/type-safety.md` | TypeScript conventions, type organization |
|
|
103
|
-
| `.trellis/{spec_base}/frontend/quality-guidelines.md` | Linting, testing, accessibility |
|
|
104
|
-
"""
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
def write_prd_footer() -> str:
|
|
108
|
-
"""Write PRD footer section."""
|
|
109
|
-
return """
|
|
110
|
-
|
|
111
|
-
### Thinking Guides (Optional)
|
|
112
|
-
|
|
113
|
-
The `.trellis/spec/guides/` directory contains thinking guides that are already
|
|
114
|
-
filled with general best practices. You can customize them for your project if needed.
|
|
115
|
-
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
## How to Fill Guidelines
|
|
119
|
-
|
|
120
|
-
### Principle: Document Reality, Not Ideals
|
|
121
|
-
|
|
122
|
-
Write what your codebase **actually does**, not what you wish it did.
|
|
123
|
-
AI needs to match existing patterns, not introduce new ones.
|
|
124
|
-
|
|
125
|
-
### Steps
|
|
126
|
-
|
|
127
|
-
1. **Look at existing code** - Find 2-3 examples of each pattern
|
|
128
|
-
2. **Document the pattern** - Describe what you see
|
|
129
|
-
3. **Include file paths** - Reference real files as examples
|
|
130
|
-
4. **List anti-patterns** - What does your team avoid?
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
## Tips for Using AI
|
|
135
|
-
|
|
136
|
-
Ask AI to help analyze your codebase:
|
|
137
|
-
|
|
138
|
-
- "Look at my codebase and document the patterns you see"
|
|
139
|
-
- "Analyze my code structure and summarize the conventions"
|
|
140
|
-
- "Find error handling patterns and document them"
|
|
141
|
-
|
|
142
|
-
The AI will read your code and help you document it.
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
|
|
146
|
-
## Completion Checklist
|
|
147
|
-
|
|
148
|
-
- [ ] Guidelines filled for your project type
|
|
149
|
-
- [ ] At least 2-3 real code examples in each guideline
|
|
150
|
-
- [ ] Anti-patterns documented
|
|
151
|
-
|
|
152
|
-
When done:
|
|
153
|
-
|
|
154
|
-
```bash
|
|
155
|
-
python3 ./.trellis/scripts/task.py finish
|
|
156
|
-
python3 ./.trellis/scripts/task.py archive 00-bootstrap-guidelines
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
## Why This Matters
|
|
162
|
-
|
|
163
|
-
After completing this task:
|
|
164
|
-
|
|
165
|
-
1. AI will write code that matches your project style
|
|
166
|
-
2. Relevant `/trellis:before-*-dev` commands will inject real context
|
|
167
|
-
3. `/trellis:check-*` commands will validate against your actual standards
|
|
168
|
-
4. Future developers (human or AI) will onboard faster
|
|
169
|
-
"""
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
def write_prd(task_dir: Path, project_type: str, spec_base: str) -> None:
|
|
173
|
-
"""Write prd.md file."""
|
|
174
|
-
content = write_prd_header()
|
|
175
|
-
|
|
176
|
-
if project_type == "frontend":
|
|
177
|
-
content += write_prd_frontend_section(spec_base)
|
|
178
|
-
elif project_type == "backend":
|
|
179
|
-
content += write_prd_backend_section(spec_base)
|
|
180
|
-
else: # fullstack
|
|
181
|
-
content += write_prd_backend_section(spec_base)
|
|
182
|
-
content += write_prd_frontend_section(spec_base)
|
|
183
|
-
|
|
184
|
-
content += write_prd_footer()
|
|
185
|
-
|
|
186
|
-
prd_file = task_dir / "prd.md"
|
|
187
|
-
prd_file.write_text(content, encoding="utf-8")
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
# =============================================================================
|
|
191
|
-
# Task JSON
|
|
192
|
-
# =============================================================================
|
|
193
|
-
|
|
194
|
-
def write_task_json(task_dir: Path, developer: str, project_type: str, spec_base: str) -> None:
|
|
195
|
-
"""Write task.json file."""
|
|
196
|
-
today = datetime.now().strftime("%Y-%m-%d")
|
|
197
|
-
|
|
198
|
-
# Generate subtasks and related files based on project type
|
|
199
|
-
if project_type == "frontend":
|
|
200
|
-
subtasks = [
|
|
201
|
-
{"name": "Fill frontend guidelines", "status": "pending"},
|
|
202
|
-
{"name": "Add code examples", "status": "pending"},
|
|
203
|
-
]
|
|
204
|
-
related_files = [f".trellis/{spec_base}/frontend/"]
|
|
205
|
-
elif project_type == "backend":
|
|
206
|
-
subtasks = [
|
|
207
|
-
{"name": "Fill backend guidelines", "status": "pending"},
|
|
208
|
-
{"name": "Add code examples", "status": "pending"},
|
|
209
|
-
]
|
|
210
|
-
related_files = [f".trellis/{spec_base}/backend/"]
|
|
211
|
-
else: # fullstack
|
|
212
|
-
subtasks = [
|
|
213
|
-
{"name": "Fill backend guidelines", "status": "pending"},
|
|
214
|
-
{"name": "Fill frontend guidelines", "status": "pending"},
|
|
215
|
-
{"name": "Add code examples", "status": "pending"},
|
|
216
|
-
]
|
|
217
|
-
related_files = [f".trellis/{spec_base}/backend/", f".trellis/{spec_base}/frontend/"]
|
|
218
|
-
|
|
219
|
-
task_data = {
|
|
220
|
-
"id": TASK_NAME,
|
|
221
|
-
"name": "Bootstrap Guidelines",
|
|
222
|
-
"description": "Fill in project development guidelines for AI agents",
|
|
223
|
-
"status": "in_progress",
|
|
224
|
-
"dev_type": "docs",
|
|
225
|
-
"priority": "P1",
|
|
226
|
-
"creator": developer,
|
|
227
|
-
"assignee": developer,
|
|
228
|
-
"createdAt": today,
|
|
229
|
-
"completedAt": None,
|
|
230
|
-
"commit": None,
|
|
231
|
-
"subtasks": subtasks,
|
|
232
|
-
"children": [],
|
|
233
|
-
"parent": None,
|
|
234
|
-
"relatedFiles": related_files,
|
|
235
|
-
"notes": f"First-time setup task created by trellis init ({project_type} project)",
|
|
236
|
-
"meta": {},
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
task_json = task_dir / "task.json"
|
|
240
|
-
task_json.write_text(json.dumps(task_data, indent=2, ensure_ascii=False), encoding="utf-8")
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
# =============================================================================
|
|
244
|
-
# Main
|
|
245
|
-
# =============================================================================
|
|
246
|
-
|
|
247
|
-
def main() -> int:
|
|
248
|
-
"""Main entry point."""
|
|
249
|
-
# Parse project type argument
|
|
250
|
-
project_type = "fullstack"
|
|
251
|
-
if len(sys.argv) > 1:
|
|
252
|
-
project_type = sys.argv[1]
|
|
253
|
-
|
|
254
|
-
# Validate project type
|
|
255
|
-
if project_type not in ("frontend", "backend", "fullstack"):
|
|
256
|
-
print(f"Unknown project type: {project_type}, defaulting to fullstack")
|
|
257
|
-
project_type = "fullstack"
|
|
258
|
-
|
|
259
|
-
repo_root = get_repo_root()
|
|
260
|
-
developer = get_developer(repo_root)
|
|
261
|
-
|
|
262
|
-
# Check developer initialized
|
|
263
|
-
if not developer:
|
|
264
|
-
print("Error: Developer not initialized")
|
|
265
|
-
print(f"Run: python3 ./{DIR_WORKFLOW}/{DIR_SCRIPTS}/init_developer.py <your-name>")
|
|
266
|
-
return 1
|
|
267
|
-
|
|
268
|
-
# Resolve spec base path (monorepo: spec/<package>, single-repo: spec)
|
|
269
|
-
package = resolve_package(repo_root=repo_root)
|
|
270
|
-
spec_base = get_spec_base(package, repo_root)
|
|
271
|
-
|
|
272
|
-
tasks_dir = get_tasks_dir(repo_root)
|
|
273
|
-
task_dir = tasks_dir / TASK_NAME
|
|
274
|
-
relative_path = f"{DIR_WORKFLOW}/{DIR_TASKS}/{TASK_NAME}"
|
|
275
|
-
|
|
276
|
-
# Check if already exists
|
|
277
|
-
if task_dir.exists():
|
|
278
|
-
print(f"Bootstrap task already exists: {relative_path}")
|
|
279
|
-
return 0
|
|
280
|
-
|
|
281
|
-
# Create task directory
|
|
282
|
-
task_dir.mkdir(parents=True, exist_ok=True)
|
|
283
|
-
|
|
284
|
-
# Write files
|
|
285
|
-
write_task_json(task_dir, developer, project_type, spec_base)
|
|
286
|
-
write_prd(task_dir, project_type, spec_base)
|
|
287
|
-
|
|
288
|
-
# Set as current task
|
|
289
|
-
set_current_task(relative_path, repo_root)
|
|
290
|
-
|
|
291
|
-
# Silent output - init command handles user-facing messages
|
|
292
|
-
# Only output the task path for programmatic use
|
|
293
|
-
print(relative_path)
|
|
294
|
-
return 0
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if __name__ == "__main__":
|
|
298
|
-
sys.exit(main())
|