vini-ds 0.1.0-alpha.2 → 0.1.0-alpha.4
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 +9 -3
- package/cli.mjs +145 -48
- package/package.json +11 -13
package/README.md
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
# VINi CLI
|
|
2
2
|
|
|
3
|
-
Connect with `npx vini-ds init`. This is a public alpha, 0.1.0-alpha.
|
|
3
|
+
Connect with `npx vini-ds init`. This is a public alpha, 0.1.0-alpha.4; it supports the bounded setup described below. For a reproducible installation, use the exact version.
|
|
4
4
|
|
|
5
|
-
Preview: `npx vini-ds@0.1.0-alpha.
|
|
5
|
+
Preview: `npx vini-ds@0.1.0-alpha.4 init --plan`. Connect: `npx vini-ds@0.1.0-alpha.4 init`.
|
|
6
6
|
|
|
7
7
|
Requires an existing React 18/Vite project and Node 20+. Detects npm or pnpm; configures CSS, ThemeBrandProvider and project-local Codex MCP/Skill. Does not change global Codex settings or project trust. This alpha supports the direct createRoot(...).render(JSX) entry form; use --entry for an explicit supported entry. New desktop Codex session discovery is a separate check.
|
|
8
8
|
|
|
9
|
-
Check an existing project with `npx vini-ds@latest status` (or `status --json`). A registry error means the available version is unknown. Review the suggested exact version with `npx vini-ds@0.1.0-alpha.
|
|
9
|
+
Check an existing project with `npx vini-ds@latest status` (or `status --json`). A registry error means the available version is unknown. Review the suggested exact version with `npx vini-ds@0.1.0-alpha.4 update --plan`. For the name migration, complete the manual review below and use --imports-migrated; other updates use the same command without --plan. Identify the dev or preview server serving the original application URL. If it still serves old assets, update or restart only that server when its ownership and authorization are clear; otherwise ask its owner. Reload the same URL and exercise the affected component; never terminate an unidentified process. Reconnect the project-local VINi MCP in the current client and read `vini://system/current`, the affected component contract, and `check_updates` there. A separate STDIO process does not verify the current client. Treat package installation, the application page, and the current MCP client as separate results. Update creates a recovery backup; if installation fails, inspect the reported recovery path before retrying. Previously installed private-GitHub Kits need an explicit migration and are not overwritten.
|
|
10
|
+
|
|
11
|
+
## Migrating existing projects to @vini-ds
|
|
12
|
+
|
|
13
|
+
Confirm the exact new CLI and all three packages are actually published before migrating. For a CLI-managed installation, run `npx vini-ds@0.1.0-alpha.4 update --plan` and review the existing receipt and planned dependency changes. Save the project state and manually review and replace every old `@vini/*` or `@timelex/vini-*` import, CSS path, configuration and other reference with the appropriate `@vini-ds/*` name. The CLI does not rewrite arbitrary project sources. Once that review is complete, run `npx vini-ds@0.1.0-alpha.4 update --imports-migrated`; the flag records your review, not proof of it. The CLI validates the entry, avoids an extra provider and replaces the managed dependencies without aliases. Check the build, lockfile and affected application scenario, then reconnect and verify the actual MCP client.
|
|
14
|
+
|
|
15
|
+
Older CLI or MCP instances may report the changed release as unknown after a future latest change; unknown is not proof that no update exists. Use the exact new CLI and reconnect the existing client. Direct unmanaged dependencies require a separate reviewed manual migration: remove old declarations after reviewing the project, then inspect `init --plan` before installing. No automatic edits to arbitrary project files are performed.
|
package/cli.mjs
CHANGED
|
@@ -2,19 +2,32 @@
|
|
|
2
2
|
import { promises as fs } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { createHash, randomUUID } from 'node:crypto';
|
|
5
|
-
import { createRequire } from 'node:module';
|
|
6
5
|
import { fileURLToPath } from 'node:url';
|
|
7
|
-
import { isDeepStrictEqual } from 'node:util';
|
|
8
|
-
import { spawn } from 'node:child_process';
|
|
6
|
+
import { isDeepStrictEqual, promisify } from 'node:util';
|
|
7
|
+
import { execFile, spawn } from 'node:child_process';
|
|
9
8
|
import ts from 'typescript';
|
|
10
9
|
|
|
11
10
|
const self=fileURLToPath(import.meta.url);
|
|
11
|
+
const execFileAsync=promisify(execFile);
|
|
12
12
|
const digest=value=>createHash('sha256').update(value).digest('hex');
|
|
13
13
|
const fail=message=>{throw new Error(`VINi: ${message}`);};
|
|
14
14
|
const exists=async file=>fs.lstat(file).catch(error=>{if(error.code==='ENOENT')return null;throw error;});
|
|
15
|
-
const
|
|
15
|
+
const legacyPackages={ui:'@timelex/vini-ui',tokens:'@timelex/vini-tokens',agent:'@timelex/vini-agent'};
|
|
16
|
+
const nativeDsPackages={ui:'@vini-ds/ui',tokens:'@vini-ds/tokens',agent:'@vini-ds/agent'};
|
|
17
|
+
const packageKeys=['ui','tokens','agent'];
|
|
18
|
+
const isNativeDs=distribution=>!!distribution&&packageKeys.every(key=>distribution[key]===nativeDsPackages[key]);
|
|
19
|
+
const localNames=distribution=>Object.fromEntries(packageKeys.map(key=>[key,isNativeDs(distribution)?nativeDsPackages[key]:`@vini/${key}`]));
|
|
20
|
+
const packageSpec=(distribution,key)=>distribution[key]===localNames(distribution)[key]?distribution.version:`npm:${distribution[key]}@${distribution.version}`;
|
|
21
|
+
function validateNativeManifest(info,key,distribution){
|
|
22
|
+
if(!isNativeDs(distribution))return;
|
|
23
|
+
if(['dependencies','devDependencies','peerDependencies','optionalDependencies'].some(section=>Object.values(info[section]??{}).some(value=>typeof value==='string'&&/^npm:/u.test(value.trim()))))throw new Error(`${key} native package metadata contains an npm alias`);
|
|
24
|
+
if(key==='ui'){
|
|
25
|
+
const name=distribution.tokens,dep=info.dependencies?.[name],peer=info.peerDependencies?.[name];
|
|
26
|
+
if(['dependencies','devDependencies','peerDependencies','optionalDependencies','peerDependenciesMeta'].some(section=>Object.hasOwn(info[section]??{},'@vini/tokens'))||peer!==distribution.version||(dep!==undefined&&dep!==distribution.version)||Object.hasOwn(info.optionalDependencies??{},name)||info.peerDependenciesMeta?.[name]?.optional===true)throw new Error('native UI token dependency does not match the release');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
16
29
|
const pointer='<!-- BEGIN:vini-npm -->\nFor VINi interface work, use `.agents/skills/vini-ds/SKILL.md` and the project-local `vini-ds` MCP server.\n<!-- END:vini-npm -->';
|
|
17
|
-
const usage='vini init|update [--plan] | status [--json] [--cwd PROJECT] [--app-root APP] [--entry src/main.tsx] [--package-manager npm|pnpm] [--registry HTTPS_URL]';
|
|
30
|
+
const usage='vini init|update [--plan] [--imports-migrated] | status [--json] [--cwd PROJECT] [--app-root APP] [--entry src/main.tsx] [--package-manager npm|pnpm] [--registry HTTPS_URL]';
|
|
18
31
|
|
|
19
32
|
export function parseArgs(args) {
|
|
20
33
|
if(args.length===1&&['--help','-h'].includes(args[0]))return {help:true};
|
|
@@ -24,10 +37,12 @@ export function parseArgs(args) {
|
|
|
24
37
|
for(let i=1;i<args.length;i++) {
|
|
25
38
|
if(args[i]==='--plan'){if(options.plan)fail('duplicate --plan');options.plan=true;continue;}
|
|
26
39
|
if(args[i]==='--json'){if(options.json)fail('duplicate --json');options.json=true;continue;}
|
|
40
|
+
if(args[i]==='--imports-migrated'){if(options.importsMigrated)fail('duplicate --imports-migrated');options.importsMigrated=true;continue;}
|
|
27
41
|
const key=names[args[i]];if(!key||options[key]||!args[i+1]||args[i+1].startsWith('--'))fail(usage);options[key]=args[++i];
|
|
28
42
|
}
|
|
29
43
|
if(options.packageManager&&!['npm','pnpm'].includes(options.packageManager))fail('only npm and pnpm are supported');
|
|
30
44
|
if(options.json&&options.command!=='status')fail('--json is supported by status');
|
|
45
|
+
if(options.importsMigrated&&options.command!=='update')fail('--imports-migrated is supported by update');
|
|
31
46
|
if(options.command==='status'&&(options.plan||options.entry||options.packageManager))fail(usage);
|
|
32
47
|
if(options.registry){const url=new URL(options.registry);if(url.username||url.password||url.search||url.hash||(url.protocol!=='https:'&&!(url.protocol==='http:'&&['localhost','127.0.0.1','[::1]'].includes(url.hostname))))fail('registry must use HTTPS (HTTP localhost is allowed for testing)');}
|
|
33
48
|
return options;
|
|
@@ -49,22 +64,30 @@ function distributionCheck(value) {
|
|
|
49
64
|
for(const key of ['ui','tokens','agent'])if(!/^@[a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9-]*$/.test(value[key]??''))fail(`invalid distribution ${key}`);
|
|
50
65
|
return value;
|
|
51
66
|
}
|
|
67
|
+
function familyTransition(from,to) {
|
|
68
|
+
const keys=['ui','tokens','agent'];
|
|
69
|
+
if(keys.every(key=>from[key]===to[key]))return 'same';
|
|
70
|
+
if(keys.every(key=>from[key]===legacyPackages[key]&&to[key]===`@vini/${key}`)&&compareVersions(to.version,from.version)>0)return 'legacy-to-native';
|
|
71
|
+
if(isNativeDs(to)&&(keys.every(key=>from[key]===legacyPackages[key])||keys.every(key=>from[key]===`@vini/${key}`))&&compareVersions(to.version,from.version)>0)return 'manual-import-migration';
|
|
72
|
+
return 'unsupported';
|
|
73
|
+
}
|
|
52
74
|
export function transformEntry(source,file='main.tsx',distribution) {
|
|
53
75
|
if(source.startsWith('\uFEFF'))fail('entry has a BOM; review it manually');
|
|
54
76
|
const ast=ts.createSourceFile(file,source,ts.ScriptTarget.Latest,true,ts.ScriptKind.TSX);
|
|
55
77
|
if(ast.parseDiagnostics.length)fail('entry has syntax errors');
|
|
78
|
+
const local=localNames(distribution),css=[`${local.tokens}/fonts.css`,`${local.tokens}/themes.css`,`${local.tokens}/typography.css`,`${local.ui}/styles.css`];
|
|
56
79
|
const rootNames=new Set(),rootNamespaces=new Set(),providers=new Set(),imports=new Set();
|
|
57
80
|
for(const statement of ast.statements)if(ts.isImportDeclaration(statement)&&ts.isStringLiteral(statement.moduleSpecifier)) {
|
|
58
81
|
const module=statement.moduleSpecifier.text;imports.add(module);
|
|
59
|
-
if(distribution)for(const key of
|
|
82
|
+
if(distribution)for(const key of packageKeys)for(const published of new Set([distribution[key],legacyPackages[key],`@vini/${key}`,nativeDsPackages[key]])){if(published!==local[key]&&(module===published||module.startsWith(published+'/')))fail(`direct ${published} import requires an explicit manual-to-CLI migration; use one package identity`);}
|
|
60
83
|
const clause=statement.importClause,bindings=clause?.namedBindings;
|
|
61
84
|
if(module==='react-dom/client') {
|
|
62
85
|
if(clause?.name)rootNamespaces.add(clause.name.text);
|
|
63
86
|
if(bindings&&ts.isNamespaceImport(bindings))rootNamespaces.add(bindings.name.text);
|
|
64
87
|
if(bindings&&ts.isNamedImports(bindings))for(const item of bindings.elements)if((item.propertyName?.text??item.name.text)==='createRoot')rootNames.add(item.name.text);
|
|
65
88
|
}
|
|
66
|
-
if(module===
|
|
67
|
-
if(module===
|
|
89
|
+
if(module===local.ui&&bindings&&ts.isNamedImports(bindings))for(const item of bindings.elements)if((item.propertyName?.text??item.name.text)==='ThemeBrandProvider')providers.add(item.name.text);
|
|
90
|
+
if(module===local.ui&&bindings&&ts.isNamespaceImport(bindings))providers.add(`${bindings.name.text}.ThemeBrandProvider`);
|
|
68
91
|
}
|
|
69
92
|
const renders=[];
|
|
70
93
|
const isCreate=expression=>ts.isCallExpression(expression)&&(ts.isIdentifier(expression.expression)?rootNames.has(expression.expression.text):ts.isPropertyAccessExpression(expression.expression)&&ts.isIdentifier(expression.expression.expression)&&rootNamespaces.has(expression.expression.expression.text)&&expression.expression.name.text==='createRoot');
|
|
@@ -76,7 +99,7 @@ export function transformEntry(source,file='main.tsx',distribution) {
|
|
|
76
99
|
const found=[];function findProvider(node){if(ts.isJsxElement(node)&&providers.has(node.openingElement.tagName.getText(ast)))found.push(node);ts.forEachChild(node,findProvider);}findProvider(jsx);
|
|
77
100
|
let result=source;const prepend=css.filter(item=>!imports.has(item)).map(item=>`import ${JSON.stringify(item)};`);
|
|
78
101
|
if(found.length>1)fail('multiple ThemeBrandProvider scopes require manual setup');
|
|
79
|
-
if(!found.length){let alias='ViniThemeBrandProvider';while(new RegExp(`\\b${alias}\\b`).test(source))alias+='Root';prepend.push(`import { ThemeBrandProvider as ${alias} } from "
|
|
102
|
+
if(!found.length){let alias='ViniThemeBrandProvider';while(new RegExp(`\\b${alias}\\b`).test(source))alias+='Root';prepend.push(`import { ThemeBrandProvider as ${alias} } from "${local.ui}";`);const wrapped=`<${alias} theme="light" brand="vini" colorway="blue" typographyScope="desktop">{${argument.getText(ast)}}</${alias}>`;result=source.slice(0,argument.getStart(ast))+wrapped+source.slice(argument.end);}
|
|
80
103
|
else if(found[0]!==jsx){
|
|
81
104
|
// A provider directly inside StrictMode/Fragment still covers the whole app.
|
|
82
105
|
const outer=ts.isJsxElement(jsx)?jsx.children:ts.isJsxFragment(jsx)?jsx.children:[];
|
|
@@ -101,21 +124,41 @@ function agentsMerge(source) {
|
|
|
101
124
|
if(source.includes('<!-- BEGIN:vini-npm -->')||source.includes('<!-- END:vini-npm -->')){if(source.split('<!-- BEGIN:vini-npm -->').length!==2||source.split('<!-- END:vini-npm -->').length!==2||!source.includes(pointer))fail('modified VINi npm instructions need manual merge');return source;}
|
|
102
125
|
return source+(source&&!source.endsWith('\n')?'\n':'')+(source?'\n':'')+pointer+'\n';
|
|
103
126
|
}
|
|
104
|
-
export async function run(executable,args,{cwd,timeout=600000,env=process.env}={}) {
|
|
127
|
+
export async function run(executable,args,{cwd,timeout=600000,env=process.env,stdoutOnly=false}={}) {
|
|
105
128
|
return new Promise((resolve,reject)=>{
|
|
106
|
-
const child=spawn(executable,args,{cwd,env,shell:false,stdio:['ignore','pipe','pipe'],detached:process.platform!=='win32'});let output='',done=false,timed=false,killTimer;
|
|
107
|
-
const finish=error=>{if(done)return;done=true;clearTimeout(timer);clearTimeout(killTimer);error?reject(error):resolve(output);};
|
|
129
|
+
const child=spawn(executable,args,{cwd,env,shell:false,stdio:['ignore','pipe','pipe'],detached:process.platform!=='win32'});let output='',stdout='',done=false,timed=false,killTimer;
|
|
130
|
+
const finish=error=>{if(done)return;done=true;clearTimeout(timer);clearTimeout(killTimer);error?reject(error):resolve(stdoutOnly?stdout:output);};
|
|
108
131
|
const timer=setTimeout(()=>{timed=true;try{if(process.platform!=='win32')process.kill(-child.pid,'SIGTERM');else child.kill('SIGTERM');}catch{}killTimer=setTimeout(()=>{try{if(process.platform!=='win32')process.kill(-child.pid,'SIGKILL');else child.kill('SIGKILL');}catch{}const error=new Error(`${executable} timed out; preserve recovery before retrying`);error.uncertainChildren=true;finish(error);},1000);},timeout);
|
|
109
|
-
|
|
132
|
+
child.stdout.on('data',buf=>{const value=buf.toString();stdout=(stdout+value).slice(-16000);output=(output+value).slice(-16000);});
|
|
133
|
+
child.stderr.on('data',buf=>{output=(output+buf.toString()).slice(-16000);});
|
|
110
134
|
child.on('error',error=>finish(error));child.on('close',code=>{if(timed)return;finish(code===0?null:new Error(`${executable} exited ${code}:\n${output}`));});
|
|
111
135
|
});
|
|
112
136
|
}
|
|
113
|
-
async function
|
|
114
|
-
const
|
|
137
|
+
async function projectModuleEntry(app,entry) {
|
|
138
|
+
const modules=path.join(app,'node_modules'),stat=await exists(modules);
|
|
139
|
+
if(!stat||stat.isSymbolicLink()||!stat.isDirectory())fail('node_modules must be a real project directory');
|
|
140
|
+
const root=await fs.realpath(modules),resolved=await fs.realpath(entry);
|
|
141
|
+
if(!resolved.startsWith(root+path.sep))fail('installed package resolves outside project node_modules');
|
|
142
|
+
return resolved;
|
|
143
|
+
}
|
|
144
|
+
async function manifestForEntry(resolved,name,app) {
|
|
145
|
+
resolved=await projectModuleEntry(app,resolved);let dir=path.dirname(resolved);
|
|
115
146
|
while(true){const file=path.join(dir,'package.json');if(await exists(file)){const value=json(await fileBytes(file),file);if(value.name&&value.version)return {root:dir,manifest:value,entry:resolved};}const parent=path.dirname(dir);if(parent===dir)fail(`cannot find package metadata: ${name}`);dir=parent;}
|
|
116
147
|
}
|
|
148
|
+
// Node caches resolved pnpm symlink targets in-process. A completed install may
|
|
149
|
+
// replace those symlinks, so inspect the new installation in a fresh process.
|
|
150
|
+
async function freshResolveMaybe(manifest,names,cwd) {
|
|
151
|
+
const script='const {createRequire}=require("node:module");const req=createRequire(process.argv[1]);process.stdout.write(JSON.stringify(JSON.parse(process.argv[2]).map(name=>{try{return {path:req.resolve(name)}}catch(error){return {error:error.code||"unknown"}}})));';
|
|
152
|
+
let output;try{({stdout:output}=await execFileAsync(process.execPath,['-e',script,manifest,JSON.stringify(names)],{cwd,timeout:10000,maxBuffer:1024*1024,encoding:'utf8'}));}catch(error){fail(`fresh package resolution failed (${error.code??'unknown'})`);}
|
|
153
|
+
const entries=JSON.parse(output);if(!Array.isArray(entries)||entries.length!==names.length||!entries.every(value=>value&&((typeof value.path==='string'&&path.isAbsolute(value.path)&&value.error===undefined)||(typeof value.error==='string'&&value.path===undefined))))fail('fresh package resolution returned invalid paths');return entries;
|
|
154
|
+
}
|
|
155
|
+
async function freshResolve(manifest,names,cwd) {
|
|
156
|
+
const entries=await freshResolveMaybe(manifest,names,cwd);
|
|
157
|
+
for(let i=0;i<names.length;i++)if(entries[i].error)fail(`cannot resolve ${names[i]} after install (${entries[i].error})`);
|
|
158
|
+
return entries.map(entry=>entry.path);
|
|
159
|
+
}
|
|
117
160
|
async function verifyAgentContext(runner,entry,distribution,cwd) {
|
|
118
|
-
const result=JSON.parse(await runner(process.execPath,[entry,'--check'],{cwd,timeout:10000}));
|
|
161
|
+
const result=JSON.parse(await runner(process.execPath,[entry,'--check'],{cwd,timeout:10000,stdoutOnly:true}));
|
|
119
162
|
if(result.ok!==true||result.name!==distribution.agent||result.version!==distribution.version)fail('installed agent selfcheck does not match the CLI distribution');
|
|
120
163
|
for(const key of ['ui','tokens','agent'])if(result.packages?.[key]?.name!==distribution[key]||result.packages[key].version!==distribution.version)fail('agent contract and installed npm package pair differ');
|
|
121
164
|
return result;
|
|
@@ -132,23 +175,29 @@ async function readInstallation(root,requestedApp,expected) {
|
|
|
132
175
|
if(raw){receipt=json(raw,receiptPath);if(receipt.installer!=='vini-npm'||!receipt.distribution||typeof receipt.configTable!=='string')fail('unrecognized npm setup receipt');distributionCheck(receipt.distribution);}
|
|
133
176
|
const relative=requestedApp??receipt?.appRoot??'.';const app=await fs.realpath(path.resolve(root,relative));
|
|
134
177
|
if(app!==root&&!app.startsWith(root+path.sep))fail('app root must be inside project');
|
|
178
|
+
let appRootMatchesReceipt=null;
|
|
179
|
+
if(receipt){
|
|
180
|
+
const recorded=typeof receipt.appRoot==='string'?await fs.realpath(path.resolve(root,receipt.appRoot)).catch(()=>null):null;
|
|
181
|
+
appRootMatchesReceipt=!!recorded&&(recorded===root||recorded.startsWith(root+path.sep))&&recorded===app;
|
|
182
|
+
}
|
|
135
183
|
const manifestPath=path.join(app,'package.json');await safeParents(root,manifestPath);
|
|
136
|
-
const manifest=json(await fileBytes(manifestPath),manifestPath);
|
|
184
|
+
const manifest=json(await fileBytes(manifestPath),manifestPath);
|
|
137
185
|
const dependencies={...manifest.optionalDependencies,...manifest.devDependencies,...manifest.dependencies};
|
|
138
186
|
const lockfiles=[];for(const name of ['package-lock.json','pnpm-lock.yaml']){const bytes=await fileBytes(path.join(app,name),true);if(bytes)lockfiles.push({name,sha256:`sha256:${digest(bytes)}`});}
|
|
139
187
|
const installed={};let installedAgent;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
188
|
+
const keys=['ui','tokens','agent'],local=localNames(receipt?.distribution??expected),resolved=await freshResolveMaybe(manifestPath,keys.map(key=>`${local[key]}${key==='agent'?'/mcp':''}`),app);
|
|
189
|
+
for(const [index,key] of keys.entries()) {
|
|
190
|
+
const alias=local[key];let actual=null,error=null;
|
|
191
|
+
try{if(resolved[index].error){const problem=new Error('not resolvable');problem.code=resolved[index].error;throw problem;}const pkg=await manifestForEntry(resolved[index].path,alias,app);validateNativeManifest(pkg.manifest,key,receipt?.distribution??expected);actual={name:pkg.manifest.name,version:pkg.manifest.version};if(key==='agent')installedAgent=pkg;}
|
|
143
192
|
catch(problem){if(problem.code==='MODULE_NOT_FOUND'||problem.code==='ERR_PACKAGE_PATH_NOT_EXPORTED')error='not-resolvable';else error='metadata-unavailable';}
|
|
144
|
-
const declared=dependencies[alias]??null,recorded=receipt?(receipt.distribution
|
|
193
|
+
const declared=dependencies[alias]??null,recorded=receipt?packageSpec(receipt.distribution,key):null;
|
|
145
194
|
installed[key]={declared,actual,error,matchesLauncher:!!actual&&actual.name===expected[key]&&actual.version===expected.version,matchesReceipt:!!actual&&!!receipt&&actual.name===receipt.distribution[key]&&actual.version===receipt.distribution.version&&declared===recorded};
|
|
146
195
|
}
|
|
147
196
|
let launcher='not-installed';
|
|
148
197
|
if(receipt){const file=path.join(root,'.vini-ds/npm-launcher.mjs');await safeParents(root,file);const bytes=await fileBytes(file,true);launcher=bytes&&digest(bytes)===receipt.launcherSha256?'matches-receipt':'missing-or-modified';}
|
|
149
198
|
let agentContext=null;
|
|
150
199
|
if(installedAgent){const file=path.join(installedAgent.root,'context/current.json');const bytes=await fileBytes(file,true);if(bytes){const current=json(bytes,file);agentContext={version:current.version??null,baseline:current.baseline??null,release:current.viniRelease??null};}}
|
|
151
|
-
return {projectRoot:root,appRoot:app,receipt:receipt?{distribution:receipt.distribution,appRoot:receipt.appRoot}:null,launcher:{status:launcher,expected:receipt?.distribution??null},installed,lockfiles,agentContext};
|
|
200
|
+
return {projectRoot:root,appRoot:app,appRootMatchesReceipt,receipt:receipt?{distribution:receipt.distribution,appRoot:receipt.appRoot}:null,launcher:{status:launcher,expected:receipt?.distribution??null},installed,lockfiles,agentContext};
|
|
152
201
|
}
|
|
153
202
|
const validIntegrity=value=>{if(typeof value!=='string'||!/^sha512-[A-Za-z0-9+/]+={0,2}$/u.test(value))return false;const encoded=value.slice(7),bytes=Buffer.from(encoded,'base64');return bytes.length===64&&bytes.toString('base64')===encoded;};
|
|
154
203
|
function validRelease(value) {
|
|
@@ -185,7 +234,15 @@ async function availableRelease(registry,cliName,expected,request=requestMetadat
|
|
|
185
234
|
const entries=await Promise.all(['ui','tokens','agent'].map(async key=>{
|
|
186
235
|
const info=await request(endpoint(distribution[key],distribution.version));
|
|
187
236
|
if(info?.name!==distribution[key]||info.version!==distribution.version||!validIntegrity(info?.dist?.integrity))throw new Error(`${key} exact-version metadata is unavailable or invalid`);
|
|
188
|
-
|
|
237
|
+
validateNativeManifest(info,key,distribution);
|
|
238
|
+
if(key==='ui'){
|
|
239
|
+
const token=localNames(distribution).tokens,native=distribution.tokens===token;
|
|
240
|
+
const dependency=info.dependencies?.[token];
|
|
241
|
+
const peer=info.peerDependencies?.[token];
|
|
242
|
+
const optional=Object.hasOwn(info.optionalDependencies??{},token)||info.peerDependenciesMeta?.[token]?.optional===true;
|
|
243
|
+
if(isNativeDs(distribution)&&['dependencies','peerDependencies','optionalDependencies','peerDependenciesMeta'].some(section=>Object.hasOwn(info[section]??{},'@vini/tokens')))throw new Error('native UI metadata includes old token identity');
|
|
244
|
+
if(optional||(native ? peer!==distribution.version || (dependency!==undefined&&dependency!==distribution.version) : dependency!==`npm:${distribution.tokens}@${distribution.version}` || (peer!==undefined&&peer!==distribution.version)))throw new Error('published UI token dependency does not match the release');
|
|
245
|
+
}
|
|
189
246
|
if(key==='agent'&&!isDeepStrictEqual(info.viniRelease??null,latest.viniRelease??null))throw new Error('CLI and agent release metadata differ');
|
|
190
247
|
return [key,{name:info.name,version:info.version,integrity:info.dist.integrity}];
|
|
191
248
|
}));const packages=Object.fromEntries(entries);
|
|
@@ -198,14 +255,15 @@ export async function status(options={},suppliedDistribution,{request=requestMet
|
|
|
198
255
|
const state=await readInstallation(root,options.appRoot,expected);
|
|
199
256
|
const registry=options.registry??process.env.npm_config_registry??'https://registry.npmjs.org/';
|
|
200
257
|
const published=await availableRelease(registry,cli.name,expected,request);
|
|
201
|
-
const aligned=!!state.receipt&&state.launcher.status==='matches-receipt'&&['ui','tokens','agent'].every(key=>state.installed[key].matchesReceipt);
|
|
258
|
+
const aligned=!!state.receipt&&state.appRootMatchesReceipt&&state.launcher.status==='matches-receipt'&&['ui','tokens','agent'].every(key=>state.installed[key].matchesReceipt);
|
|
202
259
|
const installedVersion=aligned?state.receipt.distribution.version:null;
|
|
203
260
|
const installedToLauncher=aligned&&['ui','tokens','agent'].every(key=>state.installed[key].matchesLauncher);
|
|
204
261
|
const latest=published.status==='available'?published.distribution.version:null;
|
|
262
|
+
const family=aligned&&published.status==='available'?familyTransition(state.receipt.distribution,published.distribution):null;
|
|
205
263
|
const ordering=aligned&&latest?compareVersions(installedVersion,latest):null;
|
|
206
|
-
const relation=!state.receipt?'not-installed':!aligned?'mismatch':published.status!=='available'?'unknown':ordering===0?'current':ordering<0?'update-available':'ahead-of-latest';
|
|
207
|
-
const next=relation==='not-installed'?`npx ${cli.name}@${expected.version} init --plan`:relation==='mismatch'?'Installed packages or launcher differ from the receipt; resolve the mismatch before updating.':relation==='unknown'?'Registry unavailable; retry status before deciding about updates.':relation==='update-available'?`npx ${cli.name}@${latest} update --plan`:relation==='ahead-of-latest'?'Installed release is newer than the registry latest tag; no downgrade is selected.':'Installed package versions match the latest available release.';
|
|
208
|
-
return {status:relation,...state,launcherVersion:expected.version,launcherMatchesInstalled:installedToLauncher,available:published,changes:published.status==='available'?transition(published.release,installedVersion,latest):{status:'unknown'},nextStep:next,mutated:false};
|
|
264
|
+
const relation=!state.receipt?'not-installed':!aligned?'mismatch':published.status!=='available'||family==='unsupported'?'unknown':ordering===0?'current':ordering<0?'update-available':'ahead-of-latest';
|
|
265
|
+
const next=relation==='not-installed'?`npx ${cli.name}@${expected.version} init --plan`:relation==='mismatch'?(state.appRootMatchesReceipt===false?'Selected app root differs from the recorded npm setup; review the receipt before updating.':'Installed packages or launcher differ from the receipt; resolve the mismatch before updating.'):relation==='unknown'?(family==='unsupported'?'Installed and available package families do not have a supported automatic transition; review the distribution before migration.':'Registry unavailable; retry status before deciding about updates.'):relation==='update-available'?`npx ${cli.name}@${latest} update --plan`:relation==='ahead-of-latest'?'Installed release is newer than the registry latest tag; no downgrade is selected.':'Installed package versions match the latest available release.';
|
|
266
|
+
return {status:relation,...state,launcherVersion:expected.version,launcherMatchesInstalled:installedToLauncher,available:published,familyTransition:family,changes:published.status==='available'&&family!=='unsupported'?transition(published.release,installedVersion,latest):{status:'unknown'},nextStep:next,mutated:false};
|
|
209
267
|
}
|
|
210
268
|
export function formatStatus(result) {
|
|
211
269
|
const installed=['ui','tokens','agent'].map(key=>{const p=result.installed[key];return `${key}: ${p.actual?`${p.actual.name}@${p.actual.version}`:'not installed'}${p.error?` (${p.error})`:''}`;}).join('\n');
|
|
@@ -216,7 +274,7 @@ export function formatStatus(result) {
|
|
|
216
274
|
return `VINi status: ${result.status}\n${installed}\nLauncher expects: ${result.launcherVersion}\nReceipt: ${result.receipt?.distribution.version??'not installed'}; launcher: ${result.launcher.status}\nAvailable published release: ${available}${site}${changes}\n${result.nextStep}`;
|
|
217
275
|
}
|
|
218
276
|
function launcher(distribution,appRelative) {
|
|
219
|
-
return `// Generated by VINi npm CLI; resolves persistent project packages, never npx cache.\nimport { createRequire } from 'node:module';\nimport { readFileSync, existsSync } from 'node:fs';\nimport { spawn } from 'node:child_process';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nconst project=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');\nconst req=createRequire(path.join(project,${JSON.stringify(appRelative)},'package.json'));\nconst expected=${JSON.stringify(distribution)};\nlet server;\nfor(const key of ['tokens','ui','agent']) { const entry=req.resolve(
|
|
277
|
+
return `// Generated by VINi npm CLI; resolves persistent project packages, never npx cache.\nimport { createRequire } from 'node:module';\nimport { readFileSync, existsSync } from 'node:fs';\nimport { spawn } from 'node:child_process';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nconst project=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');\nconst req=createRequire(path.join(project,${JSON.stringify(appRelative)},'package.json'));\nconst expected=${JSON.stringify(distribution)};\nconst local=${JSON.stringify(localNames(distribution))};\nlet server;\nfor(const key of ['tokens','ui','agent']) { const entry=req.resolve(local[key]+(key==='agent'?'/mcp':'')); let dir=path.dirname(entry), meta; while(true){const file=path.join(dir,'package.json');if(existsSync(file)){meta=JSON.parse(readFileSync(file,'utf8'));if(meta.name&&meta.version)break;} const parent=path.dirname(dir);if(parent===dir)throw Error('VINi package metadata missing');dir=parent;} if(meta.name!==expected[key]||meta.version!==expected.version)throw Error('VINi installed package/agent versions differ; run matching VINi CLI update');if(key==='agent')server=entry;}\nconst child=spawn(process.execPath,[server],{stdio:'inherit',cwd:project});\nfor(const sig of ['SIGINT','SIGTERM'])process.on(sig,()=>child.kill(sig));\nchild.on('error',error=>{console.error(error.message);process.exitCode=1;});\nchild.on('exit',(code,signal)=>{process.exitCode=code??1;});\n`;
|
|
220
278
|
}
|
|
221
279
|
async function managerFor(root,app,options,manifest) {
|
|
222
280
|
const dirs=[];let dir=app;while(true){dirs.push(dir);if(dir===root)break;dir=path.dirname(dir);}
|
|
@@ -237,27 +295,56 @@ export async function init(options={},suppliedDistribution,{runner=run,releaseMe
|
|
|
237
295
|
const release=releaseMetadata??cli?.viniRelease;
|
|
238
296
|
if(release&&!validRelease(release))fail('invalid CLI release metadata');
|
|
239
297
|
const root=await fs.realpath(path.resolve(options.cwd??process.cwd()));
|
|
240
|
-
const
|
|
298
|
+
const kit=path.join(root,'.vini-ds'),receiptPath=path.join(kit,'npm-install.json');await safeParents(root,receiptPath);
|
|
299
|
+
const kitStat=await exists(kit),receiptBytes=await fileBytes(receiptPath,true);let previous=null;
|
|
300
|
+
if(kitStat&&!receiptBytes)fail('existing .vini-ds belongs to another setup; migrate the private-GitHub Kit explicitly before npm init');
|
|
301
|
+
if(receiptBytes){previous=json(receiptBytes,receiptPath);if(previous.installer!=='vini-npm'||!previous.distribution||typeof previous.configTable!=='string')fail('unrecognized npm setup receipt');distributionCheck(previous.distribution);}
|
|
302
|
+
if(options.command==='update'&&!previous)fail('no npm VINi setup to update; use init');
|
|
303
|
+
if(previous&&typeof previous.appRoot!=='string')fail('npm setup receipt has no valid app root');
|
|
304
|
+
const app=await fs.realpath(path.resolve(root,options.appRoot??previous?.appRoot??'.'));
|
|
241
305
|
if(app!==root&&!app.startsWith(root+path.sep))fail('app root must be inside project');
|
|
242
306
|
const manifestFile=path.join(app,'package.json'),manifest=json(await fileBytes(manifestFile),manifestFile);
|
|
243
307
|
const deps={...manifest.devDependencies,...manifest.dependencies};
|
|
244
|
-
const allDependencies={...manifest.peerDependencies,...manifest.optionalDependencies,...deps};
|
|
245
|
-
for(const key of ['ui','tokens','agent'])if(distribution[key]!==`@vini/${key}`&&allDependencies[distribution[key]])fail(`direct ${distribution[key]} dependency requires an explicit manual-to-CLI migration; this installer uses @vini/${key} aliases and will not add a second package identity`);
|
|
246
308
|
if(!deps.react||!deps['react-dom']||![deps.react,deps['react-dom']].every(value=>typeof value==='string'&&/^(?:\^|~)?18(?:\.|$)/.test(value)))fail('this alpha requires existing React and React DOM 18 dependencies; their versions will not be replaced');
|
|
247
309
|
const manager=await managerFor(root,app,options,manifest);
|
|
248
310
|
let entry;
|
|
249
311
|
if(options.entry)entry=path.resolve(app,options.entry);
|
|
250
312
|
else {const candidates=[];for(const name of ['src/main.tsx','src/main.jsx','src/main.ts','src/main.js'])if(await exists(path.join(app,name)))candidates.push(path.join(app,name));if(candidates.length!==1)fail('cannot identify one Vite React entry; pass --entry src/main.tsx');entry=candidates[0];}
|
|
251
313
|
await safeParents(root,entry);if(entry!==app&&!entry.startsWith(app+path.sep))fail('entry must be inside app');
|
|
252
|
-
const entryBefore=await fileBytes(entry),
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if(
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
314
|
+
const entryBefore=await fileBytes(entry);let entryAfter,entryPreparation='ready';
|
|
315
|
+
try {entryAfter=Buffer.from(transformEntry(text(entryBefore,entry),entry,distribution));}
|
|
316
|
+
catch(error){if(options.plan&&previous&&isNativeDs(distribution)&&/direct .* import requires an explicit manual-to-CLI migration/.test(error.message)){entryAfter=null;entryPreparation='manual-import-migration-required';}else throw error;}
|
|
317
|
+
if(previous){
|
|
318
|
+
let recordedApp;try{recordedApp=await fs.realpath(path.resolve(root,previous.appRoot));}catch{fail('recorded npm app root is unavailable; review the setup before updating');}
|
|
319
|
+
if(recordedApp!==root&&!recordedApp.startsWith(root+path.sep))fail('recorded npm app root is outside project');
|
|
320
|
+
if(recordedApp!==app)fail('selected app root differs from the recorded npm setup');
|
|
321
|
+
}
|
|
322
|
+
const targetLocal=localNames(distribution),priorLocal=previous?localNames(previous.distribution):null;
|
|
323
|
+
for(const section of ['dependencies','devDependencies','peerDependencies','optionalDependencies'])for(const [name,spec] of Object.entries(manifest[section]??{})){
|
|
324
|
+
for(const key of ['ui','tokens','agent'])for(const published of new Set([distribution[key],legacyPackages[key],`@vini/${key}`,nativeDsPackages[key]])){
|
|
325
|
+
const canonical=priorLocal?.[key]??targetLocal[key];
|
|
326
|
+
if(name===canonical){
|
|
327
|
+
if(!previous)fail(`existing ${canonical} dependency is not managed by this npm setup; migrate explicitly`);
|
|
328
|
+
if(section!==(key==='agent'?'devDependencies':'dependencies'))fail(`${canonical} appears in an unexpected dependency section; review the npm setup`);
|
|
329
|
+
}
|
|
330
|
+
if(name===targetLocal[key]&&targetLocal[key]!==canonical)fail(`existing ${name} dependency is not managed by this npm setup; migrate explicitly`);
|
|
331
|
+
if(name===published&&name!==canonical)fail(`direct ${published} dependency requires an explicit manual-to-CLI migration; this installer uses ${canonical} and will not add a second package identity`);
|
|
332
|
+
const value=typeof spec==='string'?spec.trim():'';
|
|
333
|
+
if(value===`npm:${published}`||value.startsWith(`npm:${published}@`)){
|
|
334
|
+
const recorded=previous&&name===canonical&§ion===(key==='agent'?'devDependencies':'dependencies')&&previous.distribution[key]===published&&spec===`npm:${published}@${previous.distribution.version}`;
|
|
335
|
+
if(!recorded)fail(`unmanaged alias ${name} for ${published} requires an explicit manual-to-CLI migration; use one package identity`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if(previous){
|
|
340
|
+
const sameNames=packageKeys.every(key=>previous.distribution[key]===distribution[key]);
|
|
341
|
+
const supportedFamilyChange=(packageKeys.every(key=>previous.distribution[key]===legacyPackages[key])&&(packageKeys.every(key=>distribution[key]===`@vini/${key}`)||isNativeDs(distribution)))||(packageKeys.every(key=>previous.distribution[key]===`@vini/${key}`)&&isNativeDs(distribution));
|
|
342
|
+
if(!sameNames&&supportedFamilyChange&&compareVersions(distribution.version,previous.distribution.version)<=0)fail('package family migration requires a newer release; no downgrade is selected');
|
|
343
|
+
if(familyTransition(previous.distribution,distribution)==='unsupported')fail('package family transition is not supported; review the installed distribution before migration');
|
|
344
|
+
if(compareVersions(distribution.version,previous.distribution.version)<0)fail('installed release is newer than the requested release; no downgrade is selected');
|
|
345
|
+
}
|
|
346
|
+
const alias=(key)=>packageSpec(distribution,key);
|
|
347
|
+
if(previous)for(const key of ['ui','tokens','agent']){const prior=packageSpec(previous.distribution,key);if(deps[priorLocal[key]]!==prior&&!(priorLocal[key]===targetLocal[key]&&deps[priorLocal[key]]===alias(key)))fail(`${priorLocal[key]} differs from the recorded npm setup`);}
|
|
261
348
|
const lockfile=path.join(app,manager==='npm'?'package-lock.json':'pnpm-lock.yaml');
|
|
262
349
|
const configFile=path.join(root,'.codex/config.toml'),agentsFile=path.join(root,'AGENTS.md'),skillFile=path.join(root,'.agents/skills/vini-ds/SKILL.md'),launchFile=path.join(kit,'npm-launcher.mjs'),setupFile=path.join(kit,'QUICKSTART.md');
|
|
263
350
|
const files=[manifestFile,lockfile,entry,configFile,agentsFile,skillFile,launchFile,setupFile,receiptPath];
|
|
@@ -269,8 +356,14 @@ export async function init(options={},suppliedDistribution,{runner=run,releaseMe
|
|
|
269
356
|
const agents=Buffer.from(agentsMerge(before.get(agentsFile)?text(before.get(agentsFile),agentsFile):''));
|
|
270
357
|
const current=await readInstallation(root,path.relative(root,app)||'.',distribution);
|
|
271
358
|
const installedAligned=!!previous&¤t.launcher.status==='matches-receipt'&&['ui','tokens','agent'].every(key=>current.installed[key].matchesReceipt);
|
|
272
|
-
const
|
|
359
|
+
const migration=!!previous&&familyTransition(previous.distribution,distribution)==='manual-import-migration';
|
|
360
|
+
const plan={status:'plan-only',command:options.command??'init',projectRoot:root,appRoot:app,entry:path.relative(app,entry),entryPreparation,packageManager:manager,installed:current.installed,installedStatus:previous?(installedAligned?'matches-receipt':'mismatch'):'not-installed',from:previous?.distribution??null,to:distribution,distribution,changes:transition(release,installedAligned?previous.distribution.version:null,distribution.version),release:release??null,restart:'Restart or reconnect the project-local VINi MCP in the current client; then read vini://system/current, the affected component contract and check_updates in that client.',dependencies:{[targetLocal.ui]:alias('ui'),[targetLocal.tokens]:alias('tokens')},devDependencies:{[targetLocal.agent]:alias('agent')},...(migration?{removeDependencies:Object.values(priorLocal),manualMigration:'Review and replace all old imports and configuration in the project before update; pass --imports-migrated only after review. The CLI checks the entry and build but cannot verify every source file.'}:{}),agent:'project-local Codex MCP + Skill',applicationPage:'not-verified',nativeClient:'not-verified',postUpdateSteps:[
|
|
361
|
+
'Identify the dev or preview server serving the original application URL. If it still serves old assets, update or restart only that server when its ownership and authorization are clear; otherwise ask its owner. Reload the same URL and exercise the affected component. Do not terminate an unidentified process.',
|
|
362
|
+
'Reconnect the project-local VINi MCP in the current client and read vini://system/current, the affected component contract and check_updates there. A separate STDIO process does not verify the current client.'
|
|
363
|
+
],globalConfig:'unchanged',supported:'React 18, Vite direct createRoot(...).render(JSX), standalone npm/pnpm app'};
|
|
273
364
|
if(options.plan)return plan;
|
|
365
|
+
if(migration&&!options.importsMigrated)fail('review and migrate all project imports and configuration before update; then pass --imports-migrated');
|
|
366
|
+
if(previous&&!installedAligned)fail('installed packages or launcher differ from the receipt; resolve the mismatch before updating');
|
|
274
367
|
const recoveryRoot=path.join(root,'.vini-ds-recovery');await safeParents(root,path.join(recoveryRoot,'placeholder'));
|
|
275
368
|
const recoveryRootExisted=!!await exists(recoveryRoot);
|
|
276
369
|
const modules=path.join(app,'node_modules');
|
|
@@ -282,11 +375,13 @@ export async function init(options={},suppliedDistribution,{runner=run,releaseMe
|
|
|
282
375
|
const pm=async(args)=>runner(manager==='npm'?'npm':'corepack',manager==='npm'?args:['pnpm',...args],{cwd:app});
|
|
283
376
|
const registry=options.registry?[`--registry=${options.registry}`]:[];
|
|
284
377
|
try {
|
|
285
|
-
const next=structuredClone(manifest);next.dependencies={...next.dependencies
|
|
378
|
+
const next=structuredClone(manifest);next.dependencies={...next.dependencies};next.devDependencies={...next.devDependencies};
|
|
379
|
+
if(migration)for(const key of packageKeys){delete next.dependencies[priorLocal[key]];delete next.devDependencies[priorLocal[key]];}
|
|
380
|
+
next.dependencies[targetLocal.tokens]=alias('tokens');next.dependencies[targetLocal.ui]=alias('ui');next.devDependencies[targetLocal.agent]=alias('agent');delete next.dependencies[targetLocal.agent];delete next.devDependencies[targetLocal.ui];delete next.devDependencies[targetLocal.tokens];
|
|
286
381
|
const manifestAfter=Buffer.from(JSON.stringify(next,null,2)+'\n');
|
|
287
382
|
const unchanged=previous&&JSON.stringify(previous.distribution)===JSON.stringify(distribution)&&before.get(manifestFile).equals(manifestAfter)&&entryBefore.equals(entryAfter)&&before.get(configFile)?.equals(config)&&before.get(agentsFile)?.equals(agents)&&before.get(skillFile)!==null&&before.get(setupFile)!==null;
|
|
288
383
|
let verified=false;
|
|
289
|
-
if(unchanged){try{const
|
|
384
|
+
if(unchanged){try{const keys=['tokens','ui','agent'],entries=await freshResolve(manifestFile,keys.map(key=>`${targetLocal[key]}${key==='agent'?'/mcp':''}`),app);for(const [index,key]of keys.entries()){const pkg=await manifestForEntry(entries[index],targetLocal[key],app);if(pkg.manifest.name!==distribution[key]||pkg.manifest.version!==distribution.version)throw new Error('mismatch');validateNativeManifest(pkg.manifest,key,distribution);if(key==='agent')await verifyAgentContext(runner,pkg.entry,distribution,app);}verified=true;}catch{}}
|
|
290
385
|
if(verified){await fs.rmdir(backup);if(!recoveryRootExisted)await fs.rmdir(recoveryRoot).catch(error=>{if(error.code!=='ENOTEMPTY'&&error.code!=='ENOENT')throw error;});return {...plan,status:'already-installed',build:'not-rerun'};}
|
|
291
386
|
for(const [file,bytes]of before)if(bytes!==null){const target=path.join(backup,'files',path.relative(root,file));await fs.mkdir(path.dirname(target),{recursive:true});await fs.writeFile(target,bytes);}
|
|
292
387
|
if(moduleStat){await fs.rename(modules,path.join(backup,'node_modules'));modulesMoved=true;}
|
|
@@ -295,11 +390,13 @@ export async function init(options={},suppliedDistribution,{runner=run,releaseMe
|
|
|
295
390
|
try {await pm(manager==='npm'?['install','--ignore-scripts','--strict-peer-deps','--no-audit','--no-fund',...registry]:['install','--ignore-scripts','--config.strict-peer-dependencies=true','--no-frozen-lockfile',...registry]);}
|
|
296
391
|
catch(error){installFailed=true;throw error;}
|
|
297
392
|
expected.set(manifestFile,await fileBytes(manifestFile));expected.set(lockfile,await fileBytes(lockfile));
|
|
298
|
-
const
|
|
299
|
-
|
|
393
|
+
const packageRoots={};
|
|
394
|
+
const [tokensEntry,uiEntry,agentEntry,skillEntry,setupEntry,reactEntry,reactDomEntry]=await freshResolve(manifestFile,[targetLocal.tokens,targetLocal.ui,`${targetLocal.agent}/mcp`,`${targetLocal.agent}/skill`,`${targetLocal.agent}/setup`,'react','react-dom'],app);
|
|
395
|
+
for(const [key,entry]of [['tokens',tokensEntry],['ui',uiEntry],['agent',agentEntry]]){const pkg=await manifestForEntry(entry,targetLocal[key],app);if(pkg.manifest.name!==distribution[key]||pkg.manifest.version!==distribution.version)fail(`${key} npm version mismatch`);validateNativeManifest(pkg.manifest,key,distribution);packageRoots[key]=pkg;}
|
|
300
396
|
await verifyAgentContext(runner,packageRoots.agent.entry,distribution,app);
|
|
301
|
-
const
|
|
302
|
-
const
|
|
397
|
+
const uiPeers=await freshResolve(path.join(packageRoots.ui.root,'package.json'),['react','react-dom'],app);
|
|
398
|
+
for(const [i,name]of ['react','react-dom'].entries())if(await projectModuleEntry(app,[reactEntry,reactDomEntry][i])!==await projectModuleEntry(app,uiPeers[i]))fail(`multiple ${name} instances after install`);
|
|
399
|
+
const skill=await fileBytes(await projectModuleEntry(app,skillEntry)),setup=await fileBytes(await projectModuleEntry(app,setupEntry));
|
|
303
400
|
const launch=Buffer.from(launcher(distribution,path.relative(root,app)||'.'));
|
|
304
401
|
await write(entry,entryAfter);
|
|
305
402
|
if(manifest.scripts?.build){buildAttempted=true;await pm(['run','build']);}
|
|
@@ -334,7 +431,7 @@ export async function init(options={},suppliedDistribution,{runner=run,releaseMe
|
|
|
334
431
|
try{const failed=await exists(modules);if(failed){if(failed.isSymbolicLink()||!failed.isDirectory())throw new Error('node_modules changed type');await fs.rename(modules,path.join(backup,'node_modules-failed'));}if(modulesMoved)await fs.rename(path.join(backup,'node_modules'),modules);}catch(e){issues.push(`node_modules: ${e.message}`);}
|
|
335
432
|
if(!kitStat)await fs.rmdir(kit).catch(()=>{});
|
|
336
433
|
}
|
|
337
|
-
throw new Error(`${error.message}; ${issues.length?'recovery incomplete: '+issues.join('; '):'original files and dependencies restored'}; saved originals: ${backup}${buildAttempted?'; build outputs are not automatically restored':''}`);
|
|
434
|
+
throw new Error(`${error.message}; ${issues.length?'recovery incomplete: '+issues.join('; '):'original files and dependencies restored'}; saved originals: ${backup}${migration?'; manually migrated source imports were present before update and are not reverted; they may require the new packages, so review and restore the previous source or retry the migration before running the project':''}${buildAttempted?'; build outputs are not automatically restored':''}`);
|
|
338
435
|
} finally {if(!uncertain)await fs.rmdir(operationLock);}
|
|
339
436
|
}
|
|
340
437
|
if(process.argv[1]&&await fs.realpath(process.argv[1]).catch(()=>null)===self){try{const options=parseArgs(process.argv.slice(2));if(options.help)console.log(usage);else if(options.command==='status'){const result=await status(options);console.log(options.json?JSON.stringify(result,null,2):formatStatus(result));}else console.log(JSON.stringify(await init(options),null,2));}catch(error){console.error(error.message);process.exitCode=1;}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vini-ds",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "VINi React project and local agent setup",
|
|
6
6
|
"bin": {
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
"typescript": "5.5.4"
|
|
21
21
|
},
|
|
22
22
|
"viniDistribution": {
|
|
23
|
-
"version": "0.1.0-alpha.
|
|
24
|
-
"ui": "@
|
|
25
|
-
"tokens": "@
|
|
26
|
-
"agent": "@
|
|
23
|
+
"version": "0.1.0-alpha.4",
|
|
24
|
+
"ui": "@vini-ds/ui",
|
|
25
|
+
"tokens": "@vini-ds/tokens",
|
|
26
|
+
"agent": "@vini-ds/agent"
|
|
27
27
|
},
|
|
28
28
|
"viniRelease": {
|
|
29
29
|
"atlas": {
|
|
30
30
|
"url": "https://vini-atlas-pilot.layero.app/",
|
|
31
|
-
"archiveSha256": "sha256:
|
|
32
|
-
"siteRelease": "source-snapshot-20261104-
|
|
33
|
-
"commit": "
|
|
31
|
+
"archiveSha256": "sha256:45dcc5672f36b3262e02c2913998aceb6f3fe7b66b02405a61c9128d423f745a",
|
|
32
|
+
"siteRelease": "source-snapshot-20261104-update-completion",
|
|
33
|
+
"commit": "dcd9728349c7c013fbe649e957ad0a1afdc2dc0e"
|
|
34
34
|
},
|
|
35
35
|
"delivery": {
|
|
36
36
|
"id": "candidate-c11703e55c492320",
|
|
@@ -38,11 +38,9 @@
|
|
|
38
38
|
"packageManifestSha256": "sha256:44fc4d1f985ebe9d66344ec2cdb45640023eab886028dc7bb8e0be07f8c989e7"
|
|
39
39
|
},
|
|
40
40
|
"changes": {
|
|
41
|
-
"fromVersion": "0.1.0-alpha.
|
|
42
|
-
"summary": "
|
|
43
|
-
"components": [
|
|
44
|
-
"Sidebar"
|
|
45
|
-
]
|
|
41
|
+
"fromVersion": "0.1.0-alpha.3",
|
|
42
|
+
"summary": "Переход на прямые имена пакетов @vini-ds; CLI и контекст агента обновлены согласованно.",
|
|
43
|
+
"components": []
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
}
|