@buaa_smat/hometrans 26.0.6 → 26.0.8-devecocli.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/agents/a2h-executor.md +37 -0
- package/devecocli-plugin/common.ts +2370 -0
- package/devecocli-plugin/content-resolver.ts +363 -0
- package/devecocli-plugin/install.ts +72 -0
- package/devecocli-plugin/uninstall.ts +26 -0
- package/devecocli-plugin/update.ts +77 -0
- package/i18n/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +2 -2
- package/i18n/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +1 -1
- package/i18n/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +13 -6
- package/i18n/skills/a2h-app-migrate/SKILL.md +2 -2
- package/i18n/skills/a2h-app-migrate/references/workflow.yaml +27 -4
- package/i18n/skills/a2h-app-migrate/scripts/opencode_depth.mjs +418 -0
- package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -0
- package/i18n/skills/a2h-batch-ui-align/SKILL.md +7 -7
- package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -1
- package/i18n/skills/a2h-batch-ui-align/references/cards/state.md +20 -2
- package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +2 -2
- package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +3 -3
- package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +3 -1
- package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +2 -2
- package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +10 -6
- package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +13 -9
- package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +59 -7
- package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +3 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/interactions.mjs +186 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +33 -7
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +83 -22
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +39 -5
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +25 -1
- package/i18n/skills/a2h-page-specgen/SKILL.md +1 -1
- package/i18n/skills/a2h-page-specgen/references/gates.md +3 -1
- package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +11 -11
- package/i18n/skills/a2h-page-specgen/references/spec-template.md +3 -3
- package/i18n/skills/a2h-page-specgen/scripts/contract-calls.mjs +40 -3
- package/i18n/skills/a2h-page-specgen/scripts/entry-evidence.mjs +73 -5
- package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +144 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +11 -11
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +11 -11
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +11 -11
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +11 -11
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +10 -10
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +1 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +11 -11
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +11 -11
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +11 -11
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +11 -11
- package/i18n/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +45 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +100 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +132 -3
- package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +36 -1
- package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +1 -1
- package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +16 -0
- package/i18n/skills/a2h-utg-static/SKILL.md +2 -0
- package/index.js +1741 -0
- package/package.json +8 -8
- package/platforms/atomcode/agents/a2h-executor.frontmatter.md +6 -0
- package/platforms/codebuddy/agents/a2h-executor.frontmatter.md +5 -0
- package/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +2 -2
- package/platforms/deveco/agents/a2h-executor.frontmatter.md +7 -0
- package/platforms/deveco/agents/build-fixer.frontmatter.md +0 -2
- package/platforms/deveco/agents/code-reviewer.frontmatter.md +0 -2
- package/platforms/deveco/agents/model-render-worker.frontmatter.md +0 -2
- package/platforms/deveco/agents/model-worker.frontmatter.md +0 -2
- package/platforms/deveco/agents/specgen-worker.frontmatter.md +0 -2
- package/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +1 -1
- package/platforms/opencode/agents/a2h-executor.frontmatter.md +7 -0
- package/platforms/opencode/agents/build-fixer.frontmatter.md +0 -2
- package/platforms/opencode/agents/code-reviewer.frontmatter.md +0 -2
- package/platforms/opencode/agents/model-render-worker.frontmatter.md +0 -2
- package/platforms/opencode/agents/model-worker.frontmatter.md +0 -2
- package/platforms/opencode/agents/specgen-worker.frontmatter.md +0 -2
- package/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +13 -6
- package/plugin.jsonc +12 -0
- package/skills/a2h-app-migrate/SKILL.md +29 -3
- package/skills/a2h-app-migrate/references/host-rules.md +33 -0
- package/skills/a2h-app-migrate/references/workflow.yaml +24 -4
- package/skills/a2h-app-migrate/scripts/opencode_depth.mjs +418 -0
- package/skills/a2h-app-migrate/test/test_executor_header_sync.mjs +78 -0
- package/skills/a2h-app-migrate/test/test_opencode_depth.mjs +312 -0
- package/skills/a2h-app-migrate/tools/dag.mjs +267 -0
- package/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -0
- package/skills/a2h-batch-ui-align/SKILL.md +7 -7
- package/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -1
- package/skills/a2h-batch-ui-align/references/cards/state.md +20 -2
- package/skills/a2h-batch-ui-align/references/cards/widgets.md +2 -2
- package/skills/a2h-batch-ui-align/references/checker-rules.md +3 -3
- package/skills/a2h-batch-ui-align/references/conversion-procedure.md +3 -1
- package/skills/a2h-batch-ui-align/references/host-dispatch.md +5 -5
- package/skills/a2h-batch-ui-align/references/incremental-scope.md +2 -2
- package/skills/a2h-batch-ui-align/references/step3-capture.md +10 -6
- package/skills/a2h-batch-ui-align/references/step5-convert.md +13 -9
- package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +59 -7
- package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +3 -0
- package/skills/a2h-batch-ui-align/scripts/group_pass.mjs +3 -2
- package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +139 -23
- package/skills/a2h-batch-ui-align/scripts/host_env.mjs +32 -8
- package/skills/a2h-batch-ui-align/scripts/interactions.mjs +186 -0
- package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +33 -7
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +83 -22
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +39 -5
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_hit_test.test.mjs +82 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +25 -1
- package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +184 -2
- package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +33 -0
- package/skills/a2h-batch-ui-align/scripts/tests/interactions.test.mjs +258 -0
- package/skills/a2h-page-specgen/SKILL.md +1 -1
- package/skills/a2h-page-specgen/references/evidence.md +15 -0
- package/skills/a2h-page-specgen/references/gates.md +3 -1
- package/skills/a2h-page-specgen/references/scenario-authoring.md +10 -10
- package/skills/a2h-page-specgen/references/spec-template.md +2 -2
- package/skills/a2h-page-specgen/scripts/contract-calls.mjs +40 -3
- package/skills/a2h-page-specgen/scripts/entry-evidence.mjs +73 -5
- package/skills/a2h-page-specgen/scripts/gate.mjs +141 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +10 -10
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +10 -10
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +10 -10
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +10 -10
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +10 -10
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +1 -1
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +10 -10
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +10 -10
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +10 -10
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +10 -10
- package/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +45 -1
- package/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +100 -0
- package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +104 -3
- package/skills/a2h-resource-convert/references/conversion-rules.md +2 -0
- package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +36 -1
- package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +42 -0
- package/skills/a2h-spec-design-pipeline/SKILL.md +1 -1
- package/skills/a2h-spec-design-pipeline/references/coding-loop.md +16 -0
- package/skills/a2h-spec-design-pipeline/references/execution-model.md +2 -2
- package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +5 -1
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +5 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +4 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-cn.md +2 -1
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-en.md +3 -1
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-v2-observation-cn.md +105 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-v2-observation-en.md +122 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIRuntimePitfallCheck.js +4 -4
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIV2ObservationCheck.js +1862 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +2 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +1 -1
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +15 -2
- package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +20 -4
- package/skills/a2h-spec-design-pipeline/scripts/test_arkui_v2_observation.ts +284 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +32 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +22 -1
- package/skills/a2h-utg-static/SKILL.md +2 -0
- package/skills/a2h-utg-static/references/extractors.md +16 -0
- package/skills/a2h-utg-static/scripts/run_pipeline.mjs +22 -1
- package/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +4 -0
- package/skills/a2h-utg-static/scripts/tests/test_pr169_review_fixes.mjs +15 -0
- package/skills/a2h-utg-static/scripts/tests/test_view_attachments.mjs +330 -0
- package/skills/a2h-utg-static/scripts/view_attachments.mjs +465 -0
- package/README.md +0 -410
- package/dist/cli/config-store.js +0 -128
- package/dist/cli/config.js +0 -48
- package/dist/cli/editors.json +0 -134
- package/dist/cli/env-vars.js +0 -127
- package/dist/cli/index.js +0 -76
- package/dist/cli/init.js +0 -2618
- package/dist/cli/uninstall.js +0 -406
- package/dist/platform/compose.js +0 -228
- package/dist/platform/frontmatter.js +0 -151
- package/dist/platform/installer.js +0 -417
- package/dist/platform/language.js +0 -77
- package/dist/platform/registry.js +0 -338
- package/dist/platform/transform.js +0 -363
- package/dist/platform/types.js +0 -9
- package/dist/platform/validate.js +0 -153
- package/dist/utils/regex.js +0 -7
- package/env-requirements.json +0 -536
- package/platforms/codebuddy/agents/build-fixer.frontmatter.md +0 -5
- package/platforms/codebuddy/agents/code-reviewer.frontmatter.md +0 -5
- package/platforms/codebuddy/agents/model-render-worker.frontmatter.md +0 -5
- package/platforms/codebuddy/agents/model-worker.frontmatter.md +0 -5
- package/platforms/codebuddy/agents/specgen-worker.frontmatter.md +0 -5
- package/resource/choose_editor.png +0 -0
- package/resource/set_sdk.png +0 -0
- package/resource/title_dark.png +0 -0
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language-aware resolution of the plugin's install source.
|
|
3
|
+
*
|
|
4
|
+
* The package root carries the Chinese originals; `i18n/` mirrors only the files that actually needed translation
|
|
5
|
+
* (a Chinese file name and/or Chinese content). `i18n/FILE-NAMES.md` pairs an English copy with a Chinese-named
|
|
6
|
+
* original. For an English install every file is resolved as:
|
|
7
|
+
*
|
|
8
|
+
* 1. the relative path is listed in FILE-NAMES.md -> use the English copy, and the file lands under the English name;
|
|
9
|
+
* 2. otherwise `i18n/<relative path>` exists -> use it (same name);
|
|
10
|
+
* 3. otherwise -> use the package-root file.
|
|
11
|
+
*
|
|
12
|
+
* `platforms/` files go through exactly the same resolver, so an `i18n/platforms/...` overlay would work as soon as it
|
|
13
|
+
* exists. A Chinese install never touches `i18n/` at all and is byte-identical to the behavior before this module.
|
|
14
|
+
*
|
|
15
|
+
* Language selection (`resolveInstallLanguage`): explicit `--lang` > HOMETRANS_PLUGIN_LANG > the host time zone
|
|
16
|
+
* (China -> zh, anywhere else -> en) > the host locale > zh (the behavior of every earlier release).
|
|
17
|
+
*
|
|
18
|
+
* This module is imported both by the bundled plugin entry and by the standalone scripts (`node
|
|
19
|
+
* devecocli-plugin/<cmd>.ts`), so it depends only on Node built-in modules and uses `.ts`-suffixed imports.
|
|
20
|
+
*/
|
|
21
|
+
import fs from 'node:fs/promises';
|
|
22
|
+
import path from 'node:path';
|
|
23
|
+
|
|
24
|
+
export const INSTALL_LANGUAGES = ['zh', 'en'] as const;
|
|
25
|
+
export type InstallLanguage = (typeof INSTALL_LANGUAGES)[number];
|
|
26
|
+
|
|
27
|
+
/** Default when nothing can be detected: keep the behavior of every earlier release. */
|
|
28
|
+
export const DEFAULT_INSTALL_LANGUAGE: InstallLanguage = 'zh';
|
|
29
|
+
|
|
30
|
+
/** IANA time zones that mean "domestic install". Hong Kong / Macau / Taiwan are Chinese-language regions. */
|
|
31
|
+
const CHINA_TIME_ZONES = new Set([
|
|
32
|
+
'Asia/Shanghai',
|
|
33
|
+
'Asia/Chongqing',
|
|
34
|
+
'Asia/Chungking',
|
|
35
|
+
'Asia/Harbin',
|
|
36
|
+
'Asia/Urumqi',
|
|
37
|
+
'Asia/Kashgar',
|
|
38
|
+
'Asia/Macau',
|
|
39
|
+
'Asia/Hong_Kong',
|
|
40
|
+
'Asia/Taipei',
|
|
41
|
+
'Asia/Beijing',
|
|
42
|
+
'PRC',
|
|
43
|
+
'ROC',
|
|
44
|
+
'Hongkong',
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
export function isChinaTimeZone(timeZone: string | undefined | null): boolean {
|
|
48
|
+
if (!timeZone) return false;
|
|
49
|
+
return CHINA_TIME_ZONES.has(timeZone.trim());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** `zh` / `zh-CN` / `zh_CN` -> zh, `en` / `en-US` -> en, anything else -> undefined. */
|
|
53
|
+
export function parseInstallLanguage(value: string | undefined | null): InstallLanguage | undefined {
|
|
54
|
+
if (!value) return undefined;
|
|
55
|
+
const normalized = value.trim().toLowerCase().replace(/_/g, '-');
|
|
56
|
+
if (normalized === 'zh' || normalized.startsWith('zh-')) return 'zh';
|
|
57
|
+
if (normalized === 'en' || normalized.startsWith('en-')) return 'en';
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface LanguageSignals {
|
|
62
|
+
/** Explicit `--lang` value; invalid values are ignored here (parseArgs rejects them before this point). */
|
|
63
|
+
lang?: string;
|
|
64
|
+
env?: NodeJS.ProcessEnv;
|
|
65
|
+
/** Overrides time-zone detection (tests). */
|
|
66
|
+
timeZone?: string | null;
|
|
67
|
+
/** Overrides locale detection (tests). */
|
|
68
|
+
locale?: string | null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function detectTimeZone(env: NodeJS.ProcessEnv): string | null {
|
|
72
|
+
try {
|
|
73
|
+
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
74
|
+
if (tz) return tz;
|
|
75
|
+
} catch {
|
|
76
|
+
// no ICU time zone data: fall through to the environment
|
|
77
|
+
}
|
|
78
|
+
return env.TZ?.trim() || null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function detectLocale(env: NodeJS.ProcessEnv): string | null {
|
|
82
|
+
try {
|
|
83
|
+
const locale = Intl.DateTimeFormat().resolvedOptions().locale;
|
|
84
|
+
if (locale) return locale;
|
|
85
|
+
} catch {
|
|
86
|
+
// ignore
|
|
87
|
+
}
|
|
88
|
+
const fromEnv = env.LC_ALL || env.LC_MESSAGES || env.LANG;
|
|
89
|
+
return fromEnv?.trim() || null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Resolve the install language. The host exposes no locale to the plugin contract, so the time zone is the primary
|
|
94
|
+
* signal; `HOMETRANS_PLUGIN_LANG=zh|en` is the escape hatch (mirrors HOMETRANS_PLUGIN_VERBOSE).
|
|
95
|
+
*/
|
|
96
|
+
export function resolveInstallLanguage(signals: LanguageSignals = {}): InstallLanguage {
|
|
97
|
+
const env = signals.env ?? process.env;
|
|
98
|
+
const explicit =
|
|
99
|
+
parseInstallLanguage(signals.lang) ?? parseInstallLanguage(env.HOMETRANS_PLUGIN_LANG);
|
|
100
|
+
if (explicit) return explicit;
|
|
101
|
+
|
|
102
|
+
const timeZone = 'timeZone' in signals ? signals.timeZone : detectTimeZone(env);
|
|
103
|
+
if (timeZone) return isChinaTimeZone(timeZone) ? 'zh' : 'en';
|
|
104
|
+
|
|
105
|
+
const locale = 'locale' in signals ? signals.locale : detectLocale(env);
|
|
106
|
+
return parseInstallLanguage(locale) ?? DEFAULT_INSTALL_LANGUAGE;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* ------------------------------------------------------------------ */
|
|
110
|
+
/* i18n/FILE-NAMES.md */
|
|
111
|
+
/* ------------------------------------------------------------------ */
|
|
112
|
+
|
|
113
|
+
export interface OverlayRename {
|
|
114
|
+
/** English copy, relative to the i18n root (POSIX separators). */
|
|
115
|
+
english: string;
|
|
116
|
+
/** Chinese-named original, relative to the package root (POSIX separators). */
|
|
117
|
+
original: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const RENAME_ROW = /^\|\s*`([^`]+)`\s*\|\s*`([^`]+)`\s*\|\s*$/gm;
|
|
121
|
+
|
|
122
|
+
export function parseOverlayRenames(markdown: string): OverlayRename[] {
|
|
123
|
+
return [...markdown.matchAll(RENAME_ROW)].map(([, english, original]) => ({ english, original }));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const RENAME_TABLE = 'FILE-NAMES.md';
|
|
127
|
+
/** Content directories an English install overlays; `platforms/` is optional (no overlay shipped today). */
|
|
128
|
+
const REQUIRED_OVERLAY_DIRS = ['skills', 'agents', 'commands'] as const;
|
|
129
|
+
|
|
130
|
+
export interface RenameMap {
|
|
131
|
+
/** original (package-relative) -> english copy (i18n-relative) */
|
|
132
|
+
byOriginal: Map<string, string>;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Read `i18n/FILE-NAMES.md`, check that the overlay is complete, and return the rename map.
|
|
137
|
+
* Throws rather than letting an "English" install quietly come out in Chinese.
|
|
138
|
+
*/
|
|
139
|
+
export async function loadRenameMap(i18nRoot: string): Promise<RenameMap> {
|
|
140
|
+
for (const dir of REQUIRED_OVERLAY_DIRS) {
|
|
141
|
+
if (!(await isDirectory(path.join(i18nRoot, dir)))) {
|
|
142
|
+
throw new Error(`English content is missing: ${path.join(i18nRoot, dir)}. Reinstall hometrans.`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const tablePath = path.join(i18nRoot, RENAME_TABLE);
|
|
146
|
+
let table: string;
|
|
147
|
+
try {
|
|
148
|
+
table = await fs.readFile(tablePath, 'utf-8');
|
|
149
|
+
} catch {
|
|
150
|
+
throw new Error(`English content is missing: ${tablePath}. Reinstall hometrans.`);
|
|
151
|
+
}
|
|
152
|
+
const byOriginal = new Map<string, string>();
|
|
153
|
+
for (const { english, original } of parseOverlayRenames(table)) {
|
|
154
|
+
const englishRel = toPosix(english);
|
|
155
|
+
byOriginal.set(toPosix(original), englishRel);
|
|
156
|
+
if (!(await exists(path.join(i18nRoot, englishRel)))) {
|
|
157
|
+
throw new Error(`English content is missing: ${path.join(i18nRoot, englishRel)}. Reinstall hometrans.`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return { byOriginal };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* ------------------------------------------------------------------ */
|
|
164
|
+
/* Content resolver */
|
|
165
|
+
/* ------------------------------------------------------------------ */
|
|
166
|
+
|
|
167
|
+
export interface ResolvedFile {
|
|
168
|
+
/** Package-relative source path (POSIX separators). */
|
|
169
|
+
rel: string;
|
|
170
|
+
/** Relative path inside the target after an English rename (POSIX separators). */
|
|
171
|
+
destRel: string;
|
|
172
|
+
/** Absolute source path. */
|
|
173
|
+
src: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export type NameKind = 'dir' | 'file' | 'entry';
|
|
177
|
+
|
|
178
|
+
export interface ContentResolver {
|
|
179
|
+
readonly lang: InstallLanguage;
|
|
180
|
+
/** Absolute source path for a package-relative path, following FILE-NAMES first, then the i18n overlay. */
|
|
181
|
+
resolve(rel: string): Promise<string>;
|
|
182
|
+
/** Target-relative path for a package-relative source path (the English name in an English install). */
|
|
183
|
+
destRel(rel: string): string;
|
|
184
|
+
/** Whether the source exists (package root, platforms root, or i18n overlay). */
|
|
185
|
+
has(rel: string): Promise<boolean>;
|
|
186
|
+
/** Whether the source is a file or a directory. */
|
|
187
|
+
kind(rel: string): Promise<'file' | 'dir' | null>;
|
|
188
|
+
/** Every file under a package-relative directory, with its resolved source and target-relative path. */
|
|
189
|
+
walkDir(relDir: string): Promise<ResolvedFile[]>;
|
|
190
|
+
/**
|
|
191
|
+
* Top-level entry names of a package-relative directory. The overlay never adds entries: it only translates (or
|
|
192
|
+
* renames) files that exist in the package root, so the names listed here are language-independent.
|
|
193
|
+
*/
|
|
194
|
+
listNames(relDir: string, kind: NameKind): Promise<string[]>;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export interface ContentResolverOptions {
|
|
198
|
+
packageRoot: string;
|
|
199
|
+
/** English overlay root; required for an English install. */
|
|
200
|
+
i18nRoot?: string;
|
|
201
|
+
/** Where `platforms/` lives when it is not `<packageRoot>/platforms`. */
|
|
202
|
+
platformsRoot?: string;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Normalize a path to POSIX separators for use as a package-relative key. */
|
|
206
|
+
export function toPosix(p: string): string {
|
|
207
|
+
return p.split(path.sep).join('/').replace(/\\/g, '/');
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async function exists(p: string): Promise<boolean> {
|
|
211
|
+
try {
|
|
212
|
+
await fs.access(p);
|
|
213
|
+
return true;
|
|
214
|
+
} catch {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async function isDirectory(p: string): Promise<boolean> {
|
|
220
|
+
try {
|
|
221
|
+
return (await fs.stat(p)).isDirectory();
|
|
222
|
+
} catch {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** Recursively list files of `abs`, returned as package-relative POSIX paths under `relDir`. */
|
|
228
|
+
async function walkFiles(abs: string, relDir: string): Promise<string[]> {
|
|
229
|
+
const out: string[] = [];
|
|
230
|
+
const walk = async (dir: string, rel: string): Promise<void> => {
|
|
231
|
+
const entries = await fs.readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
232
|
+
for (const entry of entries) {
|
|
233
|
+
if (entry.name === 'node_modules') continue;
|
|
234
|
+
const childAbs = path.join(dir, entry.name);
|
|
235
|
+
const childRel = rel ? `${rel}/${entry.name}` : entry.name;
|
|
236
|
+
if (entry.isDirectory()) await walk(childAbs, childRel);
|
|
237
|
+
else if (entry.isFile()) out.push(childRel);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
await walk(abs, relDir);
|
|
241
|
+
return out;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** Resolver for the Chinese originals: no overlay, no i18n access. */
|
|
245
|
+
export function createZhResolver(packageRoot: string, platformsRoot?: string): ContentResolver {
|
|
246
|
+
return createResolverImpl(DEFAULT_INSTALL_LANGUAGE, {
|
|
247
|
+
packageRoot,
|
|
248
|
+
platformsRoot: platformsRoot ?? path.join(packageRoot, 'platforms'),
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Build the resolver for an install language. An English resolver reads and validates the i18n overlay up front, so a
|
|
254
|
+
* broken overlay fails before anything is written into the target.
|
|
255
|
+
*/
|
|
256
|
+
export async function createContentResolver(
|
|
257
|
+
lang: InstallLanguage,
|
|
258
|
+
opts: ContentResolverOptions,
|
|
259
|
+
): Promise<ContentResolver> {
|
|
260
|
+
if (lang === DEFAULT_INSTALL_LANGUAGE) return createZhResolver(opts.packageRoot, opts.platformsRoot);
|
|
261
|
+
if (!opts.i18nRoot) {
|
|
262
|
+
throw new Error('English install requested without an i18n root');
|
|
263
|
+
}
|
|
264
|
+
const renames = await loadRenameMap(opts.i18nRoot);
|
|
265
|
+
return createResolverImpl(lang, opts, renames);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function createResolverImpl(
|
|
269
|
+
lang: InstallLanguage,
|
|
270
|
+
opts: ContentResolverOptions,
|
|
271
|
+
renames?: RenameMap,
|
|
272
|
+
): ContentResolver {
|
|
273
|
+
const packageRoot = opts.packageRoot;
|
|
274
|
+
const i18nRoot = opts.i18nRoot;
|
|
275
|
+
const platformsRoot = opts.platformsRoot ?? path.join(packageRoot, 'platforms');
|
|
276
|
+
const byOriginal = renames?.byOriginal ?? new Map<string, string>();
|
|
277
|
+
/** One stat per probed path keeps a whole install from hammering the file system. */
|
|
278
|
+
const existsCache = new Map<string, boolean>();
|
|
279
|
+
|
|
280
|
+
const baseAbs = (rel: string): string => {
|
|
281
|
+
const norm = toPosix(rel);
|
|
282
|
+
const prefix = 'platforms/';
|
|
283
|
+
if (norm.startsWith(prefix)) return path.join(platformsRoot, norm.slice(prefix.length));
|
|
284
|
+
return path.join(packageRoot, norm);
|
|
285
|
+
};
|
|
286
|
+
const cachedExists = async (p: string): Promise<boolean> => {
|
|
287
|
+
const cached = existsCache.get(p);
|
|
288
|
+
if (cached !== undefined) return cached;
|
|
289
|
+
const found = await exists(p);
|
|
290
|
+
existsCache.set(p, found);
|
|
291
|
+
return found;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
const destRel = (rel: string): string => {
|
|
295
|
+
const norm = toPosix(rel);
|
|
296
|
+
if (lang === DEFAULT_INSTALL_LANGUAGE) return norm;
|
|
297
|
+
return byOriginal.get(norm) ?? norm;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
const resolve = async (rel: string): Promise<string> => {
|
|
301
|
+
const norm = toPosix(rel);
|
|
302
|
+
if (lang !== DEFAULT_INSTALL_LANGUAGE && i18nRoot) {
|
|
303
|
+
const renamed = byOriginal.get(norm);
|
|
304
|
+
if (renamed) return path.join(i18nRoot, renamed);
|
|
305
|
+
const candidate = path.join(i18nRoot, norm);
|
|
306
|
+
if (await cachedExists(candidate)) return candidate;
|
|
307
|
+
}
|
|
308
|
+
return baseAbs(norm);
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
const has = async (rel: string): Promise<boolean> => {
|
|
312
|
+
const norm = toPosix(rel);
|
|
313
|
+
if (lang !== DEFAULT_INSTALL_LANGUAGE && i18nRoot) {
|
|
314
|
+
const renamed = byOriginal.get(norm);
|
|
315
|
+
if (renamed) return cachedExists(path.join(i18nRoot, renamed));
|
|
316
|
+
if (await cachedExists(path.join(i18nRoot, norm))) return true;
|
|
317
|
+
}
|
|
318
|
+
return cachedExists(baseAbs(norm));
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
return {
|
|
322
|
+
lang,
|
|
323
|
+
resolve,
|
|
324
|
+
destRel,
|
|
325
|
+
has,
|
|
326
|
+
|
|
327
|
+
async kind(rel: string): Promise<'file' | 'dir' | null> {
|
|
328
|
+
try {
|
|
329
|
+
const stat = await fs.stat(await resolve(rel));
|
|
330
|
+
return stat.isDirectory() ? 'dir' : stat.isFile() ? 'file' : null;
|
|
331
|
+
} catch {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
|
|
336
|
+
async walkDir(relDir: string): Promise<ResolvedFile[]> {
|
|
337
|
+
const dir = toPosix(relDir).replace(/\/+$/, '');
|
|
338
|
+
const out: ResolvedFile[] = [];
|
|
339
|
+
for (const rel of await walkFiles(baseAbs(dir), dir)) {
|
|
340
|
+
// A file whose name was translated is copied from the English original under its English name; everything
|
|
341
|
+
// else resolves per file (translated content, same name). i18n-only files that are not FILE-NAMES targets are
|
|
342
|
+
// stale leftovers and are deliberately not installed.
|
|
343
|
+
out.push({ rel, destRel: destRel(rel), src: await resolve(rel) });
|
|
344
|
+
}
|
|
345
|
+
return out;
|
|
346
|
+
},
|
|
347
|
+
|
|
348
|
+
async listNames(relDir: string, kind: NameKind): Promise<string[]> {
|
|
349
|
+
const dir = toPosix(relDir);
|
|
350
|
+
const names: string[] = [];
|
|
351
|
+
const entries = await fs.readdir(baseAbs(dir), { withFileTypes: true }).catch(() => []);
|
|
352
|
+
for (const entry of entries) {
|
|
353
|
+
if (entry.name === 'node_modules') continue;
|
|
354
|
+
if (kind === 'dir' && !entry.isDirectory()) continue;
|
|
355
|
+
if (kind === 'file' && !entry.isFile()) continue;
|
|
356
|
+
names.push(entry.name);
|
|
357
|
+
}
|
|
358
|
+
// The overlay only translates entries that exist in the package root (a renamed file is resolved through its
|
|
359
|
+
// package-root original by walkDir / resolve), so i18n-only entries are never listed here.
|
|
360
|
+
return names;
|
|
361
|
+
},
|
|
362
|
+
};
|
|
363
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin install: installs skills / agents / commands adapted to the target platform
|
|
3
|
+
* (directory layout, frontmatter conversion and validation rules: see the platform descriptors in common.ts).
|
|
4
|
+
*
|
|
5
|
+
* node devecocli-plugin/install.ts [--agent <name>] [--dir <path>] [--project <path>] [--lang zh|en] [--dry-run] [--verbose]
|
|
6
|
+
*
|
|
7
|
+
* When neither --agent nor --dir / --project is given, installs to every agent in plugin.jsonc installed on this machine.
|
|
8
|
+
* The install language is auto-detected (--lang > HOMETRANS_PLUGIN_LANG > host time zone > host locale > zh); an English
|
|
9
|
+
* install resolves every file through i18n/ (see content-resolver.ts).
|
|
10
|
+
*
|
|
11
|
+
* Output policy (silent by default): a real successful install prints no per-target details; only validation ERRORs go to
|
|
12
|
+
* stderr and end with exit code 1; `--verbose` or HOMETRANS_PLUGIN_VERBOSE=1 restores full
|
|
13
|
+
* details; `--dry-run` is an explicit check action and always prints what would be done.
|
|
14
|
+
*/
|
|
15
|
+
import {
|
|
16
|
+
commandsDirLabel,
|
|
17
|
+
createResolver,
|
|
18
|
+
exists,
|
|
19
|
+
installTo,
|
|
20
|
+
resolveInstallLanguage,
|
|
21
|
+
runCommand,
|
|
22
|
+
} from './common.ts';
|
|
23
|
+
|
|
24
|
+
await runCommand(async (opts, manifest) => {
|
|
25
|
+
const lang = resolveInstallLanguage({ lang: opts.lang });
|
|
26
|
+
const resolver = await createResolver(lang);
|
|
27
|
+
let count = 0;
|
|
28
|
+
let failed = false;
|
|
29
|
+
for (const target of opts.targets) {
|
|
30
|
+
if (!target.explicit && !(await exists(target.platform.markerDir))) {
|
|
31
|
+
if (opts.verbose) {
|
|
32
|
+
console.log(`[${manifest.name}] skip ${target.name}: ${target.platform.markerDir} not found`);
|
|
33
|
+
}
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const r = await installTo(target, { dryRun: opts.dryRun, resolver });
|
|
37
|
+
const errors = r.issues.filter((i) => i.level === 'error');
|
|
38
|
+
const warns = r.issues.filter((i) => i.level === 'warn');
|
|
39
|
+
// When validation finds an ERROR the whole run ends with a non-zero exit code, so the caller can detect the install problem
|
|
40
|
+
if (errors.length > 0) failed = true;
|
|
41
|
+
const dirOf = (d: string | null): string => d ?? '(none)';
|
|
42
|
+
const summary = `${r.skills} skills -> ${dirOf(target.platform.skillsDir)}, ${r.agents} agents -> ${dirOf(target.platform.agentsDir)}, ${r.commands} commands -> ${dirOf(commandsDirLabel(target.platform))}`;
|
|
43
|
+
if (opts.dryRun) {
|
|
44
|
+
console.log(`[${manifest.name}] dry-run ${target.name}: would install ${summary}`);
|
|
45
|
+
} else {
|
|
46
|
+
count++;
|
|
47
|
+
// Silent mode: validation ERRORs only (stderr); --verbose prints full details
|
|
48
|
+
if (!opts.verbose) {
|
|
49
|
+
for (const e of errors) console.error(` - validation ERROR: ${e.message}`);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
console.log(`[${manifest.name}] installed to ${target.name}: ${summary}`);
|
|
53
|
+
}
|
|
54
|
+
for (const s of r.skipped) console.log(` - skipped: ${s}`);
|
|
55
|
+
for (const note of r.notes) console.log(` - transform: ${note}`);
|
|
56
|
+
if (errors.length === 0 && warns.length === 0) {
|
|
57
|
+
console.log(` - validation: PASS (${r.skills + r.agents + r.commands} files re-checked)`);
|
|
58
|
+
} else {
|
|
59
|
+
for (const e of errors) console.log(` - validation ERROR: ${e.message}`);
|
|
60
|
+
for (const w of warns) console.log(` - validation WARN: ${w.message}`);
|
|
61
|
+
}
|
|
62
|
+
// OpenCode family (opencode / deveco): do not modify user config files; only point out the
|
|
63
|
+
// permission.skill restriction scenario (skills are allowed by default, no extra configuration needed)
|
|
64
|
+
if (target.platform.skillSlashMetadata && r.skills > 0) {
|
|
65
|
+
console.log(
|
|
66
|
+
` - note: skills load by default; if your ${target.name} config restricts permission.skill, add an allow rule for "a2h-*"`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (count === 0 && !opts.dryRun) console.log(`[${manifest.name}] no agent installed`);
|
|
71
|
+
if (failed) process.exitCode = 1;
|
|
72
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin uninstall: removes what this plugin installed from the target agents, including leftovers that old versions installed in the wrong
|
|
3
|
+
* location (only entries with the same names as the bundled content are removed; the user's other skills / agents are unaffected).
|
|
4
|
+
*
|
|
5
|
+
* node devecocli-plugin/uninstall.ts [--agent <name>] [--dir <path>] [--project <path>] [--verbose]
|
|
6
|
+
*
|
|
7
|
+
* When neither --agent nor --dir / --project is given, cleans up every agent in plugin.jsonc.
|
|
8
|
+
*
|
|
9
|
+
* Output policy (silent by default): prints nothing on success; `--verbose` or
|
|
10
|
+
* HOMETRANS_PLUGIN_VERBOSE=1 prints what was removed from each target.
|
|
11
|
+
*/
|
|
12
|
+
import { runCommand, uninstallFrom } from './common.ts';
|
|
13
|
+
|
|
14
|
+
await runCommand(async (opts, manifest) => {
|
|
15
|
+
for (const target of opts.targets) {
|
|
16
|
+
const r = await uninstallFrom(target);
|
|
17
|
+
if (!opts.verbose) continue;
|
|
18
|
+
if (r.skills + r.agents + r.commands === 0) {
|
|
19
|
+
console.log(`[${manifest.name}] ${target.name}: nothing to uninstall`);
|
|
20
|
+
} else {
|
|
21
|
+
console.log(
|
|
22
|
+
`[${manifest.name}] uninstalled from ${target.name}: ${r.skills} skills, ${r.agents} agents, ${r.commands} commands removed`,
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin update: removes this plugin's old skills / agents / commands from the target agents (including leftovers in wrong
|
|
3
|
+
* locations from old versions), then reinstalls the current version (with platform adaptation and read-back validation).
|
|
4
|
+
*
|
|
5
|
+
* node devecocli-plugin/update.ts [--agent <name>] [--dir <path>] [--project <path>] [--lang zh|en] [--dry-run] [--verbose]
|
|
6
|
+
*
|
|
7
|
+
* When neither --agent nor --dir / --project is given, only refreshes agents that already have this plugin installed; explicitly given targets are always installed.
|
|
8
|
+
* The install language is auto-detected again (--lang > HOMETRANS_PLUGIN_LANG > host time zone > host locale > zh), so a
|
|
9
|
+
* machine that moved time zone receives the matching language on update.
|
|
10
|
+
*
|
|
11
|
+
* Output policy (silent by default): a real successful update prints no per-target details; only validation ERRORs go to
|
|
12
|
+
* stderr and end with exit code 1; `--verbose` or HOMETRANS_PLUGIN_VERBOSE=1 restores full
|
|
13
|
+
* details; `--dry-run` is an explicit check action and always prints what would be done.
|
|
14
|
+
*/
|
|
15
|
+
import {
|
|
16
|
+
createResolver,
|
|
17
|
+
installTo,
|
|
18
|
+
isInstalledIn,
|
|
19
|
+
resolveInstallLanguage,
|
|
20
|
+
runCommand,
|
|
21
|
+
uninstallFrom,
|
|
22
|
+
} from './common.ts';
|
|
23
|
+
|
|
24
|
+
await runCommand(async (opts, manifest) => {
|
|
25
|
+
const lang = resolveInstallLanguage({ lang: opts.lang });
|
|
26
|
+
const resolver = await createResolver(lang);
|
|
27
|
+
let count = 0;
|
|
28
|
+
let failed = false;
|
|
29
|
+
for (const target of opts.targets) {
|
|
30
|
+
if (!target.explicit && !(await isInstalledIn(target))) {
|
|
31
|
+
if (opts.verbose) console.log(`[${manifest.name}] skip ${target.name}: plugin not installed`);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (opts.dryRun) {
|
|
35
|
+
const r = await installTo(target, { dryRun: true, resolver });
|
|
36
|
+
console.log(
|
|
37
|
+
`[${manifest.name}] dry-run ${target.name}: would update to ${manifest.version} (${r.skills} skills, ${r.agents} agents, ${r.commands} commands)`,
|
|
38
|
+
);
|
|
39
|
+
for (const note of r.notes) console.log(` - transform: ${note}`);
|
|
40
|
+
const errors = r.issues.filter((i) => i.level === 'error');
|
|
41
|
+
const warns = r.issues.filter((i) => i.level === 'warn');
|
|
42
|
+
if (errors.length === 0 && warns.length === 0) {
|
|
43
|
+
console.log(` - validation: PASS (${r.skills + r.agents + r.commands} files re-checked)`);
|
|
44
|
+
} else {
|
|
45
|
+
for (const e of errors) console.log(` - validation ERROR: ${e.message}`);
|
|
46
|
+
for (const w of warns) console.log(` - validation WARN: ${w.message}`);
|
|
47
|
+
}
|
|
48
|
+
if (errors.length > 0) failed = true;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
await uninstallFrom(target);
|
|
52
|
+
const r = await installTo(target, { resolver });
|
|
53
|
+
count++;
|
|
54
|
+
const errors = r.issues.filter((i) => i.level === 'error');
|
|
55
|
+
const warns = r.issues.filter((i) => i.level === 'warn');
|
|
56
|
+
// When validation finds an ERROR the whole run ends with a non-zero exit code, so the caller can detect the update problem
|
|
57
|
+
if (errors.length > 0) failed = true;
|
|
58
|
+
// Silent mode: validation ERRORs only (stderr); --verbose prints full details
|
|
59
|
+
if (!opts.verbose) {
|
|
60
|
+
for (const e of errors) console.error(` - validation ERROR: ${e.message}`);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
console.log(
|
|
64
|
+
`[${manifest.name}] updated ${target.name} to ${manifest.version}: ${r.skills} skills, ${r.agents} agents, ${r.commands} commands`,
|
|
65
|
+
);
|
|
66
|
+
for (const s of r.skipped) console.log(` - skipped: ${s}`);
|
|
67
|
+
for (const note of r.notes) console.log(` - transform: ${note}`);
|
|
68
|
+
if (errors.length === 0 && warns.length === 0) {
|
|
69
|
+
console.log(` - validation: PASS (${r.skills + r.agents + r.commands} files re-checked)`);
|
|
70
|
+
} else {
|
|
71
|
+
for (const e of errors) console.log(` - validation ERROR: ${e.message}`);
|
|
72
|
+
for (const w of warns) console.log(` - validation WARN: ${w.message}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (count === 0 && !opts.dryRun) console.log(`[${manifest.name}] no agent updated`);
|
|
76
|
+
if (failed) process.exitCode = 1;
|
|
77
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Before Step #
|
|
2
2
|
|
|
3
|
-
This platform is codebuddy (CodeBuddy; IDE and CLI share `~/.codebuddy`). The install layer already declares `tools: Agent` in
|
|
3
|
+
This platform is codebuddy (CodeBuddy; IDE and CLI share `~/.codebuddy`). The install layer already declares `tools: Agent` in the frontmatter of the node executor agent `a2h-executor` (verified: it only adds dispatch capability and narrows no other tools; only it dispatches, at depth 1 — leaf workers do not dispatch and declare nothing). Distinguish by host form:
|
|
4
4
|
|
|
5
5
|
- **CodeBuddy CLI (>= v2.187.0, verified)**: nesting depth >= 2 is supported — nodes still dispatch one sub-agent at a time per policy.dispatch (only one node sub-agent runs at any moment), and a node sub-agent can dispatch workers itself.
|
|
6
6
|
- **CodeBuddy IDE (v4.12.4, verified unsupported)**: nesting depth is 1 by default — run every skill node with primary_skill_inline and never dispatch a node sub-agent.
|
|
7
7
|
|
|
8
|
-
Do not probe the depth configuration, do not stop and wait, do not explain scheduling to the user, and do not ask about serial or parallel.
|
|
8
|
+
Do not probe the depth configuration, do not stop and wait, do not explain scheduling to the user, and do not ask about serial or parallel. On the CLI, if dispatching `a2h-executor` fails with an unknown agent type, do **not** fall back to the host's built-in general sub-agent per policy.dispatch (it has no dispatch grant, so the leaf's internal workers cannot be dispatched); run that node with primary_skill_inline instead and say so in the final report.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
# Before Step #
|
|
2
2
|
|
|
3
|
-
This platform is deveco (DevEco Code, semantically equivalent to opencode). The install layer already declares `permission: task: allow` in
|
|
3
|
+
This platform is deveco (DevEco Code, semantically equivalent to opencode). The install layer already declares `permission: task: allow` in the frontmatter of the node executor agent `a2h-executor` (verified on v0.2.6: granting the task permission on the dispatching agent is all dispatch needs; only it dispatches, at depth 1 — leaf workers do not dispatch and get no grant), and the default nesting depth is already >= 2 — no depth probing, no blocking prompt: nodes still dispatch one sub-agent at a time per policy.dispatch (only one node sub-agent runs at any moment), and a node sub-agent can dispatch workers itself; do not explain scheduling to the user, do not ask about serial or parallel. If dispatching `a2h-executor` fails with an unknown agent type, do **not** fall back to the host's built-in general sub-agent per policy.dispatch (it has no dispatch grant, so the leaf's internal workers cannot be dispatched); run that node with primary_skill_inline instead and say so in the final report.
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
# Before Step #
|
|
2
2
|
|
|
3
|
-
This platform is opencode. Before the formal migration workflow starts, run
|
|
3
|
+
This platform is opencode. The migration workflow needs a sub-agent nesting depth of >= 2, while opencode defaults to 1. Before the formal migration workflow starts, run this in the user's current working directory (the directory opencode was started from) — do not explain scheduling to the user, do not ask about serial or parallel:
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
If the depth is already >= 2, go straight on to the subsequent workflow.
|
|
5
|
+
```bash
|
|
6
|
+
node <directory of this SKILL.md>/scripts/opencode_depth.mjs
|
|
7
|
+
```
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
The script determines the opencode version itself and computes the effective depth in opencode's load order (global config, `OPENCODE_CONFIG`, `opencode.json` / `opencode.jsonc` from the git root down to the current directory, `.opencode/` directories, the system-managed directory, `OPENCODE_CONFIG_CONTENT`; later ones override earlier ones); when it is not >= 2, it declares only `"experimental": { "subagent_depth": 2 }` in the project-level configuration of the current working directory (if the file already exists, only that entry is changed). A file the script creates that sits in a git worktree and is untracked is added to `.git/info/exclude`, so the migration's commits never carry it into the user's repository. Act on `next` in the output JSON:
|
|
10
|
+
|
|
11
|
+
- `continue` (exit code 0): the depth is already satisfied, or v2 has just written the project-level configuration (hot-reloaded, effective immediately) → go straight on to the subsequent workflow without interrupting the user.
|
|
12
|
+
- `restart` (exit code 2): v1 has just written the project-level configuration and v1 does not hot-reload → relay `message` to the user (which file was written, and that they must restart the opencode session in that directory and re-enter the original command); **do not run any subsequent step this round**.
|
|
13
|
+
- `manual` (exit code 2): nothing was rewritten automatically (a configuration loaded later pins the depth below 2, the project-level file contains comments, or `OPENCODE_DISABLE_PROJECT_CONFIG` is set) → relay `message` so the user edits the place it names; **do not run any subsequent step this round**.
|
|
14
|
+
|
|
15
|
+
When the output carries `report: true` (this workflow wrote a configuration file — including a v1 rerun after the restart whose effective value comes from the file written in the previous round), the final report states `message` whatever `next` is: which file was written, whether it was added to `.git/info/exclude`, or that the file was the user's own and the change is left in the worktree.
|
|
16
|
+
|
|
17
|
+
v1 additionally requires the dispatching agent to carry the task grant — the install layer already declares `permission: task: allow` in the frontmatter of the node executor agent `a2h-executor` (only it dispatches, at depth 1; leaf workers do not dispatch and get no grant), so the user has nothing to do; v2 has no such requirement (the declaration is harmless there). If dispatching `a2h-executor` fails with an unknown agent type, do **not** fall back to the host's built-in general sub-agent per policy.dispatch (it has no dispatch grant, so the leaf's internal workers cannot be dispatched); run that node with primary_skill_inline instead and say so in the final report.
|
|
@@ -35,7 +35,7 @@ Every `run` / `continue` / `complete` / `confirm` / `rewind` stdout includes `pr
|
|
|
35
35
|
|
|
36
36
|
When `run` / `continue` returns `waiting_external`, read `wait.kind` from the current attempt's `<file_id>.request.json`:
|
|
37
37
|
|
|
38
|
-
- `skill`: execute according to `wait.dispatch`. `task_subagent` → **dispatch one sub-agent
|
|
38
|
+
- `skill`: execute according to `wait.dispatch`. `task_subagent` → **dispatch one `a2h-executor` sub-agent** (on an unknown-agent-type dispatch error, redispatch the same prompt to the built-in general sub-agent, note starting with `fallback: general agent`), which loads `wait.skill` and executes `wait.invoke` (task prompt per `policy.dispatch`); the main session does not load the leaf skill. `primary_skill_inline` → the primary session loads `wait.skill` and executes `wait.invoke` inline. A host that cannot dispatch sub-agents or has a nesting depth of 1 falls back to inline (`policy.dispatch`). The sub-agent never calls the executor / Runner; callbacks are issued only by the main session. Never substitute a shell worker for the Skill.
|
|
39
39
|
- `host_action`: the current host performs signing adoption, the final report or another host action.
|
|
40
40
|
- `config`: collect startup configuration from the user. `image_read`: strictly follow `wait.instructions` and launch a one-shot foreground sub-agent to read images. These two use the executor's `answer` callback; the others use `complete`.
|
|
41
41
|
|
|
@@ -168,7 +168,7 @@ The full text lives only in `workflow.yaml` → `policy.*`. The executor must co
|
|
|
168
168
|
1. **Single authority** — topology / invoke / gates come only from the yaml; before changing an invoke, read the leaf skill's Invocation (contract table in stage-map.md).
|
|
169
169
|
2. **scaffold_new** — `discover.arch` must be the first to touch `${HMOS}` (`create_project`'s emptiness check ignores only `.git`) → `policy.parallel_rule`.
|
|
170
170
|
3. **post_utg** — fixed serial: `ui.batch` → `enrich.spec_gen`; spec_gen always reads only `${UTG_SNAPSHOT}` → `policy.parallel_rule`.
|
|
171
|
-
4. **Dispatch** — the main session loads only this skill and orchestrates; it **loads no leaf skill**. The Runner's skill wait carries `wait.dispatch`: the 6 skill nodes (arch / utg_static / ui.batch / spec_gen / module_docs / spec_pipeline) are `task_subagent` and each run in one dispatched sub-agent (depth 1; the leaves' internal workers are at depth 2), one at a time, in fixed serial order. task prompt = the `policy.dispatch` common header + `wait.invoke`. A sub-agent must not end its turn to wait for background notifications: page-specgen gets `wait_mode=foreground` and spec_pipeline gets `WAIT_MODE=foreground`. The return value is not trusted: the main session only writes it as the outcome callback, and the Runner judges completion by the node's success checks; a reply that is not JSON → continue the same session, at most 2 times. The only exception: with `SPEC_ENGINE=spec-generate` enrich.spec_gen is `primary_skill_inline` and runs inline in the main session → `policy.dispatch`.
|
|
171
|
+
4. **Dispatch** — the main session loads only this skill and orchestrates; it **loads no leaf skill**. The Runner's skill wait carries `wait.dispatch`: the 6 skill nodes (arch / utg_static / ui.batch / spec_gen / module_docs / spec_pipeline) are `task_subagent` and each run in one dispatched `a2h-executor` sub-agent (the host's built-in general sub-agent when it has none; depth 1; the leaves' internal workers are at depth 2), one at a time, in fixed serial order. task prompt = the `policy.dispatch` common header + `wait.invoke`. A sub-agent must not end its turn to wait for background notifications: page-specgen gets `wait_mode=foreground` and spec_pipeline gets `WAIT_MODE=foreground`. The return value is not trusted: the main session only writes it as the outcome callback, and the Runner judges completion by the node's success checks; a reply that is not JSON → continue the same session, at most 2 times. The only exception: with `SPEC_ENGINE=spec-generate` enrich.spec_gen is `primary_skill_inline` and runs inline in the main session → `policy.dispatch`.
|
|
172
172
|
5. **Gates** — do not skip a node because of an `auto` confirmation (otherwise nobody writes the checkpoint); `auto` or the gate not in `INTERACTIVE_GATES` → `--write-confirmed --confirmed-by auto`; on the whitelist, stop and wait, and after the user confirms, `--write-confirmed --confirmed-by user` → `policy.human_interaction`. `review.arch` does **not** `skip_if` on `REUSE_DISCOVER_ARCH` (reusing the docs ≠ confirmation; a missing checkpoint must be rewritten / re-asked — see `policy.human_gate_protocol`). Producer nodes (`discover.arch` / `enrich.spec_gen` / `ui.batch`) must run their `before_run` **before actually executing** (`--clear-checkpoint` invalidates the corresponding gate); when reusing artifacts or skipping, clearing is **forbidden**. The production executor commits the before_run cursor item by item before returning the Skill wait; for a node with `after_run`, the executor runs it first after the host callback, then the Runner judges success.
|
|
173
173
|
6. **spec boundary** — `specs.json` is written only by enrich.spec_gen's leaf picked by `SPEC_ENGINE` (`spec-generate` → a2h-spec-generate's `publish-specs`; `page-specgen` → a2h-page-specgen's `finalize`); do not expand the leaf's internals; do not change the `${RUN_DIR}` layout → `policy.spec_order_boundary`. When semantics are incomplete, publish with gaps per the **deveco-cli contract**: the three steps use `--allow-incomplete`, specs.json records `completeness: "incomplete-known"` + `incomplete{...}`, the node still succeeds, downstream consumes as usual, and the gaps stay in specs.json incomplete; they are not written into the final report (see enrich.spec_gen's invoke); the one exception: on an incremental run, scope pages that got no SPEC (`incomplete.scopeUnmatched` / `scope.unmatched`) are the outcome of the incremental scope, not a SPEC quality gap, and logic.finalize's "Incremental scope" section (`scope_report.mjs`) lists them under "what was skipped". `page-specgen` publishes with holes the same way: `finalize` exits 0 whenever it published a `specs.json`; a partial or gate-failed run writes `incomplete{areas,pages,failedShards,...}` into the manifest and the ledger, not the final report, and downstream consumes it as usual; only "no SPEC published at all" fails the node. Switching engines = a new run.
|
|
174
174
|
|