@agentuity/cli 0.0.20 → 0.0.22
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../src/cmd/project/download.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD,UAAU,eAAe;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../src/cmd/project/download.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD,UAAU,eAAe;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,UAAU,YAAY;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CACf;AAsBD,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAyH9E;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-flow.d.ts","sourceRoot":"","sources":["../../../src/cmd/project/template-flow.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAM3C,UAAU,iBAAiB;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"template-flow.d.ts","sourceRoot":"","sources":["../../../src/cmd/project/template-flow.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAM3C,UAAU,iBAAiB;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2J7E"}
|
package/package.json
CHANGED
|
@@ -26,6 +26,7 @@ interface DownloadOptions {
|
|
|
26
26
|
template: TemplateInfo;
|
|
27
27
|
templateDir?: string;
|
|
28
28
|
templateBranch?: string;
|
|
29
|
+
logger: Logger;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
interface SetupOptions {
|
|
@@ -58,7 +59,7 @@ async function cleanup(sourceDir: string, dest: string) {
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
export async function downloadTemplate(options: DownloadOptions): Promise<void> {
|
|
61
|
-
const { dest, template, templateDir, templateBranch } = options;
|
|
62
|
+
const { dest, template, templateDir, templateBranch, logger } = options;
|
|
62
63
|
|
|
63
64
|
mkdirSync(dest, { recursive: true });
|
|
64
65
|
|
|
@@ -80,8 +81,15 @@ export async function downloadTemplate(options: DownloadOptions): Promise<void>
|
|
|
80
81
|
const tempDir = mkdtempSync(join(tmpdir(), 'agentuity-'));
|
|
81
82
|
const tarballPath = join(tempDir, 'download.tar.gz');
|
|
82
83
|
|
|
84
|
+
logger.debug('[download] URL:', url);
|
|
85
|
+
logger.debug('[download] Branch:', branch);
|
|
86
|
+
logger.debug('[download] Template path:', templatePath);
|
|
87
|
+
logger.debug('[download] Temp dir:', tempDir);
|
|
88
|
+
|
|
83
89
|
try {
|
|
84
|
-
// Download tarball to temp file
|
|
90
|
+
// Step 1: Download tarball to temp file
|
|
91
|
+
// We download to a file first rather than piping directly to tar-fs
|
|
92
|
+
// because this avoids Bun/Node stream compatibility issues
|
|
85
93
|
await downloadWithSpinner(
|
|
86
94
|
{
|
|
87
95
|
url,
|
|
@@ -90,39 +98,85 @@ export async function downloadTemplate(options: DownloadOptions): Promise<void>
|
|
|
90
98
|
: 'Downloading template files...',
|
|
91
99
|
},
|
|
92
100
|
async (stream) => {
|
|
93
|
-
//
|
|
101
|
+
// Collect all chunks from the download stream
|
|
94
102
|
const chunks: Buffer[] = [];
|
|
95
103
|
for await (const chunk of stream) {
|
|
96
104
|
chunks.push(Buffer.from(chunk));
|
|
97
105
|
}
|
|
98
|
-
|
|
106
|
+
const buffer = Buffer.concat(chunks);
|
|
107
|
+
await Bun.write(tarballPath, buffer);
|
|
108
|
+
|
|
109
|
+
logger.debug('[download] Downloaded bytes:', buffer.length);
|
|
110
|
+
logger.debug('[download] Tarball path:', tarballPath);
|
|
99
111
|
}
|
|
100
112
|
);
|
|
101
113
|
|
|
102
|
-
// Extract tarball
|
|
114
|
+
// Step 2: Extract tarball
|
|
115
|
+
// We extract only the files within the template directory
|
|
116
|
+
// The tarball structure is: sdk-{branch}/templates/{template.directory}/...
|
|
103
117
|
const extractDir = join(tempDir, 'extract');
|
|
104
118
|
mkdirSync(extractDir, { recursive: true });
|
|
105
119
|
|
|
106
120
|
const prefix = `sdk-${branch}/${templatePath}/`;
|
|
121
|
+
logger.debug('[extract] Extract dir:', extractDir);
|
|
122
|
+
logger.debug('[extract] Filter prefix:', prefix);
|
|
123
|
+
|
|
124
|
+
// Track extraction stats for debugging
|
|
125
|
+
let ignoredCount = 0;
|
|
126
|
+
let extractedCount = 0;
|
|
127
|
+
|
|
128
|
+
// Track which entries we've mapped so we don't ignore them later
|
|
129
|
+
// Note: tar-fs calls map BEFORE ignore (despite what docs say)
|
|
130
|
+
const mappedEntries = new Set<string>();
|
|
131
|
+
|
|
107
132
|
const extractor = extract(extractDir, {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return !header.name.startsWith(prefix) || header.name.length === prefix.length;
|
|
111
|
-
},
|
|
133
|
+
// map callback: called FIRST, allows modifying the entry before extraction
|
|
134
|
+
// We strip the prefix so files are extracted to the root of extractDir
|
|
112
135
|
map: (header: Headers) => {
|
|
113
|
-
|
|
136
|
+
const originalName = header.name;
|
|
137
|
+
if (header.name.startsWith(prefix) && header.name.length > prefix.length) {
|
|
138
|
+
// This is a file/dir we want to extract - strip the prefix
|
|
114
139
|
header.name = header.name.substring(prefix.length);
|
|
140
|
+
mappedEntries.add(header.name); // Track that we mapped this
|
|
141
|
+
logger.debug('[extract] MAP:', originalName, '->', header.name);
|
|
142
|
+
logger.debug('[extract] EXTRACT:', originalName);
|
|
143
|
+
extractedCount++;
|
|
115
144
|
}
|
|
116
145
|
return header;
|
|
117
146
|
},
|
|
147
|
+
// ignore callback: called AFTER map, receives the MAPPED name
|
|
148
|
+
// Return true to skip the entry, false to extract it
|
|
149
|
+
ignore: (name: string, header?: Headers) => {
|
|
150
|
+
if (!header) {
|
|
151
|
+
ignoredCount++;
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// If we already mapped this entry, don't ignore it
|
|
156
|
+
if (mappedEntries.has(header.name)) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Otherwise, ignore it
|
|
161
|
+
logger.debug('[extract] IGNORE:', header.name);
|
|
162
|
+
ignoredCount++;
|
|
163
|
+
return true;
|
|
164
|
+
},
|
|
118
165
|
});
|
|
119
166
|
|
|
167
|
+
// Pipe: tarball file -> gunzip -> tar extractor
|
|
120
168
|
createReadStream(tarballPath).pipe(createGunzip()).pipe(extractor);
|
|
121
169
|
await finished(extractor);
|
|
122
170
|
|
|
171
|
+
logger.debug('[extract] Extraction complete');
|
|
172
|
+
logger.debug('[extract] Ignored entries:', ignoredCount);
|
|
173
|
+
logger.debug('[extract] Extracted entries:', extractedCount);
|
|
174
|
+
|
|
175
|
+
// Step 3: Copy extracted files to destination
|
|
123
176
|
await cleanup(extractDir, dest);
|
|
124
177
|
} finally {
|
|
125
178
|
// Clean up temp directory
|
|
179
|
+
logger.debug('[cleanup] Removing temp dir:', tempDir);
|
|
126
180
|
rmSync(tempDir, { recursive: true, force: true });
|
|
127
181
|
}
|
|
128
182
|
}
|