@mindfoldhq/trellis 0.3.0 → 0.3.2

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.
Files changed (37) hide show
  1. package/README.md +4 -0
  2. package/dist/commands/update.d.ts.map +1 -1
  3. package/dist/commands/update.js +25 -17
  4. package/dist/commands/update.js.map +1 -1
  5. package/dist/configurators/index.js +1 -1
  6. package/dist/configurators/index.js.map +1 -1
  7. package/dist/configurators/workflow.d.ts.map +1 -1
  8. package/dist/configurators/workflow.js +57 -51
  9. package/dist/configurators/workflow.js.map +1 -1
  10. package/dist/migrations/manifests/0.3.0-beta.0.json +60 -41
  11. package/dist/migrations/manifests/0.3.0.json +4 -4
  12. package/dist/migrations/manifests/0.3.1.json +9 -0
  13. package/dist/migrations/manifests/0.3.2.json +9 -0
  14. package/dist/templates/claude/commands/trellis/record-session.md +3 -0
  15. package/dist/templates/claude/settings.json +20 -0
  16. package/dist/templates/codex/skills/record-session/SKILL.md +3 -0
  17. package/dist/templates/cursor/commands/trellis-record-session.md +3 -0
  18. package/dist/templates/gemini/commands/trellis/record-session.toml +3 -0
  19. package/dist/templates/iflow/commands/trellis/record-session.md +3 -0
  20. package/dist/templates/iflow/settings.json +20 -0
  21. package/dist/templates/kilo/commands/trellis/record-session.md +3 -0
  22. package/dist/templates/kiro/skills/record-session/SKILL.md +3 -0
  23. package/dist/templates/markdown/index.d.ts +0 -1
  24. package/dist/templates/markdown/index.d.ts.map +1 -1
  25. package/dist/templates/markdown/index.js +0 -1
  26. package/dist/templates/markdown/index.js.map +1 -1
  27. package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md.txt +13 -0
  28. package/dist/templates/markdown/spec/guides/index.md.txt +0 -10
  29. package/dist/templates/opencode/commands/trellis/record-session.md +3 -0
  30. package/dist/templates/trellis/config.yaml +15 -0
  31. package/dist/templates/trellis/index.d.ts +3 -0
  32. package/dist/templates/trellis/index.d.ts.map +1 -1
  33. package/dist/templates/trellis/index.js +4 -0
  34. package/dist/templates/trellis/index.js.map +1 -1
  35. package/dist/templates/trellis/scripts/add_session.py +52 -10
  36. package/dist/templates/trellis/scripts/common/config.py +52 -0
  37. package/package.json +1 -1
@@ -23,6 +23,7 @@ if sys.platform == "win32":
23
23
 
24
24
  import argparse
25
25
  import re
26
+ import subprocess
26
27
  import sys
27
28
  from datetime import datetime
28
29
  from pathlib import Path
@@ -34,9 +35,7 @@ from common.paths import (
34
35
  get_workspace_dir,
35
36
  )
36
37
  from common.developer import ensure_developer
37
-
38
-
39
- MAX_LINES = 2000
38
+ from common.config import get_session_commit_message, get_max_journal_lines
40
39
 
41
40
 
42
41
  # =============================================================================
@@ -110,14 +109,16 @@ def count_journal_files(dev_dir: Path, active_num: int) -> str:
110
109
  return "\n".join(result_lines)
111
110
 
112
111
 
113
- def create_new_journal_file(dev_dir: Path, num: int, developer: str, today: str) -> Path:
112
+ def create_new_journal_file(
113
+ dev_dir: Path, num: int, developer: str, today: str, max_lines: int = 2000,
114
+ ) -> Path:
114
115
  """Create a new journal file."""
115
116
  prev_num = num - 1
116
117
  new_file = dev_dir / f"{FILE_JOURNAL_PREFIX}{num}.md"
117
118
 
