mini-trellis 0.2.0 → 0.2.1

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 (30) hide show
  1. package/README.md +100 -105
  2. package/dist/commands/doctor.d.ts.map +1 -1
  3. package/dist/commands/doctor.js +80 -5
  4. package/dist/commands/doctor.js.map +1 -1
  5. package/dist/commands/init.js +1 -1
  6. package/dist/commands/init.js.map +1 -1
  7. package/dist/commands/mem.d.ts +2 -0
  8. package/dist/commands/mem.d.ts.map +1 -1
  9. package/dist/commands/mem.js +85 -2
  10. package/dist/commands/mem.js.map +1 -1
  11. package/dist/configurators/shared.d.ts.map +1 -1
  12. package/dist/configurators/shared.js +2 -2
  13. package/dist/configurators/shared.js.map +1 -1
  14. package/dist/templates/codex/config.toml +5 -5
  15. package/dist/templates/codex/hooks.json +4 -1
  16. package/dist/templates/common/bundled-skills/mini-trellis-session-insight/SKILL.md +13 -7
  17. package/dist/templates/common/bundled-skills/mini-trellis-session-insight/references/cli-quick-reference.md +24 -11
  18. package/dist/templates/common/bundled-skills/mini-trellis-session-insight/references/triggering-patterns.md +18 -10
  19. package/dist/templates/common/commands/remember.md +17 -3
  20. package/dist/templates/common/skills/update-spec.md +4 -0
  21. package/dist/templates/markdown/agents.md +7 -1
  22. package/dist/templates/markdown/spec/guides/mini-memory.md.txt +15 -8
  23. package/dist/templates/opencode/lib/session-utils.js +6 -51
  24. package/dist/templates/opencode/plugins/session-start.js +3 -16
  25. package/dist/templates/pi/extensions/mini-trellis/index.ts.txt +27 -87
  26. package/dist/templates/shared-hooks/session-start.py +99 -60
  27. package/dist/templates/trellis/config.yaml +3 -3
  28. package/dist/templates/trellis/scripts/add_session.py +95 -9
  29. package/dist/templates/trellis/scripts/common/config.py +4 -3
  30. package/package.json +3 -3
@@ -4,7 +4,7 @@
4
4
  Add a new session to journal file and update index.md.
5
5
 
6
6
  Usage:
7
- python3 add_session.py --title "Title" --commit "hash" --summary "Summary" [--package cli]
7
+ python3 add_session.py --title "Title" --commit "hash" --summary "Summary" [--topic .trellis/research/topic.md]
8
8
  python3 add_session.py --title "Title" --branch "feat/my-branch"
9
9
 
10
10
  # Pipe detailed content via stdin (use --stdin to opt in):
@@ -48,10 +48,12 @@ from __future__ import annotations
48
48
  import argparse
49
49
  import hashlib
50
50
  import json
51
+ import os
51
52
  import re
52
53
  import sys
53
- from datetime import datetime
54
+ from datetime import datetime, timezone
54
55
  from pathlib import Path
56
+ from urllib.parse import quote
55
57
 
