@aqptech/aqp-lab-skill 0.0.0-stage → 0.1.0
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/README.md +71 -2
- package/bin/aqp-lab-skill.mjs +7 -0
- package/lib/installer.mjs +321 -0
- package/package.json +27 -4
- package/release-manifest.json +22 -0
package/README.md
CHANGED
|
@@ -1,3 +1,72 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AQP Lab Skill — verified npm installer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Native release availability:** The only publicly available native release is the
|
|
4
|
+
Windows x64 / CPython 3.11 developer-preview ZIP. The Apple Silicon M1 candidate
|
|
5
|
+
passed local native E2E but has not been uploaded to the official Release.
|
|
6
|
+
Linux and macOS Intel installs are blocked until separately verified binaries
|
|
7
|
+
are released.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npx @aqptech/aqp-lab-skill@latest install --agent opencode
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The installer writes one `aqp-lab` folder to the selected Agent's Skill
|
|
16
|
+
directory, **not** to the current working repository. The default is OpenCode:
|
|
17
|
+
`~/.config/opencode/skills/aqp-lab` on Windows/macOS/Linux. Other explicit
|
|
18
|
+
choices: `--agent codex`, `--agent claude`, `--agent cursor` or
|
|
19
|
+
`--agent generic` (the shared `~/.agents/skills` folder). You can override
|
|
20
|
+
all defaults with `--target /absolute/path/to/skills`. Targets must not
|
|
21
|
+
contain symlinks or junctions.
|
|
22
|
+
|
|
23
|
+
**Prerequisites:** Node.js 20+ and a working 64-bit CPython 3.11 environment
|
|
24
|
+
with the pinned dependencies from the Skill's `requirements.txt`. To use a
|
|
25
|
+
specific pre-existing Python interpreter, pass `--python /absolute/path/to/python`.
|
|
26
|
+
The installer runs the installed Skill's **real** `tools/verify` entrypoint.
|
|
27
|
+
It does **not** silently create environments, fetch Python, install pip
|
|
28
|
+
packages, change system PATH, or enable trading. If prerequisites are missing,
|
|
29
|
+
the installation fails without replacing the previous Skill. Use the
|
|
30
|
+
packaged `tools/setup` later only with separate explicit authorization.
|
|
31
|
+
|
|
32
|
+
## Safe behavior
|
|
33
|
+
|
|
34
|
+
- Platform selection is exact: Windows x64 / CPython 3.11 is the only
|
|
35
|
+
published target as of this manifest. macOS arm64 has a pinned
|
|
36
|
+
**local-QA-only** ZIP and requires an explicit `--archive` path to use.
|
|
37
|
+
No Linux/macOS Intel fallback to Windows binaries is permitted.
|
|
38
|
+
- A pinned official GitHub Release HTTPS URL and immutable ZIP SHA-256 are
|
|
39
|
+
enforced. A local `--archive /absolute/path/to/pinned.zip` is also hashed
|
|
40
|
+
against the same release manifest, not trusted by filename.
|
|
41
|
+
- Unpacks files into a randomly named staging directory, rejects ZIP traversal,
|
|
42
|
+
links, special files and unexpected entries, validates all 259 inner SHA-256
|
|
43
|
+
hashes, checks research-only and source identities, and runs the actual native
|
|
44
|
+
verifier before installing the Skill.
|
|
45
|
+
- An existing `aqp-lab` is left alone unless its identity and self-check match.
|
|
46
|
+
To replace it, explicitly add `--replace`; the prior directory is preserved
|
|
47
|
+
as a separate backup for rollback. No credentials or private keys are bundled.
|
|
48
|
+
- The output is a **research-only developer preview**, never authorization to
|
|
49
|
+
deploy a model, access a Broker, or place trades.
|
|
50
|
+
|
|
51
|
+
## Agent copy-paste prompt
|
|
52
|
+
|
|
53
|
+
> Install AQP Lab Skill into your own supported Skill folder using
|
|
54
|
+
> `npx @aqptech/aqp-lab-skill@latest install --agent opencode`.
|
|
55
|
+
> Do not bypass SHA-256 or source identity checks, use another OS's binary,
|
|
56
|
+
> overwrite an existing Skill, install dependencies without my permission, or
|
|
57
|
+
> enable live trading. Run the installed Skill's verification command and
|
|
58
|
+
> report the actual result, install path, release SHA and prerequisites.
|
|
59
|
+
> If my platform's official native ZIP is not released, stop and say BLOCKED.
|
|
60
|
+
|
|
61
|
+
## Package development
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
npm ci --ignore-scripts
|
|
65
|
+
npm test
|
|
66
|
+
npm pack --dry-run --json
|
|
67
|
+
node bin/aqp-lab-skill.mjs --help
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Publishing requires an authorized npm account with access to the
|
|
71
|
+
`@aqptech` scope and a separate public release/rollout decision.
|
|
72
|
+
A local `npm pack` is not a registry publication.
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { createReadStream, createWriteStream } from 'node:fs';
|
|
3
|
+
import * as fs from 'node:fs/promises';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { Readable, Transform } from 'node:stream';
|
|
8
|
+
import { pipeline } from 'node:stream/promises';
|
|
9
|
+
import { spawn } from 'node:child_process';
|
|
10
|
+
import yauzl from 'yauzl';
|
|
11
|
+
|
|
12
|
+
const manifestPath = fileURLToPath(new URL('../release-manifest.json', import.meta.url));
|
|
13
|
+
const MAX_ARCHIVE = 128 * 1024 * 1024;
|
|
14
|
+
const MAX_UNPACKED = 1024 * 1024 * 1024;
|
|
15
|
+
const MAX_ENTRY = 128 * 1024 * 1024;
|
|
16
|
+
const EXPECTED_FILES = 260;
|
|
17
|
+
const EXPECTED_NATIVE_MODULES = 227;
|
|
18
|
+
const AGENTS = Object.freeze({
|
|
19
|
+
opencode: ['.config', 'opencode', 'skills'],
|
|
20
|
+
codex: ['.codex', 'skills'],
|
|
21
|
+
claude: ['.claude', 'skills'],
|
|
22
|
+
cursor: ['.cursor', 'skills'],
|
|
23
|
+
generic: ['.agents', 'skills'],
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
function fail(reason) { throw new Error(reason); }
|
|
27
|
+
const sha256 = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
28
|
+
async function sha256File(file) {
|
|
29
|
+
const hash = createHash('sha256');
|
|
30
|
+
for await (const chunk of createReadStream(file)) hash.update(chunk);
|
|
31
|
+
return hash.digest('hex');
|
|
32
|
+
}
|
|
33
|
+
async function exists(p) {
|
|
34
|
+
try { await fs.lstat(p); return true; }
|
|
35
|
+
catch (e) { if (e.code === 'ENOENT') return false; throw e; }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Reject symbolic links/junctions in every existing ancestor, including the Skill root.
|
|
39
|
+
async function ensureOrdinaryDirectory(dir) {
|
|
40
|
+
const absolute = path.resolve(dir);
|
|
41
|
+
const { root } = path.parse(absolute);
|
|
42
|
+
let parent = root;
|
|
43
|
+
for (const part of absolute.slice(root.length).split(path.sep).filter(Boolean)) {
|
|
44
|
+
parent = path.join(parent, part);
|
|
45
|
+
try {
|
|
46
|
+
const stat = await fs.lstat(parent);
|
|
47
|
+
if (stat.isSymbolicLink() || !stat.isDirectory()) fail('Unsafe installation directory: ' + parent);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
if (e.code !== 'ENOENT') throw e;
|
|
50
|
+
await fs.mkdir(parent);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function chooseRelease(manifest, platform = process.platform, arch = process.arch, archive = false) {
|
|
56
|
+
const key = platform + '-' + arch;
|
|
57
|
+
const release = manifest.platforms?.[key];
|
|
58
|
+
if (!release) fail('No verified AQP Lab native release for ' + key + '. Refusing architecture fallback.');
|
|
59
|
+
if (release.state !== 'released' && !archive) {
|
|
60
|
+
fail('The ' + key + ' build is ' + release.state + ', not publicly released. A pinned local --archive is required.');
|
|
61
|
+
}
|
|
62
|
+
if (!/^[a-f0-9]{64}$/.test(release.sha256) || !/^[a-f0-9]{40}$/.test(release.labGitCommit)) {
|
|
63
|
+
fail('Invalid release identity pin');
|
|
64
|
+
}
|
|
65
|
+
if (release.state === 'released' && (!release.url || !release.url.startsWith('https://github.com/AlphaQuantPro/Alpha-Releases/releases/download/'))) {
|
|
66
|
+
fail('Unsupported release download origin');
|
|
67
|
+
}
|
|
68
|
+
return { ...release, key };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function safeZipName(name) {
|
|
72
|
+
if (typeof name !== 'string' || !name.startsWith('aqp-lab/') || name.endsWith('/') ||
|
|
73
|
+
name.includes('\\') || name.includes(':') || /[\u0000-\u001f\u007f]/.test(name)) {
|
|
74
|
+
fail('Untrusted ZIP path');
|
|
75
|
+
}
|
|
76
|
+
const components = name.split('/');
|
|
77
|
+
if (components.some((p) => !p || p === '.' || p === '..' || p.endsWith('.') || p.endsWith(' ') ||
|
|
78
|
+
/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\..*)?$/i.test(p))) {
|
|
79
|
+
fail('Untrusted ZIP path segments');
|
|
80
|
+
}
|
|
81
|
+
return components.slice(1).join('/');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function extractPinnedZip(zipPath, destination) {
|
|
85
|
+
const zip = await yauzl.openPromise(zipPath, {
|
|
86
|
+
lazyEntries: true, strictFileNames: true, validateEntrySizes: true,
|
|
87
|
+
});
|
|
88
|
+
let bytes = 0;
|
|
89
|
+
const names = new Set();
|
|
90
|
+
let files = 0;
|
|
91
|
+
try {
|
|
92
|
+
for await (const entry of zip.eachEntry()) {
|
|
93
|
+
const relative = safeZipName(entry.fileName);
|
|
94
|
+
const normalized = relative.normalize('NFC').toLowerCase();
|
|
95
|
+
if (names.has(normalized)) fail('Duplicate ZIP path: ' + relative);
|
|
96
|
+
names.add(normalized);
|
|
97
|
+
if (++files > EXPECTED_FILES) fail('Too many ZIP entries');
|
|
98
|
+
const fileMode = entry.externalFileAttributes >>> 16;
|
|
99
|
+
const fileType = fileMode & 0o170000;
|
|
100
|
+
if (fileType && fileType !== 0o100000) fail('ZIP links and special files are prohibited');
|
|
101
|
+
if (entry.compressionMethod !== 0 && entry.compressionMethod !== 8) fail('Unsupported ZIP compression');
|
|
102
|
+
if (entry.uncompressedSize > MAX_ENTRY || (bytes += entry.uncompressedSize) > MAX_UNPACKED) {
|
|
103
|
+
fail('ZIP extraction size limit exceeded');
|
|
104
|
+
}
|
|
105
|
+
const target = path.join(destination, ...relative.split('/'));
|
|
106
|
+
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
107
|
+
const stream = await zip.openReadStreamPromise(entry);
|
|
108
|
+
await pipeline(stream, createWriteStream(target, { flags: 'wx', mode: 0o600 }));
|
|
109
|
+
if (process.platform !== 'win32' &&
|
|
110
|
+
['aqp', 'tools/verify', 'tools/setup'].includes(relative)) {
|
|
111
|
+
await fs.chmod(target, 0o700);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
} finally { zip.close(); }
|
|
115
|
+
if (files !== EXPECTED_FILES) fail('Expected 260 ZIP files, got ' + files);
|
|
116
|
+
return files;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async function fileInventory(folder) {
|
|
120
|
+
const found = new Set();
|
|
121
|
+
async function traverse(dir, prefix = '') {
|
|
122
|
+
for (const entry of await fs.readdir(dir, { withFileTypes: true })) {
|
|
123
|
+
const rel = prefix ? prefix + '/' + entry.name : entry.name;
|
|
124
|
+
const real = path.join(dir, entry.name);
|
|
125
|
+
const stats = await fs.lstat(real);
|
|
126
|
+
if (stats.isSymbolicLink()) fail('Symlink found inside installed Skill');
|
|
127
|
+
if (stats.isDirectory()) await traverse(real, rel);
|
|
128
|
+
else if (stats.isFile()) found.add(rel);
|
|
129
|
+
else fail('Special file found inside Skill');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
await traverse(folder);
|
|
133
|
+
return found;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export async function verifyInstalled(folder, release) {
|
|
137
|
+
const present = await fileInventory(folder);
|
|
138
|
+
const raw = await fs.readFile(path.join(folder, 'package.json'));
|
|
139
|
+
if (raw.length > 1024 * 1024) fail('Unreasonably large Skill receipt');
|
|
140
|
+
const receipt = JSON.parse(raw.toString('utf8'));
|
|
141
|
+
if (receipt.schema !== 'aqp.research.skill_bundle.v2.native_compiled' ||
|
|
142
|
+
receipt.labGitCommit !== release.labGitCommit ||
|
|
143
|
+
(release.receiptPlatformTag === null ? receipt.platformTag !== undefined : receipt.platformTag !== release.platformTag) ||
|
|
144
|
+
receipt.compiledModules !== EXPECTED_NATIVE_MODULES ||
|
|
145
|
+
receipt.pythonAs2VmIncluded !== false ||
|
|
146
|
+
receipt.defaultAs2ComputeBackend !== 'rust_native' ||
|
|
147
|
+
receipt.researchOnly !== true || receipt.liveExecutionAllowed !== false) {
|
|
148
|
+
fail('Installed Skill release identity mismatch');
|
|
149
|
+
}
|
|
150
|
+
const hashes = receipt.filesSha256;
|
|
151
|
+
if (!hashes || typeof hashes !== 'object' || Array.isArray(hashes) ||
|
|
152
|
+
Object.keys(hashes).length !== 259) fail('Skill SHA-256 inventory incomplete');
|
|
153
|
+
const allowed = new Set(['package.json']);
|
|
154
|
+
for (const [relative, expected] of Object.entries(hashes)) {
|
|
155
|
+
safeZipName('aqp-lab/' + relative);
|
|
156
|
+
if (!/^[a-f0-9]{64}$/i.test(expected)) fail('Invalid file digest');
|
|
157
|
+
const name = relative.toLowerCase();
|
|
158
|
+
if (allowed.has(name)) fail('Duplicate case-insensitive receipt path');
|
|
159
|
+
allowed.add(name);
|
|
160
|
+
const actual = await sha256File(path.join(folder, ...relative.split('/')));
|
|
161
|
+
if (actual.toLowerCase() !== expected.toLowerCase()) fail('File digest mismatch: ' + relative);
|
|
162
|
+
}
|
|
163
|
+
if (present.size !== EXPECTED_FILES ||
|
|
164
|
+
[...present].some((name) => !allowed.has(name.toLowerCase()))) {
|
|
165
|
+
fail('Skill has missing or unexpected files');
|
|
166
|
+
}
|
|
167
|
+
return receipt;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async function saveArchive(release, output, supplied) {
|
|
171
|
+
if (supplied) {
|
|
172
|
+
const source = path.resolve(supplied);
|
|
173
|
+
const stat = await fs.lstat(source);
|
|
174
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > MAX_ARCHIVE) fail('Unsafe local archive');
|
|
175
|
+
await fs.copyFile(source, output, 0);
|
|
176
|
+
} else {
|
|
177
|
+
const response = await fetch(release.url, { signal: AbortSignal.timeout(300000) });
|
|
178
|
+
if (!response.ok || !response.body) fail('Release download failed: HTTP ' + response.status);
|
|
179
|
+
const location = new URL(response.url);
|
|
180
|
+
if (location.protocol !== 'https:' ||
|
|
181
|
+
!['github.com', 'release-assets.githubusercontent.com', 'objects.githubusercontent.com'].includes(location.hostname)) {
|
|
182
|
+
fail('Release redirected to an unapproved host');
|
|
183
|
+
}
|
|
184
|
+
if (Number(response.headers.get('content-length') || 0) > MAX_ARCHIVE) fail('Archive too large');
|
|
185
|
+
let received = 0;
|
|
186
|
+
const limiter = new Transform({
|
|
187
|
+
transform(chunk, _encoding, cb) {
|
|
188
|
+
received += chunk.length;
|
|
189
|
+
cb(received > MAX_ARCHIVE ? new Error('Archive download too large') : null, chunk);
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
await pipeline(Readable.fromWeb(response.body), limiter, createWriteStream(output, { flags: 'wx', mode: 0o600 }));
|
|
193
|
+
}
|
|
194
|
+
const actual = await sha256File(output);
|
|
195
|
+
if (actual !== release.sha256) fail('Downloaded ZIP SHA-256 differs from signed release pin');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function command(program, argv, cwd, extraEnv = {}) {
|
|
199
|
+
return new Promise((resolve, reject) => {
|
|
200
|
+
const proc = spawn(program, argv, {
|
|
201
|
+
cwd, windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'],
|
|
202
|
+
env: { ...process.env, ...extraEnv },
|
|
203
|
+
});
|
|
204
|
+
let output = '';
|
|
205
|
+
const add = (part) => { output = (output + part.toString()).slice(-6000); };
|
|
206
|
+
proc.stdout.on('data', add);
|
|
207
|
+
proc.stderr.on('data', add);
|
|
208
|
+
proc.on('error', reject);
|
|
209
|
+
proc.on('close', (code) => code === 0 ? resolve(output) :
|
|
210
|
+
reject(new Error(program + ' exited ' + code + ': ' + output.slice(-1000))));
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async function checkRuntime(folder, selectedPython, release) {
|
|
215
|
+
if (selectedPython && !path.isAbsolute(selectedPython)) {
|
|
216
|
+
fail('--python must be an absolute interpreter path');
|
|
217
|
+
}
|
|
218
|
+
const python = selectedPython || (process.platform === 'win32' ? 'python' : 'python3');
|
|
219
|
+
const code = 'import sys;sys.exit(0 if sys.version_info[:2]==(3,11) and sys.maxsize>2**32 else 1)';
|
|
220
|
+
await command(python, ['-I', '-B', '-c', code], folder);
|
|
221
|
+
const env = selectedPython ? {
|
|
222
|
+
PATH: path.dirname(selectedPython) + path.delimiter + (process.env.PATH || ''),
|
|
223
|
+
} : {};
|
|
224
|
+
if (release.platformTag === 'macos_arm64') {
|
|
225
|
+
const version = (await command('sw_vers', ['-productVersion'], folder)).trim();
|
|
226
|
+
if (Number(version.split('.')[0]) < 14) fail('macOS 14+ required by pinned ONNX Runtime');
|
|
227
|
+
}
|
|
228
|
+
if (process.platform === 'win32') {
|
|
229
|
+
const verifier = path.join(folder, 'tools', 'verify.cmd');
|
|
230
|
+
await command('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command',
|
|
231
|
+
"& '" + verifier.replaceAll("'", "''") + "'"], folder, env);
|
|
232
|
+
} else {
|
|
233
|
+
await command(path.join(folder, 'tools', 'verify'), [], folder, env);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function parseArgs(args) {
|
|
238
|
+
if (args.length === 0 || args[0] === 'help' || args.includes('--help') || args.includes('-h')) return { help: true };
|
|
239
|
+
if (args.shift() !== 'install') fail('Only "install" is supported');
|
|
240
|
+
const config = { agent: 'opencode', replace: false };
|
|
241
|
+
for (let i = 0; i < args.length; i++) {
|
|
242
|
+
const option = args[i];
|
|
243
|
+
if (option === '--replace') { config.replace = true; continue; }
|
|
244
|
+
if (!['--agent', '--target', '--archive', '--python'].includes(option)) fail('Unknown option: ' + option);
|
|
245
|
+
const value = args[++i];
|
|
246
|
+
if (!value || value.startsWith('--')) fail('Missing value for ' + option);
|
|
247
|
+
config[option.slice(2)] = value;
|
|
248
|
+
}
|
|
249
|
+
if (!AGENTS[config.agent]) fail('Unknown Agent: ' + config.agent);
|
|
250
|
+
return config;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export async function runCli(argv) {
|
|
254
|
+
const options = parseArgs([...argv]);
|
|
255
|
+
if (options.help) {
|
|
256
|
+
console.log(`AQP Lab Skill native installer (research-only)
|
|
257
|
+
Usage: aqp-lab-skill install [--agent opencode|codex|claude|cursor|generic]
|
|
258
|
+
[--target <absolute-skills-directory>] [--archive <pinned-zip>]
|
|
259
|
+
[--python <absolute-python-3.11>] [--replace]
|
|
260
|
+
Default Agent: opencode. No dependencies or Python versions are installed automatically.
|
|
261
|
+
Platforms without a verified released ZIP fail closed; existing Skills are never overwritten without --replace.`);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (options.target && !path.isAbsolute(options.target)) fail('--target must be an absolute directory');
|
|
265
|
+
const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
|
|
266
|
+
if (manifest.schema !== 'aqp.lab.npm.release-manifest.v1') fail('Unrecognized installer manifest');
|
|
267
|
+
const release = chooseRelease(manifest, process.platform, process.arch, Boolean(options.archive));
|
|
268
|
+
const root = options.target || path.join(os.homedir(), ...AGENTS[options.agent]);
|
|
269
|
+
await ensureOrdinaryDirectory(root);
|
|
270
|
+
const target = path.join(root, 'aqp-lab');
|
|
271
|
+
const stageParent = await fs.mkdtemp(path.join(root, '.aqp-lab-stage-'));
|
|
272
|
+
const staged = path.join(stageParent, 'aqp-lab');
|
|
273
|
+
let backup = null;
|
|
274
|
+
let moved = false;
|
|
275
|
+
try {
|
|
276
|
+
if (await exists(target)) {
|
|
277
|
+
const stat = await fs.lstat(target);
|
|
278
|
+
if (stat.isSymbolicLink() || !stat.isDirectory()) fail('Unsafe existing Skill target');
|
|
279
|
+
if (!options.replace) {
|
|
280
|
+
try {
|
|
281
|
+
await verifyInstalled(target, release);
|
|
282
|
+
await checkRuntime(target, options.python, release);
|
|
283
|
+
console.log('AQP_LAB_ALREADY_INSTALLED:', target);
|
|
284
|
+
return;
|
|
285
|
+
} catch {
|
|
286
|
+
fail('Existing Skill differs or failed verification. Refusing overwrite (use --replace to preserve a backup).');
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
await saveArchive(release, path.join(stageParent, 'release.zip'), options.archive);
|
|
291
|
+
await fs.mkdir(staged);
|
|
292
|
+
await extractPinnedZip(path.join(stageParent, 'release.zip'), staged);
|
|
293
|
+
await verifyInstalled(staged, release);
|
|
294
|
+
await checkRuntime(staged, options.python, release);
|
|
295
|
+
if (await exists(target)) {
|
|
296
|
+
backup = path.join(root, 'aqp-lab.backup-' + randomUUID());
|
|
297
|
+
await fs.rename(target, backup);
|
|
298
|
+
}
|
|
299
|
+
try {
|
|
300
|
+
await fs.rename(staged, target);
|
|
301
|
+
moved = true;
|
|
302
|
+
// The final path may differ from the staging path; verify after relocation.
|
|
303
|
+
await checkRuntime(target, options.python, release);
|
|
304
|
+
} catch (error) {
|
|
305
|
+
if (moved && await exists(target)) {
|
|
306
|
+
await fs.rename(target, staged);
|
|
307
|
+
moved = false;
|
|
308
|
+
}
|
|
309
|
+
if (backup && await exists(backup)) await fs.rename(backup, target);
|
|
310
|
+
throw error;
|
|
311
|
+
}
|
|
312
|
+
console.log('AQP_LAB_INSTALLED:', target);
|
|
313
|
+
console.log('SOURCE_COMMIT:', release.labGitCommit);
|
|
314
|
+
if (backup) console.log('PREVIOUS_VERSION_BACKUP:', backup);
|
|
315
|
+
} finally {
|
|
316
|
+
if (!moved && backup && !(await exists(target)) && await exists(backup)) {
|
|
317
|
+
await fs.rename(backup, target);
|
|
318
|
+
}
|
|
319
|
+
await fs.rm(stageParent, { recursive: true, force: true });
|
|
320
|
+
}
|
|
321
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aqptech/aqp-lab-skill",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Verified native AQP Lab Skill installer (research-only)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=20.0.0"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"aqp-lab-skill": "./bin/aqp-lab-skill.mjs"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"bin/",
|
|
15
|
+
"lib/",
|
|
16
|
+
"release-manifest.json",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"test": "node --test",
|
|
21
|
+
"check": "node --check ./bin/aqp-lab-skill.mjs && node --check ./lib/installer.mjs"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"yauzl": "3.4.0"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "aqp.lab.npm.release-manifest.v1",
|
|
3
|
+
"platforms": {
|
|
4
|
+
"win32-x64": {
|
|
5
|
+
"state": "released",
|
|
6
|
+
"asset": "AQP_Lab_Skill_Windows_x64_2026-11-18.zip",
|
|
7
|
+
"url": "https://github.com/AlphaQuantPro/Alpha-Releases/releases/download/aqp-lab-skill-2026.11.18/AQP_Lab_Skill_Windows_x64_2026-11-18.zip",
|
|
8
|
+
"sha256": "e2037d970ef8ce664b144e869ec9d562058ee3b9f99ed82733f0224e84676ec6",
|
|
9
|
+
"labGitCommit": "a6860bea20addd1806e11506e7c01f9913d22e96",
|
|
10
|
+
"platformTag": "win_amd64",
|
|
11
|
+
"receiptPlatformTag": null
|
|
12
|
+
},
|
|
13
|
+
"darwin-arm64": {
|
|
14
|
+
"state": "local-qa-only",
|
|
15
|
+
"asset": "aqp-lab-macos-arm64-m1-qa-20261125-factory-fix.zip",
|
|
16
|
+
"url": null,
|
|
17
|
+
"sha256": "f433a6acca2b780cf6d3233567fe5eac97f7f74a68ffc009df7cf86cb1d6e682",
|
|
18
|
+
"labGitCommit": "5c1ae8ae7583b9f671944fb5d9638b19ee9d815a",
|
|
19
|
+
"platformTag": "macos_arm64"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|