@thinkingai/ae-cli 6.0.60 → 6.0.62
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 +6 -1
- package/README.zh.md +8 -1
- package/bin/runtime-capabilities.json +1 -1
- package/dist/{ai-monitor-FCXSLHAP.js → ai-monitor-X5GL44JT.js} +10 -9
- package/dist/ai-monitor.js +14 -13
- package/dist/{auth-ATK2SLEV.js → auth-SPQ46XQ3.js} +18 -10
- package/dist/{automation-FLCPFMN4.js → automation-7XC3VBZI.js} +87 -12
- package/dist/{capability-6KTSOI7L.js → capability-JZP4KXZC.js} +10 -9
- package/dist/{chunk-OAWPT7VP.js → chunk-2I5SZ5DS.js} +2 -2
- package/dist/{chunk-VRMGHQKE.js → chunk-2VKMHNUU.js} +11 -11
- package/dist/{chunk-2ETRY2CU.js → chunk-6HOM2FOJ.js} +19 -9
- package/dist/{chunk-KTJXD27G.js → chunk-AAN6KBUK.js} +3 -3
- package/dist/{chunk-4PSTYEG5.js → chunk-AMURHMS3.js} +11 -7
- package/dist/{chunk-6M7ZEDT2.js → chunk-BQFLABJQ.js} +11 -7
- package/dist/{chunk-BEYLCUZX.js → chunk-E457FREE.js} +3 -3
- package/dist/{chunk-CF6JTT2U.js → chunk-EFGUBGA6.js} +1 -1
- package/dist/{chunk-5M5LBRR3.js → chunk-ETQXIZFP.js} +15 -8
- package/dist/{chunk-72NJKS7O.js → chunk-F36ORPI6.js} +7 -32
- package/dist/{chunk-5E7MTTFN.js → chunk-F7TCQPQX.js} +23 -9
- package/dist/{chunk-AXTO4FTM.js → chunk-FGGEF7MI.js} +3 -3
- package/dist/{chunk-JEUXDY3B.js → chunk-HQED4YB4.js} +1 -1
- package/dist/{chunk-2F64AZYH.js → chunk-KA5WKR5P.js} +2 -2
- package/dist/{chunk-P7QDCWJ6.js → chunk-LFJ7N36I.js} +5 -1
- package/dist/chunk-N2MAYIRU.js +32 -0
- package/dist/chunk-NNK3JBH4.js +60 -0
- package/dist/{chunk-HTZ2MLYA.js → chunk-PLNS5J33.js} +11 -5
- package/dist/{chunk-HSZAIPUX.js → chunk-PRCHMOWT.js} +7 -5
- package/dist/chunk-PUSFEC6B.js +29 -0
- package/dist/{chunk-Z3Q2AEIN.js → chunk-R2SVAO4G.js} +14 -2
- package/dist/{chunk-SDKW6LYE.js → chunk-RYY5NJK3.js} +3 -3
- package/dist/{chunk-QVRIDN42.js → chunk-UCMO4LKL.js} +2 -2
- package/dist/{chunk-VJUXKVRE.js → chunk-VR2D54AA.js} +2 -2
- package/dist/{chunk-HVMCPKOZ.js → chunk-YIG3L4RC.js} +1 -1
- package/dist/{chunk-LOR4IA26.js → chunk-YJYC5PLL.js} +166 -188
- package/dist/{chunk-F2VFZUGG.js → chunk-ZVUXAHEV.js} +2 -2
- package/dist/{community-report-client-TJVCLZ3K.js → community-report-client-ULRNXLQV.js} +1 -1
- package/dist/{compat-check-XD2U7PZ2.js → compat-check-JD5D77ET.js} +5 -4
- package/dist/{config-U3GDWU6E.js → config-IIMRATTP.js} +7 -6
- package/dist/{context-YAQG6YQC.js → context-BXHIPIIX.js} +8 -6
- package/dist/{data-integration-QE37EQ3A.js → data-integration-VRJQ3HVK.js} +7 -6
- package/dist/{evaluation-2JSF4V47.js → evaluation-Q3AIGFOG.js} +5 -5
- package/dist/index.js +49 -43
- package/dist/{local-data-upload-client-KCMG6J62.js → local-data-upload-client-YTWMAAGE.js} +1 -1
- package/dist/{memory-WEB27VI6.js → memory-B44LY27L.js} +6 -7
- package/dist/{metadata-7FYE4234.js → metadata-ZVPG2MIA.js} +10 -9
- package/dist/{model-T7H7Q6BG.js → model-ANZBYVST.js} +4 -5
- package/dist/{personal-semantic-preference-O6VXM74A.js → personal-semantic-preference-YNCV4QG3.js} +45 -14
- package/dist/{project-semantic-2GGFJWW6.js → project-semantic-E7ZAQL5S.js} +9 -8
- package/dist/{sync-ULBB7WO5.js → sync-Y4OZRQAY.js} +9 -9
- package/dist/{te-agent-6RMF7LUV.js → te-agent-RKAUTYJZ.js} +303 -17
- package/dist/{te-analysis-HSYC7GNV.js → te-analysis-7N5VC4JB.js} +25 -20
- package/dist/{te-community-FLKZGQKB.js → te-community-SIA2UHTS.js} +13 -11
- package/dist/{te-dataops-OQQGTCUA.js → te-dataops-5MJQCODU.js} +13 -11
- package/dist/{te-engage-RIEBHL5T.js → te-engage-ZTLOMKO3.js} +73 -20
- package/dist/{te-kb-4HG2FMHJ.js → te-kb-LDL3MF2Y.js} +107 -25
- package/dist/{te-system-AL4B4XZL.js → te-system-473I5O53.js} +6 -7
- package/dist/{te-team-5O4UVUWE.js → te-team-JOWHCMZA.js} +92 -10
- package/dist/{things-TSJ64GBT.js → things-DOQ2L3O2.js} +9 -8
- package/dist/{update-Q5LURAWV.js → update-KUS6TCPB.js} +8 -6
- package/dist/{workspace-FF2HXJGR.js → workspace-MJFPIV7C.js} +6 -7
- package/package.json +6 -3
- package/skills/ae-agent/SKILL.md +19 -5
- package/skills/ae-agent/references/a2a.md +103 -0
- package/skills/ae-agent/references/command_index.md +11 -0
- package/skills/ae-analysis/SKILL.md +35 -23
- package/skills/ae-analysis/references/analysis_data_retrieval.md +1 -1
- package/skills/ae-analysis/references/asset_authentication_export.md +1 -1
- package/skills/ae-analysis/references/asset_authentication_update.md +6 -2
- package/skills/ae-analysis/references/bad_case_review.md +4 -4
- package/skills/ae-analysis/references/command_index.md +7 -7
- package/skills/ae-analysis/references/governance_recommendation_export.md +2 -2
- package/skills/ae-analysis/references/personal_semantic_preference_add.md +9 -1
- package/skills/ae-analysis/references/personal_semantic_preference_delete.md +2 -0
- package/skills/ae-analysis/references/personal_semantic_preference_get.md +2 -0
- package/skills/ae-analysis/references/personal_semantic_preference_list.md +10 -2
- package/skills/ae-analysis/references/personal_semantic_preference_update.md +8 -0
- package/skills/ae-analysis/references/project_owner_update.md +5 -1
- package/skills/ae-analysis/references/scenario_evaluation.md +17 -1
- package/skills/ae-analysis/references/scenario_list.md +5 -6
- package/skills/ae-automation/SKILL.md +6 -2
- package/skills/ae-automation/references/cli.md +9 -3
- package/skills/ae-capability/SKILL.md +8 -4
- package/skills/ae-engage/SKILL.md +6 -1
- package/skills/ae-engage/references/common-metric.md +47 -1
- package/skills/ae-engage/references/flow-metric-update.md +1 -1
- package/skills/ae-engage/references/task-metric-update.md +1 -1
- package/skills/ae-kb/SKILL.md +11 -7
- package/skills/ae-kb/references/publication.md +45 -0
- package/skills/ae-kb/references/query-workflow.md +5 -1
- package/skills/ae-team/SKILL.md +7 -3
- package/skills/ae-team/references/copy-to-personal.md +7 -0
- package/skills/ae-team/references/promote.md +7 -0
- package/skills/ae-team/references/update.md +3 -3
- package/dist/chunk-Y74WTIKJ.js +0 -10
- package/skills/ae-tracking-matrix/SKILL.md +0 -170
- package/skills/ae-tracking-matrix/assets//345/237/213/347/202/271/346/250/241/347/211/210.xlsx +0 -0
- package/skills/ae-tracking-matrix/i18n.yaml +0 -12
- package/skills/ae-tracking-matrix/references/ae-capabilities.md +0 -93
- package/skills/ae-tracking-matrix/references/business-semantic-checks.md +0 -30
- package/skills/ae-tracking-matrix/references/categories/acquaintance_social_tracking_plan_template.md +0 -256
- package/skills/ae-tracking-matrix/references/categories/blockchain_game_tracking_plan_template.md +0 -213
- package/skills/ae-tracking-matrix/references/categories/card_game_tracking_plan_template.md +0 -407
- package/skills/ae-tracking-matrix/references/categories/casual_game_tracking_plan_template.md +0 -218
- package/skills/ae-tracking-matrix/references/categories/casual_music.md +0 -112
- package/skills/ae-tracking-matrix/references/categories/chess_cards_tracking_plan_template.md +0 -301
- package/skills/ae-tracking-matrix/references/categories/ecommerce_tracking_plan_template.md +0 -356
- package/skills/ae-tracking-matrix/references/categories/fishing.md +0 -775
- package/skills/ae-tracking-matrix/references/categories/game_basic_module_tracking_plan.md +0 -89
- package/skills/ae-tracking-matrix/references/categories/idle_card.md +0 -27
- package/skills/ae-tracking-matrix/references/categories/idle_game_tracking_plan_template.md +0 -415
- package/skills/ae-tracking-matrix/references/categories/interactive_video.md +0 -133
- package/skills/ae-tracking-matrix/references/categories/merge.md +0 -639
- package/skills/ae-tracking-matrix/references/categories/mmo_mobile_tracking_plan_template.md +0 -406
- package/skills/ae-tracking-matrix/references/categories/mmo_web.md +0 -230
- package/skills/ae-tracking-matrix/references/categories/music.md +0 -137
- package/skills/ae-tracking-matrix/references/categories/online_education_tracking_plan_template.md +0 -414
- package/skills/ae-tracking-matrix/references/categories/qipai_mj.md +0 -199
- package/skills/ae-tracking-matrix/references/categories/reading_tracking_plan_template.md +0 -158
- package/skills/ae-tracking-matrix/references/categories/roguelike_tracking_plan_template.md +0 -546
- package/skills/ae-tracking-matrix/references/categories/rpg.md +0 -195
- package/skills/ae-tracking-matrix/references/categories/short_drama_tracking_plan_template.md +0 -115
- package/skills/ae-tracking-matrix/references/categories/simulation_business_tracking_plan_template.md +0 -151
- package/skills/ae-tracking-matrix/references/categories/slg_tracking_plan_template.md +0 -260
- package/skills/ae-tracking-matrix/references/categories/slots_tracking_plan_template.md +0 -232
- package/skills/ae-tracking-matrix/references/categories/stranger_social_tracking_plan_template.md +0 -359
- package/skills/ae-tracking-matrix/references/categories/tower_defense.md +0 -365
- package/skills/ae-tracking-matrix/references/categories/video_editor_tracking_plan_template.md +0 -211
- package/skills/ae-tracking-matrix/references/categories/wechat_minigame.md +0 -132
- package/skills/ae-tracking-matrix/references/category-registry.md +0 -77
- package/skills/ae-tracking-matrix/references/data-verification/diagnosis_kb.md +0 -230
- package/skills/ae-tracking-matrix/references/data-verification/sql_checks.md +0 -406
- package/skills/ae-tracking-matrix/references/data-verification/tracking_plan_comparison.md +0 -128
- package/skills/ae-tracking-matrix/references/eval-cases.md +0 -74
- package/skills/ae-tracking-matrix/references/naming-dict.md +0 -238
- package/skills/ae-tracking-matrix/references/optimization-checklist.md +0 -85
- package/skills/ae-tracking-matrix/references/plan-generation/export-schema.md +0 -142
- package/skills/ae-tracking-matrix/references/plan-generation/module-baseline.md +0 -47
- package/skills/ae-tracking-matrix/references/plan-generation/reference.md +0 -794
- package/skills/ae-tracking-matrix/references/plan-generation/template-catalog.md +0 -94
- package/skills/ae-tracking-matrix/references/scene-routing.md +0 -80
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/android.md +0 -3787
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/c.md +0 -827
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-lua.md +0 -655
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-x.md +0 -953
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocoscreator.md +0 -1128
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/corona.md +0 -714
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/egret.md +0 -1268
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/flutter.md +0 -776
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/h5-and-app-sdk-integration.md +0 -182
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/ios.md +0 -2755
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/javascript.md +0 -1182
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/layaair.md +0 -1300
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/macos.md +0 -1369
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/mini-program-mini-game.md +0 -1692
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/openharmony.md +0 -902
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/react-native.md +0 -763
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/uni-app.md +0 -1107
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/unity.md +0 -1532
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/unreal.md +0 -845
- package/skills/ae-tracking-matrix/references/sdk/faq/android_sdk_faq.md +0 -228
- package/skills/ae-tracking-matrix/references/sdk/faq/ios_sdk_faq.md +0 -149
- package/skills/ae-tracking-matrix/references/sdk/faq/java_sdk_faq.md +0 -407
- package/skills/ae-tracking-matrix/references/sdk/faq/javascript_sdk_faq.md +0 -163
- package/skills/ae-tracking-matrix/references/sdk/faq/minigame_sdk_faq.md +0 -149
- package/skills/ae-tracking-matrix/references/sdk/faq/miniprogram_sdk_faq.md +0 -153
- package/skills/ae-tracking-matrix/references/sdk/faq/python_sdk_faq.md +0 -232
- package/skills/ae-tracking-matrix/references/sdk/faq/sdk_log_guide.md +0 -314
- package/skills/ae-tracking-matrix/references/sdk/faq/sdk_usage_notes.md +0 -117
- package/skills/ae-tracking-matrix/references/sdk/faq/unity_sdk_faq.md +0 -148
- package/skills/ae-tracking-matrix/references/sdk/integration-tools/filebeat-logstash-guide.md +0 -645
- package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_guide.md +0 -307
- package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_parser_plugin.md +0 -347
- package/skills/ae-tracking-matrix/references/sdk/integration-tools/restful_api_notes.md +0 -72
- package/skills/ae-tracking-matrix/references/sdk/integration-tools/ta-datax-writer-guide.md +0 -264
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/c.md +0 -566
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/erlang.md +0 -409
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/golang.md +0 -446
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/java.md +0 -557
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/lua.md +0 -457
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/nodejs.md +0 -490
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/php.md +0 -523
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/python.md +0 -484
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/ruby.md +0 -442
- package/skills/ae-tracking-matrix/references/sdk/te-data-rules/data-rules.md +0 -391
- package/skills/ae-tracking-matrix/references/sdk/te-data-rules/first-event-validation.md +0 -91
- package/skills/ae-tracking-matrix/references/sdk/te-data-rules/preset-properties-system-fields.md +0 -635
- package/skills/ae-tracking-matrix/references/sdk/te-data-rules/updatable-events.md +0 -113
- package/skills/ae-tracking-matrix/references/sdk/te-data-rules/user-identification-rules.md +0 -466
- package/skills/ae-tracking-matrix/references/standard-base/README.md +0 -22
- package/skills/ae-tracking-matrix/references/standard-base/basic_event_data.md +0 -174
- package/skills/ae-tracking-matrix/references/standard-base/common_event_properties.md +0 -20
- package/skills/ae-tracking-matrix/references/standard-base/common_event_properties_setup.md +0 -7
- package/skills/ae-tracking-matrix/references/standard-base/data_type_design_principles.md +0 -14
- package/skills/ae-tracking-matrix/references/standard-base/gameplay_event_data.md +0 -370
- package/skills/ae-tracking-matrix/references/standard-base/id_system_faq.md +0 -47
- package/skills/ae-tracking-matrix/references/standard-base/integration_must_know.md +0 -37
- package/skills/ae-tracking-matrix/references/standard-base/multi_platform_integration_notes.md +0 -27
- package/skills/ae-tracking-matrix/references/standard-base/multi_user_id_system_recommendations.md +0 -23
- package/skills/ae-tracking-matrix/references/standard-base/tracking_notes.md +0 -14
- package/skills/ae-tracking-matrix/references/standard-base/user_data.md +0 -46
- package/skills/ae-tracking-matrix/references/standard-base/user_id_system.md +0 -13
- package/skills/ae-tracking-matrix/references/system-fields.md +0 -297
- package/skills/ae-tracking-matrix/references/te-field-translations.md +0 -1791
- package/skills/ae-tracking-matrix/references/workflows/data-verification.md +0 -232
- package/skills/ae-tracking-matrix/references/workflows/feasibility-analysis.md +0 -829
- package/skills/ae-tracking-matrix/references/workflows/integration-qna.md +0 -355
- package/skills/ae-tracking-matrix/references/workflows/plan-generation.md +0 -283
- package/skills/ae-tracking-matrix/references/workflows/plan-lint.md +0 -168
- package/skills/ae-tracking-matrix/references/workflows/plan-review-optimize.md +0 -205
- package/skills/ae-tracking-matrix/references/workflows/prd-to-suggestions.md +0 -75
- package/skills/ae-tracking-matrix/references/workflows/troubleshooting.md +0 -36
- package/skills/ae-tracking-matrix/references/workflows/validated-upload.md +0 -107
- package/skills/ae-tracking-matrix/scripts/build_template_catalog.py +0 -114
- package/skills/ae-tracking-matrix/scripts/export_tracking_plan.py +0 -53
- package/skills/ae-tracking-matrix/scripts/finalize_plan.py +0 -166
- package/skills/ae-tracking-matrix/scripts/lint_tracking_plan.py +0 -674
- package/skills/ae-tracking-matrix/scripts/plan_contract.py +0 -200
- package/skills/ae-tracking-matrix/scripts/plan_types.py +0 -60
- package/skills/ae-tracking-matrix/scripts/prepare_delivery.py +0 -169
- package/skills/ae-tracking-matrix/scripts/sync_plan.py +0 -296
- package/skills/ae-tracking-matrix/scripts/upload_plan.py +0 -340
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
+
getLocalCliPackageInfo
|
|
4
|
+
} from "./chunk-PUSFEC6B.js";
|
|
5
|
+
import {
|
|
6
|
+
internalCallSourceHeaders,
|
|
3
7
|
peekCliToken
|
|
4
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-PLNS5J33.js";
|
|
5
9
|
import {
|
|
6
10
|
getActiveHost,
|
|
7
11
|
getConfigDir,
|
|
8
12
|
isAeSandboxRuntime,
|
|
9
13
|
readSandboxCliTokenEntry
|
|
10
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-AMURHMS3.js";
|
|
11
15
|
import {
|
|
12
16
|
PermissionError,
|
|
13
17
|
externalCliTokenRequestOptions,
|
|
14
18
|
normalizeUrl,
|
|
15
19
|
readExternalCliToken
|
|
16
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-R2SVAO4G.js";
|
|
17
21
|
|
|
18
22
|
// src/core/compat-check.ts
|
|
19
|
-
import
|
|
20
|
-
import
|
|
23
|
+
import fs10 from "fs";
|
|
24
|
+
import path10 from "path";
|
|
21
25
|
import { createHash as createHash3 } from "crypto";
|
|
22
26
|
import { Agent } from "undici";
|
|
23
27
|
|
|
@@ -307,45 +311,21 @@ function formatCompatNotice(verdict) {
|
|
|
307
311
|
}
|
|
308
312
|
|
|
309
313
|
// src/core/version-sync.ts
|
|
310
|
-
import fs9 from "fs";
|
|
311
|
-
import path9 from "path";
|
|
312
|
-
|
|
313
|
-
// src/core/installation.ts
|
|
314
314
|
import fs8 from "fs";
|
|
315
315
|
import path8 from "path";
|
|
316
|
-
import crypto3 from "crypto";
|
|
317
316
|
|
|
318
|
-
// src/core/
|
|
319
|
-
import
|
|
320
|
-
import
|
|
321
|
-
import
|
|
322
|
-
function getLocalCliPackageInfo() {
|
|
323
|
-
let dir = path2.dirname(fileURLToPath(import.meta.url));
|
|
324
|
-
for (let i = 0; i < 8; i += 1) {
|
|
325
|
-
const candidate = path2.join(dir, "package.json");
|
|
326
|
-
try {
|
|
327
|
-
if (fs2.existsSync(candidate)) {
|
|
328
|
-
const pkg = JSON.parse(fs2.readFileSync(candidate, "utf8"));
|
|
329
|
-
if (pkg.name && pkg.version && String(pkg.name).includes("ae-cli")) {
|
|
330
|
-
return { name: pkg.name, version: pkg.version, root: dir };
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
} catch {
|
|
334
|
-
}
|
|
335
|
-
const parent = path2.dirname(dir);
|
|
336
|
-
if (parent === dir) break;
|
|
337
|
-
dir = parent;
|
|
338
|
-
}
|
|
339
|
-
return { name: "@tant/ae-cli", version: "0.0.0", root: "" };
|
|
340
|
-
}
|
|
317
|
+
// src/core/installation.ts
|
|
318
|
+
import fs7 from "fs";
|
|
319
|
+
import path7 from "path";
|
|
320
|
+
import crypto3 from "crypto";
|
|
341
321
|
|
|
342
322
|
// src/core/skills-install.ts
|
|
343
|
-
import
|
|
323
|
+
import fs2 from "fs";
|
|
344
324
|
import os from "os";
|
|
345
|
-
import
|
|
325
|
+
import path2 from "path";
|
|
346
326
|
import { parseDocument } from "yaml";
|
|
347
327
|
function globalSkillsDirectory() {
|
|
348
|
-
return
|
|
328
|
+
return path2.join(os.homedir(), ".agents", "skills");
|
|
349
329
|
}
|
|
350
330
|
function skillName(content) {
|
|
351
331
|
const frontmatter = content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
|
|
@@ -357,30 +337,30 @@ function skillName(content) {
|
|
|
357
337
|
return data.name;
|
|
358
338
|
}
|
|
359
339
|
function readFiles(root, prefix = "", files = /* @__PURE__ */ new Map()) {
|
|
360
|
-
for (const entry of
|
|
340
|
+
for (const entry of fs2.readdirSync(path2.join(root, prefix), { withFileTypes: true })) {
|
|
361
341
|
if (entry.name.startsWith(".") || ["metadata.json", "__pycache__", "__pypackages__"].includes(entry.name)) continue;
|
|
362
|
-
const relative =
|
|
342
|
+
const relative = path2.join(prefix, entry.name);
|
|
363
343
|
if (entry.isSymbolicLink()) throw new Error("Bundled Skills must contain regular files.");
|
|
364
344
|
if (entry.isDirectory()) readFiles(root, relative, files);
|
|
365
|
-
else if (entry.isFile()) files.set(relative,
|
|
345
|
+
else if (entry.isFile()) files.set(relative, fs2.readFileSync(path2.join(root, relative)));
|
|
366
346
|
}
|
|
367
347
|
return files;
|
|
368
348
|
}
|
|
369
349
|
function readBundledSkills(directory, select) {
|
|
370
|
-
const entries =
|
|
350
|
+
const entries = fs2.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith("."));
|
|
371
351
|
const names = /* @__PURE__ */ new Set();
|
|
372
352
|
const skills = entries.flatMap((entry) => {
|
|
373
353
|
try {
|
|
374
354
|
let selectedName;
|
|
375
355
|
if (select) {
|
|
376
|
-
const header =
|
|
377
|
-
if (!
|
|
378
|
-
selectedName = skillName(
|
|
356
|
+
const header = path2.join(directory, entry.name, "SKILL.md");
|
|
357
|
+
if (!fs2.lstatSync(header).isFile()) throw new Error("Bundled Skill metadata must be a regular file.");
|
|
358
|
+
selectedName = skillName(fs2.readFileSync(header, "utf8"));
|
|
379
359
|
if (names.has(selectedName)) throw new Error("Duplicate bundled Skill name.");
|
|
380
360
|
names.add(selectedName);
|
|
381
361
|
if (!select(selectedName)) return [];
|
|
382
362
|
}
|
|
383
|
-
const files = readFiles(
|
|
363
|
+
const files = readFiles(path2.join(directory, entry.name));
|
|
384
364
|
const name = skillName(files.get("SKILL.md").toString("utf8"));
|
|
385
365
|
if (selectedName !== void 0 && selectedName !== name) throw new Error("Bundled Skill metadata changed.");
|
|
386
366
|
return [{ name, files }];
|
|
@@ -398,12 +378,12 @@ function verifyGlobalSkills(skills, directory) {
|
|
|
398
378
|
return skills.flatMap((skill) => {
|
|
399
379
|
let reason = "";
|
|
400
380
|
try {
|
|
401
|
-
const target =
|
|
402
|
-
if (skillName(
|
|
381
|
+
const target = path2.join(directory, skill.name);
|
|
382
|
+
if (skillName(fs2.readFileSync(path2.join(target, "SKILL.md"), "utf8")) !== skill.name) {
|
|
403
383
|
reason = "Installed Skill name does not match the bundled Skill.";
|
|
404
384
|
} else {
|
|
405
385
|
for (const [file, expected] of skill.files) {
|
|
406
|
-
if (!
|
|
386
|
+
if (!fs2.readFileSync(path2.join(target, file)).equals(expected)) {
|
|
407
387
|
reason = "Installed files do not match the CLI package version.";
|
|
408
388
|
break;
|
|
409
389
|
}
|
|
@@ -418,8 +398,8 @@ function verifyGlobalSkills(skills, directory) {
|
|
|
418
398
|
|
|
419
399
|
// src/core/business-config.ts
|
|
420
400
|
import crypto2 from "crypto";
|
|
421
|
-
import
|
|
422
|
-
import
|
|
401
|
+
import fs6 from "fs";
|
|
402
|
+
import path6 from "path";
|
|
423
403
|
|
|
424
404
|
// src/core/skill-businesses.json
|
|
425
405
|
var skill_businesses_default = {
|
|
@@ -434,8 +414,7 @@ var skill_businesses_default = {
|
|
|
434
414
|
"ae-generate-tracking-code",
|
|
435
415
|
"ae-generate-tracking-plan",
|
|
436
416
|
"ae-metadata",
|
|
437
|
-
"ae-migrate-tracking-code"
|
|
438
|
-
"ae-tracking-matrix"
|
|
417
|
+
"ae-migrate-tracking-code"
|
|
439
418
|
],
|
|
440
419
|
dataops: [
|
|
441
420
|
"ae-dataops"
|
|
@@ -599,19 +578,19 @@ function canManageGlobalSkills() {
|
|
|
599
578
|
|
|
600
579
|
// src/core/business-skill-refresh.ts
|
|
601
580
|
import crypto from "crypto";
|
|
602
|
-
import
|
|
603
|
-
import
|
|
581
|
+
import fs5 from "fs";
|
|
582
|
+
import path5 from "path";
|
|
604
583
|
|
|
605
584
|
// src/core/business-skill-sync.ts
|
|
606
|
-
import
|
|
585
|
+
import fs4 from "fs";
|
|
607
586
|
import os3 from "os";
|
|
608
|
-
import
|
|
587
|
+
import path4 from "path";
|
|
609
588
|
import { createHash as createHash2, randomUUID } from "crypto";
|
|
610
589
|
|
|
611
590
|
// src/core/skills-tool.ts
|
|
612
|
-
import
|
|
591
|
+
import fs3 from "fs";
|
|
613
592
|
import os2 from "os";
|
|
614
|
-
import
|
|
593
|
+
import path3 from "path";
|
|
615
594
|
import { createHash } from "crypto";
|
|
616
595
|
import { createRequire, isBuiltin } from "module";
|
|
617
596
|
import { pathToFileURL } from "url";
|
|
@@ -620,12 +599,12 @@ var MANAGED_SKILLS_TOOL_VERSION = "1.5.12";
|
|
|
620
599
|
var TOOL_SOURCE_SHA256 = "5a2c18ddd70886d5367e39a0f88827ffd1024420e4d9db08149742386c088d2d";
|
|
621
600
|
function skillPathIdentity(file) {
|
|
622
601
|
try {
|
|
623
|
-
const stat =
|
|
602
|
+
const stat = fs3.lstatSync(file, { bigint: true });
|
|
624
603
|
return {
|
|
625
604
|
dev: String(stat.dev),
|
|
626
605
|
ino: String(stat.ino),
|
|
627
606
|
type: stat.isSymbolicLink() ? "symlink" : stat.isDirectory() ? "directory" : stat.isFile() ? "file" : "other",
|
|
628
|
-
...stat.isSymbolicLink() ? { link:
|
|
607
|
+
...stat.isSymbolicLink() ? { link: fs3.readlinkSync(file) } : {}
|
|
629
608
|
};
|
|
630
609
|
} catch (error) {
|
|
631
610
|
if (error.code === "ENOENT") return null;
|
|
@@ -634,28 +613,28 @@ function skillPathIdentity(file) {
|
|
|
634
613
|
}
|
|
635
614
|
function realSkillPath(file) {
|
|
636
615
|
try {
|
|
637
|
-
return
|
|
616
|
+
return fs3.realpathSync(file);
|
|
638
617
|
} catch (error) {
|
|
639
618
|
if (error.code !== "ENOENT") throw error;
|
|
640
|
-
const parent =
|
|
619
|
+
const parent = path3.dirname(file);
|
|
641
620
|
if (parent === file) throw error;
|
|
642
|
-
return
|
|
621
|
+
return path3.join(realSkillPath(parent), path3.basename(file));
|
|
643
622
|
}
|
|
644
623
|
}
|
|
645
624
|
function skillPathProblem(targetDirectory, skill, sourceRoot) {
|
|
646
625
|
try {
|
|
647
|
-
const target = realSkillPath(
|
|
648
|
-
const source = realSkillPath(
|
|
649
|
-
const overlaps = (a, b) => a === b || a.startsWith(b +
|
|
626
|
+
const target = realSkillPath(path3.resolve(targetDirectory, skill));
|
|
627
|
+
const source = realSkillPath(path3.resolve(sourceRoot));
|
|
628
|
+
const overlaps = (a, b) => a === b || a.startsWith(b + path3.sep);
|
|
650
629
|
if (overlaps(target, source) || overlaps(source, target)) return "package_source_overlap";
|
|
651
|
-
let parent =
|
|
630
|
+
let parent = path3.resolve(targetDirectory);
|
|
652
631
|
while (true) {
|
|
653
632
|
try {
|
|
654
|
-
if (
|
|
633
|
+
if (fs3.lstatSync(parent).isSymbolicLink()) return "copy_parent_linked";
|
|
655
634
|
} catch (error) {
|
|
656
635
|
if (error.code !== "ENOENT") throw error;
|
|
657
636
|
}
|
|
658
|
-
const next =
|
|
637
|
+
const next = path3.dirname(parent);
|
|
659
638
|
if (next === parent) return null;
|
|
660
639
|
parent = next;
|
|
661
640
|
}
|
|
@@ -665,27 +644,27 @@ function skillPathProblem(targetDirectory, skill, sourceRoot) {
|
|
|
665
644
|
}
|
|
666
645
|
function skillCopyHash(directory, source = false) {
|
|
667
646
|
try {
|
|
668
|
-
if (!
|
|
647
|
+
if (!fs3.lstatSync(directory).isDirectory()) throw new Error("Not a regular Skill directory.");
|
|
669
648
|
} catch (error) {
|
|
670
649
|
if (error.code === "ENOENT") return null;
|
|
671
650
|
throw error;
|
|
672
651
|
}
|
|
673
652
|
const hash = createHash("sha256");
|
|
674
653
|
const visit = (relative) => {
|
|
675
|
-
for (const name of
|
|
654
|
+
for (const name of fs3.readdirSync(path3.join(directory, relative)).sort()) {
|
|
676
655
|
if (name === ".DS_Store") continue;
|
|
677
|
-
const child =
|
|
678
|
-
const absolute =
|
|
679
|
-
const stat =
|
|
656
|
+
const child = path3.join(relative, name);
|
|
657
|
+
const absolute = path3.join(directory, child);
|
|
658
|
+
const stat = fs3.lstatSync(absolute);
|
|
680
659
|
if (source && (name === "metadata.json" || stat.isDirectory() && [".git", "__pycache__", "__pypackages__"].includes(name))) continue;
|
|
681
|
-
const normalized = child.split(
|
|
660
|
+
const normalized = child.split(path3.sep).join("/");
|
|
682
661
|
if (stat.isSymbolicLink()) throw new Error("Symbolic links are not managed Skill copies.");
|
|
683
662
|
if (stat.isDirectory()) {
|
|
684
663
|
hash.update(`directory:${normalized}\0`);
|
|
685
664
|
visit(child);
|
|
686
665
|
} else if (stat.isFile()) {
|
|
687
666
|
hash.update(`file:${normalized}\0${stat.size}\0`);
|
|
688
|
-
hash.update(
|
|
667
|
+
hash.update(fs3.readFileSync(absolute));
|
|
689
668
|
} else throw new Error("Unsupported Skill file type.");
|
|
690
669
|
}
|
|
691
670
|
};
|
|
@@ -742,7 +721,7 @@ function adaptedToolSource(source, entry) {
|
|
|
742
721
|
);
|
|
743
722
|
source = replaceOnce(source, "main().finally(() => flushTelemetry().then(() => process.exit(0)));", "");
|
|
744
723
|
const require2 = createRequire(entry);
|
|
745
|
-
const resolveImport = (specifier) => isBuiltin(specifier) ? specifier : pathToFileURL(specifier.startsWith(".") ?
|
|
724
|
+
const resolveImport = (specifier) => isBuiltin(specifier) ? specifier : pathToFileURL(specifier.startsWith(".") ? path3.resolve(path3.dirname(entry), specifier) : require2.resolve(specifier)).href;
|
|
746
725
|
source = source.replace(
|
|
747
726
|
/\bfrom (['"])([^'"]+)\1/g,
|
|
748
727
|
(_match, quote, specifier) => `from ${quote}${resolveImport(specifier)}${quote}`
|
|
@@ -952,19 +931,19 @@ catch { process.stdout.write(JSON.stringify({ ok: false })); process.exitCode =
|
|
|
952
931
|
`;
|
|
953
932
|
function createPinnedSkillsTool(options = {}) {
|
|
954
933
|
const require2 = createRequire(import.meta.url);
|
|
955
|
-
const packageFile = options.entry ?
|
|
956
|
-
const entry = options.entry ??
|
|
957
|
-
const metadata = JSON.parse(
|
|
958
|
-
const source =
|
|
934
|
+
const packageFile = options.entry ? path3.join(path3.dirname(options.entry), "..", "package.json") : require2.resolve("skills/package.json");
|
|
935
|
+
const entry = options.entry ?? path3.join(path3.dirname(packageFile), "dist", "cli.mjs");
|
|
936
|
+
const metadata = JSON.parse(fs3.readFileSync(packageFile, "utf8"));
|
|
937
|
+
const source = fs3.readFileSync(entry, "utf8");
|
|
959
938
|
if (metadata.version !== MANAGED_SKILLS_TOOL_VERSION || createHash("sha256").update(source).digest("hex") !== TOOL_SOURCE_SHA256) {
|
|
960
939
|
throw new Error("Managed Skill synchronization requires the verified skills@1.5.12 package.");
|
|
961
940
|
}
|
|
962
941
|
const script = adaptedToolSource(source, entry);
|
|
963
942
|
const run = (request) => {
|
|
964
|
-
const directory =
|
|
965
|
-
const worker =
|
|
943
|
+
const directory = fs3.mkdtempSync(path3.join(os2.tmpdir(), "ae-cli-skills-tool-"));
|
|
944
|
+
const worker = path3.join(directory, "adapter.mjs");
|
|
966
945
|
try {
|
|
967
|
-
|
|
946
|
+
fs3.writeFileSync(worker, script, { mode: 384 });
|
|
968
947
|
const result2 = spawn2.sync(process.execPath, [worker], {
|
|
969
948
|
input: JSON.stringify(request),
|
|
970
949
|
encoding: "utf8",
|
|
@@ -981,7 +960,7 @@ function createPinnedSkillsTool(options = {}) {
|
|
|
981
960
|
} catch {
|
|
982
961
|
throw new Error("Skills adapter failed. Check the pinned package and directory permissions.");
|
|
983
962
|
} finally {
|
|
984
|
-
|
|
963
|
+
fs3.rmSync(directory, { recursive: true, force: true });
|
|
985
964
|
}
|
|
986
965
|
};
|
|
987
966
|
return {
|
|
@@ -998,17 +977,17 @@ var POLICY_HASH = createHash2("sha256").update(JSON.stringify({ removal_policy:
|
|
|
998
977
|
function historicalCliSkills(options) {
|
|
999
978
|
const env = options.env ?? process.env;
|
|
1000
979
|
const home = env.HOME || env.USERPROFILE || os3.homedir();
|
|
1001
|
-
const file = env.XDG_STATE_HOME ?
|
|
980
|
+
const file = env.XDG_STATE_HOME ? path4.join(env.XDG_STATE_HOME, "skills", ".skill-lock.json") : path4.join(home, ".agents", ".skill-lock.json");
|
|
1002
981
|
const names = /* @__PURE__ */ new Set();
|
|
1003
982
|
let content = "";
|
|
1004
983
|
const isCliSource = (value, type) => {
|
|
1005
984
|
if (typeof value !== "string") return false;
|
|
1006
|
-
if (type === "local" &&
|
|
1007
|
-
const source2 =
|
|
1008
|
-
if (source2 ===
|
|
1009
|
-
if (
|
|
985
|
+
if (type === "local" && path4.isAbsolute(value)) {
|
|
986
|
+
const source2 = path4.resolve(value);
|
|
987
|
+
if (source2 === path4.resolve(options.skillsDirectory)) return true;
|
|
988
|
+
if (path4.basename(source2) !== "skills") return false;
|
|
1010
989
|
try {
|
|
1011
|
-
const pkg = JSON.parse(
|
|
990
|
+
const pkg = JSON.parse(fs4.readFileSync(path4.join(source2, "..", "package.json"), "utf8"));
|
|
1012
991
|
return ["@tant/ae-cli", "@thinkingai/ae-cli"].includes(pkg.name) && typeof pkg.bin?.["ae-cli"] === "string";
|
|
1013
992
|
} catch {
|
|
1014
993
|
return false;
|
|
@@ -1026,7 +1005,7 @@ function historicalCliSkills(options) {
|
|
|
1026
1005
|
].includes(source);
|
|
1027
1006
|
};
|
|
1028
1007
|
try {
|
|
1029
|
-
content =
|
|
1008
|
+
content = fs4.readFileSync(file, "utf8");
|
|
1030
1009
|
const lock = JSON.parse(content);
|
|
1031
1010
|
const mapped = new Set(Object.values(skill_businesses_default).flat());
|
|
1032
1011
|
if (typeof lock.version === "number" && lock.skills && typeof lock.skills === "object") {
|
|
@@ -1043,11 +1022,11 @@ function historicalCliSkills(options) {
|
|
|
1043
1022
|
function writeJson(file, value) {
|
|
1044
1023
|
const temporary = `${file}.${process.pid}.${randomUUID()}.tmp`;
|
|
1045
1024
|
try {
|
|
1046
|
-
|
|
1047
|
-
|
|
1025
|
+
fs4.writeFileSync(temporary, JSON.stringify(value, null, 2) + "\n", { mode: 384, flag: "wx" });
|
|
1026
|
+
fs4.renameSync(temporary, file);
|
|
1048
1027
|
} finally {
|
|
1049
1028
|
try {
|
|
1050
|
-
|
|
1029
|
+
fs4.unlinkSync(temporary);
|
|
1051
1030
|
} catch {
|
|
1052
1031
|
}
|
|
1053
1032
|
}
|
|
@@ -1067,15 +1046,15 @@ function contextIdentity(options) {
|
|
|
1067
1046
|
}
|
|
1068
1047
|
function reserveBusinessSkillContext(options) {
|
|
1069
1048
|
const directory = options.stateDirectory ?? getConfigDir();
|
|
1070
|
-
|
|
1049
|
+
fs4.mkdirSync(directory, { recursive: true, mode: 448 });
|
|
1071
1050
|
const generation = randomUUID();
|
|
1072
|
-
writeJson(
|
|
1051
|
+
writeJson(path4.join(directory, CONTEXT_FILE), { ...contextIdentity(options), generation });
|
|
1073
1052
|
return generation;
|
|
1074
1053
|
}
|
|
1075
1054
|
function currentContext(options, file, generation) {
|
|
1076
1055
|
try {
|
|
1077
1056
|
if (options.isCurrentContext && !options.isCurrentContext()) return false;
|
|
1078
|
-
const active = JSON.parse(
|
|
1057
|
+
const active = JSON.parse(fs4.readFileSync(file, "utf8"));
|
|
1079
1058
|
const identity = contextIdentity(options);
|
|
1080
1059
|
return active.generation === generation && active.host === identity.host && active.token_fingerprint === identity.token_fingerprint;
|
|
1081
1060
|
} catch {
|
|
@@ -1083,12 +1062,12 @@ function currentContext(options, file, generation) {
|
|
|
1083
1062
|
}
|
|
1084
1063
|
}
|
|
1085
1064
|
function isBusinessSkillContextCurrent(options) {
|
|
1086
|
-
return currentContext(options,
|
|
1065
|
+
return currentContext(options, path4.join(options.stateDirectory ?? getConfigDir(), CONTEXT_FILE), options.generation);
|
|
1087
1066
|
}
|
|
1088
1067
|
function takeLock(file) {
|
|
1089
1068
|
const owner = randomUUID();
|
|
1090
1069
|
const ownerName = `owner-${process.pid}-${owner}.json`;
|
|
1091
|
-
const candidate =
|
|
1070
|
+
const candidate = fs4.mkdtempSync(`${file}.candidate-`);
|
|
1092
1071
|
const alive = (pid) => {
|
|
1093
1072
|
try {
|
|
1094
1073
|
process.kill(pid, 0);
|
|
@@ -1098,29 +1077,29 @@ function takeLock(file) {
|
|
|
1098
1077
|
}
|
|
1099
1078
|
};
|
|
1100
1079
|
try {
|
|
1101
|
-
|
|
1102
|
-
|
|
1080
|
+
fs4.chmodSync(candidate, 448);
|
|
1081
|
+
fs4.writeFileSync(path4.join(candidate, ownerName), JSON.stringify({ pid: process.pid, owner }), { mode: 384 });
|
|
1103
1082
|
for (let attempt = 0; attempt < 4; attempt++) {
|
|
1104
1083
|
try {
|
|
1105
|
-
|
|
1084
|
+
fs4.renameSync(candidate, file);
|
|
1106
1085
|
try {
|
|
1107
|
-
|
|
1086
|
+
fs4.unlinkSync(`${file}.reclaim`);
|
|
1108
1087
|
} catch {
|
|
1109
1088
|
}
|
|
1110
1089
|
return () => {
|
|
1111
1090
|
try {
|
|
1112
|
-
|
|
1091
|
+
fs4.unlinkSync(path4.join(file, ownerName));
|
|
1113
1092
|
} catch {
|
|
1114
1093
|
}
|
|
1115
1094
|
try {
|
|
1116
|
-
|
|
1095
|
+
fs4.rmdirSync(file);
|
|
1117
1096
|
} catch {
|
|
1118
1097
|
}
|
|
1119
1098
|
};
|
|
1120
1099
|
} catch (error) {
|
|
1121
1100
|
let stat;
|
|
1122
1101
|
try {
|
|
1123
|
-
stat =
|
|
1102
|
+
stat = fs4.lstatSync(file);
|
|
1124
1103
|
} catch (cause) {
|
|
1125
1104
|
if (cause.code === "ENOENT") continue;
|
|
1126
1105
|
throw error;
|
|
@@ -1129,12 +1108,12 @@ function takeLock(file) {
|
|
|
1129
1108
|
if (stat.isFile()) {
|
|
1130
1109
|
let pid;
|
|
1131
1110
|
try {
|
|
1132
|
-
pid = JSON.parse(
|
|
1111
|
+
pid = JSON.parse(fs4.readFileSync(file, "utf8")).pid;
|
|
1133
1112
|
} catch {
|
|
1134
1113
|
}
|
|
1135
1114
|
if (typeof pid === "number" && Number.isInteger(pid) && pid > 0 && alive(pid)) return null;
|
|
1136
1115
|
try {
|
|
1137
|
-
|
|
1116
|
+
fs4.unlinkSync(file);
|
|
1138
1117
|
} catch (cause) {
|
|
1139
1118
|
if (!["ENOENT", "EISDIR", "EPERM"].includes(cause.code ?? "")) throw cause;
|
|
1140
1119
|
}
|
|
@@ -1143,7 +1122,7 @@ function takeLock(file) {
|
|
|
1143
1122
|
if (!stat.isDirectory()) return null;
|
|
1144
1123
|
let names;
|
|
1145
1124
|
try {
|
|
1146
|
-
names =
|
|
1125
|
+
names = fs4.readdirSync(file);
|
|
1147
1126
|
} catch (cause) {
|
|
1148
1127
|
if (cause.code === "ENOENT") continue;
|
|
1149
1128
|
throw cause;
|
|
@@ -1154,13 +1133,13 @@ function takeLock(file) {
|
|
|
1154
1133
|
}
|
|
1155
1134
|
for (const name of names) {
|
|
1156
1135
|
try {
|
|
1157
|
-
|
|
1136
|
+
fs4.unlinkSync(path4.join(file, name));
|
|
1158
1137
|
} catch (cause) {
|
|
1159
1138
|
if (cause.code !== "ENOENT") throw cause;
|
|
1160
1139
|
}
|
|
1161
1140
|
}
|
|
1162
1141
|
try {
|
|
1163
|
-
|
|
1142
|
+
fs4.rmdirSync(file);
|
|
1164
1143
|
} catch (cause) {
|
|
1165
1144
|
if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(cause.code ?? "")) throw cause;
|
|
1166
1145
|
}
|
|
@@ -1168,13 +1147,13 @@ function takeLock(file) {
|
|
|
1168
1147
|
}
|
|
1169
1148
|
return null;
|
|
1170
1149
|
} finally {
|
|
1171
|
-
|
|
1150
|
+
fs4.rmSync(candidate, { recursive: true, force: true });
|
|
1172
1151
|
}
|
|
1173
1152
|
}
|
|
1174
1153
|
function readLedger(file) {
|
|
1175
1154
|
let value;
|
|
1176
1155
|
try {
|
|
1177
|
-
value = JSON.parse(
|
|
1156
|
+
value = JSON.parse(fs4.readFileSync(file, "utf8"));
|
|
1178
1157
|
} catch (error) {
|
|
1179
1158
|
if (error.code === "ENOENT") return { schema_version: 1, copies: {} };
|
|
1180
1159
|
throw new Error("Managed Skill ledger is unreadable.");
|
|
@@ -1183,12 +1162,12 @@ function readLedger(file) {
|
|
|
1183
1162
|
throw new Error("Managed Skill ledger has an unsupported format.");
|
|
1184
1163
|
}
|
|
1185
1164
|
for (const [filePath, copy] of Object.entries(value.copies)) {
|
|
1186
|
-
if (!
|
|
1165
|
+
if (!path4.isAbsolute(filePath) || !copy || typeof copy.skill !== "string" || typeof copy.agent !== "string" || !/^[a-f0-9]{64}$/.test(copy.hash) || typeof copy.package_version !== "string") throw new Error("Managed Skill ledger has an invalid copy.");
|
|
1187
1166
|
}
|
|
1188
1167
|
return value;
|
|
1189
1168
|
}
|
|
1190
1169
|
function result(skill, target, reason) {
|
|
1191
|
-
return { skill, agent: target.agent, path:
|
|
1170
|
+
return { skill, agent: target.agent, path: path4.join(target.directory, skill), ...reason ? { reason } : {} };
|
|
1192
1171
|
}
|
|
1193
1172
|
function directInstallerLink(file, target, text) {
|
|
1194
1173
|
if (typeof text !== "string") return false;
|
|
@@ -1196,21 +1175,21 @@ function directInstallerLink(file, target, text) {
|
|
|
1196
1175
|
if (process.platform === "win32") {
|
|
1197
1176
|
if (value.toUpperCase().startsWith("\\\\?\\UNC\\")) value = "\\\\" + value.slice(8);
|
|
1198
1177
|
else if (value.startsWith("\\\\?\\") || value.startsWith("\\??\\")) value = value.slice(4);
|
|
1199
|
-
return [target,
|
|
1178
|
+
return [target, path4.relative(path4.dirname(file), target)].some((expected) => value.toLowerCase() === expected.toLowerCase());
|
|
1200
1179
|
}
|
|
1201
|
-
return value === target || value ===
|
|
1180
|
+
return value === target || value === path4.relative(path4.dirname(file), target);
|
|
1202
1181
|
}
|
|
1203
1182
|
function legacySkillLink(file, skill, sourceRoot, sourceHash, targets, ledger, removing = false) {
|
|
1204
1183
|
const canonical = targets.find((target2) => target2.agent === "universal");
|
|
1205
1184
|
if (!canonical) return;
|
|
1206
|
-
const target =
|
|
1185
|
+
const target = path4.join(canonical.directory, skill);
|
|
1207
1186
|
const managed = ledger.copies[target];
|
|
1208
1187
|
if (!managed || managed.skill !== skill || managed.agent !== canonical.agent || !removing && managed.hash !== sourceHash || skillPathProblem(canonical.directory, skill, sourceRoot)) return;
|
|
1209
1188
|
try {
|
|
1210
|
-
if (!
|
|
1211
|
-
const text =
|
|
1189
|
+
if (!fs4.lstatSync(file).isSymbolicLink()) return;
|
|
1190
|
+
const text = fs4.readlinkSync(file);
|
|
1212
1191
|
if (!directInstallerLink(file, target, text)) return;
|
|
1213
|
-
if (!removing && (skillCopyHash(target) !== sourceHash ||
|
|
1192
|
+
if (!removing && (skillCopyHash(target) !== sourceHash || fs4.realpathSync(file) !== fs4.realpathSync(target))) return;
|
|
1214
1193
|
return { target, text };
|
|
1215
1194
|
} catch {
|
|
1216
1195
|
return;
|
|
@@ -1227,20 +1206,20 @@ function syncBusinessSkills(options) {
|
|
|
1227
1206
|
managed_count: 0
|
|
1228
1207
|
};
|
|
1229
1208
|
const directory = options.stateDirectory ?? getConfigDir();
|
|
1230
|
-
const contextFile =
|
|
1209
|
+
const contextFile = path4.join(directory, CONTEXT_FILE);
|
|
1231
1210
|
let unlock = null;
|
|
1232
1211
|
try {
|
|
1233
1212
|
if (options.isCurrentContext && !options.isCurrentContext()) {
|
|
1234
1213
|
report.status = "stale";
|
|
1235
1214
|
return report;
|
|
1236
1215
|
}
|
|
1237
|
-
|
|
1216
|
+
fs4.mkdirSync(directory, { recursive: true, mode: 448 });
|
|
1238
1217
|
const generation = options.generation ?? reserveBusinessSkillContext(options);
|
|
1239
1218
|
if (!currentContext(options, contextFile, generation)) {
|
|
1240
1219
|
report.status = "stale";
|
|
1241
1220
|
return report;
|
|
1242
1221
|
}
|
|
1243
|
-
unlock = takeLock(
|
|
1222
|
+
unlock = takeLock(path4.join(directory, LOCK_FILE));
|
|
1244
1223
|
if (!unlock) {
|
|
1245
1224
|
report.status = "busy";
|
|
1246
1225
|
return report;
|
|
@@ -1249,7 +1228,7 @@ function syncBusinessSkills(options) {
|
|
|
1249
1228
|
report.status = "stale";
|
|
1250
1229
|
return report;
|
|
1251
1230
|
}
|
|
1252
|
-
const ledgerFile =
|
|
1231
|
+
const ledgerFile = path4.join(directory, LEDGER_FILE);
|
|
1253
1232
|
const ledger = readLedger(ledgerFile);
|
|
1254
1233
|
const packageVersion = options.packageVersion ?? "unknown";
|
|
1255
1234
|
const history = historicalCliSkills(options);
|
|
@@ -1257,7 +1236,7 @@ function syncBusinessSkills(options) {
|
|
|
1257
1236
|
...contextIdentity(options),
|
|
1258
1237
|
package_version: packageVersion,
|
|
1259
1238
|
businesses: normalizeBusinesses(options.businesses),
|
|
1260
|
-
source_root:
|
|
1239
|
+
source_root: fs4.realpathSync(options.skillsDirectory),
|
|
1261
1240
|
policy_hash: POLICY_HASH,
|
|
1262
1241
|
history_hash: history.hash
|
|
1263
1242
|
};
|
|
@@ -1303,7 +1282,7 @@ function syncBusinessSkills(options) {
|
|
|
1303
1282
|
for (const name of skills) {
|
|
1304
1283
|
const state = getSkillBusinessState(name, options.businesses);
|
|
1305
1284
|
if (options.mode !== "adopt" && state === void 0) continue;
|
|
1306
|
-
const source =
|
|
1285
|
+
const source = path4.join(options.skillsDirectory, name);
|
|
1307
1286
|
const sourceHash = bundled.some((skill) => skill.name === name) ? skillCopyHash(source, true) : null;
|
|
1308
1287
|
if (!sourceHash && options.mode === "adopt") throw new Error("Complete package Skill source is missing.");
|
|
1309
1288
|
for (const target of targets) {
|
|
@@ -1328,7 +1307,7 @@ function syncBusinessSkills(options) {
|
|
|
1328
1307
|
}
|
|
1329
1308
|
const legacyLink2 = node.type === "symlink" ? legacySkillLink(item.path, name, options.skillsDirectory, sourceHash ?? "", targets, ledger, true) : void 0;
|
|
1330
1309
|
const canonical = targets.find((copy) => copy.agent === "universal");
|
|
1331
|
-
const historicalLink = node.type === "symlink" && canonical && directInstallerLink(item.path,
|
|
1310
|
+
const historicalLink = node.type === "symlink" && canonical && directInstallerLink(item.path, path4.join(canonical.directory, name), node.link);
|
|
1332
1311
|
const historicalCopy = history.names.has(name) && (target.agent === "universal" && node.type !== "symlink" || historicalLink);
|
|
1333
1312
|
if (!managed && (legacyLink2 || historicalCopy)) {
|
|
1334
1313
|
ledger.copies[item.path] = {
|
|
@@ -1398,7 +1377,7 @@ function syncBusinessSkills(options) {
|
|
|
1398
1377
|
if (managed) delete ledger.copies[item.path];
|
|
1399
1378
|
continue;
|
|
1400
1379
|
}
|
|
1401
|
-
if (actualHash === null && !target.detected && !managed && !
|
|
1380
|
+
if (actualHash === null && !target.detected && !managed && !fs4.existsSync(target.directory)) continue;
|
|
1402
1381
|
operations.push({
|
|
1403
1382
|
action: "install",
|
|
1404
1383
|
skill: name,
|
|
@@ -1491,8 +1470,8 @@ function syncRefreshedBusinessSkills(refresh, businesses) {
|
|
|
1491
1470
|
if (!Object.keys(states).length) return;
|
|
1492
1471
|
try {
|
|
1493
1472
|
const pkg = getLocalCliPackageInfo();
|
|
1494
|
-
const options = { ...refresh, skillsDirectory:
|
|
1495
|
-
if (!
|
|
1473
|
+
const options = { ...refresh, skillsDirectory: path5.join(pkg.root, "skills"), businesses: states, packageVersion: pkg.version };
|
|
1474
|
+
if (!fs5.existsSync(path5.join(getConfigDir(), "business-skills.json"))) {
|
|
1496
1475
|
const adoption = syncBusinessSkills({ ...options, mode: "adopt" });
|
|
1497
1476
|
if (["failed", "busy", "stale"].includes(adoption.status)) {
|
|
1498
1477
|
if (adoption.status !== "stale") process.stderr.write("[ae-cli] Skills could not be synchronized. Retry: ae-cli config refresh\n");
|
|
@@ -1512,14 +1491,14 @@ function syncRefreshedBusinessSkills(refresh, businesses) {
|
|
|
1512
1491
|
var BUSINESS_CONFIG_TTL_MS = 10 * 60 * 1e3;
|
|
1513
1492
|
var UNAVAILABLE_TTL_MS = 5 * 60 * 1e3;
|
|
1514
1493
|
function cachePath() {
|
|
1515
|
-
return
|
|
1494
|
+
return path6.join(getConfigDir(), "business-config.json");
|
|
1516
1495
|
}
|
|
1517
1496
|
function cacheKey(host, token) {
|
|
1518
1497
|
return `${normalizeUrl(host)}#${crypto2.createHash("sha256").update(token).digest("hex")}`;
|
|
1519
1498
|
}
|
|
1520
1499
|
function readStore() {
|
|
1521
1500
|
try {
|
|
1522
|
-
const value = JSON.parse(
|
|
1501
|
+
const value = JSON.parse(fs6.readFileSync(cachePath(), "utf8"));
|
|
1523
1502
|
if (value?.entries && typeof value.entries === "object" && !Array.isArray(value.entries)) return value;
|
|
1524
1503
|
} catch {
|
|
1525
1504
|
}
|
|
@@ -1531,13 +1510,13 @@ function remember(host, token, entry) {
|
|
|
1531
1510
|
const target = cachePath();
|
|
1532
1511
|
const temporary = `${target}.${process.pid}.${crypto2.randomBytes(6).toString("hex")}.tmp`;
|
|
1533
1512
|
try {
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1513
|
+
fs6.mkdirSync(path6.dirname(target), { recursive: true });
|
|
1514
|
+
fs6.writeFileSync(temporary, JSON.stringify(store), { encoding: "utf8", mode: 384 });
|
|
1515
|
+
fs6.renameSync(temporary, target);
|
|
1516
|
+
fs6.chmodSync(target, 384);
|
|
1538
1517
|
} catch {
|
|
1539
1518
|
try {
|
|
1540
|
-
|
|
1519
|
+
fs6.rmSync(temporary, { force: true });
|
|
1541
1520
|
} catch {
|
|
1542
1521
|
}
|
|
1543
1522
|
}
|
|
@@ -1606,7 +1585,7 @@ async function readBusinessConfigForExecution(hostOverride, synchronizeSkills =
|
|
|
1606
1585
|
const token = peekCliToken(host);
|
|
1607
1586
|
if (!token) return {};
|
|
1608
1587
|
return await resolveBusinessConfig(host, token, async () => {
|
|
1609
|
-
const { fetchCliConfig: fetchCliConfig2 } = await import("./compat-check-
|
|
1588
|
+
const { fetchCliConfig: fetchCliConfig2 } = await import("./compat-check-JD5D77ET.js");
|
|
1610
1589
|
return fetchCliConfig2(host, token);
|
|
1611
1590
|
}, Date.now(), synchronizeSkills);
|
|
1612
1591
|
} catch {
|
|
@@ -1654,7 +1633,7 @@ function failInstallation(report, stage, message, cause = "validation") {
|
|
|
1654
1633
|
function installPlan(packageName, version, root = "<npm-root>") {
|
|
1655
1634
|
const config = distribution(packageName);
|
|
1656
1635
|
const target = exactVersion(version);
|
|
1657
|
-
const executable =
|
|
1636
|
+
const executable = path7.join(root, packageName, "bin", "ae-cli.js");
|
|
1658
1637
|
return [
|
|
1659
1638
|
`npm install -g ${packageName}@${target} --registry=${config.registry}`,
|
|
1660
1639
|
`node ${JSON.stringify(executable)} install`
|
|
@@ -1674,27 +1653,27 @@ function skipGlobalSkillReason() {
|
|
|
1674
1653
|
}
|
|
1675
1654
|
function readPackage(root) {
|
|
1676
1655
|
try {
|
|
1677
|
-
return JSON.parse(
|
|
1656
|
+
return JSON.parse(fs7.readFileSync(path7.join(root, "package.json"), "utf8"));
|
|
1678
1657
|
} catch {
|
|
1679
1658
|
return null;
|
|
1680
1659
|
}
|
|
1681
1660
|
}
|
|
1682
1661
|
function linked(root) {
|
|
1683
1662
|
try {
|
|
1684
|
-
return
|
|
1663
|
+
return fs7.lstatSync(root).isSymbolicLink();
|
|
1685
1664
|
} catch {
|
|
1686
1665
|
return false;
|
|
1687
1666
|
}
|
|
1688
1667
|
}
|
|
1689
1668
|
function cliBinBelongsToPackage(bin, packageRoot, platform) {
|
|
1690
|
-
const entry =
|
|
1691
|
-
if (platform !== "win32") return
|
|
1692
|
-
const shim =
|
|
1669
|
+
const entry = fs7.realpathSync(path7.join(packageRoot, "bin", "ae-cli.js"));
|
|
1670
|
+
if (platform !== "win32") return fs7.realpathSync(bin) === entry;
|
|
1671
|
+
const shim = fs7.readFileSync(bin, "utf8");
|
|
1693
1672
|
const targets = [...shim.matchAll(/"%(?:dp0%|~dp0)[\\/]([^"\r\n]+)"/gi)];
|
|
1694
1673
|
return targets.some(([, relative]) => {
|
|
1695
1674
|
try {
|
|
1696
|
-
const target =
|
|
1697
|
-
return
|
|
1675
|
+
const target = path7.resolve(path7.dirname(bin), relative.replace(/\\/g, path7.sep));
|
|
1676
|
+
return fs7.realpathSync(target).toLowerCase() === entry.toLowerCase();
|
|
1698
1677
|
} catch {
|
|
1699
1678
|
return false;
|
|
1700
1679
|
}
|
|
@@ -1735,9 +1714,9 @@ function runInstallation(options = {}) {
|
|
|
1735
1714
|
const prefixResult = runner(npm, ["prefix", "-g"], 15e3);
|
|
1736
1715
|
const globalRoot = rootResult.stdout.trim();
|
|
1737
1716
|
const prefix = prefixResult.stdout.trim();
|
|
1738
|
-
if (!commandSucceeded(rootResult) || !commandSucceeded(prefixResult) || !
|
|
1739
|
-
const packageRoot =
|
|
1740
|
-
const bin = platform === "win32" ?
|
|
1717
|
+
if (!commandSucceeded(rootResult) || !commandSucceeded(prefixResult) || !path7.isAbsolute(globalRoot) || !path7.isAbsolute(prefix) || /[\r\n]/.test(globalRoot + prefix)) return failInstallation(report, stage, "Cannot resolve npm global root and prefix. Check npm configuration.");
|
|
1718
|
+
const packageRoot = path7.join(globalRoot, packageName);
|
|
1719
|
+
const bin = platform === "win32" ? path7.join(prefix, "ae-cli.cmd") : path7.join(prefix, "bin", "ae-cli");
|
|
1741
1720
|
report.cli.path = bin;
|
|
1742
1721
|
const env = options.env ?? process.env;
|
|
1743
1722
|
const installedBefore = readPackage(packageRoot);
|
|
@@ -1760,8 +1739,8 @@ function runInstallation(options = {}) {
|
|
|
1760
1739
|
};
|
|
1761
1740
|
const generation = reserveBusinessSkillContext({ ...identity, stateDirectory });
|
|
1762
1741
|
context = { ...identity, stateDirectory, generation, isCurrentContext };
|
|
1763
|
-
if (!
|
|
1764
|
-
const previousSkills =
|
|
1742
|
+
if (!fs7.existsSync(path7.join(stateDirectory, "business-skills.json")) && installedBefore?.name === packageName) {
|
|
1743
|
+
const previousSkills = path7.join(packageRoot, "skills");
|
|
1765
1744
|
try {
|
|
1766
1745
|
readBundledSkills(previousSkills);
|
|
1767
1746
|
syncSkills({ ...context, skillsDirectory: previousSkills, businesses: {}, mode: "adopt", packageVersion: installedBefore.version });
|
|
@@ -1773,7 +1752,7 @@ function runInstallation(options = {}) {
|
|
|
1773
1752
|
return failInstallation(report, "skills_local", "The active environment changed before installation. Re-run install or update for the current environment.");
|
|
1774
1753
|
}
|
|
1775
1754
|
}
|
|
1776
|
-
if (options.skipCliInstall || installedBefore?.name === packageName && installedBefore.version === target &&
|
|
1755
|
+
if (options.skipCliInstall || installedBefore?.name === packageName && installedBefore.version === target && fs7.existsSync(bin)) {
|
|
1777
1756
|
report.cli.action = "skipped";
|
|
1778
1757
|
progress("[ae-cli] [2/4] Verifying the existing CLI...");
|
|
1779
1758
|
} else {
|
|
@@ -1786,16 +1765,16 @@ function runInstallation(options = {}) {
|
|
|
1786
1765
|
stage = "package_validation";
|
|
1787
1766
|
const installed = readPackage(packageRoot);
|
|
1788
1767
|
if (installed?.name !== packageName || installed.version !== target) return failInstallation(report, stage, "Installed CLI package identity or version does not match the requested distribution.");
|
|
1789
|
-
if (!
|
|
1768
|
+
if (!fs7.existsSync(bin)) return failInstallation(report, stage, "npm did not create the global ae-cli executable. Enable npm bin-links, reinstall, and add the global executable directory to PATH.");
|
|
1790
1769
|
if (!cliBinBelongsToPackage(bin, packageRoot, platform)) return failInstallation(report, stage, "The global executable does not belong to the installed CLI package.");
|
|
1791
1770
|
const versionResult = runner(bin, ["--version"], 15e3);
|
|
1792
1771
|
if (!commandSucceeded(versionResult) || versionResult.stdout.trim() !== target) return failInstallation(report, stage, "ae-cli --version did not return the requested version. Refresh the shell command cache and check npm bin links.");
|
|
1793
|
-
report.cli.entrypoint =
|
|
1772
|
+
report.cli.entrypoint = fs7.realpathSync(path7.join(packageRoot, "bin", "ae-cli.js"));
|
|
1794
1773
|
report.cli.verified = true;
|
|
1795
1774
|
const pathKey = platform === "win32" ? Object.keys(env).find((key) => key.toLowerCase() === "path") : "PATH";
|
|
1796
|
-
const installedPathBin = (env[pathKey ?? "PATH"] ?? "").split(platform === "win32" ? ";" :
|
|
1797
|
-
if (!installedPathBin ||
|
|
1798
|
-
report.cli.warnings.push(`Add ${
|
|
1775
|
+
const installedPathBin = (env[pathKey ?? "PATH"] ?? "").split(platform === "win32" ? ";" : path7.delimiter).filter(Boolean).map((dir) => path7.join(dir.replace(/^"(.*)"$/, "$1"), platform === "win32" ? "ae-cli.cmd" : "ae-cli")).find((file) => fs7.existsSync(file) && !file.includes(`${path7.sep}_npx${path7.sep}`));
|
|
1776
|
+
if (!installedPathBin || fs7.realpathSync(installedPathBin) !== fs7.realpathSync(bin)) {
|
|
1777
|
+
report.cli.warnings.push(`Add ${path7.dirname(bin)} to the front of PATH and refresh the shell command cache. The absolute executable was verified.`);
|
|
1799
1778
|
report.next_steps.push(`Use the verified executable at ${bin}, or correct PATH before invoking ae-cli.`);
|
|
1800
1779
|
}
|
|
1801
1780
|
if (skipSkills) {
|
|
@@ -1804,7 +1783,7 @@ function runInstallation(options = {}) {
|
|
|
1804
1783
|
progress(`[ae-cli] [3/4] ${skipSkills}`);
|
|
1805
1784
|
} else if (context) {
|
|
1806
1785
|
stage = "skills_local";
|
|
1807
|
-
const skillsPath =
|
|
1786
|
+
const skillsPath = path7.join(packageRoot, "skills");
|
|
1808
1787
|
const skills = readBundledSkills(skillsPath);
|
|
1809
1788
|
if (!isBusinessSkillContextCurrent(context)) {
|
|
1810
1789
|
return failInstallation(report, stage, "The active environment changed during CLI installation. Re-run install or update to synchronize its Skills.");
|
|
@@ -1867,14 +1846,14 @@ var LOCK_STALE_MS = 10 * 60 * 1e3;
|
|
|
1867
1846
|
var SYNC_STATE_FILE = "version-sync.json";
|
|
1868
1847
|
var SYNC_LOCK_FILE = "version-sync.lock";
|
|
1869
1848
|
function syncStatePath() {
|
|
1870
|
-
return
|
|
1849
|
+
return path8.join(getConfigDir(), SYNC_STATE_FILE);
|
|
1871
1850
|
}
|
|
1872
1851
|
function syncLockPath() {
|
|
1873
|
-
return
|
|
1852
|
+
return path8.join(getConfigDir(), SYNC_LOCK_FILE);
|
|
1874
1853
|
}
|
|
1875
1854
|
function readSyncStore() {
|
|
1876
1855
|
try {
|
|
1877
|
-
const raw = JSON.parse(
|
|
1856
|
+
const raw = JSON.parse(fs8.readFileSync(syncStatePath(), "utf8"));
|
|
1878
1857
|
if (raw && typeof raw === "object" && raw.hosts && typeof raw.hosts === "object") {
|
|
1879
1858
|
return raw;
|
|
1880
1859
|
}
|
|
@@ -1884,8 +1863,8 @@ function readSyncStore() {
|
|
|
1884
1863
|
}
|
|
1885
1864
|
function writeSyncStore(store) {
|
|
1886
1865
|
try {
|
|
1887
|
-
|
|
1888
|
-
|
|
1866
|
+
fs8.mkdirSync(getConfigDir(), { recursive: true });
|
|
1867
|
+
fs8.writeFileSync(syncStatePath(), JSON.stringify(store, null, 2));
|
|
1889
1868
|
} catch {
|
|
1890
1869
|
}
|
|
1891
1870
|
}
|
|
@@ -1989,20 +1968,20 @@ function friendlyVersionSyncFailure(result2) {
|
|
|
1989
1968
|
return `Version synchronization failed at ${result2.stage}.`;
|
|
1990
1969
|
}
|
|
1991
1970
|
function acquireInstallLock(now) {
|
|
1992
|
-
|
|
1971
|
+
fs8.mkdirSync(getConfigDir(), { recursive: true });
|
|
1993
1972
|
const file = syncLockPath();
|
|
1994
1973
|
try {
|
|
1995
|
-
return
|
|
1974
|
+
return fs8.openSync(file, "wx");
|
|
1996
1975
|
} catch {
|
|
1997
1976
|
try {
|
|
1998
|
-
const age = now.getTime() -
|
|
1977
|
+
const age = now.getTime() - fs8.statSync(file).mtimeMs;
|
|
1999
1978
|
if (age >= LOCK_STALE_MS) {
|
|
2000
|
-
|
|
2001
|
-
return
|
|
1979
|
+
fs8.unlinkSync(file);
|
|
1980
|
+
return fs8.openSync(file, "wx");
|
|
2002
1981
|
}
|
|
2003
1982
|
} catch {
|
|
2004
1983
|
try {
|
|
2005
|
-
return
|
|
1984
|
+
return fs8.openSync(file, "wx");
|
|
2006
1985
|
} catch {
|
|
2007
1986
|
return null;
|
|
2008
1987
|
}
|
|
@@ -2012,11 +1991,11 @@ function acquireInstallLock(now) {
|
|
|
2012
1991
|
}
|
|
2013
1992
|
function releaseInstallLock(fd) {
|
|
2014
1993
|
try {
|
|
2015
|
-
|
|
1994
|
+
fs8.closeSync(fd);
|
|
2016
1995
|
} catch {
|
|
2017
1996
|
}
|
|
2018
1997
|
try {
|
|
2019
|
-
|
|
1998
|
+
fs8.unlinkSync(syncLockPath());
|
|
2020
1999
|
} catch {
|
|
2021
2000
|
}
|
|
2022
2001
|
}
|
|
@@ -2078,12 +2057,12 @@ function autoSyncDirection(current, expected) {
|
|
|
2078
2057
|
|
|
2079
2058
|
// src/core/feature-config.ts
|
|
2080
2059
|
import crypto4 from "crypto";
|
|
2081
|
-
import
|
|
2082
|
-
import
|
|
2060
|
+
import fs9 from "fs";
|
|
2061
|
+
import path9 from "path";
|
|
2083
2062
|
var FEATURE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
2084
2063
|
var UNAVAILABLE_TTL_MS2 = 5 * 60 * 1e3;
|
|
2085
2064
|
function cachePath2() {
|
|
2086
|
-
return
|
|
2065
|
+
return path9.join(getConfigDir(), "feature-config.json");
|
|
2087
2066
|
}
|
|
2088
2067
|
function cacheKey2(host, token) {
|
|
2089
2068
|
const fingerprint = crypto4.createHash("sha256").update(token).digest("hex");
|
|
@@ -2091,7 +2070,7 @@ function cacheKey2(host, token) {
|
|
|
2091
2070
|
}
|
|
2092
2071
|
function readStore2() {
|
|
2093
2072
|
try {
|
|
2094
|
-
const value = JSON.parse(
|
|
2073
|
+
const value = JSON.parse(fs9.readFileSync(cachePath2(), "utf8"));
|
|
2095
2074
|
return value?.entries && typeof value.entries === "object" ? value : { entries: {} };
|
|
2096
2075
|
} catch {
|
|
2097
2076
|
return { entries: {} };
|
|
@@ -2101,13 +2080,13 @@ function writeStore(store) {
|
|
|
2101
2080
|
const target = cachePath2();
|
|
2102
2081
|
const temp = `${target}.${process.pid}.${crypto4.randomBytes(6).toString("hex")}.tmp`;
|
|
2103
2082
|
try {
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2083
|
+
fs9.mkdirSync(path9.dirname(target), { recursive: true });
|
|
2084
|
+
fs9.writeFileSync(temp, JSON.stringify(store), { encoding: "utf8", mode: 384 });
|
|
2085
|
+
fs9.renameSync(temp, target);
|
|
2086
|
+
fs9.chmodSync(target, 384);
|
|
2108
2087
|
} catch {
|
|
2109
2088
|
try {
|
|
2110
|
-
|
|
2089
|
+
fs9.rmSync(temp, { force: true });
|
|
2111
2090
|
} catch {
|
|
2112
2091
|
}
|
|
2113
2092
|
}
|
|
@@ -2154,13 +2133,13 @@ var NOTIFY_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
|
2154
2133
|
var FETCH_TIMEOUT_MS = 3e3;
|
|
2155
2134
|
var CLI_CONFIG_PATH = "/v1/ta/cli/config";
|
|
2156
2135
|
function cacheFilePath() {
|
|
2157
|
-
return
|
|
2136
|
+
return path10.join(getConfigDir(), "compat-check.json");
|
|
2158
2137
|
}
|
|
2159
2138
|
function readStore3() {
|
|
2160
2139
|
try {
|
|
2161
2140
|
const file = cacheFilePath();
|
|
2162
|
-
if (!
|
|
2163
|
-
const raw = JSON.parse(
|
|
2141
|
+
if (!fs10.existsSync(file)) return { hosts: {} };
|
|
2142
|
+
const raw = JSON.parse(fs10.readFileSync(file, "utf8"));
|
|
2164
2143
|
if (!raw || typeof raw !== "object" || !raw.hosts) return { hosts: {} };
|
|
2165
2144
|
return raw;
|
|
2166
2145
|
} catch {
|
|
@@ -2170,8 +2149,8 @@ function readStore3() {
|
|
|
2170
2149
|
function writeStore2(store) {
|
|
2171
2150
|
try {
|
|
2172
2151
|
const dir = getConfigDir();
|
|
2173
|
-
if (!
|
|
2174
|
-
|
|
2152
|
+
if (!fs10.existsSync(dir)) fs10.mkdirSync(dir, { recursive: true });
|
|
2153
|
+
fs10.writeFileSync(cacheFilePath(), JSON.stringify(store, null, 2));
|
|
2175
2154
|
} catch {
|
|
2176
2155
|
}
|
|
2177
2156
|
}
|
|
@@ -2230,7 +2209,7 @@ async function fetchCliConfig(host, cliToken) {
|
|
|
2230
2209
|
const options = {
|
|
2231
2210
|
dispatcher,
|
|
2232
2211
|
signal: controller.signal,
|
|
2233
|
-
headers: { Accept: "application/json", ...external ? { "cli-token": cliToken } : {} },
|
|
2212
|
+
headers: { Accept: "application/json", ...external ? { "cli-token": cliToken } : {}, ...internalCallSourceHeaders() },
|
|
2234
2213
|
...externalCliTokenRequestOptions(url.toString())
|
|
2235
2214
|
};
|
|
2236
2215
|
resp = await fetch(url.toString(), options);
|
|
@@ -2496,7 +2475,6 @@ function notifyIfHostCompat(pkg, hostOverride) {
|
|
|
2496
2475
|
export {
|
|
2497
2476
|
exactVersion,
|
|
2498
2477
|
installHost,
|
|
2499
|
-
getLocalCliPackageInfo,
|
|
2500
2478
|
businessForCommand,
|
|
2501
2479
|
businessForCapability,
|
|
2502
2480
|
canManageGlobalSkills,
|