56
58
  from common.paths import (
57
59
  DIR_TASKS,
@@ -517,6 +519,29 @@ def render_marker(fingerprint: str) -> str:
517
519
  return f"{MARKER_PREFIX} v={MARKER_VERSION} fp={fingerprint} -->"
518
520
 
519
521
 
522
+ def _append_topic_links(
523
+ summary: str,
524
+ topic_paths: list[str] | None,
525
+ link_base: Path | None = None,
526
+ repo_root: Path | None = None,
527
+ ) -> str:
528
+ """Append topic links, resolving them relative to the journal file.
529
+
530
+ The record fingerprint keeps project-relative paths stable, while the
531
+ rendered Markdown link must resolve from the journal's directory.
532
+ """
533
+ if not topic_paths:
534
+ return summary
535
+
536
+ links: list[str] = []
537
+ for topic in topic_paths:
538
+ href = topic
539
+ if link_base is not None and repo_root is not None:
540
+ href = quote(Path(os.path.relpath(repo_root / topic, start=link_base)).as_posix())
541
+ links.append(f"[{topic}]({href})")
542
+ return summary + "\nTopics: " + ", ".join(links)
543
+
544
+
520
545
  def render_legacy_marker(fingerprint: str) -> str:
521
546
  """The v1 marker form: no version tag. Read, never written."""
522
547
  return f"{MARKER_PREFIX} fp={fingerprint} -->"
@@ -1197,6 +1222,7 @@ def add_session(
1197
1222
  branch: str | None = None,
1198
1223
  commit_subjects: list[str] | None = None,
1199
1224
  idempotency_key: str | None = None,
1225
+ topic_paths: list[str] | None = None,
1200
1226
  ) -> int:
1201
1227
  """Add a new session, resuming an interrupted one instead of duplicating it."""
1202
1228
  repo_root = get_repo_root()
@@ -1243,8 +1269,9 @@ def add_session(
1243
1269
  index_file = dev_dir / "index.md"
1244
1270
  today = datetime.now().strftime("%Y-%m-%d")
1245
1271
 
1272
+ record_summary = _append_topic_links(summary, topic_paths)
1246
1273
  payload = _fingerprint_payload(
1247
- developer, title, summary, package, branch, evidence,
1274
+ developer, title, record_summary, package, branch, evidence,
1248
1275
  changes, extra_content, tests, next_steps, idempotency_key,
1249
1276
  )
1250
1277
  marker = render_marker(compute_record_fingerprint(payload))
@@ -1310,8 +1337,9 @@ def add_session(
1310
1337
  journal_file, current_num, current_lines = get_latest_journal_info(dev_dir)
1311
1338
  new_session = resolve_next_session(repo_root, dev_dir, index_file)
1312
1339
 
1340
+ rendered_summary = _append_topic_links(summary, topic_paths, dev_dir, repo_root)
1313
1341
  session_content = generate_session_content(
1314
- new_session, title, evidence, summary, today, marker, package, branch,
1342
+ new_session, title, evidence, rendered_summary, today, marker, package, branch,
1315
1343
  changes=changes, extra_content=extra_content, tests=tests,
1316
1344
  next_steps=next_steps,
1317
1345
  )
@@ -1413,12 +1441,12 @@ def add_session(
1413
1441
 
1414
1442
  print("", file=sys.stderr)
1415
1443
  print("========================================", file=sys.stderr)
1416
- print(f"[OK] Session {new_session} added successfully!", file=sys.stderr)
1444
+ print(f"[OK] Journal session {new_session} and index recorded (topic content must be verified separately).", file=sys.stderr)
1417
1445
  print("========================================", file=sys.stderr)
1418
1446
  print("", file=sys.stderr)
1419
1447
  print("Files updated:", file=sys.stderr)
1420
- print(f" - {target_file.name if target_file else 'journal'}", file=sys.stderr)
1421
- print(" - index.md", file=sys.stderr)
1448
+ print(f" - {target_file.relative_to(repo_root).as_posix() if target_file else 'journal'}", file=sys.stderr)
1449
+ print(f" - {index_file.relative_to(repo_root).as_posix()}", file=sys.stderr)
1422
1450
 
1423
1451
  # -------------------------------------------------------------------
1424
1452
  # Index-recorded → committed
@@ -1478,8 +1506,12 @@ def main() -> int:
1478
1506
  ),
1479
1507
  )
1480
1508
  parser.add_argument("--summary", default="Session summary was not supplied.", help="Brief summary")
1509
+ parser.add_argument(
1510
+ "--topic", action="append", default=[], metavar="PATH",
1511
+ help="Existing spec/research Markdown to validate and link in the journal (repeatable); does not edit or verify its conclusions",
1512
+ )
1481
1513
  parser.add_argument("--content-file", help="Path to file with detailed content")
1482
- parser.add_argument("--package", help="Package name tag (e.g., cli, docs-site)")
1514
+ parser.add_argument("--package", help="Package name tag (e.g., cli, core)")
1483
1515
  parser.add_argument("--branch", help="Branch name (auto-detected if omitted)")
1484
1516
  parser.add_argument("--change", action="append", help="Main Changes bullet (repeatable)")
1485
1517
  parser.add_argument("--test", action="append", help="Testing bullet (repeatable)")
@@ -1508,6 +1540,21 @@ def main() -> int:
1508
1540
 
1509
1541
  # Load active task once — shared by package and branch resolution
1510
1542
  repo_root = get_repo_root()
1543
+ topic_links: list[str] = []
1544
+ for topic in args.topic:
1545
+ try:
1546
+ candidate = (repo_root / topic).resolve(strict=True)
1547
+ relative = candidate.relative_to(repo_root.resolve()).as_posix()
1548
+ if (not relative.startswith((".trellis/spec/", ".trellis/research/"))
1549
+ or candidate.suffix.lower() != ".md"
1550
+ or not candidate.is_file()
1551
+ or not candidate.read_text(encoding="utf-8").strip()):
1552
+ raise ValueError("expected a non-empty spec/research Markdown file")
1553
+ except (OSError, ValueError, UnicodeError):
1554
+ print("Error: --topic must name a readable, non-empty spec/research Markdown inside this project; journal not written.", file=sys.stderr)
1555
+ return 1
1556
+ if relative not in topic_links:
1557
+ topic_links.append(relative)
1511
1558
  current = get_current_task(repo_root)
1512
1559
  task_data = load_task(repo_root / current) if current else None
1513
1560
 
@@ -1538,8 +1585,47 @@ def main() -> int:
1538
1585
  branch=branch,
1539
1586
  commit_subjects=args.commit_subject,
1540
1587
  idempotency_key=args.idempotency_key,
1588
+ topic_paths=topic_links,
1541
1589
  )
1542
1590
 
1543
1591
 
1592
+ def _write_recording_status(exit_code: int) -> None:
1593
+ """Best-effort last completed attempt, with no note content or user identity.
1594
+
1595
+ Atomic replacement keeps concurrent diagnostics readable. The journal and
1596
+ index remain the source of truth; failure may leave a resumable checkpoint.
1597
+ """
1598
+ try:
1599
+ trellis = get_repo_root() / DIR_WORKFLOW
1600
+ if not trellis.is_dir():
1601
+ return
1602
+ target = trellis / ".runtime" / "writes" / "latest.json"
1603
+ target.parent.mkdir(parents=True, exist_ok=True)
1604
+ payload: dict[str, object] = {
1605
+ "schema": 1,
1606
+ "last_write_at": datetime.now(timezone.utc).isoformat(),
1607
+ "last_status": "ok" if exit_code == 0 else "error",
1608
+ "last_exit_code": exit_code,
1609
+ }
1610
+ if exit_code != 0:
1611
+ payload["last_error_category"] = "recording-failed"
1612
+ if write_text_atomic(target, json.dumps(payload) + "\n"):
1613
+ return
1614
+ except OSError:
1615
+ pass
1616
+ print("mini-trellis: recording diagnostic write failed (state-write)", file=sys.stderr)
1617
+
1618
+
1619
+ def run_with_status() -> int:
1620
+ try:
1621
+ result = main()
1622
+ except Exception:
1623
+ _write_recording_status(1)
1624
+ raise
1625
+ # argparse's --help / invalid arguments exit before a recording attempt.
1626
+ _write_recording_status(result)
1627
+ return result
1628
+
1629
+
1544
1630
  if __name__ == "__main__":
1545
- sys.exit(main())
1631
+ sys.exit(run_with_status())
@@ -121,7 +121,8 @@ def get_session_auto_commit(repo_root: Path | None = None) -> bool:
121
121
  Governs both ``add_session.py:_auto_commit_workspace`` and
122
122
  ``task_store.py:_auto_commit_archive``.
123
123
 
124
- Default: ``True`` (existing behavior — auto-stage + auto-commit).
124
+ Missing-key fallback: ``True`` for existing projects. New installations
125
+ explicitly set ``session_auto_commit: false`` in their config template.
125
126
  Set ``session_auto_commit: false`` in ``.trellis/config.yaml`` to skip
126
127
  auto-staging entirely; the journal/archive files are still written to
127
128
  disk, but the user manages ``git add`` / ``git commit`` themselves.
@@ -313,7 +314,7 @@ def get_packages(repo_root: Path | None = None) -> dict[str, dict] | None:
313
314
  or None if not configured (single-repo mode).
314
315
 
315
316
  Example return:
316
- {"cli": {"path": "packages/cli"}, "docs-site": {"path": "docs-site", "type": "submodule"}}
317
+ {"cli": {"path": "packages/cli"}, "docs": {"path": "docs", "type": "submodule"}}
317
318
  """
318
319
  config = _load_config(repo_root)
319
320
  packages = config.get("packages")
@@ -345,7 +346,7 @@ def get_submodule_packages(repo_root: Path | None = None) -> dict[str, str]:
345
346
  Empty dict if none configured.
346
347
 
347
348
  Example return:
348
- {"docs-site": "docs-site"}
349
+ {"docs": "docs"}
349
350
  """
350
351
  packages = get_packages(repo_root)
351
352
  if packages is None:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mini-trellis",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Minimal memory layer for AI coding agents: spec, research, journal, and cross-session recall.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,9 +33,9 @@
33
33
  "dependencies": {
34
34
  "chalk": "^5.3.0",
35
35
  "commander": "^12.1.0",
36
- "figlet": "^1.9.4",
36
+ "figlet": "1.8.2",
37
37
  "inquirer": "^9.3.7",
38
- "mini-trellis-core": "0.2.0"
38
+ "mini-trellis-core": "0.2.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@eslint/js": "^9.18.0",