mini-trellis 0.1.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.
Files changed (186) hide show
  1. package/COPYRIGHT +20 -0
  2. package/LICENSE +235 -0
  3. package/README.md +66 -0
  4. package/bin/mini-trellis.js +3 -0
  5. package/dist/cli/index.d.ts +3 -0
  6. package/dist/cli/index.d.ts.map +1 -0
  7. package/dist/cli/index.js +153 -0
  8. package/dist/cli/index.js.map +1 -0
  9. package/dist/commands/init.d.ts +19 -0
  10. package/dist/commands/init.d.ts.map +1 -0
  11. package/dist/commands/init.js +401 -0
  12. package/dist/commands/init.js.map +1 -0
  13. package/dist/commands/mem.d.ts +30 -0
  14. package/dist/commands/mem.d.ts.map +1 -0
  15. package/dist/commands/mem.js +412 -0
  16. package/dist/commands/mem.js.map +1 -0
  17. package/dist/commands/migrate.d.ts +40 -0
  18. package/dist/commands/migrate.d.ts.map +1 -0
  19. package/dist/commands/migrate.js +272 -0
  20. package/dist/commands/migrate.js.map +1 -0
  21. package/dist/commands/uninstall.d.ts +11 -0
  22. package/dist/commands/uninstall.d.ts.map +1 -0
  23. package/dist/commands/uninstall.js +135 -0
  24. package/dist/commands/uninstall.js.map +1 -0
  25. package/dist/commands/upgrade.d.ts +28 -0
  26. package/dist/commands/upgrade.d.ts.map +1 -0
  27. package/dist/commands/upgrade.js +84 -0
  28. package/dist/commands/upgrade.js.map +1 -0
  29. package/dist/configurators/claude.d.ts +3 -0
  30. package/dist/configurators/claude.d.ts.map +1 -0
  31. package/dist/configurators/claude.js +62 -0
  32. package/dist/configurators/claude.js.map +1 -0
  33. package/dist/configurators/codex.d.ts +3 -0
  34. package/dist/configurators/codex.d.ts.map +1 -0
  35. package/dist/configurators/codex.js +21 -0
  36. package/dist/configurators/codex.js.map +1 -0
  37. package/dist/configurators/index.d.ts +24 -0
  38. package/dist/configurators/index.d.ts.map +1 -0
  39. package/dist/configurators/index.js +80 -0
  40. package/dist/configurators/index.js.map +1 -0
  41. package/dist/configurators/opencode.d.ts +2 -0
  42. package/dist/configurators/opencode.d.ts.map +1 -0
  43. package/dist/configurators/opencode.js +62 -0
  44. package/dist/configurators/opencode.js.map +1 -0
  45. package/dist/configurators/pi.d.ts +2 -0
  46. package/dist/configurators/pi.d.ts.map +1 -0
  47. package/dist/configurators/pi.js +18 -0
  48. package/dist/configurators/pi.js.map +1 -0
  49. package/dist/configurators/shared.d.ts +147 -0
  50. package/dist/configurators/shared.d.ts.map +1 -0
  51. package/dist/configurators/shared.js +377 -0
  52. package/dist/configurators/shared.js.map +1 -0
  53. package/dist/configurators/workflow.d.ts +15 -0
  54. package/dist/configurators/workflow.d.ts.map +1 -0
  55. package/dist/configurators/workflow.js +46 -0
  56. package/dist/configurators/workflow.js.map +1 -0
  57. package/dist/constants/paths.d.ts +74 -0
  58. package/dist/constants/paths.d.ts.map +1 -0
  59. package/dist/constants/paths.js +83 -0
  60. package/dist/constants/paths.js.map +1 -0
  61. package/dist/constants/version.d.ts +9 -0
  62. package/dist/constants/version.d.ts.map +1 -0
  63. package/dist/constants/version.js +15 -0
  64. package/dist/constants/version.js.map +1 -0
  65. package/dist/index.d.ts +9 -0
  66. package/dist/index.d.ts.map +1 -0
  67. package/dist/index.js +9 -0
  68. package/dist/index.js.map +1 -0
  69. package/dist/templates/claude/index.d.ts +11 -0
  70. package/dist/templates/claude/index.d.ts.map +1 -0
  71. package/dist/templates/claude/index.js +17 -0
  72. package/dist/templates/claude/index.js.map +1 -0
  73. package/dist/templates/claude/settings.json +40 -0
  74. package/dist/templates/codex/config.toml +39 -0
  75. package/dist/templates/codex/hooks.json +15 -0
  76. package/dist/templates/codex/index.d.ts +11 -0
  77. package/dist/templates/codex/index.d.ts.map +1 -0
  78. package/dist/templates/codex/index.js +22 -0
  79. package/dist/templates/codex/index.js.map +1 -0
  80. package/dist/templates/common/bundled-skills/mini-trellis-session-insight/SKILL.md +37 -0
  81. package/dist/templates/common/bundled-skills/mini-trellis-session-insight/references/cli-quick-reference.md +36 -0
  82. package/dist/templates/common/bundled-skills/mini-trellis-session-insight/references/triggering-patterns.md +93 -0
  83. package/dist/templates/common/commands/remember.md +22 -0
  84. package/dist/templates/common/index.d.ts +48 -0
  85. package/dist/templates/common/index.d.ts.map +1 -0
  86. package/dist/templates/common/index.js +104 -0
  87. package/dist/templates/common/index.js.map +1 -0
  88. package/dist/templates/common/skills/update-spec.md +16 -0
  89. package/dist/templates/extract.d.ts +40 -0
  90. package/dist/templates/extract.d.ts.map +1 -0
  91. package/dist/templates/extract.js +106 -0
  92. package/dist/templates/extract.js.map +1 -0
  93. package/dist/templates/markdown/agents.md +15 -0
  94. package/dist/templates/markdown/index.d.ts +10 -0
  95. package/dist/templates/markdown/index.d.ts.map +1 -0
  96. package/dist/templates/markdown/index.js +18 -0
  97. package/dist/templates/markdown/index.js.map +1 -0
  98. package/dist/templates/markdown/research-readme.md +9 -0
  99. package/dist/templates/markdown/spec/guides/index.md.txt +5 -0
  100. package/dist/templates/markdown/spec/guides/mini-memory.md.txt +30 -0
  101. package/dist/templates/markdown/workspace-index.md +23 -0
  102. package/dist/templates/opencode/lib/context-visibility.js +148 -0
  103. package/dist/templates/opencode/lib/session-utils.js +394 -0
  104. package/dist/templates/opencode/lib/trellis-context.js +627 -0
  105. package/dist/templates/opencode/package.json +5 -0
  106. package/dist/templates/opencode/plugins/session-start.js +65 -0
  107. package/dist/templates/pi/extensions/mini-trellis/index.ts.txt +170 -0
  108. package/dist/templates/pi/index.d.ts +4 -0
  109. package/dist/templates/pi/index.d.ts.map +1 -0
  110. package/dist/templates/pi/index.js +9 -0
  111. package/dist/templates/pi/index.js.map +1 -0
  112. package/dist/templates/pi/settings.json +9 -0
  113. package/dist/templates/shared-hooks/index.d.ts +13 -0
  114. package/dist/templates/shared-hooks/index.d.ts.map +1 -0
  115. package/dist/templates/shared-hooks/index.js +26 -0
  116. package/dist/templates/shared-hooks/index.js.map +1 -0
  117. package/dist/templates/shared-hooks/session-start.py +676 -0
  118. package/dist/templates/template-utils.d.ts +26 -0
  119. package/dist/templates/template-utils.d.ts.map +1 -0
  120. package/dist/templates/template-utils.js +64 -0
  121. package/dist/templates/template-utils.js.map +1 -0
  122. package/dist/templates/trellis/config.yaml +34 -0
  123. package/dist/templates/trellis/gitattributes.txt +9 -0
  124. package/dist/templates/trellis/gitignore.txt +32 -0
  125. package/dist/templates/trellis/index.d.ts +8 -0
  126. package/dist/templates/trellis/index.d.ts.map +1 -0
  127. package/dist/templates/trellis/index.js +16 -0
  128. package/dist/templates/trellis/index.js.map +1 -0
  129. package/dist/templates/trellis/scripts/__init__.py +5 -0
  130. package/dist/templates/trellis/scripts/add_session.py +1545 -0
  131. package/dist/templates/trellis/scripts/common/__init__.py +94 -0
  132. package/dist/templates/trellis/scripts/common/active_task.py +855 -0
  133. package/dist/templates/trellis/scripts/common/cli_adapter.py +950 -0
  134. package/dist/templates/trellis/scripts/common/config.py +482 -0
  135. package/dist/templates/trellis/scripts/common/developer.py +192 -0
  136. package/dist/templates/trellis/scripts/common/git.py +203 -0
  137. package/dist/templates/trellis/scripts/common/git_context.py +106 -0
  138. package/dist/templates/trellis/scripts/common/io.py +160 -0
  139. package/dist/templates/trellis/scripts/common/log.py +45 -0
  140. package/dist/templates/trellis/scripts/common/packages_context.py +238 -0
  141. package/dist/templates/trellis/scripts/common/paths.py +543 -0
  142. package/dist/templates/trellis/scripts/common/safe_commit.py +322 -0
  143. package/dist/templates/trellis/scripts/common/session_context.py +708 -0
  144. package/dist/templates/trellis/scripts/common/task_context.py +470 -0
  145. package/dist/templates/trellis/scripts/common/task_queue.py +188 -0
  146. package/dist/templates/trellis/scripts/common/task_store.py +1930 -0
  147. package/dist/templates/trellis/scripts/common/task_utils.py +498 -0
  148. package/dist/templates/trellis/scripts/common/tasks.py +122 -0
  149. package/dist/templates/trellis/scripts/common/trellis_config.py +239 -0
  150. package/dist/templates/trellis/scripts/common/types.py +110 -0
  151. package/dist/templates/trellis/scripts/common/workflow_phase.py +242 -0
  152. package/dist/templates/trellis/scripts/get_context.py +16 -0
  153. package/dist/templates/trellis/scripts/init_developer.py +51 -0
  154. package/dist/types/ai-tools.d.ts +30 -0
  155. package/dist/types/ai-tools.d.ts.map +1 -0
  156. package/dist/types/ai-tools.js +89 -0
  157. package/dist/types/ai-tools.js.map +1 -0
  158. package/dist/utils/atomic-write.d.ts +12 -0
  159. package/dist/utils/atomic-write.d.ts.map +1 -0
  160. package/dist/utils/atomic-write.js +30 -0
  161. package/dist/utils/atomic-write.js.map +1 -0
  162. package/dist/utils/cwd-guard.d.ts +38 -0
  163. package/dist/utils/cwd-guard.d.ts.map +1 -0
  164. package/dist/utils/cwd-guard.js +62 -0
  165. package/dist/utils/cwd-guard.js.map +1 -0
  166. package/dist/utils/file-writer.d.ts +36 -0
  167. package/dist/utils/file-writer.d.ts.map +1 -0
  168. package/dist/utils/file-writer.js +204 -0
  169. package/dist/utils/file-writer.js.map +1 -0
  170. package/dist/utils/managed-paths.d.ts +5 -0
  171. package/dist/utils/managed-paths.d.ts.map +1 -0
  172. package/dist/utils/managed-paths.js +51 -0
  173. package/dist/utils/managed-paths.js.map +1 -0
  174. package/dist/utils/managed-removal.d.ts +42 -0
  175. package/dist/utils/managed-removal.d.ts.map +1 -0
  176. package/dist/utils/managed-removal.js +223 -0
  177. package/dist/utils/managed-removal.js.map +1 -0
  178. package/dist/utils/posix.d.ts +13 -0
  179. package/dist/utils/posix.d.ts.map +1 -0
  180. package/dist/utils/posix.js +15 -0
  181. package/dist/utils/posix.js.map +1 -0
  182. package/dist/utils/uninstall-scrubbers.d.ts +66 -0
  183. package/dist/utils/uninstall-scrubbers.d.ts.map +1 -0
  184. package/dist/utils/uninstall-scrubbers.js +417 -0
  185. package/dist/utils/uninstall-scrubbers.js.map +1 -0
  186. package/package.json +80 -0
