autohand-cli 0.6.0 → 0.6.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 (136) hide show
  1. package/dist/agents-32JB7KMB.js +9 -0
  2. package/dist/agents-3K6PHXQ6.js +9 -0
  3. package/dist/agents-A7AUMVQD.js +8 -0
  4. package/dist/agents-AHFECO5Q.js +9 -0
  5. package/dist/agents-DQFYBMJG.js +8 -0
  6. package/dist/agents-GX6L7BXZ.js +9 -0
  7. package/dist/agents-IWJJ7YJM.js +8 -0
  8. package/dist/agents-J2QLDVOP.js +9 -0
  9. package/dist/agents-OWTSY74S.js +9 -0
  10. package/dist/agents-RB34F4XE.js +9 -0
  11. package/dist/agents-XL27P67O.js +9 -0
  12. package/dist/agents-new-5I3B2W2I.js +9 -0
  13. package/dist/agents-new-CHV2AV34.js +9 -0
  14. package/dist/agents-new-F6F2VMDB.js +9 -0
  15. package/dist/agents-new-FDMUH7NL.js +9 -0
  16. package/dist/agents-new-GBF6JJIA.js +9 -0
  17. package/dist/agents-new-GCZEY4TE.js +8 -0
  18. package/dist/agents-new-OCIB72NU.js +9 -0
  19. package/dist/agents-new-PQGD47BZ.js +9 -0
  20. package/dist/agents-new-V6BNVJAB.js +9 -0
  21. package/dist/agents-new-WQUEZ2XH.js +8 -0
  22. package/dist/chunk-2DEJU7WQ.js +373 -0
  23. package/dist/chunk-2EPIFDFM.js +68 -0
  24. package/dist/chunk-2FUWKZFN.js +68 -0
  25. package/dist/chunk-2HIILNYH.js +197 -0
  26. package/dist/chunk-2QAL3HH4.js +79 -0
  27. package/dist/chunk-3FRM7HJY.js +57 -0
  28. package/dist/chunk-4LDR3Y3A.js +79 -0
  29. package/dist/{chunk-6PYYLBNT.js → chunk-4LLTISFP.js} +1 -1
  30. package/dist/chunk-4UISIRMD.js +288 -0
  31. package/dist/chunk-4VWPX2X3.js +131 -0
  32. package/dist/chunk-7FMMKTRG.js +64 -0
  33. package/dist/chunk-7MFSCH7E.js +382 -0
  34. package/dist/chunk-7TV5KURP.js +79 -0
  35. package/dist/chunk-7WBK33MM.js +57 -0
  36. package/dist/chunk-7XN6PAKV.js +79 -0
  37. package/dist/chunk-A7HRTONQ.js +382 -0
  38. package/dist/chunk-ALMJANSA.js +197 -0
  39. package/dist/chunk-CD7GNBIE.js +288 -0
  40. package/dist/chunk-CV3LEQRD.js +57 -0
  41. package/dist/chunk-DAHMHLM6.js +102 -0
  42. package/dist/chunk-DAMLAWGE.js +68 -0
  43. package/dist/chunk-F4YPGOQJ.js +105 -0
  44. package/dist/chunk-FQDXFNOI.js +57 -0
  45. package/dist/chunk-FQI7EJY2.js +105 -0
  46. package/dist/chunk-GAJCZDZ5.js +286 -0
  47. package/dist/chunk-GEOP77H3.js +79 -0
  48. package/dist/chunk-GRX3IQHC.js +131 -0
  49. package/dist/chunk-GX24PC3L.js +288 -0
  50. package/dist/chunk-H53NQAC2.js +131 -0
  51. package/dist/chunk-HJYISR7Y.js +382 -0
  52. package/dist/chunk-HLSI4HQM.js +105 -0
  53. package/dist/chunk-IAOMCEYU.js +68 -0
  54. package/dist/chunk-J7RENRJG.js +382 -0
  55. package/dist/chunk-JUDX6E53.js +105 -0
  56. package/dist/chunk-JZQKOM7X.js +382 -0
  57. package/dist/chunk-K75NWR5V.js +108 -0
  58. package/dist/chunk-KCMWJB53.js +288 -0
  59. package/dist/chunk-KERHTHMK.js +302 -0
  60. package/dist/chunk-KJ4M6KAK.js +57 -0
  61. package/dist/chunk-L3JXU574.js +77 -0
  62. package/dist/chunk-LR2XPUPT.js +236 -0
  63. package/dist/chunk-MCWNGAZG.js +198 -0
  64. package/dist/chunk-MQTBFYEG.js +288 -0
  65. package/dist/chunk-NCUJWSGP.js +287 -0
  66. package/dist/chunk-NWEUBPSG.js +79 -0
  67. package/dist/chunk-OJ5EBWOQ.js +232 -0
  68. package/dist/chunk-PKQZWNS2.js +131 -0
  69. package/dist/chunk-PQJIQBQ5.js +57 -0
  70. package/dist/chunk-PX5AGAEX.js +105 -0
  71. package/dist/chunk-Q7HX4VZD.js +197 -0
  72. package/dist/chunk-QE5RKNVN.js +30 -0
  73. package/dist/chunk-QLVXFPE3.js +145 -0
  74. package/dist/chunk-QUC577LO.js +79 -0
  75. package/dist/chunk-RAL2W5UX.js +55 -0
  76. package/dist/chunk-RANNBYFJ.js +105 -0
  77. package/dist/chunk-RCSSFUGL.js +131 -0
  78. package/dist/chunk-RUQVXU6K.js +131 -0
  79. package/dist/chunk-RZ7TASUI.js +57 -0
  80. package/dist/chunk-SN7D2PJO.js +68 -0
  81. package/dist/chunk-T4WQUJAE.js +79 -0
  82. package/dist/chunk-U2Z5BABG.js +57 -0
  83. package/dist/chunk-UHC4DIK5.js +105 -0
  84. package/dist/chunk-UNS4S6J3.js +197 -0
  85. package/dist/chunk-UW2LYWIM.js +131 -0
  86. package/dist/chunk-VRCQBFSX.js +102 -0
  87. package/dist/chunk-W76N6IZV.js +197 -0
  88. package/dist/chunk-WTEZYXD2.js +67 -0
  89. package/dist/chunk-X7EWON4T.js +105 -0
  90. package/dist/chunk-XARAKKJ4.js +197 -0
  91. package/dist/chunk-Y6JDGDEE.js +197 -0
  92. package/dist/chunk-Y7FSNXMR.js +382 -0
  93. package/dist/chunk-YPZMUIB5.js +50 -0
  94. package/dist/chunk-ZMDUVLR4.js +148 -0
  95. package/dist/chunk-ZRFAICDG.js +382 -0
  96. package/dist/export-HEFUNSR4.js +8 -0
  97. package/dist/feedback-3U2WYQK6.js +9 -0
  98. package/dist/feedback-5IIX372K.js +9 -0
  99. package/dist/feedback-6S6DWGIU.js +9 -0
  100. package/dist/feedback-7DEOY2AP.js +9 -0
  101. package/dist/feedback-BBQT42R6.js +9 -0
  102. package/dist/feedback-CGCSAWQT.js +9 -0
  103. package/dist/feedback-NEDFOKMA.js +9 -0
  104. package/dist/feedback-OXGGJVNA.js +9 -0
  105. package/dist/feedback-ZJECE2FS.js +8 -0
  106. package/dist/help-NQUZ7TNJ.js +10 -0
  107. package/dist/index.cjs +16 -2
  108. package/dist/index.js +2 -2
  109. package/dist/login-D53NQ7UY.js +10 -0
  110. package/dist/login-GPXDNB2F.js +10 -0
  111. package/dist/login-HDF4GSTP.js +10 -0
  112. package/dist/login-SDAZTJAK.js +10 -0
  113. package/dist/login-SM6LEDDA.js +10 -0
  114. package/dist/login-TDI7HBRZ.js +10 -0
  115. package/dist/login-Y7XXSNOZ.js +10 -0
  116. package/dist/logout-32RNT7G2.js +10 -0
  117. package/dist/logout-43W7N6JU.js +10 -0
  118. package/dist/logout-BMHTSXIY.js +10 -0
  119. package/dist/logout-JNNJJYYL.js +10 -0
  120. package/dist/logout-LW42QASH.js +10 -0
  121. package/dist/logout-QLWM6P26.js +10 -0
  122. package/dist/logout-TL7GLGWU.js +10 -0
  123. package/dist/memory-GVYG653L.js +8 -0
  124. package/dist/new-MCN36AOD.js +8 -0
  125. package/dist/{status-RNUAXIRO.js → status-DCVSUWZG.js} +1 -1
  126. package/dist/status-F6TQOCON.js +8 -0
  127. package/dist/status-IT5CYW37.js +8 -0
  128. package/dist/status-MRJOSVE3.js +8 -0
  129. package/dist/status-MWFV2DZG.js +8 -0
  130. package/dist/status-N3PMJRSB.js +8 -0
  131. package/dist/status-NK7YSBXZ.js +8 -0
  132. package/dist/status-QLQ5ZKJ3.js +8 -0
  133. package/dist/status-SQEFMII5.js +8 -0
  134. package/dist/status-U33PEUBO.js +8 -0
  135. package/dist/status-XAJH67SE.js +8 -0
  136. package/package.json +16 -2
