@buaa_smat/hometrans 26.0.4 → 26.0.5-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/code-reviewer.md +2 -0
- package/agents/model-render-worker.md +1 -1
- package/devecocli-plugin/common.ts +2271 -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/agents/code-reviewer.md +2 -0
- package/i18n/agents/model-render-worker.md +1 -1
- package/i18n/skills/a2h-app-migrate/SKILL.md +51 -3
- package/i18n/skills/a2h-app-migrate/references/workflow.yaml +140 -32
- package/i18n/skills/a2h-app-migrate/scripts/dag_graph.mjs +297 -0
- package/i18n/skills/a2h-app-migrate/scripts/validate_workflow.mjs +134 -21
- package/i18n/skills/a2h-app-migrate/test/test_finalize.mjs +21 -4
- package/i18n/skills/a2h-app-migrate/test/test_image_probe.mjs +3 -3
- package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +12 -5
- package/i18n/skills/a2h-arkts-logic-coder/SKILL.md +7 -8
- package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +1 -1
- package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +27 -15
- package/i18n/skills/a2h-batch-ui-align/SKILL.md +1 -1
- package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +4 -0
- package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +36 -0
- package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +4 -0
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +4 -0
- package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +3 -3
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +8 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_in_linear.ts +164 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/self_drawn_sheet.ts +105 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/staggered_lanes.ts +127 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/window_size_constant.ts +114 -0
- package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +4 -1
- package/i18n/skills/a2h-page-specgen/references/spec-example.md +35 -5
- package/i18n/skills/a2h-page-specgen/references/spec-template.md +4 -4
- package/i18n/skills/a2h-spec-generate/SKILL.md +3 -1
- package/i18n/skills/a2h-spec-generate/references/fusion-task-contract.md +15 -3
- package/i18n/skills/a2h-spec-generate/references/review-checklist.md +1 -0
- package/i18n/skills/a2h-spec-generate/references/spec-sample-complex.md +16 -0
- package/i18n/skills/a2h-spec-generate/references/spec-sample-transfer.md +16 -0
- package/i18n/skills/a2h-spec-generate/references/spec-samples.md +5 -1
- package/i18n/skills/a2h-spec-generate/references/synthesis-rules.md +21 -1
- package/i18n/skills/a2h-spec-generate/references/worker-rules.md +25 -2
- package/i18n/skills/a2h-spec-generate/scripts/check_spec.ts +121 -6
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +2 -1
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +3 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +16 -2
- package/i18n/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +11 -2
- package/i18n/skills/a2h-spec-generate/test/check-spec.test.ts +35 -0
- package/index.js +1643 -0
- package/package.json +8 -8
- package/plugin.jsonc +12 -0
- package/skills/a2h-app-migrate/SKILL.md +53 -5
- package/skills/a2h-app-migrate/references/workflow.yaml +140 -32
- package/skills/a2h-app-migrate/scripts/assert_dag_complete.mjs +226 -0
- package/skills/a2h-app-migrate/scripts/dag_graph.mjs +297 -0
- package/skills/a2h-app-migrate/scripts/dag_process_executor.mjs +199 -0
- package/skills/a2h-app-migrate/scripts/dag_production_executor.mjs +897 -0
- package/skills/a2h-app-migrate/scripts/dag_runner.mjs +1767 -0
- package/skills/a2h-app-migrate/scripts/ledger.mjs +15 -2
- package/skills/a2h-app-migrate/scripts/lib-yaml-lite.mjs +8 -2
- package/skills/a2h-app-migrate/scripts/resume_plan.mjs +3 -8
- package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +134 -21
- package/skills/a2h-app-migrate/test/test_dag_complete.mjs +222 -0
- package/skills/a2h-app-migrate/test/test_dag_production.mjs +670 -0
- package/skills/a2h-app-migrate/test/test_dag_runner.mjs +423 -0
- package/skills/a2h-app-migrate/test/test_finalize.mjs +21 -4
- package/skills/a2h-app-migrate/test/test_image_probe.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_resume_plan.mjs +16 -1
- package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +12 -5
- package/skills/a2h-arkts-logic-coder/SKILL.md +7 -8
- package/skills/a2h-arkts-logic-coder/references/ISSUES.md +1 -1
- package/skills/a2h-arkts-logic-coder/references/code-generation.md +27 -15
- package/skills/a2h-batch-ui-align/SKILL.md +1 -1
- package/skills/a2h-batch-ui-align/references/cards/widgets.md +4 -0
- package/skills/a2h-batch-ui-align/references/checker-rules.md +36 -0
- package/skills/a2h-batch-ui-align/references/conversion-procedure.md +4 -0
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +4 -0
- package/skills/a2h-batch-ui-align/references/step5-convert.md +3 -3
- package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +49 -3
- package/skills/a2h-batch-ui-align/scripts/static_check/core/android.ts +36 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +8 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +8 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_in_linear.ts +164 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/self_drawn_sheet.ts +105 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/staggered_lanes.ts +127 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/window_size_constant.ts +114 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_coolmall_ds1123.test.mjs +433 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_overlay_in_linear.test.mjs +288 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +46 -0
- package/skills/a2h-page-specgen/references/scenario-authoring.md +4 -1
- package/skills/a2h-page-specgen/references/spec-example.md +35 -5
- package/skills/a2h-page-specgen/references/spec-template.md +4 -4
- package/skills/a2h-spec-generate/SKILL.md +3 -1
- package/skills/a2h-spec-generate/references/fusion-task-contract.md +15 -3
- package/skills/a2h-spec-generate/references/review-checklist.md +1 -0
- package/skills/a2h-spec-generate/references/spec-sample-complex.md +16 -0
- package/skills/a2h-spec-generate/references/spec-sample-transfer.md +16 -0
- package/skills/a2h-spec-generate/references/spec-samples.md +5 -1
- package/skills/a2h-spec-generate/references/synthesis-rules.md +21 -1
- package/skills/a2h-spec-generate/references/worker-rules.md +25 -2
- package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +3 -1
- package/skills/a2h-spec-generate/scripts/check_spec.ts +262 -6
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +12 -2
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +3 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +16 -2
- package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +54 -3
- package/skills/a2h-spec-generate/test/check-spec.test.ts +247 -0
- package/README.md +0 -440
- package/dist/cli/config-store.js +0 -128
- package/dist/cli/config.js +0 -48
- package/dist/cli/editors.json +0 -114
- 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 -337
- package/dist/platform/transform.js +0 -363
- package/dist/platform/types.js +0 -9
- package/dist/platform/validate.js +0 -152
- package/dist/utils/regex.js +0 -7
- package/env-requirements.json +0 -536
- package/resource/choose_editor.png +0 -0
- package/resource/convert_pipeline_process.svg +0 -114
- package/resource/project_architecture.svg +0 -120
- package/resource/set_environment.png +0 -0
- package/resource/set_multimodel.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
|
+
});
|
|
@@ -386,6 +386,8 @@ Fix every issue the review report lists, plus the Remaining Issues rows of `carr
|
|
|
386
386
|
|
|
387
387
|
**Permissions are allowlisted.** A missing-permission finding is fixed in `module.json5` `requestPermissions` only with a name that appears in the pipeline's `references/permission-index.json` (`a2h-spec-design-pipeline`; read it, do not guess) **and** is not `"restricted": true` there. A name absent from the index (an invented or misspelled permission) or a restricted (ACL) permission is never written: list it under Remaining Issues as `permission <name>: not in permission-index` / `restricted (ACL) — needs a manual application`, exactly as B2's wiring step and F0 skip them. Append only; never rewrite or reorder the existing entries.
|
|
388
388
|
|
|
389
|
+
**A fix that adds or removes a visible element checks the Android render branch first.** A spec step such as "the bottom shows the load-more footer" can come from a ViewModel assignment that the Android UI never draws in that state. When `android_project_path` is available, before adding or removing a visible element, open the Android UI code for that state (the Compose `when (state)` / `if` branch, View `visibility`, the adapter's item types) and confirm the element is drawn there. If the Android branch does not draw it, do not change the code: list the row under Remaining Issues as `spec contradicts Android render: <spec step> vs <android file:line>`, so the spec is corrected instead of the app. Observed miss: a spec said an empty order tab "shows the pull-to-load initial state at the bottom" because the Android ViewModel sets `PullToLoad` on an empty first page; Android's `Empty` branch draws only `EmptyData`, the fix added the footer anyway, and every empty tab gained a "pull up to load more" line.
|
|
390
|
+
|
|
389
391
|
**Do not revert a legitimate deviation.** A detail recorded in `commit-info.md`'s `## Spec deviations` (search `<harmonyos_project_path>/.hometrans/spec_group_*/chunk_*/commit-info.md`) was filled from the Android source because the spec left it uncertain: when `android_project_path` is available, check the anchor and keep that behavior; change it only when the basis no longer holds (the anchor is unrelated, the spec actually settles the detail, or the report shows the implementation is wrong), and re-record the row when you do.
|
|
390
392
|
|
|
391
393
|
## Step F2 — Build Once
|
|
@@ -29,7 +29,7 @@ Rules:
|
|
|
29
29
|
4. Copy `taskId` and `inputFingerprint` verbatim from `task.md` / `expected.json`. Every citation must be verified by reading the file with line numbers; never estimate an anchor. When evidence is insufficient, record it honestly instead of guessing, and never fabricate a citation.
|
|
30
30
|
5. **Never write identity.** No `Control: <controlRef>` line and no `controlRef` field anywhere — submit structured `identityAnchor`/`identityAnchors` only; Node derives the final stable IDs. `controlGroupKey` is a local label, not an identity.
|
|
31
31
|
6. You are the page owner: one user-visible flow = one area-owned SPEC, and every area SPEC needs a `dataFlow` row (entry, data sources, transforms, displayed values, persistence) plus a `pageCoverage` ledger assigning every `controlGroup`/`discovery` to an existing `specStem` or an explicit exclusion reason (R4/R8). Multiple `owner.kind: "area"` SPECs are allowed, one per flow; a duplicate controlGroup/discovery binding fails R7. Fabricated citations and promoted `unknown`/unresolved fields fail the self-check.
|
|
32
|
-
7. **Display-SPEC completeness (R6) and displayed-value derivations (R6a) are required, not optional**: after reconciling, re-check from source what the Area renders/displays exactly as task.md's R6 defines — including when the Area captured no interactions at all. Every numeric/text field states its source field, window, aggregation, rounding, sign and unit conversion. Never emit a behavior without a citation (R5).
|
|
32
|
+
7. **Display-SPEC completeness (R6) and displayed-value derivations (R6a) are required, not optional**: after reconciling, re-check from source what the Area renders/displays exactly as task.md's R6 defines — including when the Area captured no interactions at all. Every numeric/text field states its source field, window, aggregation, rounding, sign and unit conversion, and the rule must determine exactly one result: when a different order gives a different number (round each operand then subtract vs subtract then round), when the rounding mode changes the value (half-up, truncation, negative halves), or when the time basis changes the slot (nearest series index vs floor, which timezone), write that choice out. List the fields one by one — never summarise several fields as "every record" or "each value", and never leave a field out because it shares a sentence with a neighbour. Attach one worked example to each derived numeric field (concrete input → concrete output); an example that disagrees with the rule, or a rule you cannot exemplify, means the derivation is not understood: reread the source and rewrite it. **R6b (state space)**: a page-flow SPEC writes `## 状态清单` between `## UI序列` and the first scenario, one row per state — `- <state>: <what the user sees>`. All eight states need a row: first frame, loading, success, empty data, insufficient data, failure, non-default locale, return after leaving. A state this page cannot reach still gets a row — `- Loading: not applicable (why)` — never omitted and never blank. Write the visible result, or "keeps the last successful data"; never "otherwise nothing updates". The first frame and the non-default locale carry the real literal. Never emit a behavior without a citation (R5).
|
|
33
33
|
8. Run the self-check command `task.md` inlines — the spec skill's `check-fused-spec.mjs` (`check-fused-spec.mjs --run <run> --task <id> --reqgen-root <reqgen-root>`). It first runs `check-fusion`, which validates the fused draft and writes the validated `draft.json` beside your output (L1 mints no ids; the canonical `controlRef` is resolved at global L2 from the anchors), then validates every SPEC your `specs[]` declares. Fix every reported error and re-run it. The task is complete only when that command reports the draft and all SPECs valid.
|
|
34
34
|
9. Do not spawn subagents or nested tasks.
|
|
35
35
|
10. Do not run Gradle, Android Lint, adb, emulators, or any build tool.
|
|
@@ -10,10 +10,56 @@ This skill is a **thin executor** for the declarative graph in [references/workf
|
|
|
10
10
|
**The single authority on topology, gates, invoke, artifact contracts and failure policy:** `references/workflow.yaml` (especially `policy.*` + the node DAG).
|
|
11
11
|
Artifact sources of truth / CLI contract quick reference: [references/stage-map.md](references/stage-map.md).
|
|
12
12
|
|
|
13
|
-
Load the yaml → trim by `PROFILE` → advance
|
|
13
|
+
Load the yaml → trim by `PROFILE` → let the production DAG Runner advance each node's `needs`, while semantic `invoke` work is handed to the current host; sub-agents return JSON; the production executor initializes MANIFEST, and the Runner exclusively commits LEDGER and node terminal states. Do not restate the details in this file.
|
|
14
14
|
|
|
15
15
|
**No voluntary stop for context budget** — the model must not end the run on its own because of the context budget (`policy.context_budget`). The context window, remaining tokens, a growing session or compaction are not stop conditions.
|
|
16
16
|
|
|
17
|
+
## Deterministic DAG Runner (production entry)
|
|
18
|
+
|
|
19
|
+
Every node in the real `workflow.yaml` is advanced by the Node state machine: topology, variables, artifact validation, failure policy, ledger and the unique `run_end` belong to the Runner; `dag_production_executor.mjs` only executes the current node's deterministic actions or hands semantic work to the current host. Production runs select this executor automatically, need no `--executor-command`, and do not enable parallel scheduling.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
node ${SKILLS_ROOT}/a2h-app-migrate/scripts/dag_runner.mjs run \
|
|
23
|
+
--workflow ${SKILLS_ROOT}/a2h-app-migrate/references/workflow.yaml \
|
|
24
|
+
--run-dir <DAG_RUN_DIR> --profile full \
|
|
25
|
+
--vars '{"ANDROID":"<ANDROID>","HMOS":"<HMOS>"}'
|
|
26
|
+
node ${SKILLS_ROOT}/a2h-app-migrate/scripts/dag_runner.mjs continue --state <DAG_RUN_DIR>/dag-run-state.json
|
|
27
|
+
node ${SKILLS_ROOT}/a2h-app-migrate/scripts/dag_runner.mjs status --state <DAG_RUN_DIR>/dag-run-state.json
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`DAG_RUN_DIR` stores only Runner state, attempt requests/results and action cursors; it must be separate from production `${WORK}`, `${RUN_DIR}` and `${HMOS}`. Do not write production directories before preflight passes; `run_start` is committed only after `boot.workspace` succeeds. `continue` resumes the same `run_id`; a committed action cursor is inherited only for Runner interruption recovery, while business retries and review rewinds use a new cursor.
|
|
31
|
+
|
|
32
|
+
Every `run` / `continue` / `complete` / `confirm` / `rewind` stdout includes `presentation`. Before handling a wait, the host must refresh the fixed progress block from `policy.user_facing` in `events` order: render the full checklist from `checklist` and current `nodes`; select the sentence for `doing` / `terminal` from `event.user_facing`, status, reason/evidence; immediately give the user the warning requested by a `notice` event's `event.text`. Merge multiple events from one response into one checklist instead of flooding separate messages. Announce a terminal state only after the Runner returns `terminal`, never merely because the executor returned `ok:true`; `status` does not replay historical events.
|
|
33
|
+
|
|
34
|
+
### Host handling of waits and callbacks
|
|
35
|
+
|
|
36
|
+
When `run` / `continue` returns `waiting_external`, read `wait.kind` from the current attempt's `<file_id>.request.json`:
|
|
37
|
+
|
|
38
|
+
- `skill`: the primary session loads `wait.skill` and executes `wait.invoke` as `primary_skill_inline`; never substitute a shell worker for the Skill.
|
|
39
|
+
- `host_action`: the current host performs signing adoption, the final report or another host action.
|
|
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
|
+
|
|
42
|
+
After a Skill / host action finishes, write `{"attempt_id":"<id>","ok":true,"set_vars":{}}`; on failure write `ok:false` and a non-empty `reason`. Then run:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
node ${SKILLS_ROOT}/a2h-app-migrate/scripts/dag_production_executor.mjs complete \
|
|
46
|
+
--request <DAG_RUN_DIR>/attempts/<file_id>.request.json --outcome <outcome.json>
|
|
47
|
+
node ${SKILLS_ROOT}/a2h-app-migrate/scripts/dag_runner.mjs complete \
|
|
48
|
+
--state <DAG_RUN_DIR>/dag-run-state.json --attempt-id <id> \
|
|
49
|
+
--result-file <DAG_RUN_DIR>/attempts/<file_id>.result.json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
For config / image-read answers, replace the executor subcommand with `answer --answer <answer.json>`, then call Runner `complete` as above. The executor produces only the strict result; the host must not append node terminal states, `run_start` or `run_end`. Stale attempts, invalid results and early executor exits block the run; never record them as business soft failures or pretend they completed. Only a contract script exiting non-zero by contract (including capture_audit / gate scripts) and a host `ok:false` count as business failed; executor protocol errors, config errors (e.g. `INVALID_SKILL`, `INVALID_SET_VARS`) and implementation gaps (`UNSUPPORTED_*`) always exit non-zero without a result, and the Runner blocks.
|
|
53
|
+
|
|
54
|
+
`waiting_human` can advance only through a real gate confirmation or a bounded rewind, not a normal `complete` bypass:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
node ${SKILLS_ROOT}/a2h-app-migrate/scripts/dag_runner.mjs confirm --state <DAG_RUN_DIR>/dag-run-state.json --node review.arch --confirmed-by user
|
|
58
|
+
node ${SKILLS_ROOT}/a2h-app-migrate/scripts/dag_runner.mjs rewind --state <DAG_RUN_DIR>/dag-run-state.json --node review.arch
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`rewind` reruns only the current gate's `runner.rewind_to` and its downstream, clears the corresponding REUSE variables and increments generation. `FROM_NODE` resume uses a new DAG control directory and `run --resume-from <node> --base-profile <profile>`, retains production `${WORK}` / `${LEDGER}`, and still follows `planResume()` profile, SPEC_ENGINE, artifact-probe and inheritance rules. If a hard_stop has `error.ledger_started` false (it stopped before run_start, so the ledger has no record of this run), do not use `--resume-from`; fix the cause per `error.hint` and start a fresh `run`.
|
|
62
|
+
|
|
17
63
|
---
|
|
18
64
|
|
|
19
65
|
## Parameters
|
|
@@ -155,7 +201,9 @@ See workflow.yaml → `observability`.
|
|
|
155
201
|
| `scripts/env_preflight.mjs` | Startup preflight / one-click customer self-check (fills in work/run-dir/ui-info-root by default); fixed serial |
|
|
156
202
|
| `scripts/infer_android_root.mjs` | At entry, determines the Android project root from the APK path prefix (substitutes it when the given path is not the project root, before preflight) |
|
|
157
203
|
| `scripts/paths_preflight.mjs` | Path submodule |
|
|
158
|
-
| `scripts/validate_workflow.mjs` | Static self-check of workflow.yaml |
|
|
204
|
+
| `scripts/validate_workflow.mjs` | Static self-check of workflow.yaml (including every production node's Runner kind, fixed order, reuse/skip, gates and finalize ownership) |
|
|
205
|
+
| `scripts/dag_runner.mjs` | Production DAG state machine; exclusively owns node terminal states, resume/rewind, ledger commits and the unique run_end |
|
|
206
|
+
| `scripts/dag_production_executor.mjs` | Production node action driver; deterministic scripts, per-action cursors, Skill/config/image/host_action waits and strict callbacks |
|
|
159
207
|
| `scripts/human_review_gate.mjs` | Human gates (arch / spec_gen / ui_batch) |
|
|
160
208
|
| `scripts/run_dir.mjs` | Run directory for spec generation: `--show` reads the pointer / decides between resuming and creating a new one (`--fresh`) / `--record` takes the actual directory as authoritative (pointer `${WORK}/reqgen/current.json` records the current one) |
|
|
161
209
|
| `scripts/spec_layout.mjs` | The single implementation of the enrich.spec_gen artifact layout (`<run>/generation/pages` page-grouped root, location of specs.json); both engines share that publish root (page-specgen's private workspace also lives under the root) |
|
|
@@ -163,7 +211,7 @@ See workflow.yaml → `observability`.
|
|
|
163
211
|
| `scripts/check_spec_pipeline_done.mjs` | Completion check for logic.spec_pipeline (all groups terminal, no unfinished chunks, Finalization has written `state.finalization` **with both gate markers** `finalization.homecheck` / `finalization.smoke` — `done` alone is not completion; all failed → exit 3; hard fingerprint `specs_json_sha256`/paths mismatch → exit 4; soft knobs like `wave_width` go to `soft_stale` only and do not archive; `--archive-stale` / `--archive-failed` archive only on exit 4/3 so before_run can start a new round) |
|
|
164
212
|
| `scripts/check_module_docs_done.mjs` | Completion check for enrich.module_docs (`--mark` records the start time; the state file must be no older than it — the state file is the incremental baseline and is kept across runs) |
|
|
165
213
|
| `scripts/check_ui_batch_done.mjs` | Probe 4: whether ui.batch is reusable (batch_report.md exists, batch_progress.json's mode is full, no pending pages) |
|
|
166
|
-
| `scripts/ledger.mjs` | Reads/writes `${LEDGER}`: append only, kept across runs; `--start`
|
|
214
|
+
| `scripts/ledger.mjs` | Reads/writes `${LEDGER}`: append only, kept across runs; supports `--start` / `--node … --status` / `--failures`; in production only the Runner commits run_start, node terminal states and the unique run_end, never the host directly |
|
|
167
215
|
| `scripts/diagnose.mjs` | Incremental start-up diagnosis (read-only): scenario 1 / 2 / 3, reuse / repair / rebuild per artifact, migrated pages whose source changed and new pages, the scope `SCOPE=auto` recommends |
|
|
168
216
|
| `scripts/source_fp.mjs` | Per-page Android source fingerprint (UTG anchors + referenced layouts, line endings normalised); written into the ledger at finalize, so the diagnosis finds migrated pages whose source changed |
|
|
169
217
|
| `scripts/migration_manifest.mjs` | logic.finalize step 4: merges this round's UI / business-logic status per UTG page id into `${HMOS}/.hometrans/migration_manifest.json` (kept across runs and scopes; a failed retry never overwrites a migrated record; never fails the node) |
|