@@ -0,0 +1,106 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { ensureDir, writeFile } from "../utils/file-writer.js";
5
+ import { replacePythonCommandLiterals } from "../configurators/shared.js";
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+ /**
9
+ * Get the path to the trellis templates directory (.trellis/ scaffolding).
10
+ */
11
+ export function getTrellisTemplatePath() {
12
+ const templatePath = path.join(__dirname, "trellis");
13
+ if (fs.existsSync(templatePath)) {
14
+ return templatePath;
15
+ }
16
+ throw new Error("Could not find trellis templates directory. Expected at templates/trellis/");
17
+ }
18
+ /** @deprecated Use getTrellisTemplatePath() instead. */
19
+ export function getTrellisSourcePath() {
20
+ return getTrellisTemplatePath();
21
+ }
22
+ /**
23
+ * Get the path to the claude templates directory (hooks, agents, settings).
24
+ */
25
+ export function getClaudeTemplatePath() {
26
+ const templatePath = path.join(__dirname, "claude");
27
+ if (fs.existsSync(templatePath)) {
28
+ return templatePath;
29
+ }
30
+ throw new Error("Could not find claude templates directory. Expected at templates/claude/");
31
+ }
32
+ /**
33
+ * Get the path to the opencode templates directory (agents, plugins, lib).
34
+ */
35
+ export function getOpenCodeTemplatePath() {
36
+ const templatePath = path.join(__dirname, "opencode");
37
+ if (fs.existsSync(templatePath)) {
38
+ return templatePath;
39
+ }
40
+ throw new Error("Could not find opencode templates directory. Expected at templates/opencode/");
41
+ }
42
+ /**
43
+ * Get the path to the Pi Agent templates directory (agents, extension, settings).
44
+ */
45
+ export function getPiTemplatePath() {
46
+ const templatePath = path.join(__dirname, "pi");
47
+ if (fs.existsSync(templatePath)) {
48
+ return templatePath;
49
+ }
50
+ throw new Error("Could not find pi templates directory. Expected at templates/pi/");
51
+ }
52
+ /** @deprecated Use getPiTemplatePath() instead. */
53
+ export function getPiSourcePath() {
54
+ return getPiTemplatePath();
55
+ }
56
+ /**
57
+ * Read a file from the trellis template directory.
58
+ */
59
+ export function readTrellisFile(relativePath) {
60
+ const trellisPath = getTrellisSourcePath();
61
+ const filePath = path.join(trellisPath, relativePath);
62
+ return fs.readFileSync(filePath, "utf-8");
63
+ }
64
+ /**
65
+ * Read template content from a category directory.
66
+ */
67
+ export function readTemplate(category, filename) {
68
+ const templatePath = path.join(__dirname, category, filename);
69
+ return fs.readFileSync(templatePath, "utf-8");
70
+ }
71
+ export function readScript(relativePath) {
72
+ return readTrellisFile(`scripts/${relativePath}`);
73
+ }
74
+ export function readMarkdown(relativePath) {
75
+ return readTrellisFile(relativePath);
76
+ }
77
+ export function readCommand(filename) {
78
+ return readTemplate("commands", filename);
79
+ }
80
+ /**
81
+ * Copy a directory from trellis templates to target, making scripts executable.
82
+ */
83
+ export async function copyTrellisDir(srcRelativePath, destPath, options) {
84
+ const trellisPath = getTrellisSourcePath();
85
+ const srcPath = path.join(trellisPath, srcRelativePath);
86
+ await copyDirRecursive(srcPath, destPath, options);
87
+ }
88
+ async function copyDirRecursive(src, dest, options) {
89
+ ensureDir(dest);
90
+ for (const entry of fs.readdirSync(src)) {
91
+ const srcPath = path.join(src, entry);
92
+ const destPath = path.join(dest, entry);
93
+ const stat = fs.statSync(srcPath);
94
+ if (stat.isDirectory()) {
95
+ await copyDirRecursive(srcPath, destPath, options);
96
+ }
97
+ else {
98
+ const content = fs.readFileSync(srcPath, "utf-8");
99
+ const isExecutable = options?.executable && (entry.endsWith(".sh") || entry.endsWith(".py"));
100
+ await writeFile(destPath, replacePythonCommandLiterals(content), {
101
+ executable: isExecutable,
102
+ });
103
+ }
104
+ }
105
+ }
106
+ //# sourceMappingURL=extract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/templates/extract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAE1E,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AAC,CAAC;AACrD,CAAC;AAED,KAAK,UAAU,gBAAgB,CAC7B,GAAW,EACX,IAAY,EACZ,OAAkC;IAElC,SAAS,CAAC,IAAI,CAAC,CAAC;IAEhB,KAAK,MAAM,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;QACxC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACxC,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAElC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACvB,MAAM,gBAAgB,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QACrD,CAAC;aAAM,CAAC;YACN,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAClD,MAAM,YAAY,GAChB,OAAO,EAAE,UAAU,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1E,MAAM,SAAS,CAAC,QAAQ,EAAE,4BAA4B,CAAC,OAAO,CAAC,EAAE;gBAC/D,UAAU,EAAE,YAAY;aACzB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,15 @@
1
+ <!-- TRELLIS:START -->
2
+ # mini-trellis
3
+
4
+ This project uses mini-trellis as a memory layer. Working knowledge lives under `.trellis/`:
5
+
6
+ - `.trellis/spec/` — durable contracts (short markdown; read `index.md` first)
7
+ - `.trellis/research/` — topic inbox (`<topic>.md`; `README.md` is not a topic)
8
+ - `.trellis/workspace/` — per-developer journals
9
+
10
+ Record a session with `/mini-trellis:remember` (Claude/OpenCode), `/mini-trellis-remember` (Pi), or `$mini-trellis-remember` (Codex). Search past dialogue with `mini-trellis mem`. Promote lasting boundaries into spec with `mini-trellis-update-spec`.
11
+
12
+ mini-trellis does not create or drive tasks.
13
+
14
+ Managed by mini-trellis. Edits outside this block are preserved.
15
+ <!-- TRELLIS:END -->
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Markdown templates for the mini-trellis memory skeleton.
3
+ */
4
+ export declare const agentsMdContent: string;
5
+ export declare const workspaceIndexContent: string;
6
+ export declare const agentProgressIndexContent: string;
7
+ export declare const researchReadmeContent: string;
8
+ export declare const guidesIndexContent: string;
9
+ export declare const miniMemoryGuideContent: string;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/markdown/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH,eAAO,MAAM,eAAe,EAAE,MAAuC,CAAC;AAEtE,eAAO,MAAM,qBAAqB,EAAE,MACK,CAAC;AAE1C,eAAO,MAAM,yBAAyB,QAAwB,CAAC;AAE/D,eAAO,MAAM,qBAAqB,EAAE,MACK,CAAC;AAE1C,eAAO,MAAM,kBAAkB,EAAE,MAEhC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,MAEpC,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Markdown templates for the mini-trellis memory skeleton.
3
+ */
4
+ import { readFileSync } from "node:fs";
5
+ import { dirname, join } from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+ function readLocalTemplate(filename) {
10
+ return readFileSync(join(__dirname, filename), "utf-8");
11
+ }
12
+ export const agentsMdContent = readLocalTemplate("agents.md");
13
+ export const workspaceIndexContent = readLocalTemplate("workspace-index.md");
14
+ export const agentProgressIndexContent = workspaceIndexContent;
15
+ export const researchReadmeContent = readLocalTemplate("research-readme.md");
16
+ export const guidesIndexContent = readLocalTemplate("spec/guides/index.md.txt");
17
+ export const miniMemoryGuideContent = readLocalTemplate("spec/guides/mini-memory.md.txt");
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/markdown/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,SAAS,iBAAiB,CAAC,QAAgB;IACzC,OAAO,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAW,iBAAiB,CAAC,WAAW,CAAC,CAAC;AAEtE,MAAM,CAAC,MAAM,qBAAqB,GAChC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;AAE1C,MAAM,CAAC,MAAM,yBAAyB,GAAG,qBAAqB,CAAC;AAE/D,MAAM,CAAC,MAAM,qBAAqB,GAChC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;AAE1C,MAAM,CAAC,MAAM,kBAAkB,GAAW,iBAAiB,CACzD,0BAA0B,CAC3B,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAW,iBAAiB,CAC7D,gCAAgC,CACjC,CAAC"}
@@ -0,0 +1,9 @@
1
+ # Research
2
+
3
+ Topic-level research notes.
4
+
5
+ - Write `.trellis/research/<topic>.md` while investigating.
6
+ - Promote durable contracts into `.trellis/spec/` (short markdown).
7
+ - Move finished or stale topics to `.trellis/research/archive/` with `git mv`. SessionStart does not list `archive/`.
8
+
9
+ `README.md` is not a topic.
@@ -0,0 +1,5 @@
1
+ # Guides
2
+
3
+ | Guide | Purpose | When to Use |
4
+ |-------|---------|-------------|
5
+ | [Mini-Trellis Memory Layer](./mini-memory.md) | Journal, research inbox, spec indexes, and SessionStart | Session start, compact, remember, or promoting research into spec |
@@ -0,0 +1,30 @@
1
+ # Mini-Trellis Memory Layer
2
+
3
+ > SessionStart orients from journal, spec indexes, and research. It does not create or drive tasks.
4
+
5
+ ## Layers
6
+
7
+ | Layer | Path | Role |
8
+ |-------|------|------|
9
+ | Journal | `.trellis/workspace/<dev>/journal-*.md` | Git-durable session notes |
10
+ | Research | `.trellis/research/<topic>.md` | Topic inbox. `README.md` is not a topic |
11
+ | Spec | `.trellis/spec/**/index.md`, then linked files | Durable contracts. Short markdown |
12
+ | Dialogue | `mini-trellis mem list\|search\|context\|extract` | Cross-session chat |
13
+
14
+ ## SessionStart contract
15
+
16
+ - Inject the active journal path, spec **index** paths, and research topic files.
17
+ - Do **not** list individual spec articles — only `index.md`.
18
+ - Do **not** inject `.trellis/research/archive/`.
19
+ - Compact source: remind the user to run remember (`/mini-trellis:remember`, `/mini-trellis-remember` on Pi, `$mini-trellis-remember` on Codex) if durable notes from the compacted window are missing.
20
+
21
+ ## Remember
22
+
23
+ ```bash
24
+ python3 ./.trellis/scripts/add_session.py \
25
+ --title "Short title" \
26
+ --commit - \
27
+ --summary "What happened, what was decided, what to reuse"
28
+ ```
29
+
30
+ If the session produced reusable research, write `.trellis/research/<topic>.md`. Promote a note into `.trellis/spec/` only if the boundary still holds, then link it from the matching `index.md`. Cold research: `git mv` into `.trellis/research/archive/`.
@@ -0,0 +1,23 @@
1
+ # Workspace Index
2
+
3
+ Per-developer journals live under `.trellis/workspace/<name>/`.
4
+
5
+ ## Active Developers
6
+
7
+ | Developer | Last Active | Sessions | Active File |
8
+ |-----------|-------------|----------|-------------|
9
+ | (none yet) | - | - | - |
10
+
11
+ ## Getting Started
12
+
13
+ ```bash
14
+ python3 ./.trellis/scripts/init_developer.py <your-name>
15
+ ```
16
+
17
+ Record a session:
18
+
19
+ ```bash
20
+ python3 ./.trellis/scripts/add_session.py --title "Short title" --commit - --summary "..."
21
+ ```
22
+
23
+ Journals rotate at 2000 lines (`journal-N.md`).
@@ -0,0 +1,148 @@
1
+ import { createHash } from "node:crypto"
2
+
3
+ const PART_ID_PATTERN = /^prt_([0-9a-f]{12})[0-9A-Za-z]{14}$/
4
+ const CONTEXT_PART_KINDS = {
5
+ sessionStart: { offset: 2n, slot: "0" },
6
+ workflowState: { offset: 1n, slot: "1" },
7
+ }
8
+ const MAX_CONTEXT_PART_OFFSET = Object.values(CONTEXT_PART_KINDS).reduce(
9
+ (maximum, definition) => definition.offset > maximum ? definition.offset : maximum,
10
+ 0n,
11
+ )
12
+
13
+ /**
14
+ * Return the first ordinary user-authored text part.
15
+ *
16
+ * Trellis plugins can run in either order, so callers must not mistake a
17
+ * synthetic context part inserted by another plugin for the user's prompt.
18
+ */
19
+ export function findUserTextPart(parts) {
20
+ if (!Array.isArray(parts)) return undefined
21
+ return parts.find(
22
+ part => part?.type === "text" && part.synthetic !== true && part.text !== undefined,
23
+ )
24
+ }
25
+
26
+ function findIdentitySourcePart(parts) {
27
+ return parts
28
+ .filter(
29
+ part =>
30
+ part?.synthetic !== true &&
31
+ typeof part?.id === "string" &&
32
+ typeof part?.sessionID === "string" &&
33
+ typeof part?.messageID === "string" &&
34
+ PART_ID_PATTERN.test(part.id),
35
+ )
36
+ .sort((left, right) => (left.id < right.id ? -1 : left.id > right.id ? 1 : 0))[0]
37
+ }
38
+
39
+ function contextPartId(source, kind) {
40
+ const definition = CONTEXT_PART_KINDS[kind]
41
+ if (!definition) throw new TypeError(`unknown context part kind: ${kind}`)
42
+
43
+ const match = PART_ID_PATTERN.exec(source.id)
44
+ if (!match) throw new TypeError(`unsupported OpenCode part ID: ${source.id}`)
45
+ const sourceOrdinal = BigInt(`0x${match[1]}`)
46
+ if (sourceOrdinal <= MAX_CONTEXT_PART_OFFSET) {
47
+ throw new TypeError(`unsupported OpenCode part ID ordinal: ${source.id}`)
48
+ }
49
+ const ordinal = sourceOrdinal - definition.offset
50
+ const suffix = createHash("sha256")
51
+ .update(`${source.messageID}\0${kind}`)
52
+ .digest("hex")
53
+ .slice(0, 13)
54
+ return `prt_${ordinal.toString(16).padStart(12, "0")}${definition.slot}${suffix}`
55
+ }
56
+
57
+ /**
58
+ * Persist machine-authored context ahead of the ordinary user parts without
59
+ * mutating any existing part. The generated identity sorts before the source
60
+ * user part in the same order during both the first request and stored replay.
61
+ */
62
+ export function insertSyntheticTextPart(parts, text, kind) {
63
+ if (!Array.isArray(parts)) throw new TypeError("parts must be an array")
64
+ if (typeof text !== "string") throw new TypeError("text must be a string")
65
+ if (!CONTEXT_PART_KINDS[kind]) throw new TypeError(`unknown context part kind: ${kind}`)
66
+
67
+ const source = findIdentitySourcePart(parts)
68
+ if (!source) throw new TypeError("no ordinary OpenCode part with a persisted identity")
69
+
70
+ const id = contextPartId(source, kind)
71
+ if (parts.some(part => part?.id === id)) {
72
+ throw new TypeError(`duplicate synthetic context part: ${kind}`)
73
+ }
74
+ const part = {
75
+ id,
76
+ sessionID: source.sessionID,
77
+ messageID: source.messageID,
78
+ type: "text",
79
+ text,
80
+ synthetic: true,
81
+ }
82
+ const insertionIndex = parts.findIndex(existing => typeof existing?.id !== "string" || id < existing.id)
83
+ if (insertionIndex === -1) parts.push(part)
84
+ else parts.splice(insertionIndex, 0, part)
85
+ return part
86
+ }
87
+
88
+ /** OpenCode hook that mutates the in-memory model payload, not stored history. */
89
+ export const MESSAGES_TRANSFORM_HOOK = "experimental.chat.messages.transform"
90
+
91
+ /**
92
+ * Index of the last user message in an OpenCode `{info, parts}[]` transcript.
93
+ * Compaction and prompt both pass that shape to messages.transform.
94
+ */
95
+ export function findLatestUserMessageIndex(messages) {
96
+ if (!Array.isArray(messages)) return -1
97
+ for (let i = messages.length - 1; i >= 0; i--) {
98
+ if (messages[i]?.info?.role === "user") return i
99
+ }
100
+ return -1
101
+ }
102
+
103
+ export function platformInputFromMessages(messages) {
104
+ const index = findLatestUserMessageIndex(messages)
105
+ if (index < 0) return null
106
+ const info = messages[index].info
107
+ if (!info || typeof info !== "object") return null
108
+ return {
109
+ sessionID: info.sessionID,
110
+ agent: info.agent,
111
+ }
112
+ }
113
+
114
+ export function latestUserPromptText(messages) {
115
+ const index = findLatestUserMessageIndex(messages)
116
+ if (index < 0) return ""
117
+ const part = findUserTextPart(messages[index].parts)
118
+ return typeof part?.text === "string" ? part.text : ""
119
+ }
120
+
121
+ export function transcriptHasAssistantMessage(messages) {
122
+ if (!Array.isArray(messages)) return false
123
+ return messages.some(message => message?.info?.role === "assistant")
124
+ }
125
+
126
+ /**
127
+ * Clone the latest user message and prepend an ephemeral synthetic text
128
+ * part. The original message object and its `parts` array are left
129
+ * untouched so a transform cannot leak into OpenCode's stored history.
130
+ */
131
+ export function prependEphemeralText(messages, text) {
132
+ if (!Array.isArray(messages)) return false
133
+ if (typeof text !== "string") return false
134
+ const index = findLatestUserMessageIndex(messages)
135
+ if (index < 0) return false
136
+ const original = messages[index]
137
+ const parts = Array.isArray(original.parts) ? original.parts.slice() : []
138
+ parts.unshift({
139
+ type: "text",
140
+ text,
141
+ synthetic: true,
142
+ })
143
+ messages[index] = {
144
+ ...original,
145
+ parts,
146
+ }
147
+ return true
148
+ }