@@ -0,0 +1,9 @@
1
+ import {
2
+ handler,
3
+ metadata
4
+ } from "./chunk-ZMDUVLR4.js";
5
+ import "./chunk-RAL2W5UX.js";
6
+ export {
7
+ handler,
8
+ metadata
9
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ handler,
3
+ metadata
4
+ } from "./chunk-UNS4S6J3.js";
5
+ import "./chunk-DAMLAWGE.js";
6
+ export {
7
+ handler,
8
+ metadata
9
+ };
@@ -0,0 +1,8 @@
1
+ import {
2
+ handler,
3
+ metadata
4
+ } from "./chunk-MCWNGAZG.js";
5
+ export {
6
+ handler,
7
+ metadata
8
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ handler,
3
+ metadata
4
+ } from "./chunk-W76N6IZV.js";
5
+ import "./chunk-SN7D2PJO.js";
6
+ export {
7
+ handler,
8
+ metadata
9
+ };
@@ -0,0 +1,8 @@
1
+ import {
2
+ handler,
3
+ metadata
4
+ } from "./chunk-QLVXFPE3.js";
5
+ export {
6
+ handler,
7
+ metadata
8
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ handler,
3
+ metadata
4
+ } from "./chunk-XARAKKJ4.js";
5
+ import "./chunk-IAOMCEYU.js";
6
+ export {
7
+ handler,
8
+ metadata
9
+ };
@@ -0,0 +1,8 @@
1
+ import {
2
+ handler,
3
+ metadata
4
+ } from "./chunk-K75NWR5V.js";
5
+ export {
6
+ handler,
7
+ metadata
8
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ handler,
3
+ metadata
4
+ } from "./chunk-Q7HX4VZD.js";
5
+ import "./chunk-2FUWKZFN.js";
6
+ export {
7
+ handler,
8
+ metadata
9
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ handler,
3
+ metadata
4
+ } from "./chunk-Y6JDGDEE.js";
5
+ import "./chunk-WTEZYXD2.js";
6
+ export {
7
+ handler,
8
+ metadata
9
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ handler,
3
+ metadata
4
+ } from "./chunk-ALMJANSA.js";
5
+ import "./chunk-2EPIFDFM.js";
6
+ export {
7
+ handler,
8
+ metadata
9
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ handler,
3
+ metadata
4
+ } from "./chunk-2HIILNYH.js";
5
+ import "./chunk-7FMMKTRG.js";
6
+ export {
7
+ handler,
8
+ metadata
9
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ createAgent,
3
+ metadata
4
+ } from "./chunk-PX5AGAEX.js";
5
+ import "./chunk-2EPIFDFM.js";
6
+ export {
7
+ createAgent,
8
+ metadata
9
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ createAgent,
3
+ metadata
4
+ } from "./chunk-X7EWON4T.js";
5
+ import "./chunk-SN7D2PJO.js";
6
+ export {
7
+ createAgent,
8
+ metadata
9
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ createAgent,
3
+ metadata
4
+ } from "./chunk-FQI7EJY2.js";
5
+ import "./chunk-WTEZYXD2.js";
6
+ export {
7
+ createAgent,
8
+ metadata
9
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ createAgent,
3
+ metadata
4
+ } from "./chunk-UHC4DIK5.js";
5
+ import "./chunk-DAMLAWGE.js";
6
+ export {
7
+ createAgent,
8
+ metadata
9
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ createAgent,
3
+ metadata
4
+ } from "./chunk-F4YPGOQJ.js";
5
+ import "./chunk-IAOMCEYU.js";
6
+ export {
7
+ createAgent,
8
+ metadata
9
+ };
@@ -0,0 +1,8 @@
1
+ import {
2
+ createAgent,
3
+ metadata
4
+ } from "./chunk-VRCQBFSX.js";
5
+ export {
6
+ createAgent,
7
+ metadata
8
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ createAgent,
3
+ metadata
4
+ } from "./chunk-JUDX6E53.js";
5
+ import "./chunk-7FMMKTRG.js";
6
+ export {
7
+ createAgent,
8
+ metadata
9
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ createAgent,
3
+ metadata
4
+ } from "./chunk-HLSI4HQM.js";
5
+ import "./chunk-RAL2W5UX.js";
6
+ export {
7
+ createAgent,
8
+ metadata
9
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ createAgent,
3
+ metadata
4
+ } from "./chunk-RANNBYFJ.js";
5
+ import "./chunk-2FUWKZFN.js";
6
+ export {
7
+ createAgent,
8
+ metadata
9
+ };
@@ -0,0 +1,8 @@
1
+ import {
2
+ createAgent,
3
+ metadata
4
+ } from "./chunk-DAHMHLM6.js";
5
+ export {
6
+ createAgent,
7
+ metadata
8
+ };
@@ -0,0 +1,373 @@
1
+ // src/commands/export.ts
2
+ import chalk from "chalk";
3
+ import path2 from "path";
4
+ import enquirer from "enquirer";
5
+
6
+ // src/session/exportSession.ts
7
+ import fs from "fs-extra";
8
+ import path from "path";
9
+ var DEFAULT_OPTIONS = {
10
+ includeToolOutputs: true,
11
+ includeTimestamps: false,
12
+ includeMetadata: true,
13
+ maxCodeBlockLength: 500,
14
+ includeToc: false
15
+ };
16
+ function formatCodeBlock(code, language, maxLength) {
17
+ let content = code;
18
+ if (maxLength && content.length > maxLength) {
19
+ content = content.slice(0, maxLength) + "\n... (truncated)";
20
+ }
21
+ const lang = language || "";
22
+ return "```" + lang + "\n" + content + "\n```";
23
+ }
24
+ function detectLanguage(content, context) {
25
+ if (context) {
26
+ const extMatch = context.match(/\.(\w+)$/);
27
+ if (extMatch) {
28
+ const ext = extMatch[1].toLowerCase();
29
+ const langMap = {
30
+ ts: "typescript",
31
+ tsx: "typescript",
32
+ js: "javascript",
33
+ jsx: "javascript",
34
+ py: "python",
35
+ rs: "rust",
36
+ go: "go",
37
+ rb: "ruby",
38
+ java: "java",
39
+ cpp: "cpp",
40
+ c: "c",
41
+ sh: "bash",
42
+ bash: "bash",
43
+ json: "json",
44
+ yaml: "yaml",
45
+ yml: "yaml",
46
+ md: "markdown",
47
+ sql: "sql",
48
+ html: "html",
49
+ css: "css"
50
+ };
51
+ return langMap[ext] || ext;
52
+ }
53
+ }
54
+ if (content.includes("function") || content.includes("const ") || content.includes("let ")) {
55
+ return "javascript";
56
+ }
57
+ if (content.includes("def ") || content.includes("import ") && content.includes(":")) {
58
+ return "python";
59
+ }
60
+ if (content.includes("fn ") || content.includes("let mut")) {
61
+ return "rust";
62
+ }
63
+ if (content.includes("func ") || content.includes("package ")) {
64
+ return "go";
65
+ }
66
+ return "";
67
+ }
68
+ function formatTimestamp(timestamp) {
69
+ const date = new Date(timestamp);
70
+ return date.toLocaleString("en-US", {
71
+ month: "short",
72
+ day: "numeric",
73
+ hour: "2-digit",
74
+ minute: "2-digit"
75
+ });
76
+ }
77
+ function formatMessage(message, options, index) {
78
+ const parts = [];
79
+ const roleEmoji = {
80
+ user: "\u{1F464}",
81
+ assistant: "\u{1F916}",
82
+ tool: "\u{1F527}",
83
+ system: "\u2699\uFE0F"
84
+ };
85
+ const emoji = roleEmoji[message.role] || "\u{1F4AC}";
86
+ const roleLabel = message.role.charAt(0).toUpperCase() + message.role.slice(1);
87
+ const timestamp = options.includeTimestamps && message.timestamp ? ` (${formatTimestamp(message.timestamp)})` : "";
88
+ parts.push(`### ${emoji} ${roleLabel}${timestamp}`);
89
+ parts.push("");
90
+ if (message.role === "tool") {
91
+ if (options.includeToolOutputs) {
92
+ const toolName = message.name || "Tool";
93
+ parts.push(`**${toolName}**`);
94
+ parts.push("");
95
+ if (message.content.includes("\n") || message.content.length > 100) {
96
+ const lang = detectLanguage(message.content, message.name);
97
+ parts.push(formatCodeBlock(message.content, lang, options.maxCodeBlockLength));
98
+ } else {
99
+ parts.push(`> ${message.content}`);
100
+ }
101
+ } else {
102
+ parts.push("*Tool output omitted*");
103
+ }
104
+ } else {
105
+ const content = message.content;
106
+ const codeBlockRegex = /```(\w*)\n([\s\S]*?)```/g;
107
+ let lastIndex = 0;
108
+ let match;
109
+ while ((match = codeBlockRegex.exec(content)) !== null) {
110
+ if (match.index > lastIndex) {
111
+ parts.push(content.slice(lastIndex, match.index).trim());
112
+ }
113
+ const lang = match[1] || "";
114
+ const code = match[2];
115
+ parts.push(formatCodeBlock(code, lang, options.maxCodeBlockLength));
116
+ lastIndex = match.index + match[0].length;
117
+ }
118
+ if (lastIndex < content.length) {
119
+ const remaining = content.slice(lastIndex).trim();
120
+ if (remaining) {
121
+ parts.push(remaining);
122
+ }
123
+ }
124
+ }
125
+ parts.push("");
126
+ parts.push("---");
127
+ parts.push("");
128
+ return parts.join("\n");
129
+ }
130
+ function exportToMarkdown(metadata2, messages, options = {}) {
131
+ const opts = { ...DEFAULT_OPTIONS, ...options };
132
+ const parts = [];
133
+ parts.push(`# ${metadata2.projectName} - Session ${metadata2.sessionId.slice(0, 8)}`);
134
+ parts.push("");
135
+ if (opts.includeMetadata) {
136
+ parts.push("## Session Info");
137
+ parts.push("");
138
+ parts.push(`| Property | Value |`);
139
+ parts.push(`|----------|-------|`);
140
+ parts.push(`| **Project** | ${metadata2.projectName} |`);
141
+ parts.push(`| **Started** | ${formatTimestamp(metadata2.createdAt)} |`);
142
+ if (metadata2.closedAt) {
143
+ parts.push(`| **Ended** | ${formatTimestamp(metadata2.closedAt)} |`);
144
+ }
145
+ parts.push(`| **Model** | ${metadata2.model} |`);
146
+ parts.push(`| **Messages** | ${metadata2.messageCount} |`);
147
+ parts.push(`| **Status** | ${metadata2.status} |`);
148
+ parts.push("");
149
+ if (metadata2.summary) {
150
+ parts.push("### Summary");
151
+ parts.push("");
152
+ parts.push(metadata2.summary);
153
+ parts.push("");
154
+ }
155
+ parts.push("---");
156
+ parts.push("");
157
+ }
158
+ if (opts.includeToc) {
159
+ parts.push("## Table of Contents");
160
+ parts.push("");
161
+ let userCount2 = 0;
162
+ for (const message of messages) {
163
+ if (message.role === "user") {
164
+ userCount2++;
165
+ const preview = message.content.slice(0, 50).replace(/\n/g, " ");
166
+ parts.push(`${userCount2}. [${preview}...](#message-${userCount2})`);
167
+ }
168
+ }
169
+ parts.push("");
170
+ parts.push("---");
171
+ parts.push("");
172
+ }
173
+ parts.push("## Conversation");
174
+ parts.push("");
175
+ let userCount = 0;
176
+ for (let i = 0; i < messages.length; i++) {
177
+ const message = messages[i];
178
+ if (opts.includeToc && message.role === "user") {
179
+ userCount++;
180
+ parts.push(`<a name="message-${userCount}"></a>`);
181
+ parts.push("");
182
+ }
183
+ parts.push(formatMessage(message, opts, i));
184
+ }
185
+ parts.push("---");
186
+ parts.push("");
187
+ parts.push(`*Exported from Autohand CLI on ${(/* @__PURE__ */ new Date()).toLocaleString()}*`);
188
+ return parts.join("\n");
189
+ }
190
+ function exportToJson(metadata2, messages, pretty = true) {
191
+ const data = {
192
+ metadata: metadata2,
193
+ messages,
194
+ exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
195
+ version: "1.0"
196
+ };
197
+ return pretty ? JSON.stringify(data, null, 2) : JSON.stringify(data);
198
+ }
199
+ function exportToHtml(metadata2, messages, options = {}) {
200
+ const markdown = exportToMarkdown(metadata2, messages, options);
201
+ let html = markdown.replace(/^### (.*$)/gm, "<h3>$1</h3>").replace(/^## (.*$)/gm, "<h2>$1</h2>").replace(/^# (.*$)/gm, "<h1>$1</h1>").replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>").replace(/\*(.*?)\*/g, "<em>$1</em>").replace(/```(\w*)\n([\s\S]*?)```/g, '<pre><code class="language-$1">$2</code></pre>').replace(/`([^`]+)`/g, "<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>').replace(/\|([^|]+)\|/g, "<td>$1</td>").replace(/^> (.*$)/gm, "<blockquote>$1</blockquote>").replace(/^---$/gm, "<hr>").replace(/\n\n/g, "</p><p>").replace(/\n/g, "<br>");
202
+ return `<!DOCTYPE html>
203
+ <html lang="en">
204
+ <head>
205
+ <meta charset="UTF-8">
206
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
207
+ <title>${metadata2.projectName} - Session ${metadata2.sessionId.slice(0, 8)}</title>
208
+ <style>
209
+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 800px; margin: 0 auto; padding: 2rem; line-height: 1.6; }
210
+ h1, h2, h3 { color: #333; }
211
+ pre { background: #f5f5f5; padding: 1rem; border-radius: 4px; overflow-x: auto; }
212
+ code { background: #f5f5f5; padding: 0.2rem 0.4rem; border-radius: 3px; font-size: 0.9em; }
213
+ pre code { background: none; padding: 0; }
214
+ blockquote { border-left: 4px solid #ddd; margin: 0; padding-left: 1rem; color: #666; }
215
+ hr { border: none; border-top: 1px solid #ddd; margin: 1.5rem 0; }
216
+ table { border-collapse: collapse; width: 100%; }
217
+ td, th { border: 1px solid #ddd; padding: 0.5rem; text-align: left; }
218
+ </style>
219
+ </head>
220
+ <body>
221
+ <p>${html}</p>
222
+ </body>
223
+ </html>`;
224
+ }
225
+ async function saveExport(content, filePath) {
226
+ await fs.ensureDir(path.dirname(filePath));
227
+ await fs.writeFile(filePath, content, "utf8");
228
+ }
229
+ function getSuggestedFilename(metadata2, format) {
230
+ const date = new Date(metadata2.createdAt);
231
+ const dateStr = date.toISOString().split("T")[0];
232
+ const projectSlug = metadata2.projectName.toLowerCase().replace(/[^a-z0-9]+/g, "-");
233
+ const sessionShort = metadata2.sessionId.slice(0, 8);
234
+ return `${projectSlug}-${dateStr}-${sessionShort}.${format}`;
235
+ }
236
+
237
+ // src/commands/export.ts
238
+ var metadata = {
239
+ command: "/export",
240
+ description: "Export current session to markdown",
241
+ implemented: true
242
+ };
243
+ async function execute(args, context) {
244
+ if (!context?.sessionManager) {
245
+ console.log(chalk.red("Session manager not available."));
246
+ return;
247
+ }
248
+ const { sessionManager, currentSession, workspaceRoot } = context;
249
+ let session = currentSession;
250
+ if (!session) {
251
+ const sessions = await sessionManager.listSessions();
252
+ if (sessions.length === 0) {
253
+ console.log(chalk.yellow("No sessions found to export."));
254
+ return;
255
+ }
256
+ const { Select: Select2 } = enquirer;
257
+ const sessionPrompt = new Select2({
258
+ name: "session",
259
+ message: "Select a session to export:",
260
+ choices: sessions.slice(0, 10).map((s) => ({
261
+ name: s.sessionId,
262
+ message: `${s.projectName} - ${new Date(s.createdAt).toLocaleString()} (${s.messageCount} messages)`
263
+ }))
264
+ });
265
+ try {
266
+ const selectedId = await sessionPrompt.run();
267
+ session = await sessionManager.loadSession(selectedId);
268
+ } catch {
269
+ console.log(chalk.gray("Cancelled."));
270
+ return;
271
+ }
272
+ }
273
+ const metadata2 = session.metadata;
274
+ const messages = session.getMessages();
275
+ if (messages.length === 0) {
276
+ console.log(chalk.yellow("No messages in session to export."));
277
+ return;
278
+ }
279
+ const { Select, Confirm, Input } = enquirer;
280
+ const formatPrompt = new Select({
281
+ name: "format",
282
+ message: "Export format:",
283
+ choices: [
284
+ { name: "md", message: "Markdown (.md)" },
285
+ { name: "json", message: "JSON (.json)" },
286
+ { name: "html", message: "HTML (.html)" }
287
+ ]
288
+ });
289
+ let format;
290
+ try {
291
+ format = await formatPrompt.run();
292
+ } catch {
293
+ console.log(chalk.gray("Cancelled."));
294
+ return;
295
+ }
296
+ let options = {};
297
+ if (format === "md" || format === "html") {
298
+ const includeToolsPrompt = new Confirm({
299
+ name: "includeTools",
300
+ message: "Include tool outputs?",
301
+ initial: true
302
+ });
303
+ try {
304
+ options.includeToolOutputs = await includeToolsPrompt.run();
305
+ } catch {
306
+ options.includeToolOutputs = true;
307
+ }
308
+ const includeTocPrompt = new Confirm({
309
+ name: "includeToc",
310
+ message: "Include table of contents?",
311
+ initial: false
312
+ });
313
+ try {
314
+ options.includeToc = await includeTocPrompt.run();
315
+ } catch {
316
+ options.includeToc = false;
317
+ }
318
+ }
319
+ const suggestedFilename = getSuggestedFilename(metadata2, format);
320
+ const filenamePrompt = new Input({
321
+ name: "filename",
322
+ message: "Save as:",
323
+ initial: suggestedFilename
324
+ });
325
+ let filename;
326
+ try {
327
+ filename = await filenamePrompt.run();
328
+ } catch {
329
+ console.log(chalk.gray("Cancelled."));
330
+ return;
331
+ }
332
+ let content;
333
+ switch (format) {
334
+ case "md":
335
+ content = exportToMarkdown(metadata2, messages, options);
336
+ break;
337
+ case "json":
338
+ content = exportToJson(metadata2, messages);
339
+ break;
340
+ case "html":
341
+ content = exportToHtml(metadata2, messages, options);
342
+ break;
343
+ }
344
+ const filePath = path2.isAbsolute(filename) ? filename : path2.join(workspaceRoot, filename);
345
+ try {
346
+ await saveExport(content, filePath);
347
+ console.log();
348
+ console.log(chalk.green("Session exported successfully!"));
349
+ console.log(chalk.cyan(` ${filePath}`));
350
+ console.log(chalk.gray(` ${messages.length} messages, ${(Buffer.byteLength(content, "utf8") / 1024).toFixed(1)} KB`));
351
+ console.log();
352
+ } catch (error) {
353
+ console.log(chalk.red(`Failed to save export: ${error.message}`));
354
+ }
355
+ }
356
+
357
+ export {
358
+ metadata,
359
+ execute
360
+ };
361
+ /**
362
+ * @license
363
+ * Copyright 2025 Autohand AI LLC
364
+ * SPDX-License-Identifier: Apache-2.0
365
+ *
366
+ * Session Export
367
+ * Export sessions to markdown and other formats
368
+ */
369
+ /**
370
+ * @license
371
+ * Copyright 2025 Autohand AI LLC
372
+ * SPDX-License-Identifier: Apache-2.0
373
+ */
@@ -0,0 +1,68 @@
1
+ // src/constants.ts
2
+ import os from "os";
3
+ import path from "path";
4
+ var AUTOHAND_HOME = process.env.AUTOHAND_HOME || path.join(os.homedir(), ".autohand");
5
+ var AUTOHAND_PATHS = {
6
+ /** Configuration files (config.json, config.yaml, config.yml) */
7
+ config: AUTOHAND_HOME,
8
+ /** Session data storage */
9
+ sessions: path.join(AUTOHAND_HOME, "sessions"),
10
+ /** Project knowledge base */
11
+ projects: path.join(AUTOHAND_HOME, "projects"),
12
+ /** User-level memory */
13
+ memory: path.join(AUTOHAND_HOME, "memory"),
14
+ /** Feedback state and responses */
15
+ feedback: path.join(AUTOHAND_HOME, "feedback"),
16
+ /** Telemetry data */
17
+ telemetry: path.join(AUTOHAND_HOME, "telemetry"),
18
+ /** Custom commands */
19
+ commands: path.join(AUTOHAND_HOME, "commands"),
20
+ /** Agent definitions */
21
+ agents: path.join(AUTOHAND_HOME, "agents"),
22
+ /** Custom tools */
23
+ tools: path.join(AUTOHAND_HOME, "tools")
24
+ };
25
+ var AUTOHAND_FILES = {
26
+ /** Main config file */
27
+ configJson: path.join(AUTOHAND_HOME, "config.json"),
28
+ configYaml: path.join(AUTOHAND_HOME, "config.yaml"),
29
+ configYml: path.join(AUTOHAND_HOME, "config.yml"),
30
+ /** Device ID for telemetry */
31
+ deviceId: path.join(AUTOHAND_HOME, "device-id"),
32
+ /** Error log */
33
+ errorLog: path.join(AUTOHAND_HOME, "error.log"),
34
+ /** Feedback log */
35
+ feedbackLog: path.join(AUTOHAND_HOME, "feedback.log"),
36
+ /** Telemetry queue */
37
+ telemetryQueue: path.join(AUTOHAND_PATHS.telemetry, "queue.json"),
38
+ /** Session sync queue */
39
+ sessionSyncQueue: path.join(AUTOHAND_PATHS.telemetry, "session-sync-queue.json")
40
+ };
41
+ var PROJECT_DIR_NAME = ".autohand";
42
+ var getAuthBaseUrl = () => process["env"]["AUTOHAND_API_URL"] || "https://autohand.ai";
43
+ var AUTH_CONFIG = {
44
+ get apiBaseUrl() {
45
+ return `${getAuthBaseUrl()}/api/auth`;
46
+ },
47
+ get authorizationUrl() {
48
+ return `${getAuthBaseUrl()}/cli-auth`;
49
+ },
50
+ pollInterval: 2e3,
51
+ authTimeout: 5 * 60 * 1e3,
52
+ sessionExpiryDays: 30
53
+ };
54
+
55
+ export {
56
+ AUTOHAND_HOME,
57
+ AUTOHAND_PATHS,
58
+ AUTOHAND_FILES,
59
+ PROJECT_DIR_NAME,
60
+ AUTH_CONFIG
61
+ };
62
+ /**
63
+ * @license
64
+ * Copyright 2025 Autohand AI LLC
65
+ * SPDX-License-Identifier: Apache-2.0
66
+ *
67
+ * Centralized constants for Autohand CLI
68
+ */