@agentuity/cli 0.0.17 → 0.0.19
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.
- package/AGENTS.md +0 -1
- package/dist/cmd/project/download.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/cmd/project/download.ts +38 -15
package/AGENTS.md
CHANGED
|
@@ -47,7 +47,6 @@ bin/
|
|
|
47
47
|
- **Type-safe options** - Always define interfaces for command options
|
|
48
48
|
- **Commander.js patterns** - Follow commander.js best practices
|
|
49
49
|
- **Async/await** - All I/O operations are async
|
|
50
|
-
- **Path aliases** - Use `@/` prefix for imports (e.g., `import { tui } from '@/tui'` instead of `../../tui`)
|
|
51
50
|
|
|
52
51
|
## Important Conventions
|
|
53
52
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../src/cmd/project/download.ts"],"names":[],"mappings":"
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { join, resolve } from 'node:path';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
existsSync,
|
|
4
|
+
mkdirSync,
|
|
5
|
+
mkdtempSync,
|
|
6
|
+
renameSync,
|
|
7
|
+
readdirSync,
|
|
8
|
+
cpSync,
|
|
9
|
+
rmSync,
|
|
10
|
+
createReadStream,
|
|
11
|
+
} from 'node:fs';
|
|
12
|
+
import { tmpdir } from 'node:os';
|
|
4
13
|
import { finished } from 'node:stream/promises';
|
|
5
14
|
import { createGunzip } from 'node:zlib';
|
|
6
15
|
import { extract, type Headers } from 'tar-fs';
|
|
@@ -69,8 +78,10 @@ export async function downloadTemplate(options: DownloadOptions): Promise<void>
|
|
|
69
78
|
const templatePath = `templates/${template.directory}`;
|
|
70
79
|
const url = `https://codeload.github.com/${GITHUB_REPO}/tar.gz/${branch}`;
|
|
71
80
|
const tempDir = mkdtempSync(join(tmpdir(), 'agentuity-'));
|
|
81
|
+
const tarballPath = join(tempDir, 'download.tar.gz');
|
|
72
82
|
|
|
73
83
|
try {
|
|
84
|
+
// Download tarball to temp file
|
|
74
85
|
await downloadWithSpinner(
|
|
75
86
|
{
|
|
76
87
|
url,
|
|
@@ -79,22 +90,34 @@ export async function downloadTemplate(options: DownloadOptions): Promise<void>
|
|
|
79
90
|
: 'Downloading template files...',
|
|
80
91
|
},
|
|
81
92
|
async (stream) => {
|
|
82
|
-
//
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return header;
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
stream.pipe(createGunzip()).pipe(extractor);
|
|
93
|
-
await finished(extractor);
|
|
93
|
+
// Write stream to file
|
|
94
|
+
const chunks: Buffer[] = [];
|
|
95
|
+
for await (const chunk of stream) {
|
|
96
|
+
chunks.push(Buffer.from(chunk));
|
|
97
|
+
}
|
|
98
|
+
await Bun.write(tarballPath, Buffer.concat(chunks));
|
|
94
99
|
}
|
|
95
100
|
);
|
|
96
101
|
|
|
97
|
-
|
|
102
|
+
// Extract tarball
|
|
103
|
+
const extractDir = join(tempDir, 'extract');
|
|
104
|
+
mkdirSync(extractDir, { recursive: true });
|
|
105
|
+
|
|
106
|
+
const prefix = `sdk-${branch}/${templatePath}/`;
|
|
107
|
+
const extractor = extract(extractDir, {
|
|
108
|
+
ignore: (name: string) => !name.startsWith(prefix) || name.length === prefix.length,
|
|
109
|
+
map: (header: Headers) => {
|
|
110
|
+
if (header.name.startsWith(prefix)) {
|
|
111
|
+
header.name = header.name.substring(prefix.length);
|
|
112
|
+
}
|
|
113
|
+
return header;
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
createReadStream(tarballPath).pipe(createGunzip()).pipe(extractor);
|
|
118
|
+
await finished(extractor);
|
|
119
|
+
|
|
120
|
+
await cleanup(extractDir, dest);
|
|
98
121
|
} finally {
|
|
99
122
|
// Clean up temp directory
|
|
100
123
|
rmSync(tempDir, { recursive: true, force: true });
|