@agentuity/cli 0.0.19 → 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.
@@ -5,6 +5,7 @@ interface DownloadOptions {
5
5
  template: TemplateInfo;
6
6
  templateDir?: string;
7
7
  templateBranch?: string;
8
+ logger: Logger;
8
9
  }
9
10
  interface SetupOptions {
10
11
  dest: string;
@@ -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;CACxB;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,CAiE9E;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCvE"}
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,CA0J7E"}
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentuity/cli",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./dist/index.d.ts",
@@ -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,36 +98,82 @@ export async function downloadTemplate(options: DownloadOptions): Promise<void>
90
98
  : 'Downloading template files...',
91
99
  },
92
100
  async (stream) => {
93
- // Write stream to file
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
- await Bun.write(tarballPath, Buffer.concat(chunks));
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, {
108
- ignore: (name: string) => !name.startsWith(prefix) || name.length === prefix.length,
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
131
+ ignore: (_name: string, header?: Headers) => {
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;
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
109
154
  map: (header: Headers) => {
110
155
  if (header.name.startsWith(prefix)) {
156
+ const originalName = header.name;
111
157
  header.name = header.name.substring(prefix.length);
158
+ logger.debug('[extract] MAP:', originalName, '->', header.name);
112
159
  }
113
160
  return header;
114
161
  },
115
162
  });
116
163
 
164
+ // Pipe: tarball file -> gunzip -> tar extractor
117
165
  createReadStream(tarballPath).pipe(createGunzip()).pipe(extractor);
118
166
  await finished(extractor);
119
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
120
173
  await cleanup(extractDir, dest);
121
174
  } finally {
122
175
  // Clean up temp directory
176
+ logger.debug('[cleanup] Removing temp dir:', tempDir);
123
177
  rmSync(tempDir, { recursive: true, force: true });
124
178
  }
125
179
  }
@@ -151,6 +151,7 @@ export async function runCreateFlow(options: CreateFlowOptions): Promise<void> {
151
151
  template: selectedTemplate,
152
152
  templateDir,
153
153
  templateBranch,
154
+ logger,
154
155
  });
155
156
 
156
157
  // Step 7: Setup project (replace placeholders, install deps, build)