deepspider 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 (261) hide show
  1. package/.claude/agents/check.md +122 -0
  2. package/.claude/agents/debug.md +106 -0
  3. package/.claude/agents/dispatch.md +214 -0
  4. package/.claude/agents/implement.md +96 -0
  5. package/.claude/agents/plan.md +396 -0
  6. package/.claude/agents/research.md +120 -0
  7. package/.claude/commands/evolve/merge.md +80 -0
  8. package/.claude/commands/trellis/before-backend-dev.md +13 -0
  9. package/.claude/commands/trellis/before-frontend-dev.md +13 -0
  10. package/.claude/commands/trellis/break-loop.md +107 -0
  11. package/.claude/commands/trellis/check-backend.md +13 -0
  12. package/.claude/commands/trellis/check-cross-layer.md +153 -0
  13. package/.claude/commands/trellis/check-frontend.md +13 -0
  14. package/.claude/commands/trellis/create-command.md +154 -0
  15. package/.claude/commands/trellis/finish-work.md +129 -0
  16. package/.claude/commands/trellis/integrate-skill.md +219 -0
  17. package/.claude/commands/trellis/onboard.md +358 -0
  18. package/.claude/commands/trellis/parallel.md +193 -0
  19. package/.claude/commands/trellis/record-session.md +62 -0
  20. package/.claude/commands/trellis/start.md +280 -0
  21. package/.claude/commands/trellis/update-spec.md +213 -0
  22. package/.claude/hooks/inject-subagent-context.py +758 -0
  23. package/.claude/hooks/ralph-loop.py +374 -0
  24. package/.claude/hooks/session-start.py +126 -0
  25. package/.claude/settings.json +41 -0
  26. package/.claude/skills/deepagents-guide/SKILL.md +428 -0
  27. package/.cursor/commands/trellis-before-backend-dev.md +13 -0
  28. package/.cursor/commands/trellis-before-frontend-dev.md +13 -0
  29. package/.cursor/commands/trellis-break-loop.md +107 -0
  30. package/.cursor/commands/trellis-check-backend.md +13 -0
  31. package/.cursor/commands/trellis-check-cross-layer.md +153 -0
  32. package/.cursor/commands/trellis-check-frontend.md +13 -0
  33. package/.cursor/commands/trellis-create-command.md +154 -0
  34. package/.cursor/commands/trellis-finish-work.md +129 -0
  35. package/.cursor/commands/trellis-integrate-skill.md +219 -0
  36. package/.cursor/commands/trellis-onboard.md +358 -0
  37. package/.cursor/commands/trellis-record-session.md +62 -0
  38. package/.cursor/commands/trellis-start.md +156 -0
  39. package/.cursor/commands/trellis-update-spec.md +213 -0
  40. package/.env.example +11 -0
  41. package/.husky/pre-commit +1 -0
  42. package/.mcp.json +8 -0
  43. package/.trellis/.template-hashes.json +65 -0
  44. package/.trellis/.version +1 -0
  45. package/.trellis/scripts/add-session.sh +384 -0
  46. package/.trellis/scripts/common/developer.sh +129 -0
  47. package/.trellis/scripts/common/git-context.sh +263 -0
  48. package/.trellis/scripts/common/paths.sh +208 -0
  49. package/.trellis/scripts/common/phase.sh +150 -0
  50. package/.trellis/scripts/common/registry.sh +247 -0
  51. package/.trellis/scripts/common/task-queue.sh +142 -0
  52. package/.trellis/scripts/common/task-utils.sh +151 -0
  53. package/.trellis/scripts/common/worktree.sh +128 -0
  54. package/.trellis/scripts/create-bootstrap.sh +299 -0
  55. package/.trellis/scripts/get-context.sh +7 -0
  56. package/.trellis/scripts/get-developer.sh +15 -0
  57. package/.trellis/scripts/init-developer.sh +34 -0
  58. package/.trellis/scripts/multi-agent/cleanup.sh +396 -0
  59. package/.trellis/scripts/multi-agent/create-pr.sh +241 -0
  60. package/.trellis/scripts/multi-agent/plan.sh +207 -0
  61. package/.trellis/scripts/multi-agent/start.sh +310 -0
  62. package/.trellis/scripts/multi-agent/status.sh +828 -0
  63. package/.trellis/scripts/task.sh +1118 -0
  64. package/.trellis/spec/backend/deepagents-guide.md +337 -0
  65. package/.trellis/spec/backend/directory-structure.md +126 -0
  66. package/.trellis/spec/backend/examples/skills/deepagents-guide/README.md +11 -0
  67. package/.trellis/spec/backend/examples/skills/deepagents-guide/agent.js.template +20 -0
  68. package/.trellis/spec/backend/examples/skills/deepagents-guide/skills-config.js.template +13 -0
  69. package/.trellis/spec/backend/examples/skills/deepagents-guide/subagent.js.template +19 -0
  70. package/.trellis/spec/backend/hook-guidelines.md +178 -0
  71. package/.trellis/spec/backend/index.md +36 -0
  72. package/.trellis/spec/backend/quality-guidelines.md +201 -0
  73. package/.trellis/spec/backend/state-management.md +76 -0
  74. package/.trellis/spec/backend/tool-guidelines.md +144 -0
  75. package/.trellis/spec/backend/type-safety.md +71 -0
  76. package/.trellis/spec/guides/code-reuse-thinking-guide.md +92 -0
  77. package/.trellis/spec/guides/cross-layer-thinking-guide.md +94 -0
  78. package/.trellis/spec/guides/index.md +79 -0
  79. package/.trellis/tasks/archive/02-02-evolving-skills/prd.md +61 -0
  80. package/.trellis/tasks/archive/02-02-evolving-skills/task.json +29 -0
  81. package/.trellis/tasks/archive/2026-02/00-bootstrap-guidelines/prd.md +86 -0
  82. package/.trellis/tasks/archive/2026-02/00-bootstrap-guidelines/task.json +27 -0
  83. package/.trellis/tasks/archive/2026-02/02-02-skills-system/check.jsonl +3 -0
  84. package/.trellis/tasks/archive/2026-02/02-02-skills-system/debug.jsonl +2 -0
  85. package/.trellis/tasks/archive/2026-02/02-02-skills-system/implement.jsonl +5 -0
  86. package/.trellis/tasks/archive/2026-02/02-02-skills-system/prd.md +33 -0
  87. package/.trellis/tasks/archive/2026-02/02-02-skills-system/task.json +41 -0
  88. package/.trellis/workflow.md +407 -0
  89. package/.trellis/workspace/index.md +123 -0
  90. package/.trellis/workspace/pony/index.md +40 -0
  91. package/.trellis/workspace/pony/journal-1.md +7 -0
  92. package/.trellis/worktree.yaml +47 -0
  93. package/AGENTS.md +18 -0
  94. package/CLAUDE.md +292 -0
  95. package/README.md +134 -0
  96. package/agents/deepspider.md +142 -0
  97. package/docs/DEBUG.md +42 -0
  98. package/docs/GUIDE.md +334 -0
  99. package/docs/PROMPT.md +60 -0
  100. package/docs/USAGE.md +226 -0
  101. package/eslint.config.js +51 -0
  102. package/package.json +78 -0
  103. package/requirements-crypto.txt +14 -0
  104. package/src/agent/index.js +97 -0
  105. package/src/agent/logger.js +164 -0
  106. package/src/agent/middleware/filterTools.js +64 -0
  107. package/src/agent/middleware/report.js +79 -0
  108. package/src/agent/prompts/system.js +315 -0
  109. package/src/agent/run.js +575 -0
  110. package/src/agent/skills/anti-detect/SKILL.md +28 -0
  111. package/src/agent/skills/anti-detect/evolved.md +12 -0
  112. package/src/agent/skills/captcha/SKILL.md +37 -0
  113. package/src/agent/skills/captcha/evolved.md +12 -0
  114. package/src/agent/skills/config.js +30 -0
  115. package/src/agent/skills/crawler/SKILL.md +9 -0
  116. package/src/agent/skills/crawler/evolved.md +16 -0
  117. package/src/agent/skills/dynamic-analysis/SKILL.md +91 -0
  118. package/src/agent/skills/dynamic-analysis/evolved.md +12 -0
  119. package/src/agent/skills/env/SKILL.md +72 -0
  120. package/src/agent/skills/env/evolved.md +12 -0
  121. package/src/agent/skills/evolve.js +79 -0
  122. package/src/agent/skills/general/SKILL.md +12 -0
  123. package/src/agent/skills/general/evolved.md +12 -0
  124. package/src/agent/skills/js2python/SKILL.md +30 -0
  125. package/src/agent/skills/js2python/evolved.md +13 -0
  126. package/src/agent/skills/report/SKILL.md +21 -0
  127. package/src/agent/skills/report/evolved.md +12 -0
  128. package/src/agent/skills/sandbox/SKILL.md +22 -0
  129. package/src/agent/skills/sandbox/evolved.md +16 -0
  130. package/src/agent/skills/static-analysis/SKILL.md +93 -0
  131. package/src/agent/skills/static-analysis/evolved.md +12 -0
  132. package/src/agent/skills/xpath/SKILL.md +119 -0
  133. package/src/agent/subagents/anti-detect.js +45 -0
  134. package/src/agent/subagents/captcha.js +51 -0
  135. package/src/agent/subagents/crawler.js +138 -0
  136. package/src/agent/subagents/dynamic.js +64 -0
  137. package/src/agent/subagents/env-agent.js +82 -0
  138. package/src/agent/subagents/index.js +37 -0
  139. package/src/agent/subagents/js2python.js +72 -0
  140. package/src/agent/subagents/sandbox.js +55 -0
  141. package/src/agent/subagents/static.js +66 -0
  142. package/src/agent/tools/analysis.js +135 -0
  143. package/src/agent/tools/analyzer.js +85 -0
  144. package/src/agent/tools/anti-detect.js +89 -0
  145. package/src/agent/tools/antidebug.js +64 -0
  146. package/src/agent/tools/async.js +43 -0
  147. package/src/agent/tools/browser.js +324 -0
  148. package/src/agent/tools/captcha.js +223 -0
  149. package/src/agent/tools/capture.js +179 -0
  150. package/src/agent/tools/correlate.js +303 -0
  151. package/src/agent/tools/crawler.js +116 -0
  152. package/src/agent/tools/cryptohook.js +80 -0
  153. package/src/agent/tools/debug.js +246 -0
  154. package/src/agent/tools/deobfuscator.js +90 -0
  155. package/src/agent/tools/env.js +83 -0
  156. package/src/agent/tools/envdump.js +92 -0
  157. package/src/agent/tools/evolve.js +164 -0
  158. package/src/agent/tools/extract.js +114 -0
  159. package/src/agent/tools/extractor.js +54 -0
  160. package/src/agent/tools/file.js +224 -0
  161. package/src/agent/tools/hook.js +84 -0
  162. package/src/agent/tools/hookManager.js +178 -0
  163. package/src/agent/tools/index.js +137 -0
  164. package/src/agent/tools/nodejs.js +101 -0
  165. package/src/agent/tools/patch.js +46 -0
  166. package/src/agent/tools/preprocess.js +71 -0
  167. package/src/agent/tools/profile.js +122 -0
  168. package/src/agent/tools/python.js +627 -0
  169. package/src/agent/tools/report.js +124 -0
  170. package/src/agent/tools/runtime.js +132 -0
  171. package/src/agent/tools/sandbox.js +79 -0
  172. package/src/agent/tools/store.js +73 -0
  173. package/src/agent/tools/trace.js +74 -0
  174. package/src/agent/tools/tracing.js +201 -0
  175. package/src/agent/tools/utils.js +51 -0
  176. package/src/agent/tools/verify.js +184 -0
  177. package/src/agent/tools/webcrack.js +109 -0
  178. package/src/analyzer/ASTAnalyzer.js +387 -0
  179. package/src/analyzer/CallStackAnalyzer.js +379 -0
  180. package/src/analyzer/Deobfuscator.js +289 -0
  181. package/src/analyzer/EncryptionAnalyzer.js +99 -0
  182. package/src/analyzer/index.js +22 -0
  183. package/src/browser/EnvBridge.js +186 -0
  184. package/src/browser/cdp.js +168 -0
  185. package/src/browser/client.js +197 -0
  186. package/src/browser/collector.js +444 -0
  187. package/src/browser/collectors/RequestCryptoLinker.js +109 -0
  188. package/src/browser/collectors/ResponseSearcher.js +107 -0
  189. package/src/browser/collectors/ScriptCollector.js +158 -0
  190. package/src/browser/collectors/index.js +26 -0
  191. package/src/browser/defaultHooks.js +932 -0
  192. package/src/browser/hooks/crypto.js +55 -0
  193. package/src/browser/hooks/index.js +64 -0
  194. package/src/browser/hooks/native.js +9 -0
  195. package/src/browser/hooks/network.js +33 -0
  196. package/src/browser/index.js +42 -0
  197. package/src/browser/interceptors/NetworkInterceptor.js +116 -0
  198. package/src/browser/interceptors/ScriptInterceptor.js +76 -0
  199. package/src/browser/interceptors/index.js +6 -0
  200. package/src/browser/ui/analysisPanel.js +1782 -0
  201. package/src/browser/ui/confirmDialog.js +158 -0
  202. package/src/browser/ui/panel.html +152 -0
  203. package/src/browser/ui/selector.js +170 -0
  204. package/src/config/index.js +5 -0
  205. package/src/config/paths.js +71 -0
  206. package/src/config/patterns/crypto.js +36 -0
  207. package/src/config/profiles/chrome.json +71 -0
  208. package/src/config/profiles/firefox.json +44 -0
  209. package/src/config/profiles/safari.json +38 -0
  210. package/src/core/EnvMonitor.js +200 -0
  211. package/src/core/PatchGenerator.js +278 -0
  212. package/src/core/Sandbox.js +181 -0
  213. package/src/env/AntiAntiDebug.js +111 -0
  214. package/src/env/AsyncHook.js +68 -0
  215. package/src/env/BrowserAPIList.js +265 -0
  216. package/src/env/CookieHook.js +48 -0
  217. package/src/env/CryptoHook.js +205 -0
  218. package/src/env/EnvCodeGenerator.js +157 -0
  219. package/src/env/EnvDumper.js +356 -0
  220. package/src/env/EnvExtractor.js +220 -0
  221. package/src/env/HookBase.js +618 -0
  222. package/src/env/NetworkHook.js +159 -0
  223. package/src/env/modules/bom/history.js +29 -0
  224. package/src/env/modules/bom/location.js +26 -0
  225. package/src/env/modules/bom/navigator.js +70 -0
  226. package/src/env/modules/bom/screen.js +26 -0
  227. package/src/env/modules/bom/storage.js +23 -0
  228. package/src/env/modules/dom/document.js +110 -0
  229. package/src/env/modules/dom/event.js +51 -0
  230. package/src/env/modules/index.js +34 -0
  231. package/src/env/modules/webapi/fetch.js +46 -0
  232. package/src/env/modules/webapi/url.js +47 -0
  233. package/src/env/modules/webapi/xhr.js +48 -0
  234. package/src/index.js +27 -0
  235. package/src/mcp/server.js +89 -0
  236. package/src/store/DataStore.js +708 -0
  237. package/src/store/Store.js +158 -0
  238. package/src/store/Validator.js +24 -0
  239. package/test/analyze.test.js +90 -0
  240. package/test/envdump.test.js +74 -0
  241. package/test/flow.test.js +90 -0
  242. package/test/hooks.test.js +138 -0
  243. package/test/plugin.test.js +35 -0
  244. package/test/refactor-full.test.js +30 -0
  245. package/test/refactor.test.js +21 -0
  246. package/test/samples/obfuscated.js +61 -0
  247. package/test/samples/original.js +66 -0
  248. package/test/samples/v10_eval_chain.js +52 -0
  249. package/test/samples/v11_bytecode_vm.js +81 -0
  250. package/test/samples/v12_polymorphic.js +69 -0
  251. package/test/samples/v1_ob_basic.js +98 -0
  252. package/test/samples/v2_ob_advanced.js +99 -0
  253. package/test/samples/v3_jjencode.js +77 -0
  254. package/test/samples/v4_aaencode.js +73 -0
  255. package/test/samples/v5_control_flow.js +86 -0
  256. package/test/samples/v6_string_encryption.js +71 -0
  257. package/test/samples/v7_jsvmp.js +83 -0
  258. package/test/samples/v8_anti_debug.js +79 -0
  259. package/test/samples/v9_proxy_trap.js +49 -0
  260. package/test/samples.test.js +96 -0
  261. package/test/webcrack.test.js +55 -0