118
119
  content = f"""# Journal - {developer} (Part {num})
119
120
 
120
- > Continuation from `{FILE_JOURNAL_PREFIX}{prev_num}.md` (archived at ~{MAX_LINES} lines)
121
+ > Continuation from `{FILE_JOURNAL_PREFIX}{prev_num}.md` (archived at ~{max_lines} lines)
121
122
  > Started: {today}
122
123
 
123
124
  ---
@@ -281,11 +282,40 @@ def update_index(
281
282
  # Main Function
282
283
  # =============================================================================
283
284
 
285
+ def _auto_commit_workspace(repo_root: Path) -> None:
286
+ """Stage .trellis/workspace and commit with a configured message."""
287
+ commit_msg = get_session_commit_message(repo_root)
288
+ subprocess.run(
289
+ ["git", "add", "-A", ".trellis/workspace"],
290
+ cwd=repo_root,
291
+ capture_output=True,
292
+ )
293
+ # Check if there are staged changes
294
+ result = subprocess.run(
295
+ ["git", "diff", "--cached", "--quiet", "--", ".trellis/workspace"],
296
+ cwd=repo_root,
297
+ )
298
+ if result.returncode == 0:
299
+ print("[OK] No workspace changes to commit.", file=sys.stderr)
300
+ return
301
+ commit_result = subprocess.run(
302
+ ["git", "commit", "-m", commit_msg],
303
+ cwd=repo_root,
304
+ capture_output=True,
305
+ text=True,
306
+ )
307
+ if commit_result.returncode == 0:
308
+ print(f"[OK] Auto-committed: {commit_msg}", file=sys.stderr)
309
+ else:
310
+ print(f"[WARN] Auto-commit failed: {commit_result.stderr.strip()}", file=sys.stderr)
311
+
312
+
284
313
  def add_session(
285
314
  title: str,
286
315
  commit: str = "-",
287
316
  summary: str = "(Add summary)",
288
- extra_content: str = "(Add details)"
317
+ extra_content: str = "(Add details)",
318
+ auto_commit: bool = True,
289
319
  ) -> int:
290
320
  """Add a new session."""
291
321
  repo_root = get_repo_root()
@@ -301,6 +331,8 @@ def add_session(
301
331
  print("Error: Workspace directory not found", file=sys.stderr)
302
332
  return 1
303
333
 
334
+ max_lines = get_max_journal_lines(repo_root)
335
+
304
336
  index_file = dev_dir / "index.md"
305
337
  today = datetime.now().strftime("%Y-%m-%d")
306
338
 
@@ -330,10 +362,10 @@ def add_session(
330
362
  target_file = journal_file
331
363
  target_num = current_num
332
364
 
333
- if current_lines + content_lines > MAX_LINES:
365
+ if current_lines + content_lines > max_lines:
334
366
  target_num = current_num + 1
335
- print(f"[!] Exceeds {MAX_LINES} lines, creating {FILE_JOURNAL_PREFIX}{target_num}.md", file=sys.stderr)
336
- target_file = create_new_journal_file(dev_dir, target_num, developer, today)
367
+ print(f"[!] Exceeds {max_lines} lines, creating {FILE_JOURNAL_PREFIX}{target_num}.md", file=sys.stderr)
368
+ target_file = create_new_journal_file(dev_dir, target_num, developer, today, max_lines)
337
369
  print(f"Created: {target_file}", file=sys.stderr)
338
370
 
339
371
  # Append session content
@@ -358,6 +390,11 @@ def add_session(
358
390
  print(f" - {target_file.name if target_file else 'journal'}", file=sys.stderr)
359
391
  print(" - index.md", file=sys.stderr)
360
392
 
393
+ # Auto-commit workspace changes
394
+ if auto_commit:
395
+ print("", file=sys.stderr)
396
+ _auto_commit_workspace(repo_root)
397
+
361
398
  return 0
362
399
 
363
400
 
@@ -374,6 +411,8 @@ def main() -> int:
374
411
  parser.add_argument("--commit", default="-", help="Comma-separated commit hashes")
375
412
  parser.add_argument("--summary", default="(Add summary)", help="Brief summary")
376
413
  parser.add_argument("--content-file", help="Path to file with detailed content")
414
+ parser.add_argument("--no-commit", action="store_true",
415
+ help="Skip auto-commit of workspace changes")
377
416
 
378
417
  args = parser.parse_args()
379
418
 
@@ -385,7 +424,10 @@ def main() -> int:
385
424
  elif not sys.stdin.isatty():
386
425
  extra_content = sys.stdin.read()
387
426
 
388
- return add_session(args.title, args.commit, args.summary, extra_content)
427
+ return add_session(
428
+ args.title, args.commit, args.summary, extra_content,
429
+ auto_commit=not args.no_commit,
430
+ )
389
431
 
390
432
 
391
433
  if __name__ == "__main__":
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Trellis configuration reader.
4
+
5
+ Reads settings from .trellis/config.yaml with sensible defaults.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from pathlib import Path
11
+
12
+ from .paths import DIR_WORKFLOW, get_repo_root
13
+ from .worktree import parse_simple_yaml
14
+
15
+
16
+ # Defaults
17
+ DEFAULT_SESSION_COMMIT_MESSAGE = "chore: record journal"
18
+ DEFAULT_MAX_JOURNAL_LINES = 2000
19
+
20
+ CONFIG_FILE = "config.yaml"
21
+
22
+
23
+ def _get_config_path(repo_root: Path | None = None) -> Path:
24
+ """Get path to config.yaml."""
25
+ root = repo_root or get_repo_root()
26
+ return root / DIR_WORKFLOW / CONFIG_FILE
27
+
28
+
29
+ def _load_config(repo_root: Path | None = None) -> dict:
30
+ """Load and parse config.yaml. Returns empty dict on any error."""
31
+ config_file = _get_config_path(repo_root)
32
+ try:
33
+ content = config_file.read_text(encoding="utf-8")
34
+ return parse_simple_yaml(content)
35
+ except (OSError, IOError):
36
+ return {}
37
+
38
+
39
+ def get_session_commit_message(repo_root: Path | None = None) -> str:
40
+ """Get the commit message for auto-committing session records."""
41
+ config = _load_config(repo_root)
42
+ return config.get("session_commit_message", DEFAULT_SESSION_COMMIT_MESSAGE)
43
+
44
+
45
+ def get_max_journal_lines(repo_root: Path | None = None) -> int:
46
+ """Get the maximum lines per journal file."""
47
+ config = _load_config(repo_root)
48
+ value = config.get("max_journal_lines", DEFAULT_MAX_JOURNAL_LINES)
49
+ try:
50
+ return int(value)
51
+ except (ValueError, TypeError):
52
+ return DEFAULT_MAX_JOURNAL_LINES
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindfoldhq/trellis",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "AI capabilities grow like ivy — Trellis provides the structure to guide them along a disciplined path",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",