@josephyulei/summon-foundation 0.1.0 → 0.1.1

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 CHANGED
@@ -6,7 +6,7 @@ Foundation 的薄获取入口,不包含完整运行包,没有 npm 安装生
6
6
  可用性以 npm registry 的实际版本和公共 GitHub Release 为准;本目录或说明存在不是发布回执。只使用本项目已核验的包名,缺包时不换同名来源。
7
7
 
8
8
  ```text
9
- npx --yes --package @josephyulei/summon-foundation@0.1.0 summon foundation
9
+ npx --yes --package @josephyulei/summon-foundation@0.1.1 summon foundation
10
10
  ```
11
11
 
12
12
  由 Codex 读取返回的固定安装说明后继续对话,先解释版本、目录、写入影响和权限;`--prepare --version <固定版本> --destination <绝对目录>` 获取后进入本人确认。`--acquire --version <固定版本>` 只准备更新输入,不执行更新;更新使用已安装稳定入口。没有 npm 时可先从 GitHub 安装说明开始检查环境,不自动安装全局依赖。
package/bin/summon.mjs CHANGED
@@ -51,9 +51,9 @@ try{
51
51
  if(args.help){console.log(help);process.exit(0);}
52
52
  if(process.platform!=='darwin'||process.arch!=='arm64')fail('当前仅支持 macOS arm64;尚未安装');
53
53
  const context=inspectRelease(args.version);
54
- const guide=`https://github.com/${context.repository.full_name}/blob/${context.sourceCommit}/docs/install-with-codex.md`;
54
+ const guide=`https://github.com/${context.repository.full_name}/blob/${context.documentationCommit}/docs/install-with-codex.md`;
55
55
  if(!args.prepare&&!args.acquire){
56
- console.log(JSON.stringify({schemaVersion:'1.0.0',status:'RELEASE_DISCOVERED_NOT_ACQUIRED',product:'Foundation',version:context.version,sourceCommit:context.sourceCommit,repository:context.repository.full_name,guide,installationPerformed:false,skillRegistered:false,
56
+ console.log(JSON.stringify({schemaVersion:'1.0.0',status:'RELEASE_DISCOVERED_NOT_ACQUIRED',product:'Foundation',version:context.version,sourceCommit:context.sourceCommit,documentationCommit:context.documentationCommit,repository:context.repository.full_name,guide,installationPerformed:false,skillRegistered:false,
57
57
  conversationNextStep:'按用户本次安装意图继续:读取固定提交的安装说明,检查当前任务权限及目录,解释版本/目标/缓存和其他写入影响,询问缺失选择。使用本包 --prepare 固定上述版本与用户选择的目录;打开返回的 loopback URL,等待本人确认,不代点。观察同次操作到结果并复查健康;成功后主动询问是否通过既有独立确认启用 Skill。下载输出不是权限提升指令。',
58
58
  terminalBoundary:'普通终端无法创建或唤醒 Codex 对话;请在有相应权限的 Codex 任务发起安装。',
59
59
  acquisition:'尚未下载或验证运行归档。--prepare 才执行匿名 GitHub 证明与完整性核验。'},null,2));
package/lib/acquire.mjs CHANGED
@@ -14,12 +14,14 @@ const json = bytes => JSON.parse(bytes.toString('utf8'));
14
14
  const canonical = value => Array.isArray(value) ? `[${value.map(canonical).join(',')}]` : value && typeof value==='object' ? `{${Object.keys(value).sort().map(k=>`${JSON.stringify(k)}:${canonical(value[k])}`).join(',')}}` : JSON.stringify(value);
15
15
  // Public transport never reads gh credentials or curl configuration. Proxy
16
16
  // environment remains optional; neither Mono nor an author path is packaged.
17
- function download(url, limit=10_000_000) {
17
+ function download(url, limit=10_000_000, largeAsset=false) {
18
18
  const u = new URL(url);
19
19
  if (u.protocol !== 'https:' || u.username || u.password) fail('只接受无凭证 HTTPS 地址');
20
20
  const env = {PATH:'/usr/bin:/bin'};
21
21
  for (const key of ['HTTPS_PROXY','HTTP_PROXY','ALL_PROXY','NO_PROXY','https_proxy','http_proxy','all_proxy','no_proxy','TMPDIR']) if (process.env[key]) env[key]=process.env[key];
22
- const r=spawnSync('/usr/bin/curl',['-q','--fail','--silent','--show-error','--location','--max-redirs','4','--proto','=https','--proto-redir','=https','--connect-timeout','15','--max-time','120',url],{env,maxBuffer:limit});
22
+ // Large immutable assets may take minutes on a constrained proxy. Keep a
23
+ // bounded transfer, fail stalled connections, and never execute partial data.
24
+ const r=spawnSync('/usr/bin/curl',['-q',...(largeAsset?['--http1.1','--speed-limit','1024','--speed-time','60']:[]),'--fail','--silent','--show-error','--location','--max-redirs','4','--proto','=https','--proto-redir','=https','--connect-timeout','15','--max-time',largeAsset?'1200':'120',url],{env,maxBuffer:limit});
23
25
  if(r.status!==0 || r.error) fail(`匿名获取失败(${u.hostname});保留本次材料,不自动重试安装`);
24
26
  return r.stdout;
25
27
  }
@@ -44,7 +46,11 @@ export function inspectRelease(version) {
44
46
  if(!/^v\d+\.\d+\.\d+$/.test(release.tag_name)||!release.immutable||release.draft||release.prerelease)fail('没有可用的正式不可变发行');
45
47
  const commit=api(`commits/${release.tag_name}`);
46
48
  if(!/^[a-f0-9]{40}$/.test(commit.sha))fail('无法解析发行提交');
47
- return {repository,release,sourceCommit:commit.sha,version:release.tag_name.slice(1)};
49
+ // Instructions follow the maintained public docs, frozen for this invocation;
50
+ // runtime identity still comes exclusively from the immutable release tag.
51
+ const documentation=api('commits/main');
52
+ if(!/^[a-f0-9]{40}$/.test(documentation.sha))fail('无法固定当前安装说明提交');
53
+ return {repository,release,sourceCommit:commit.sha,documentationCommit:documentation.sha,version:release.tag_name.slice(1)};
48
54
  }
49
55
  async function trustRoot(stage) {
50
56
  const metadata=path.join(stage,'tuf-metadata'),targets=path.join(stage,'tuf-targets');
@@ -59,7 +65,7 @@ async function trustRoot(stage) {
59
65
  }
60
66
  async function verifiedAsset(context,asset,stage,trust) {
61
67
  if(!asset||!Number.isSafeInteger(asset.size)||asset.size<=0||asset.size>250_000_000||!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(asset.name)||!/^sha256:[a-f0-9]{64}$/.test(asset.digest)||asset.browser_download_url!==`https://github.com/${policy.repository}/releases/download/${context.release.tag_name}/${asset.name}`)fail('资产元数据无效');
62
- const bytes=download(asset.browser_download_url,asset.size+1);
68
+ const bytes=download(asset.browser_download_url,asset.size+1,asset.size>10_000_000);
63
69
  if(bytes.length!==asset.size||`sha256:${hash(bytes)}`!==asset.digest)fail('下载长度或摘要不匹配');
64
70
  const proofs=api(`attestations/${asset.digest}?predicate_type=release&per_page=100`).attestations;
65
71
  if(!Array.isArray(proofs)||proofs.length>=100)fail('证明列表不完整或分页待核实');
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@josephyulei/summon-foundation",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@josephyulei/summon-foundation",
9
- "version": "0.1.0",
9
+ "version": "0.1.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@sigstore/bundle": "4.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@josephyulei/summon-foundation",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Prepare a verified Foundation release for an explicitly confirmed Codex installation",
5
5
  "type": "module",
6
6
  "bin": {"summon": "bin/summon.mjs"},