@@ -0,0 +1,213 @@
1
+ # Update Spec - Capture Knowledge into Specifications
2
+
3
+ When you learn something valuable (from debugging, implementing, or discussion), use this command to update the relevant spec documents.
4
+
5
+ **Timing**: After completing a task, fixing a bug, or discovering a new pattern
6
+
7
+ ---
8
+
9
+ ## When to Update Specs
10
+
11
+ | Trigger | Example | Target Spec |
12
+ |---------|---------|-------------|
13
+ | **Fixed a bug** | Found a subtle issue with error handling | `backend/error-handling.md` |
14
+ | **Discovered a pattern** | Found a better way to structure code | Relevant guidelines file |
15
+ | **Hit a gotcha** | Learned that X must be done before Y | Relevant spec + "Common Mistakes" section |
16
+ | **Established a convention** | Team agreed on naming pattern | `quality-guidelines.md` |
17
+ | **Cross-layer insight** | Understood how data flows between layers | `guides/cross-layer-thinking-guide.md` |
18
+
19
+ ---
20
+
21
+ ## Spec Structure Overview
22
+
23
+ ```
24
+ .trellis/spec/
25
+ ├── backend/ # Backend development standards
26
+ │ ├── index.md # Overview and links
27
+ │ └── *.md # Topic-specific guidelines
28
+ ├── frontend/ # Frontend development standards
29
+ │ ├── index.md # Overview and links
30
+ │ └── *.md # Topic-specific guidelines
31
+ └── guides/ # Thinking guides
32
+ ├── index.md # Guide index
33
+ └── *.md # Topic-specific guides
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Update Process
39
+
40
+ ### Step 1: Identify What You Learned
41
+
42
+ Answer these questions:
43
+
44
+ 1. **What did you learn?** (Be specific)
45
+ 2. **Why is it important?** (What problem does it prevent?)
46
+ 3. **Where does it belong?** (Which spec file?)
47
+
48
+ ### Step 2: Classify the Update Type
49
+
50
+ | Type | Description | Action |
51
+ |------|-------------|--------|
52
+ | **New Pattern** | A reusable approach discovered | Add to "Patterns" section |
53
+ | **Forbidden Pattern** | Something that causes problems | Add to "Anti-patterns" or "Don't" section |
54
+ | **Common Mistake** | Easy-to-make error | Add to "Common Mistakes" section |
55
+ | **Convention** | Agreed-upon standard | Add to relevant section |
56
+ | **Gotcha** | Non-obvious behavior | Add warning callout |
57
+
58
+ ### Step 3: Read the Target Spec
59
+
60
+ Before editing, read the current spec to:
61
+ - Understand existing structure
62
+ - Avoid duplicating content
63
+ - Find the right section for your update
64
+
65
+ ```bash
66
+ cat .trellis/spec/<category>/<file>.md
67
+ ```
68
+
69
+ ### Step 4: Make the Update
70
+
71
+ Follow these principles:
72
+
73
+ 1. **Be Specific**: Include concrete examples, not just abstract rules
74
+ 2. **Explain Why**: State the problem this prevents
75
+ 3. **Show Code**: Add code snippets for patterns
76
+ 4. **Keep it Short**: One concept per section
77
+
78
+ ### Step 5: Update the Index (if needed)
79
+
80
+ If you added a new section or the spec status changed, update the category's `index.md`.
81
+
82
+ ---
83
+
84
+ ## Update Templates
85
+
86
+ ### Adding a New Pattern
87
+
88
+ ```markdown
89
+ ### Pattern Name
90
+
91
+ **Problem**: What problem does this solve?
92
+
93
+ **Solution**: Brief description of the approach.
94
+
95
+ **Example**:
96
+ \`\`\`
97
+ // Good
98
+ code example
99
+
100
+ // Bad
101
+ code example
102
+ \`\`\`
103
+
104
+ **Why**: Explanation of why this works better.
105
+ ```
106
+
107
+ ### Adding a Forbidden Pattern
108
+
109
+ ```markdown
110
+ ### Don't: Pattern Name
111
+
112
+ **Problem**:
113
+ \`\`\`
114
+ // Don't do this
115
+ bad code example
116
+ \`\`\`
117
+
118
+ **Why it's bad**: Explanation of the issue.
119
+
120
+ **Instead**:
121
+ \`\`\`
122
+ // Do this instead
123
+ good code example
124
+ \`\`\`
125
+ ```
126
+
127
+ ### Adding a Common Mistake
128
+
129
+ ```markdown
130
+ ### Common Mistake: Description
131
+
132
+ **Symptom**: What goes wrong
133
+
134
+ **Cause**: Why this happens
135
+
136
+ **Fix**: How to correct it
137
+
138
+ **Prevention**: How to avoid it in the future
139
+ ```
140
+
141
+ ### Adding a Gotcha
142
+
143
+ ```markdown
144
+ > **Warning**: Brief description of the non-obvious behavior.
145
+ >
146
+ > Details about when this happens and how to handle it.
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Interactive Mode
152
+
153
+ If you're unsure what to update, answer these prompts:
154
+
155
+ 1. **What did you just finish?**
156
+ - [ ] Fixed a bug
157
+ - [ ] Implemented a feature
158
+ - [ ] Refactored code
159
+ - [ ] Had a discussion about approach
160
+
161
+ 2. **What surprised you or was non-obvious?**
162
+ - (Describe the insight)
163
+
164
+ 3. **Would this help someone else avoid the same problem?**
165
+ - Yes → Proceed to update spec
166
+ - No → Maybe not worth documenting
167
+
168
+ 4. **Which area does it relate to?**
169
+ - [ ] Backend code
170
+ - [ ] Frontend code
171
+ - [ ] Cross-layer data flow
172
+ - [ ] Code organization/reuse
173
+ - [ ] Quality/testing
174
+
175
+ ---
176
+
177
+ ## Quality Checklist
178
+
179
+ Before finishing your spec update:
180
+
181
+ - [ ] Is the content specific and actionable?
182
+ - [ ] Did you include a code example?
183
+ - [ ] Did you explain WHY, not just WHAT?
184
+ - [ ] Is it in the right spec file?
185
+ - [ ] Does it duplicate existing content?
186
+ - [ ] Would a new team member understand it?
187
+
188
+ ---
189
+
190
+ ## Relationship to Other Commands
191
+
192
+ ```
193
+ Development Flow:
194
+ Learn something → /trellis-update-spec → Knowledge captured
195
+ ↑ ↓
196
+ /trellis-break-loop ←──────────────────── Future sessions benefit
197
+ (deep bug analysis)
198
+ ```
199
+
200
+ - `/trellis-break-loop` - Analyzes bugs deeply, often reveals spec updates needed
201
+ - `/trellis-update-spec` - Actually makes the updates (this command)
202
+ - `/trellis-finish-work` - Reminds you to check if specs need updates
203
+
204
+ ---
205
+
206
+ ## Core Philosophy
207
+
208
+ > **Specs are living documents. Every debugging session, every "aha moment" is an opportunity to make the spec better.**
209
+
210
+ The goal is **institutional memory**:
211
+ - What one person learns, everyone benefits from
212
+ - What AI learns in one session, persists to future sessions
213
+ - Mistakes become documented guardrails
package/.env.example ADDED
@@ -0,0 +1,11 @@
1
+ # DeepSpider 配置
2
+
3
+ # LLM API 配置(兼容 OpenAI 格式的任意供应商)
4
+ LLM_API_KEY=your_api_key_here
5
+ LLM_BASE_URL=https://api.openai.com/v1
6
+ LLM_MODEL=gpt-4o
7
+
8
+ # LangSmith 追踪配置(可选)
9
+ LANGSMITH_TRACING=true
10
+ LANGSMITH_API_KEY=your_langsmith_api_key_here
11
+ LANGSMITH_PROJECT=deepspider
@@ -0,0 +1 @@
1
+ npx lint-staged
package/.mcp.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "mcpServers": {
3
+ "deepspider": {
4
+ "command": "node",
5
+ "args": ["src/mcp/server.js"]
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,65 @@
1
+ {
2
+ ".trellis/scripts/add-session.sh": "5e8e4ebf9e85684c130e636b67c6def49bab4aa6e4e303d591173b1797e82c37",
3
+ ".trellis/scripts/common/developer.sh": "fac965c73fa93cb9656f1fdda71dc525ac53309fc702f306f68a4914fc0d5788",
4
+ ".trellis/scripts/common/git-context.sh": "c0fb34d6f71b6e22b2938a4143fa3053b4ecc5fbaa144281c4cd2fce2a9837f0",
5
+ ".trellis/scripts/common/paths.sh": "c2b38f795668071e40b4fb817f1f710d61db76b38d09e1f47d71573d4ee7475a",
6
+ ".trellis/scripts/common/phase.sh": "08ab369480d3a3c226de8ecf084dc34c297c27950ebcb2aa2bc8df1cec686288",
7
+ ".trellis/scripts/common/registry.sh": "2bf06ca0b100aa960e14590fb2c41c5aa1c40f156a406429757da038e92ead65",
8
+ ".trellis/scripts/common/task-queue.sh": "fbc168ee801a5986e8bd5ec6cfceb7384c2d93a9985f9c37f35c238b8d633ea9",
9
+ ".trellis/scripts/common/task-utils.sh": "8ad2ee44df470183f536319f88b446dc603e3fddcdd1b71396960d8dd52045ea",
10
+ ".trellis/scripts/common/worktree.sh": "7a420eecab9dfe361bea1b0a5cb9ce4b42b984fbffb570a75e2d9ac59f4b569d",
11
+ ".trellis/scripts/create-bootstrap.sh": "388905f88cf89035005eff84ae3828fdd4936707481ba702c08c6a206117b205",
12
+ ".trellis/scripts/get-context.sh": "e42bcf4b167b1d322b069d795110e4947cab4073e495be285ed7a9b8c1a3d728",
13
+ ".trellis/scripts/get-developer.sh": "82f62484fceef79954bb8aa77588789c476b7187bf0ff48d355d50108425dc67",
14
+ ".trellis/scripts/init-developer.sh": "34bbd2db4198196ec3297116ff0d8455b2af32ec6a297c978bdf8cb5abffa2f8",
15
+ ".trellis/scripts/multi-agent/cleanup.sh": "205993cc945ed2224ec45fa51e55f18624a6a7743fcfd44090308b1099bcb87b",
16
+ ".trellis/scripts/multi-agent/create-pr.sh": "0818c371031eed810e404997c10713ab685ca5eb4b5815f9a646ad1e5862e96c",
17
+ ".trellis/scripts/multi-agent/plan.sh": "a2349c913314561349b92e506962b9ef9c716f61ee310a18b2fc53cde3ddf04d",
18
+ ".trellis/scripts/multi-agent/start.sh": "feca8869f5eb305a9d1609672ce121e24cfd3ac8d000018857ca917f14dc98a0",
19
+ ".trellis/scripts/multi-agent/status.sh": "00a422b73d4dc8e05afdd3a310fd4c36266201550ad23383151be8efa808af7b",
20
+ ".trellis/scripts/task.sh": "806ec3b6ebb7d046016d907ccd6546c534653291b791d02b755d901f6d930bb2",
21
+ ".trellis/spec/guides/code-reuse-thinking-guide.md": "e768d4937198ccfacfb927a27e6ee731766a7dd2de0d770a3d7293ea6e3f19d5",
22
+ ".trellis/spec/guides/cross-layer-thinking-guide.md": "b89b09d8356f9985a838613d425e15e97bd4b5b9e8640cfe0c941d97fb152ef6",
23
+ ".trellis/spec/guides/index.md": "c41ea8dd33dc9ae01b376f2bf66c6b2f80e699d84a895ca87d55c7a44368d2d5",
24
+ ".trellis/workflow.md": "3eb1408d68456fc3dd799899997245d1c096e705db6164fe26479dbdff275114",
25
+ ".trellis/worktree.yaml": "c57de79e40d5f748f099625ed4a17d5f0afbf25cac598aced0b3c964e7b7c226",
26
+ ".claude/agents/check.md": "7c7400e7ea8bf3f3f879bfa028fd5b4d41673e0150d44c52292161ba33612812",
27
+ ".claude/agents/debug.md": "94be0b1cfbae4c64caee4775ef504f43acfcd4a80427a26d6f680ceaddcbee24",
28
+ ".claude/agents/dispatch.md": "1f26bf7dc26f739ea50ce7a662b1b8df65a18d6289584383ca6c3f1ba5559a72",
29
+ ".claude/agents/implement.md": "026b2193f4de057dbe1e5e0559b8a2c2ebb6c7bcdcd24e810287c35819a33db3",
30
+ ".claude/agents/plan.md": "077cc6f9d40563b9e4814308578c2596806e7a0dee1e7fbd9ddc5e98c2287b10",
31
+ ".claude/agents/research.md": "086ae23120151b3591089a4de20fd54e6ae2b89038f5903ee9a52269cd7ded6a",
32
+ ".claude/commands/trellis/before-backend-dev.md": "7e35444de2a5779ef39944f17f566ea21d2ed7f4994246f4cfe6ebf9a11dd3e3",
33
+ ".claude/commands/trellis/before-frontend-dev.md": "a6225f9d123dbd4a7aec822652030cae50be3f5b308297015e04d42b23a27b2a",
34
+ ".claude/commands/trellis/break-loop.md": "24d07ac0ac1873cb7adf5228c597e58a58125d80fc1e8d2eb5d6948c43761566",
35
+ ".claude/commands/trellis/check-backend.md": "4e81a28d681ea770f780df55a212fd504ce21ee49b44ba16023b74b5c243cef3",
36
+ ".claude/commands/trellis/check-cross-layer.md": "b9ab24515ead84330d6634f6ad912ca3547db3a36139d62c5688161824097d60",
37
+ ".claude/commands/trellis/check-frontend.md": "5e8e3b682032ba0dd6bb843dd4826fff0159f78a7084964ccb119c6cf98b3d91",
38
+ ".claude/commands/trellis/create-command.md": "c2825c7941b4ef4a3f3365c4c807ff138096a39aece3d051776f3c11a4e4857d",
39
+ ".claude/commands/trellis/finish-work.md": "6a29961bd1ee55b79bfb44bce637275e4646317a3ac4a6cc77ba28c19d18ff80",
40
+ ".claude/commands/trellis/integrate-skill.md": "d141fd8b045c6ef27b1716c0135143879736a6cb232c56b72b4e42fd4d7effb4",
41
+ ".claude/commands/trellis/onboard.md": "02d219d8cde3785f79270febf5d03039e8b8052dc95341f9a6b582fb5c433ee0",
42
+ ".claude/commands/trellis/parallel.md": "e97ebff92fbe8959ea522530cbef1840e637c62813cf57516edeceecd84eb25e",
43
+ ".claude/commands/trellis/record-session.md": "bbb8140082f51128ed5b20eaead97ff084c10eafd52b5763acc879cde77a9351",
44
+ ".claude/commands/trellis/start.md": "3b00f04b7ccf16df0ddb87b9f3ca179ebcf45e79fdd7fbf4add1f6896a522216",
45
+ ".claude/commands/trellis/update-spec.md": "c8e259d66fa7223c9ab99fede83de3e5c39fb16d956ca9a3ab1f749fb1956390",
46
+ ".claude/hooks/inject-subagent-context.py": "3cc16fd8c6c8eb232e33538080ee7c00ee3b613df454a87da86d1856e48f2c2c",
47
+ ".claude/hooks/ralph-loop.py": "fd2b8cb40cbaa6428e7d1a9a89189c9481e2279165ee5b7fa5d1dd1d42b02662",
48
+ ".claude/hooks/session-start.py": "67b5fc4ab01b74d0352e12af5f99eada48996a88fb188216cc741e94b619894a",
49
+ ".claude/settings.json": "f03439ad594adb545fdeeb7cf564726d35972d37c73e5c632f6c64a4d1fed7c9",
50
+ ".claude/settings.local.json": "f2a6ec4081ab0412a25b049a822fb9b94f6260d36fed87a5d64bdd680cf9a577",
51
+ ".claude/skills/deepagents-guide/SKILL.md": "6f4e0ac61f18cfba2338f06190094c7234641b092d447e384d503d2046871f6b",
52
+ ".cursor/commands/trellis-before-backend-dev.md": "7e35444de2a5779ef39944f17f566ea21d2ed7f4994246f4cfe6ebf9a11dd3e3",
53
+ ".cursor/commands/trellis-before-frontend-dev.md": "a6225f9d123dbd4a7aec822652030cae50be3f5b308297015e04d42b23a27b2a",
54
+ ".cursor/commands/trellis-break-loop.md": "24d07ac0ac1873cb7adf5228c597e58a58125d80fc1e8d2eb5d6948c43761566",
55
+ ".cursor/commands/trellis-check-backend.md": "4e81a28d681ea770f780df55a212fd504ce21ee49b44ba16023b74b5c243cef3",
56
+ ".cursor/commands/trellis-check-cross-layer.md": "a79fe38f29f84a4524a70987e9fecfca569430df476082bff9dde31596ca3951",
57
+ ".cursor/commands/trellis-check-frontend.md": "5e8e3b682032ba0dd6bb843dd4826fff0159f78a7084964ccb119c6cf98b3d91",
58
+ ".cursor/commands/trellis-create-command.md": "9a9283add72832e0e015de770531edf37cf3720e4a72782c1cea6e9941603490",
59
+ ".cursor/commands/trellis-finish-work.md": "a91678f24c494775486e1462c7aeea611fde386b6dbd6fecd0d75a5fbe965de6",
60
+ ".cursor/commands/trellis-integrate-skill.md": "b200ce1087679bcedf508aeeb085c82549ab1232d8f01d95ff276aa5d1a24548",
61
+ ".cursor/commands/trellis-onboard.md": "d0bf3049e8be3a3c374587525eb574eef8ac47efe22bfa7b5daead7b9f07a778",
62
+ ".cursor/commands/trellis-record-session.md": "bbb8140082f51128ed5b20eaead97ff084c10eafd52b5763acc879cde77a9351",
63
+ ".cursor/commands/trellis-start.md": "91653b5216c58617a98d8c332937fd99534083a10cd22d6a782f7fe4053f5a15",
64
+ ".cursor/commands/trellis-update-spec.md": "008df54aa9b43d94dbc5107452628cac6cf18fb93bf801f8944f4a89904d066a"
65
+ }
@@ -0,0 +1 @@
1
+ 0.2.11
@@ -0,0 +1,384 @@
1
+ #!/bin/bash
2
+ # Add a new session to journal file and update index.md
3
+ #
4
+ # Usage:
5
+ # ./.trellis/scripts/add-session.sh --title "Title" --commit "hash" --summary "Summary"
6
+ # echo "content" | ./.trellis/scripts/add-session.sh --title "Title" --commit "hash"
7
+
8
+ set -e
9
+
10
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11
+ source "$SCRIPT_DIR/common/paths.sh"
12
+ source "$SCRIPT_DIR/common/developer.sh"
13
+
14
+ MAX_LINES=2000
15
+ TODAY=$(date +%Y-%m-%d)
16
+
17
+ # Ensure developer is initialized
18
+ ensure_developer
19
+
20
+ DEVELOPER=$(get_developer)
21
+ REPO_ROOT=$(get_repo_root)
22
+ DEV_DIR="$REPO_ROOT/$DIR_WORKFLOW/$DIR_WORKSPACE/$DEVELOPER"
23
+ INDEX_FILE="$DEV_DIR/index.md"
24
+
25
+ # =============================================================================
26
+ # Helper Functions
27
+ # =============================================================================
28
+
29
+ get_latest_journal_info() {
30
+ local latest_file=""
31
+ local latest_num=-1 # Start at -1 so journal-0.md can be detected (0 > -1)
32
+
33
+ for f in "$DEV_DIR"/${FILE_JOURNAL_PREFIX}*.md; do
34
+ if [[ -f "$f" ]]; then
35
+ local num=$(basename "$f" | sed "s/${FILE_JOURNAL_PREFIX}\([0-9]*\)\.md/\1/")
36
+ if [[ "$num" -gt "$latest_num" ]]; then
37
+ latest_num=$num
38
+ latest_file="$f"
39
+ fi
40
+ fi
41
+ done
42
+
43
+ if [[ -n "$latest_file" ]]; then
44
+ local lines=$(wc -l < "$latest_file" | tr -d ' ')
45
+ echo "$latest_file:$latest_num:$lines"
46
+ else
47
+ echo ":0:0"
48
+ fi
49
+ }
50
+
51
+ get_current_session() {
52
+ local line=$(grep "Total Sessions" "$INDEX_FILE" 2>/dev/null | head -1)
53
+ echo "$line" | sed 's/.*: //' | tr -d ' '
54
+ }
55
+
56
+ count_journal_files() {
57
+ local result=""
58
+ local journal_info=$(get_latest_journal_info)
59
+ local active_num=$(echo "$journal_info" | cut -d: -f2)
60
+ local active_file="${FILE_JOURNAL_PREFIX}$active_num.md"
61
+
62
+ for f in $(ls -v "$DEV_DIR"/${FILE_JOURNAL_PREFIX}*.md 2>/dev/null | sort -t- -k2 -n -r); do
63
+ if [[ -f "$f" ]]; then
64
+ local filename=$(basename "$f")
65
+ local lines=$(wc -l < "$f" | tr -d ' ')
66
+
67
+ local status="Archived"
68
+ if [[ "$filename" == "$active_file" ]]; then
69
+ status="Active"
70
+ fi
71
+
72
+ result="${result}| \`$filename\` | ~$lines | $status |
73
+ "
74
+ fi
75
+ done
76
+ echo "$result" | sed '/^$/d'
77
+ }
78
+
79
+ create_new_journal_file() {
80
+ local num=$1
81
+ local prev_num=$((num - 1))
82
+ local new_file="$DEV_DIR/${FILE_JOURNAL_PREFIX}$num.md"
83
+
84
+ cat > "$new_file" << EOF
85
+ # Journal - $DEVELOPER (Part $num)
86
+
87
+ > Continuation from \`${FILE_JOURNAL_PREFIX}$prev_num.md\` (archived at ~$MAX_LINES lines)
88
+ > Started: $TODAY
89
+
90
+ ---
91
+
92
+ EOF
93
+ echo "$new_file"
94
+ }
95
+
96
+ generate_session_content() {
97
+ local session_num=$1
98
+ local title=$2
99
+ local commit=$3
100
+ local summary=$4
101
+ local extra_content=$5
102
+
103
+ local commit_table=""
104
+ if [[ -n "$commit" && "$commit" != "-" ]]; then
105
+ commit_table="| Hash | Message |
106
+ |------|---------|"
107
+ IFS=',' read -ra COMMITS <<< "$commit"
108
+ for c in "${COMMITS[@]}"; do
109
+ c=$(echo "$c" | tr -d ' ')
110
+ commit_table="$commit_table
111
+ | \`$c\` | (see git log) |"
112
+ done
113
+ else
114
+ commit_table="(No commits - planning session)"
115
+ fi
116
+
117
+ cat << EOF
118
+
119
+ ## Session $session_num: $title
120
+
121
+ **Date**: $TODAY
122
+ **Task**: $title
123
+
124
+ ### Summary
125
+
126
+ $summary
127
+
128
+ ### Main Changes
129
+
130
+ $extra_content
131
+
132
+ ### Git Commits
133
+
134
+ $commit_table
135
+
136
+ ### Testing
137
+
138
+ - [OK] (Add test results)
139
+
140
+ ### Status
141
+
142
+ [OK] **Completed**
143
+
144
+ ### Next Steps
145
+
146
+ - None - task complete
147
+ EOF
148
+ }
149
+
150
+ # =============================================================================
151
+ # Update Index.md
152
+ # =============================================================================
153
+
154
+ update_index() {
155
+ local title="$1"
156
+ local commit="$2"
157
+ local new_session="$3"
158
+ local active_file="$4"
159
+
160
+ # Format commit for display
161
+ local commit_display="-"
162
+ if [[ -n "$commit" && "$commit" != "-" ]]; then
163
+ commit_display=$(echo "$commit" | sed 's/,/, /g' | sed 's/\([a-f0-9]\{7,\}\)/`\1`/g')
164
+ fi
165
+
166
+ local files_table=$(count_journal_files)
167
+
168
+ echo "Updating index.md for session $new_session..."
169
+ echo " Title: $title"
170
+ echo " Commit: $commit_display"
171
+ echo " Active File: $active_file"
172
+ echo ""
173
+
174
+ if ! grep -q "@@@auto:current-status" "$INDEX_FILE"; then
175
+ echo "Error: Markers not found in index.md. Please ensure markers exist." >&2
176
+ exit 1
177
+ fi
178
+
179
+ local tmp_file=$(mktemp)
180
+
181
+ local in_current_status=false
182
+ local in_active_documents=false
183
+ local in_session_history=false
184
+ local header_written=false
185
+
186
+ while IFS= read -r line || [[ -n "$line" ]]; do
187
+ if [[ "$line" == *"@@@auto:current-status"* ]]; then
188
+ echo "$line" >> "$tmp_file"
189
+ in_current_status=true
190
+ echo "- **Active File**: \`$active_file\`" >> "$tmp_file"
191
+ echo "- **Total Sessions**: $new_session" >> "$tmp_file"
192
+ echo "- **Last Active**: $TODAY" >> "$tmp_file"
193
+ continue
194
+ fi
195
+
196
+ if [[ "$line" == *"@@@/auto:current-status"* ]]; then
197
+ in_current_status=false
198
+ echo "$line" >> "$tmp_file"
199
+ continue
200
+ fi
201
+
202
+ if [[ "$line" == *"@@@auto:active-documents"* ]]; then
203
+ echo "$line" >> "$tmp_file"
204
+ in_active_documents=true
205
+ echo "| File | Lines | Status |" >> "$tmp_file"
206
+ echo "|------|-------|--------|" >> "$tmp_file"
207
+ echo "$files_table" >> "$tmp_file"
208
+ continue
209
+ fi
210
+
211
+ if [[ "$line" == *"@@@/auto:active-documents"* ]]; then
212
+ in_active_documents=false
213
+ echo "$line" >> "$tmp_file"
214
+ continue
215
+ fi
216
+
217
+ if [[ "$line" == *"@@@auto:session-history"* ]]; then
218
+ echo "$line" >> "$tmp_file"
219
+ in_session_history=true
220
+ header_written=false
221
+ continue
222
+ fi
223
+
224
+ if [[ "$line" == *"@@@/auto:session-history"* ]]; then
225
+ in_session_history=false
226
+ echo "$line" >> "$tmp_file"
227
+ continue
228
+ fi
229
+
230
+ if $in_current_status; then
231
+ continue
232
+ fi
233
+
234
+ if $in_active_documents; then
235
+ continue
236
+ fi
237
+
238
+ if $in_session_history; then
239
+ echo "$line" >> "$tmp_file"
240
+ if [[ "$line" == "|---"* ]] && ! $header_written; then
241
+ echo "| $new_session | $TODAY | $title | $commit_display |" >> "$tmp_file"
242
+ header_written=true
243
+ fi
244
+ continue
245
+ fi
246
+
247
+ echo "$line" >> "$tmp_file"
248
+ done < "$INDEX_FILE"
249
+
250
+ mv "$tmp_file" "$INDEX_FILE"
251
+
252
+ echo "[OK] Updated index.md successfully!"
253
+ }
254
+
255
+ # =============================================================================
256
+ # Main Function
257
+ # =============================================================================
258
+
259
+ add_session() {
260
+ local title=""
261
+ local commit="-"
262
+ local summary="(Add summary)"
263
+ local content_file=""
264
+ local extra_content="(Add details)"
265
+
266
+ while [[ $# -gt 0 ]]; do
267
+ case $1 in
268
+ --title)
269
+ title="$2"
270
+ shift 2
271
+ ;;
272
+ --commit)
273
+ commit="$2"
274
+ shift 2
275
+ ;;
276
+ --summary)
277
+ summary="$2"
278
+ shift 2
279
+ ;;
280
+ --content-file)
281
+ content_file="$2"
282
+ shift 2
283
+ ;;
284
+ *)
285
+ shift
286
+ ;;
287
+ esac
288
+ done
289
+
290
+ if [[ -z "$title" ]]; then
291
+ echo "Error: --title is required" >&2
292
+ echo "Usage: $0 --title \"Session Title\" [--commit \"hash1,hash2\"] [--summary \"Brief summary\"]" >&2
293
+ exit 1
294
+ fi
295
+
296
+ if [[ -n "$content_file" && -f "$content_file" ]]; then
297
+ extra_content=$(cat "$content_file")
298
+ elif [[ ! -t 0 ]]; then
299
+ extra_content=$(cat)
300
+ fi
301
+
302
+ local journal_info=$(get_latest_journal_info)
303
+ local current_file=$(echo "$journal_info" | cut -d: -f1)
304
+ local current_num=$(echo "$journal_info" | cut -d: -f2)
305
+ local current_lines=$(echo "$journal_info" | cut -d: -f3)
306
+ local current_session=$(get_current_session)
307
+ local new_session=$((current_session + 1))
308
+
309
+ local session_content=$(generate_session_content "$new_session" "$title" "$commit" "$summary" "$extra_content")
310
+ local content_lines=$(echo "$session_content" | wc -l | tr -d ' ')
311
+
312
+ echo "========================================" >&2
313
+ echo "ADD SESSION" >&2
314
+ echo "========================================" >&2
315
+ echo "" >&2
316
+ echo "Session: $new_session" >&2
317
+ echo "Title: $title" >&2
318
+ echo "Commit: $commit" >&2
319
+ echo "" >&2
320
+ echo "Current journal file: ${FILE_JOURNAL_PREFIX}$current_num.md" >&2
321
+ echo "Current lines: $current_lines" >&2
322
+ echo "New content lines: $content_lines" >&2
323
+ echo "Total after append: $((current_lines + content_lines))" >&2
324
+ echo "" >&2
325
+
326
+ local target_file="$current_file"
327
+ local target_num=$current_num
328
+
329
+ if [[ $((current_lines + content_lines)) -gt $MAX_LINES ]]; then
330
+ target_num=$((current_num + 1))
331
+ echo "[!] Exceeds $MAX_LINES lines, creating ${FILE_JOURNAL_PREFIX}$target_num.md" >&2
332
+ target_file=$(create_new_journal_file "$target_num")
333
+ echo "Created: $target_file" >&2
334
+ fi
335
+
336
+ echo "$session_content" >> "$target_file"
337
+ echo "[OK] Appended session to $(basename "$target_file")" >&2
338
+
339
+ echo "" >&2
340
+
341
+ # Update index.md directly
342
+ local active_file="${FILE_JOURNAL_PREFIX}$target_num.md"
343
+ update_index "$title" "$commit" "$new_session" "$active_file"
344
+
345
+ echo "" >&2
346
+ echo "========================================" >&2
347
+ echo "[OK] Session $new_session added successfully!" >&2
348
+ echo "========================================" >&2
349
+ echo "" >&2
350
+ echo "Files updated:" >&2
351
+ echo " - $(basename "$target_file")" >&2
352
+ echo " - index.md" >&2
353
+ }
354
+
355
+ show_help() {
356
+ echo "Usage: $0 --title \"Title\" [options]"
357
+ echo ""
358
+ echo "Add a new session to journal file and update index.md automatically."
359
+ echo ""
360
+ echo "Options:"
361
+ echo " --title TEXT Session title (required)"
362
+ echo " --commit HASHES Comma-separated commit hashes (optional)"
363
+ echo " --summary TEXT Brief summary of the session (optional)"
364
+ echo " --content-file Path to file with detailed content (optional)"
365
+ echo ""
366
+ echo "You can also pipe content via stdin:"
367
+ echo " echo \"Details\" | $0 --title \"Title\" --commit \"abc123\""
368
+ echo ""
369
+ echo "Examples:"
370
+ echo " $0 --title \"Fix login bug\" --commit \"abc1234\" --summary \"Fixed auth issue\""
371
+ }
372
+
373
+ # =============================================================================
374
+ # Main Entry
375
+ # =============================================================================
376
+
377
+ case "${1:-}" in
378
+ --help|-h|help)
379
+ show_help
380
+ ;;
381
+ *)
382
+ add_session "$@"
383
+ ;;
384
+ esac