@agentuity/cli 0.0.20 → 0.0.21
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,CAsH9E;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,82 @@ 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
|
+
|
|
107
128
|
const extractor = extract(extractDir, {
|
|
129
|
+
// ignore callback: called BEFORE map, receives original tar entry name in header.name
|
|
130
|
+
// Return true to skip the entry, false to extract it
|
|
108
131
|
ignore: (_name: string, header?: Headers) => {
|
|
109
|
-
if (!header)
|
|
110
|
-
|
|
132
|
+
if (!header) {
|
|
133
|
+
ignoredCount++;
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Skip entries that don't start with our prefix
|
|
138
|
+
// Also skip the exact prefix directory itself (empty name after substring)
|
|
139
|
+
const shouldIgnore =
|
|
140
|
+
!header.name.startsWith(prefix) || header.name.length === prefix.length;
|
|
141
|
+
|
|
142
|
+
if (shouldIgnore) {
|
|
143
|
+
logger.debug('[extract] IGNORE:', header.name);
|
|
144
|
+
ignoredCount++;
|
|
145
|
+
} else {
|
|
146
|
+
logger.debug('[extract] EXTRACT:', header.name);
|
|
147
|
+
extractedCount++;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return shouldIgnore;
|
|
111
151
|
},
|
|
152
|
+
// map callback: called AFTER ignore, allows modifying the entry before extraction
|
|
153
|
+
// We strip the prefix so files are extracted to the root of extractDir
|
|
112
154
|
map: (header: Headers) => {
|
|
113
155
|
if (header.name.startsWith(prefix)) {
|
|
156
|
+
const originalName = header.name;
|
|
114
157
|
header.name = header.name.substring(prefix.length);
|
|
158
|
+
logger.debug('[extract] MAP:', originalName, '->', header.name);
|
|
115
159
|
}
|
|
116
160
|
return header;
|
|
117
161
|
},
|
|
118
162
|
});
|
|
119
163
|
|
|
164
|
+
// Pipe: tarball file -> gunzip -> tar extractor
|
|
120
165
|
createReadStream(tarballPath).pipe(createGunzip()).pipe(extractor);
|
|
121
166
|
await finished(extractor);
|
|
122
167
|
|
|
168
|
+
logger.debug('[extract] Extraction complete');
|
|
169
|
+
logger.debug('[extract] Ignored entries:', ignoredCount);
|
|
170
|
+
logger.debug('[extract] Extracted entries:', extractedCount);
|
|
171
|
+
|
|
172
|
+
// Step 3: Copy extracted files to destination
|
|
123
173
|
await cleanup(extractDir, dest);
|
|
124
174
|
} finally {
|
|
125
175
|
// Clean up temp directory
|
|
176
|
+
logger.debug('[cleanup] Removing temp dir:', tempDir);
|
|
126
177
|
rmSync(tempDir, { recursive: true, force: true });
|
|
127
178
|
}
|
|
128
179
|
}
|