@buaa_smat/hometrans 26.0.6 → 26.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/agents/a2h-executor.md +37 -0
- package/dist/cli/editors.json +13 -0
- package/dist/platform/compose.js +4 -0
- package/dist/platform/registry.js +3 -1
- package/dist/platform/transform.js +37 -3
- package/env-requirements.json +15 -1
- 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/package.json +1 -1
- 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/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/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/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs
CHANGED
|
@@ -172,12 +172,36 @@ test('fillcolor_on_bitmap_in_density_folder_is_gate', () => {
|
|
|
172
172
|
});
|
|
173
173
|
|
|
174
174
|
test('fillcolor_on_svg_or_unknown_media_is_clean', () => {
|
|
175
|
-
const svg = run({ 'pages/P.ets': tinted("$r('app.media.ic_a')") }, { 'base/ic_a.svg': SVG
|
|
175
|
+
const svg = run({ 'pages/P.ets': tinted("$r('app.media.ic_a')") }, { 'base/ic_a.svg': SVG });
|
|
176
|
+
const both = run({ 'pages/P.ets': tinted("$r('app.media.ic_a')") }, { 'base/ic_a.svg': SVG, 'xxldpi/ic_a.svg': SVG });
|
|
176
177
|
const missing = run({ 'pages/P.ets': tinted("$r('app.media.ic_none')") });
|
|
177
178
|
assert.deepEqual(hits(svg, 'fillcolor-on-raster-media'), []);
|
|
179
|
+
assert.deepEqual(hits(both, 'fillcolor-on-raster-media'), []);
|
|
178
180
|
assert.deepEqual(hits(missing, 'fillcolor-on-raster-media'), []);
|
|
179
181
|
});
|
|
180
182
|
|
|
183
|
+
test('fillcolor_on_base_svg_shadowed_by_a_density_bitmap_is_gate', () => {
|
|
184
|
+
// resources are matched qualifier dir first, base/ last: an xxldpi device loads the png, which fillColor cannot tint
|
|
185
|
+
const out = run({ 'pages/P.ets': tinted("$r('app.media.ic_a')") }, { 'base/ic_a.svg': SVG, 'xxldpi/ic_a.png': 'x' });
|
|
186
|
+
assert.deepEqual(hits(out, 'fillcolor-on-raster-media'), [{ sev: 'GATE', at: 'pages/P.ets:11' }]);
|
|
187
|
+
assert.match(out, /svg in base\/; bitmap in xxldpi\/: delete the bitmap in xxldpi\//);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
test('fillcolor_on_qualifier_svg_with_a_base_bitmap_is_gate', () => {
|
|
191
|
+
// svg only in xxldpi/, a bitmap in base/: a device that does not match xxldpi loads the base png
|
|
192
|
+
const out = run({ 'pages/P.ets': tinted("$r('app.media.ic_a')") }, { 'xxldpi/ic_a.svg': SVG, 'base/ic_a.png': 'x' });
|
|
193
|
+
assert.deepEqual(hits(out, 'fillcolor-on-raster-media'), [{ sev: 'GATE', at: 'pages/P.ets:11' }]);
|
|
194
|
+
assert.ok(out.includes('svg in xxldpi/; bitmap in base/: no SVG in base/: copy the SVG into base/'), out);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
test('fillcolor_shadow_hint_names_the_real_svg_dir', () => {
|
|
198
|
+
// svg only in dark/: a light-mode xxldpi device loads the png; deleting it alone would leave no base/ copy
|
|
199
|
+
const out = run({ 'pages/P.ets': tinted("$r('app.media.ic_a')") }, { 'dark/ic_a.svg': SVG, 'xxldpi/ic_a.png': 'x' });
|
|
200
|
+
assert.deepEqual(hits(out, 'fillcolor-on-raster-media'), [{ sev: 'GATE', at: 'pages/P.ets:11' }]);
|
|
201
|
+
assert.match(out, /svg in dark\/; bitmap in xxldpi\/: no SVG in base\/: copy the SVG into base\//);
|
|
202
|
+
assert.doesNotMatch(out, /svg in base\//);
|
|
203
|
+
});
|
|
204
|
+
|
|
181
205
|
// ---------------------------------------------------------------- review fixes
|
|
182
206
|
|
|
183
207
|
test('a_qualifier_whose_media_is_a_file_does_not_crash_the_checker', () => {
|
|
@@ -354,6 +354,22 @@ describe('Queue', () => {
|
|
|
354
354
|
assert.deepEqual(leased(r), ['G001']);
|
|
355
355
|
});
|
|
356
356
|
|
|
357
|
+
test('a bind that finds the attempt already reported flags a foreground dispatch', () => {
|
|
358
|
+
init();
|
|
359
|
+
assert.deepEqual(leased(gq.lease(hp)), ['G001']);
|
|
360
|
+
const ok = gq.bind(hp, 'G001', 'ses_1');
|
|
361
|
+
assert.equal(ok.warning, undefined);
|
|
362
|
+
finish('G001');
|
|
363
|
+
// a quick background agent that reported before a prompt bind is not flagged
|
|
364
|
+
assert.equal(gq.bind(hp, 'G001', 'ses_1').warning, undefined);
|
|
365
|
+
const real = gq._impl.now;
|
|
366
|
+
patch('now', () => real() + gq.FOREGROUND_MIN_GAP_S + 60);
|
|
367
|
+
const late = gq.bind(hp, 'G001', 'ses_1');
|
|
368
|
+
assert.deepEqual(late.foreground, ['G001']);
|
|
369
|
+
assert.match(late.warning, /^Inferred, not confirmed/);
|
|
370
|
+
assert.match(late.warning, /background: true/);
|
|
371
|
+
});
|
|
372
|
+
|
|
357
373
|
test('a member captured while its group runs flags it, lists its pack, and re-queues it on release', () => {
|
|
358
374
|
const mem = (node, tier) => ({ node, tier });
|
|
359
375
|
groups[0].tier = 'captured';
|
|
@@ -487,6 +503,57 @@ describe('Queue', () => {
|
|
|
487
503
|
assert.ok(body(d).startsWith(gq.RESUME));
|
|
488
504
|
});
|
|
489
505
|
|
|
506
|
+
test('a session that ran out of context is never resumed; a new bound session clears the mark', () => {
|
|
507
|
+
init();
|
|
508
|
+
gq.lease(hp);
|
|
509
|
+
gq.bind(hp, 'G001', 'ses_1');
|
|
510
|
+
// files partly written, no report: returned for verification, flagged from the host error
|
|
511
|
+
finish('G001', { report: false });
|
|
512
|
+
const row = gq.release(hp, 'G001', { error: 'prompt is too long: 212000 tokens > 200000 maximum' }).released[0];
|
|
513
|
+
assert.equal(row.next, 'returned');
|
|
514
|
+
assert.equal(load().groups.G001.context_exhausted, true);
|
|
515
|
+
const q = gq.control(hp, { op: 'requeue', group: 'G001', message: 'fix' });
|
|
516
|
+
assert.equal(q.resume_task, undefined);
|
|
517
|
+
assert.equal(q.fresh_reason, 'context-exhausted');
|
|
518
|
+
assert.equal(load().groups.G001.next_session, undefined);
|
|
519
|
+
assert.equal(gq.lease(hp).dispatch[0].resume_task, null);
|
|
520
|
+
// the fresh session returns cleanly: a later failed verification resumes it again
|
|
521
|
+
gq.bind(hp, 'G001', 'ses_2');
|
|
522
|
+
finish('G001');
|
|
523
|
+
gq.release(hp, 'G001');
|
|
524
|
+
assert.equal(gq.control(hp, { op: 'requeue', group: 'G001', message: 'fix' }).resume_task, 'ses_2');
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
test('only an exceeded / used-up context counts as exhausted: mentions, output caps and rate limits do not', () => {
|
|
528
|
+
for (const e of ['prompt is too long: 212000 tokens > 200000 maximum', 'context_length_exceeded',
|
|
529
|
+
"This model's maximum context length is 128000 tokens", "input exceeds the model's context window",
|
|
530
|
+
'context window exceeded', 'context is full']) {
|
|
531
|
+
assert.ok(gq.CONTEXT_EXHAUSTED_RE.test(e), e);
|
|
532
|
+
}
|
|
533
|
+
for (const e of ['tool output truncated to fit the context window', 'output token limit reached',
|
|
534
|
+
'429 too many tokens per minute', 'rate limit: token limit exceeded for org', 'exceeded max_tokens for output']) {
|
|
535
|
+
assert.ok(!gq.CONTEXT_EXHAUSTED_RE.test(e), e);
|
|
536
|
+
}
|
|
537
|
+
// a returned group whose error only mentions the context window still resumes its session
|
|
538
|
+
init();
|
|
539
|
+
gq.lease(hp);
|
|
540
|
+
gq.bind(hp, 'G001', 'ses_1');
|
|
541
|
+
finish('G001', { report: false });
|
|
542
|
+
gq.release(hp, 'G001', { error: 'tool output truncated to fit the context window' });
|
|
543
|
+
assert.equal(load().groups.G001.context_exhausted, undefined);
|
|
544
|
+
assert.equal(gq.control(hp, { op: 'requeue', group: 'G001', message: 'fix' }).resume_task, 'ses_1');
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
test('a network error that also reports an exhausted context retries fresh', () => {
|
|
548
|
+
init();
|
|
549
|
+
gq.lease(hp);
|
|
550
|
+
gq.bind(hp, 'G001', 'ses_1');
|
|
551
|
+
const r = gq.release(hp, 'G001', { error: 'ECONNRESET after context_length_exceeded' }).released[0];
|
|
552
|
+
assert.equal(r.action, 'retry');
|
|
553
|
+
assert.equal(load().groups.G001.next_session, undefined);
|
|
554
|
+
assert.equal(gq.lease(hp).dispatch[0].resume_task, null);
|
|
555
|
+
});
|
|
556
|
+
|
|
490
557
|
test('empty report gets one narrowed redispatch, then fails and blocks followers', () => {
|
|
491
558
|
init();
|
|
492
559
|
gq.lease(hp);
|
|
@@ -615,6 +682,17 @@ describe('Queue', () => {
|
|
|
615
682
|
assert.ok(one.includes(gq.SHARED_MODULE_RULE) && batch.includes(gq.SHARED_MODULE_RULE));
|
|
616
683
|
});
|
|
617
684
|
|
|
685
|
+
test('one wait is capped at 300 s', () => {
|
|
686
|
+
// a blocking wait holds every completion notice: --timeout-s above the cap is cut to it
|
|
687
|
+
assert.equal(gq.WAIT_CAP_S, 300);
|
|
688
|
+
assert.equal(gq.waitDeadline(1000, 10_000), 1300);
|
|
689
|
+
assert.equal(gq.waitDeadline(1000, 540), 1300);
|
|
690
|
+
assert.equal(gq.waitDeadline(1000, 300), 1300);
|
|
691
|
+
assert.equal(gq.waitDeadline(1000, 0.2), 1000.2);
|
|
692
|
+
assert.equal(gq.waitDeadline(1000, NaN), 1300);
|
|
693
|
+
assert.equal(gq.waitDeadline(1000, -5), 1300);
|
|
694
|
+
});
|
|
695
|
+
|
|
618
696
|
test('wait returns on a report, a job exit or complete answers, else times out', async () => {
|
|
619
697
|
init();
|
|
620
698
|
gq.lease(hp);
|
|
@@ -673,6 +751,46 @@ describe('Queue', () => {
|
|
|
673
751
|
assert.deepEqual(s.answers_silent, [path.resolve(a1)]);
|
|
674
752
|
});
|
|
675
753
|
|
|
754
|
+
test('wait reports a bound reviewer that completed between two waits, once', async () => {
|
|
755
|
+
init({ max_agents: 1 }); // the slot is held by the reviewer: no 'slots' wake-up
|
|
756
|
+
fs.writeFileSync(path.join(temp, 'gap_worklist.part0.json'), JSON.stringify({ items: [{ key: 'a' }] }));
|
|
757
|
+
const a0 = path.join(temp, 'gap_answers.part0.json');
|
|
758
|
+
gq.reviewBind(hp, 'gap_part0', { answers: a0 });
|
|
759
|
+
const w = () => gq.wait(hp, { timeoutS: 0.2, pollS: 0.05 });
|
|
760
|
+
assert.ok(!(await w()).reasons.includes('answers'));
|
|
761
|
+
fs.writeFileSync(a0, JSON.stringify([{ key: 'a' }])); // completes while no wait runs
|
|
762
|
+
const r = await w();
|
|
763
|
+
assert.ok(r.reasons.includes('answers'), JSON.stringify(r.reasons));
|
|
764
|
+
assert.deepEqual(r.answers_complete, [path.resolve(a0)]);
|
|
765
|
+
assert.ok(!(await w()).reasons.includes('answers')); // already reported: no busy loop
|
|
766
|
+
});
|
|
767
|
+
|
|
768
|
+
test('a skill agent that wrote its report between two waits is reported once', async () => {
|
|
769
|
+
init();
|
|
770
|
+
gq.lease(hp); // fill the free slots: otherwise wait returns at once with 'slots'
|
|
771
|
+
const report = path.join(hp, '.hometrans', 'work', 'gap.report.md');
|
|
772
|
+
fs.mkdirSync(path.dirname(report), { recursive: true });
|
|
773
|
+
gq.reviewBind(hp, 'gap', { answers: report, kind: 'skill-agent' });
|
|
774
|
+
const w = () => gq.wait(hp, { timeoutS: 0.2, pollS: 0.02 });
|
|
775
|
+
assert.ok(!(await w()).reasons.includes('agent'));
|
|
776
|
+
fs.writeFileSync(report, '# gap\nDONE\n'); // written while no wait runs
|
|
777
|
+
const r = await w();
|
|
778
|
+
assert.deepEqual(r.agents_done, ['gap'], JSON.stringify(r.reasons));
|
|
779
|
+
assert.ok(!(await w()).reasons.includes('agent')); // already reported: no busy loop
|
|
780
|
+
});
|
|
781
|
+
|
|
782
|
+
test('the wait seen record is not listed as a detach job', async () => {
|
|
783
|
+
init({ max_agents: 1 });
|
|
784
|
+
fs.writeFileSync(path.join(temp, 'seen_worklist.part0.json'), JSON.stringify({ items: [{ key: 'a' }] }));
|
|
785
|
+
const a0 = path.join(temp, 'seen_answers.part0.json');
|
|
786
|
+
gq.reviewBind(hp, 'seen_part0', { answers: a0 });
|
|
787
|
+
fs.writeFileSync(a0, JSON.stringify([{ key: 'a' }]));
|
|
788
|
+
assert.ok((await gq.wait(hp, { timeoutS: 0.2, pollS: 0.05 })).reasons.includes('answers'));
|
|
789
|
+
assert.ok(gq._waitSeen(hp).size > 0);
|
|
790
|
+
const detach = await import('../detach.mjs');
|
|
791
|
+
assert.deepEqual(Object.keys(detach.status(hp)), []);
|
|
792
|
+
});
|
|
793
|
+
|
|
676
794
|
test('an ended job surfaces the merge error its exit 0 hides', () => {
|
|
677
795
|
const log = path.join(temp, 'run_cycle.log');
|
|
678
796
|
fs.writeFileSync(log, 'progress line {not json}\n' + JSON.stringify({ finished: false, blocked_on: ['recovery_b'],
|
|
@@ -790,6 +908,63 @@ describe('Queue', () => {
|
|
|
790
908
|
assert.deepEqual(s.agents_silent, ['verify']);
|
|
791
909
|
});
|
|
792
910
|
|
|
911
|
+
// coolmall 12-03: after Step 5.4 every wait for the wiring agent returned `idle` at once
|
|
912
|
+
test('an idle queue is reported once, then wait blocks for a bound skill agent', async () => {
|
|
913
|
+
init();
|
|
914
|
+
const st = load();
|
|
915
|
+
for (const g of Object.values(st.groups)) g.state = 'verified';
|
|
916
|
+
gq._save(path.join(hp, '.hometrans', 'queue_state.json'), st);
|
|
917
|
+
const report = path.join(hp, '.hometrans', 'work', 'wiring.report.md');
|
|
918
|
+
fs.mkdirSync(path.dirname(report), { recursive: true });
|
|
919
|
+
gq.reviewBind(hp, 'wiring', { answers: report, kind: 'skill-agent' });
|
|
920
|
+
assert.deepEqual((await gq.wait(hp, { timeoutS: 2, pollS: 0.02 })).reasons, ['idle']);
|
|
921
|
+
|
|
922
|
+
const t0 = Date.now();
|
|
923
|
+
const waiting = gq.wait(hp, { timeoutS: 2, pollS: 0.02 });
|
|
924
|
+
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
925
|
+
fs.writeFileSync(report, '# wiring\nDONE\n');
|
|
926
|
+
const r = await waiting;
|
|
927
|
+
assert.ok(Date.now() - t0 >= 150, 'blocked until the report appeared');
|
|
928
|
+
assert.ok(r.reasons.includes('agent'), JSON.stringify(r.reasons));
|
|
929
|
+
assert.deepEqual(r.agents_done, ['wiring']);
|
|
930
|
+
|
|
931
|
+
// nothing left to wait for: idle again at once, not a wait to the timeout
|
|
932
|
+
const t1 = Date.now();
|
|
933
|
+
assert.deepEqual((await gq.wait(hp, { timeoutS: 2, pollS: 0.02 })).reasons, ['idle']);
|
|
934
|
+
assert.ok(Date.now() - t1 < 1000);
|
|
935
|
+
});
|
|
936
|
+
|
|
937
|
+
test('an idle queue held back by an explicit --answers file times out and says what it waited on', async () => {
|
|
938
|
+
init();
|
|
939
|
+
const st = load();
|
|
940
|
+
for (const g of Object.values(st.groups)) g.state = 'verified';
|
|
941
|
+
gq._save(path.join(hp, '.hometrans', 'queue_state.json'), st);
|
|
942
|
+
fs.writeFileSync(path.join(temp, 'x_worklist.json'), JSON.stringify({ items: [{ key: 'a' }] }));
|
|
943
|
+
const ans = path.join(temp, 'x_answers.json');
|
|
944
|
+
const w = () => gq.wait(hp, { timeoutS: 0.3, pollS: 0.02, answers: [ans] });
|
|
945
|
+
const first = await w();
|
|
946
|
+
assert.deepEqual(first.reasons, ['idle']);
|
|
947
|
+
assert.equal(first.waiting_on, undefined);
|
|
948
|
+
const second = await w();
|
|
949
|
+
assert.deepEqual(second.reasons, ['timeout']);
|
|
950
|
+
assert.deepEqual(second.waiting_on, [`answers:${path.resolve(ans)}`]);
|
|
951
|
+
assert.ok(second.summary.idle);
|
|
952
|
+
});
|
|
953
|
+
|
|
954
|
+
test('a new idle stretch is reported even with the same counts: re-lease or a new init', () => {
|
|
955
|
+
init();
|
|
956
|
+
const st = load();
|
|
957
|
+
for (const g of Object.values(st.groups)) Object.assign(g, { state: 'verified', started_at: 100 });
|
|
958
|
+
const k = gq.idleKeyOf(st);
|
|
959
|
+
assert.equal(gq.idleKeyOf(JSON.parse(JSON.stringify(st))), k, 'same state, same key');
|
|
960
|
+
const released = JSON.parse(JSON.stringify(st));
|
|
961
|
+
released.groups.G002.started_at = 200; // leased again, ended verified again
|
|
962
|
+
assert.notEqual(gq.idleKeyOf(released), k);
|
|
963
|
+
const takeover = JSON.parse(JSON.stringify(st));
|
|
964
|
+
takeover.inited_at = st.inited_at + 1; // a new parent ran init
|
|
965
|
+
assert.notEqual(gq.idleKeyOf(takeover), k);
|
|
966
|
+
});
|
|
967
|
+
|
|
793
968
|
// T5: review parts the explorer waits on that no reviewer was bound to are news
|
|
794
969
|
test('wait returns reviews when capture_pending lists an unbound, unanswered part', async () => {
|
|
795
970
|
init();
|
|
@@ -1532,15 +1707,22 @@ describe('Queue', () => {
|
|
|
1532
1707
|
assert.equal(load().groups.G001.next_session, 'ses_7');
|
|
1533
1708
|
});
|
|
1534
1709
|
|
|
1535
|
-
test('3: requeue of a cleanly returned group
|
|
1710
|
+
test('3: requeue of a cleanly returned group resumes its session (it keeps the evidence it read); --fresh starts over', () => {
|
|
1536
1711
|
init();
|
|
1537
1712
|
gq.lease(hp);
|
|
1538
1713
|
gq.bind(hp, 'G001', 'ses_1');
|
|
1539
1714
|
finish('G001');
|
|
1540
1715
|
gq.release(hp, 'G001');
|
|
1541
1716
|
const r = gq.control(hp, { op: 'requeue', group: 'G001', message: 'fix' });
|
|
1542
|
-
assert.equal(r.resume_task,
|
|
1717
|
+
assert.equal(r.resume_task, 'ses_1');
|
|
1543
1718
|
assert.ok(!r.stop_first);
|
|
1719
|
+
assert.equal(load().groups.G001.next_session, 'ses_1');
|
|
1720
|
+
gq.lease(hp);
|
|
1721
|
+
finish('G001');
|
|
1722
|
+
gq.release(hp, 'G001');
|
|
1723
|
+
const f = gq.control(hp, { op: 'requeue', group: 'G001', message: 'fix', fresh: true });
|
|
1724
|
+
assert.equal(f.resume_task, undefined);
|
|
1725
|
+
assert.ok(!f.stop_first);
|
|
1544
1726
|
assert.equal(load().groups.G001.next_session, undefined);
|
|
1545
1727
|
});
|
|
1546
1728
|
|
|
@@ -96,6 +96,39 @@ describe('host_env', () => {
|
|
|
96
96
|
assert.equal(c.background_ready, true);
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
+
test('deveco: background sub-agents are on by default — no flag, no restart', () => {
|
|
100
|
+
Object.assign(env, { OPENCODE: '1', DEVECO: '1' });
|
|
101
|
+
const c = he.check();
|
|
102
|
+
assert.equal(c.host, 'deveco');
|
|
103
|
+
assert.equal(c.background_ready, true);
|
|
104
|
+
assert.match(c.action, /^none: DevEco Code enables background sub-agents by default/);
|
|
105
|
+
assert.equal(c.active.DEVECO_EXPERIMENTAL_BACKGROUND_SUBAGENTS, true);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('deveco: only an explicit false / 0 turns it off → enable, then restart', () => {
|
|
109
|
+
for (const off of ['false', 'FALSE', '0']) {
|
|
110
|
+
env = { SHELL: '/bin/zsh', OPENCODE: '1', DEVECO: '1', DEVECO_EXPERIMENTAL_BACKGROUND_SUBAGENTS: off };
|
|
111
|
+
const c = he.check();
|
|
112
|
+
assert.equal(c.background_ready, false, off);
|
|
113
|
+
assert.match(c.action, /^enable: .*turned off/);
|
|
114
|
+
}
|
|
115
|
+
he.enable();
|
|
116
|
+
assert.match(he.check().action, /^restart/);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('deveco: DEVECO_EXPERIMENTAL=true forces it on even with the flag off', () => {
|
|
120
|
+
Object.assign(env, { DEVECO: '1', DEVECO_EXPERIMENTAL: 'true', DEVECO_EXPERIMENTAL_BACKGROUND_SUBAGENTS: 'false' });
|
|
121
|
+
assert.equal(he.check().background_ready, true);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test('opencode v1 is unaffected by the DevEco default: unset flag still needs enable', () => {
|
|
125
|
+
env.OPENCODE = '1';
|
|
126
|
+
he._impl.opencodeVersion = () => '1.19.6';
|
|
127
|
+
const c = he.check();
|
|
128
|
+
assert.equal(c.background_ready, false);
|
|
129
|
+
assert.match(c.action, /^enable: run/);
|
|
130
|
+
});
|
|
131
|
+
|
|
99
132
|
test('disable keeps the rest of the profile', () => {
|
|
100
133
|
fs.writeFileSync(path.join(home, '.zshrc'), 'alias ll="ls -l"\n');
|
|
101
134
|
he.enable();
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
// interactions: in-page interactions a2h-utg-static found (view_attachments `attachments[]`) reach the converted
|
|
2
|
+
// page's meta.json, the group pack and the phase5_check gate (interaction-uncovered / interaction-marker-detached),
|
|
3
|
+
// and an attach node's interactions fold into its host page. Also locks the general meta.json fixes that ride with
|
|
4
|
+
// them: a captured page gets reached_from / navigates_to, an edge view keeps guard / label / gesture, a widget keeps
|
|
5
|
+
// gesture_param / trigger_targets, and conversion_set.json page rows carry navigates_to for Step 5.5.
|
|
6
|
+
// Lead case: a weather app's chart marker (TodayWeatherFragment.java:173 setMarker(new CustomMarkerView(..))) on an
|
|
7
|
+
// attach fragment of the captured main page — it reached no meta.json and no prompt, and the converted chart had no
|
|
8
|
+
// touch handling.
|
|
9
|
+
// Run from scripts/: node --test tests/interactions.test.mjs
|
|
10
|
+
import { test, describe, beforeEach, afterEach } from 'node:test';
|
|
11
|
+
import assert from 'node:assert/strict';
|
|
12
|
+
import * as fs from 'node:fs';
|
|
13
|
+
import * as os from 'node:os';
|
|
14
|
+
import * as path from 'node:path';
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
implementingLine, interactionCoverage, interactionsInScope, interactionsOf, loadInteractions, renderInteractionsSection,
|
|
18
|
+
} from '../interactions.mjs';
|
|
19
|
+
import * as bcs from '../build_conversion_set.mjs';
|
|
20
|
+
import * as pc from '../phase5_check.mjs';
|
|
21
|
+
|
|
22
|
+
const SINK_AT = 'app/src/main/java/demo/TodayFragment.java:173';
|
|
23
|
+
const ID = `ix:${SINK_AT}:PointMarker`;
|
|
24
|
+
const ATTACHMENT = {
|
|
25
|
+
at: SINK_AT, view_class: 'PointMarker', view_class_at: 'app/src/main/java/demo/ChartView.java:153', base: 'MarkerView',
|
|
26
|
+
evidence: ['extends MarkerView'], layout: 'app/src/main/res/layout/marker_layout.xml',
|
|
27
|
+
sink: { kind: 'call-arg', callee: 'setMarker', receiver: 'lineChart.getChart()', at: SINK_AT },
|
|
28
|
+
};
|
|
29
|
+
const ITEM = { ...interactionsOf({ id: 'fragment:Today', attachments: [ATTACHMENT] })[0], host: 'fragment:Main' };
|
|
30
|
+
|
|
31
|
+
const CHART = (mark) => `@ComponentV2
|
|
32
|
+
export struct DayForecastChart {
|
|
33
|
+
build() {
|
|
34
|
+
Stack() {
|
|
35
|
+
Canvas(this.ctx)
|
|
36
|
+
${mark}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
const MARKED = CHART(` // INTERACTION: ${ID}\n .onTouch((e: TouchEvent) => { this.highlight(e); })`);
|
|
42
|
+
const cov = (src, opts = {}) => interactionCoverage({ items: [ITEM], files: [['components/DayForecastChart.ets', src]], ...opts });
|
|
43
|
+
|
|
44
|
+
// ── interactions.mjs ─────────────────────────────────────────────────────────
|
|
45
|
+
|
|
46
|
+
test('interactionsOf: one interaction per attachment, id from the attaching line, duplicates folded', () => {
|
|
47
|
+
const xs = interactionsOf({ id: 'fragment:Today', attachments: [ATTACHMENT, ATTACHMENT, { sink: {} }] });
|
|
48
|
+
assert.equal(xs.length, 1);
|
|
49
|
+
assert.deepEqual({ id: xs[0].id, kind: xs[0].kind, node: xs[0].node, layout: xs[0].layout },
|
|
50
|
+
{ id: ID, kind: 'attached-view', node: 'fragment:Today', layout: 'app/src/main/res/layout/marker_layout.xml' });
|
|
51
|
+
assert.deepEqual(interactionsOf({ id: 'x' }), []);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('interactionsOf: two views attached on one line stay two interactions', () => {
|
|
55
|
+
const other = { ...ATTACHMENT, view_class: 'EmptyHint', layout: undefined,
|
|
56
|
+
sink: { kind: 'call-arg', callee: 'setEmptyView', receiver: 'chart', at: SINK_AT } };
|
|
57
|
+
const xs = interactionsOf({ id: 'fragment:Today', attachments: [ATTACHMENT, other] });
|
|
58
|
+
assert.deepEqual(xs.map((x) => x.id), [ID, `ix:${SINK_AT}:EmptyHint`]);
|
|
59
|
+
// each id is matched whole: a marker for one does not cover the other
|
|
60
|
+
const src = CHART(` // INTERACTION: ${ID}\n .onTouch((e: TouchEvent) => { this.highlight(e); })`);
|
|
61
|
+
const r = interactionCoverage({ items: xs.map((x) => ({ ...x, host: 'fragment:Main' })), files: [['c.ets', src]] });
|
|
62
|
+
assert.equal(r.checked, 2);
|
|
63
|
+
assert.equal(r.gate.length, 1);
|
|
64
|
+
assert.match(r.gate[0], /^interaction-uncovered {2}ix:\S+:173:EmptyHint /);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('an id shared by several hosts (sink in a base class) is reported once with every host, and one marker covers all', () => {
|
|
68
|
+
const items = [{ ...ITEM, host: 'fragment:A', node: 'fragment:A' }, { ...ITEM, host: 'fragment:B', node: 'fragment:B' }];
|
|
69
|
+
const r = interactionCoverage({ items, files: [['c.ets', CHART(' .width(\'100%\')')]] });
|
|
70
|
+
assert.equal(r.checked, 1);
|
|
71
|
+
assert.equal(r.gate.length, 1);
|
|
72
|
+
assert.ok(r.gate[0].includes(`${ID} (fragment:A, fragment:B)`), r.gate[0]);
|
|
73
|
+
assert.deepEqual(interactionCoverage({ items, files: [['c.ets', MARKED]] }).gate, []);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('marked on an ArkUI event attribute: covered; nothing marked: GATE interaction-uncovered', () => {
|
|
77
|
+
assert.deepEqual(cov(MARKED), { gate: [], checked: 1 });
|
|
78
|
+
const r = cov(CHART(' .width(\'100%\')'));
|
|
79
|
+
assert.equal(r.gate.length, 1);
|
|
80
|
+
assert.match(r.gate[0], /^interaction-uncovered {2}ix:app\/src\/main\/java\/demo\/TodayFragment\.java:173:PointMarker \(fragment:Main ← fragment:Today\): `lineChart\.getChart\(\)\.setMarker\(PointMarker\(\.\.\)\)` at TodayFragment\.java:173/);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('a marker with nothing implementing after it is GATE interaction-marker-detached and covers nothing', () => {
|
|
84
|
+
const r = cov(CHART(` // INTERACTION: ${ID}\n // TODO\n\n`));
|
|
85
|
+
assert.equal(r.gate.length, 2);
|
|
86
|
+
assert.match(r.gate[0], /^interaction-marker-detached {2}components\/DayForecastChart\.ets:6/);
|
|
87
|
+
assert.match(r.gate[1], /^interaction-uncovered/);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('INTERACTION-OMIT waives with a basis, not without one; a marker in a shared file covers', () => {
|
|
91
|
+
assert.deepEqual(cov(CHART(` // INTERACTION-OMIT: ${ID} — 目标设计去掉了曲线点选`)).gate, []);
|
|
92
|
+
const bad = cov(CHART(` // INTERACTION-OMIT: ${ID}`));
|
|
93
|
+
assert.match(bad.gate[0], /INTERACTION-OMIT at components\/DayForecastChart\.ets:6 has no basis/);
|
|
94
|
+
assert.deepEqual(interactionCoverage({ items: [ITEM], files: [['pages/Main.ets', '']], shared: [['components/DayForecastChart.ets', MARKED]] }).gate, []);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('scope: only interactions whose host or own node is in the set', () => {
|
|
98
|
+
assert.equal(interactionsInScope([ITEM], new Set(['fragment:Main'])).length, 1);
|
|
99
|
+
assert.equal(interactionsInScope([ITEM], new Set(['fragment:Today'])).length, 1);
|
|
100
|
+
assert.equal(interactionsInScope([ITEM], new Set(['fragment:Other'])).length, 0);
|
|
101
|
+
assert.equal(cov('', { scope: new Set(['fragment:Other']) }).checked, 0);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('implementingLine: event / gesture / bind attributes and statements count, plain attributes and comments do not', () => {
|
|
105
|
+
for (const l of ['.onTouch((e) => {})', ' .gesture(TapGesture())', '.bindPopup(this.show, {})', 'this.selected = i', 'this.showMarker(i)']) {
|
|
106
|
+
assert.ok(implementingLine(l), l);
|
|
107
|
+
}
|
|
108
|
+
for (const l of ['.width(100)', '// nothing', '}', 'Canvas(this.ctx)']) { assert.ok(!implementingLine(l), l); }
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('group pack section: id, receiver call, view class, layout, origin node and the marker rule', () => {
|
|
112
|
+
const md = renderInteractionsSection([ITEM]).join('\n');
|
|
113
|
+
assert.match(md, /## In-page interactions/);
|
|
114
|
+
assert.match(md, /### fragment:Main/);
|
|
115
|
+
assert.ok(md.includes(`\`${ID}\` attached-view (from attached \`fragment:Today\`)`));
|
|
116
|
+
assert.ok(md.includes('view class `PointMarker` extends `MarkerView`'));
|
|
117
|
+
assert.ok(md.includes('layout `app/src/main/res/layout/marker_layout.xml`'));
|
|
118
|
+
assert.match(md, /\/\/ INTERACTION-OMIT: <id> — <basis>/);
|
|
119
|
+
assert.deepEqual(renderInteractionsSection([]), []);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// ── build_conversion_set: transport + general meta fixes ─────────────────────
|
|
123
|
+
|
|
124
|
+
function w(p, data) {
|
|
125
|
+
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
126
|
+
fs.writeFileSync(p, JSON.stringify(data), 'utf8');
|
|
127
|
+
}
|
|
128
|
+
const read = (p) => JSON.parse(fs.readFileSync(p, 'utf8'));
|
|
129
|
+
|
|
130
|
+
describe('build_conversion_set carries interactions and static edges', () => {
|
|
131
|
+
let tmp; let ws; let ui;
|
|
132
|
+
const NODES = [
|
|
133
|
+
{ id: 'activity:Main', kind: 'activity', status: 'static-only' },
|
|
134
|
+
{ id: 'fragment:Main', kind: 'fragment', status: 'static-only', declared_at: 'M.java:1' },
|
|
135
|
+
{ id: 'fragment:Today', kind: 'fragment', status: 'static-only', declared_at: 'T.java:45', embedded_in: 'fragment:Main',
|
|
136
|
+
denominator: false, attachments: [ATTACHMENT] },
|
|
137
|
+
{ id: 'fragment:Settings', kind: 'fragment', status: 'static-only', declared_at: 'S.java:1',
|
|
138
|
+
widgets: [{ widget: 'backBtn', kind: 'action', view_id: 'backBtn', at: 'res/layout/s.xml:3', gesture_param: 'onLongClick',
|
|
139
|
+
trigger_targets: ['fragment:Main'] }] },
|
|
140
|
+
{ id: 'fragment:Login', kind: 'fragment', status: 'static-only', declared_at: 'L.java:1' },
|
|
141
|
+
];
|
|
142
|
+
const LINKS = [
|
|
143
|
+
// utg-static's placeholder actions: `launch` on a launch path, `default` on a fragment embed — not gestures
|
|
144
|
+
{ source: 'activity:Main', target: 'fragment:Main', mechanism: 'fragment-transaction', args: { action: 'launch' } },
|
|
145
|
+
{ source: 'fragment:Main', target: 'fragment:Today', mechanism: 'fragment-embed', args: { action: 'default' } },
|
|
146
|
+
{ source: 'fragment:Main', target: 'fragment:Settings', mechanism: 'fragment-transaction', trigger: 'onClick@M.java:129',
|
|
147
|
+
args: { label: '设置', action: 'long_press' } },
|
|
148
|
+
{ source: 'fragment:Main', target: 'fragment:Login', mechanism: 'fragment-transaction', trigger: 'onClick@M.java:140',
|
|
149
|
+
guard: { kind: 'login', text: '!isLoggedIn()' }, args: { action: 'tap' } },
|
|
150
|
+
];
|
|
151
|
+
beforeEach(() => {
|
|
152
|
+
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'ix-bcs-'));
|
|
153
|
+
ws = path.join(tmp, 'ws'); ui = path.join(tmp, 'ui');
|
|
154
|
+
w(path.join(ws, 'utg.json'), { nodes: NODES, links: LINKS });
|
|
155
|
+
w(path.join(ws, 'click_paths.json'), { paths: {} });
|
|
156
|
+
const cap = path.join(ui, 'page_0001_Main');
|
|
157
|
+
w(path.join(cap, 'meta.json'), { page_id: 'page_0001_Main', static_node: 'fragment:Main', screenshots: ['page_0001_Main/screenshot.png'] });
|
|
158
|
+
w(path.join(ui, 'export_manifest.json'), { pages: [{ page_dir: 'page_0001_Main', static_node: 'fragment:Main' }] });
|
|
159
|
+
w(path.join(ui, 'pages.json'), { pages: [{ page_dir: cap, ui_sequence: '根页面' }] });
|
|
160
|
+
});
|
|
161
|
+
afterEach(() => fs.rmSync(tmp, { recursive: true, force: true }));
|
|
162
|
+
|
|
163
|
+
test('an attach node\'s interaction lands on its captured host: meta.json and conversion_set.json', () => {
|
|
164
|
+
bcs.build(ws, ui);
|
|
165
|
+
const cs = read(path.join(ui, 'conversion_set.json'));
|
|
166
|
+
assert.equal(cs.nodes.find((r) => r.node === 'fragment:Today').role, 'attach');
|
|
167
|
+
assert.deepEqual(cs.interactions.map((x) => [x.id, x.host, x.node]), [[ID, 'fragment:Main', 'fragment:Today']]);
|
|
168
|
+
const meta = read(path.join(ui, 'page_0001_Main', 'meta.json'));
|
|
169
|
+
assert.deepEqual(meta.interactions.map((x) => x.id), [ID]);
|
|
170
|
+
assert.deepEqual(loadInteractions(ui).map((x) => x.id), [ID]);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test('a captured page gets reached_from / navigates_to; edge views keep guard, label and a non-tap gesture', () => {
|
|
174
|
+
bcs.build(ws, ui);
|
|
175
|
+
const meta = read(path.join(ui, 'page_0001_Main', 'meta.json'));
|
|
176
|
+
assert.deepEqual(meta.reached_from.map((e) => e.source), ['activity:Main']);
|
|
177
|
+
const out = Object.fromEntries(meta.navigates_to.map((e) => [e.target, e]));
|
|
178
|
+
assert.deepEqual(out['fragment:Settings'], { target: 'fragment:Settings', mechanism: 'fragment-transaction',
|
|
179
|
+
trigger: 'onClick@M.java:129', label: '设置', gesture: 'long_press' });
|
|
180
|
+
assert.deepEqual(out['fragment:Login'].guard, { kind: 'login', text: '!isLoggedIn()' });
|
|
181
|
+
assert.equal(out['fragment:Login'].gesture, undefined, 'a plain tap is not a gesture worth naming');
|
|
182
|
+
assert.equal(out['fragment:Today'].gesture, undefined, 'action: default is a placeholder, not a gesture');
|
|
183
|
+
assert.equal(meta.reached_from[0].gesture, undefined, 'action: launch is a placeholder, not a gesture');
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test('edgeView: a specific args.gesture beats a placeholder or the generic swipe action', () => {
|
|
187
|
+
const view = (args) => bcs.edgeView({ source: 'a', target: 'b', args }, 'target').gesture;
|
|
188
|
+
assert.equal(view({ action: 'swipe', gesture: 'open-drawer' }), 'open-drawer');
|
|
189
|
+
assert.equal(view({ action: 'tap', gesture: 'long_press' }), 'long_press');
|
|
190
|
+
assert.equal(view({ action: 'default', gesture: 'long_press' }), 'long_press');
|
|
191
|
+
assert.equal(view({ action: 'swipe' }), 'swipe');
|
|
192
|
+
assert.equal(view({ action: 'swipe-left', gesture: 'open-drawer' }), 'swipe-left');
|
|
193
|
+
assert.equal(view({ action: 'default' }), undefined);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test('conversion_set.json page rows carry navigates_to for Step 5.5', () => {
|
|
197
|
+
bcs.build(ws, ui);
|
|
198
|
+
const rows = Object.fromEntries(read(path.join(ui, 'conversion_set.json')).nodes.map((r) => [r.node, r]));
|
|
199
|
+
assert.deepEqual(rows['fragment:Main'].navigates_to.map((e) => e.target).sort(),
|
|
200
|
+
['fragment:Login', 'fragment:Settings', 'fragment:Today']);
|
|
201
|
+
assert.equal(rows['fragment:Login'].navigates_to, undefined);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test('a source-only page keeps gesture_param / trigger_targets on its widgets', () => {
|
|
205
|
+
bcs.build(ws, ui);
|
|
206
|
+
const dir = fs.readdirSync(ui).find((d) => d.endsWith('_Settings'));
|
|
207
|
+
const [wd] = read(path.join(ui, dir, 'meta.json')).source_hints.widgets;
|
|
208
|
+
assert.equal(wd.gesture_param, 'onLongClick');
|
|
209
|
+
assert.deepEqual(wd.trigger_targets, ['fragment:Main']);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test('rebuilding without attachments drops the stale interactions from the captured meta.json', () => {
|
|
213
|
+
bcs.build(ws, ui);
|
|
214
|
+
w(path.join(ws, 'utg.json'), { nodes: NODES.map((n) => ({ ...n, attachments: undefined })), links: LINKS });
|
|
215
|
+
bcs.build(ws, ui);
|
|
216
|
+
assert.equal(read(path.join(ui, 'page_0001_Main', 'meta.json')).interactions, undefined);
|
|
217
|
+
assert.equal(read(path.join(ui, 'conversion_set.json')).interactions, undefined);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// ── phase5_check gate ────────────────────────────────────────────────────────
|
|
222
|
+
|
|
223
|
+
test('phase5_check --group gates the group\'s interactions, --files every converted page, and render prints [interactions]', () => {
|
|
224
|
+
const hp = fs.mkdtempSync(path.join(os.tmpdir(), 'ix-p5-'));
|
|
225
|
+
const realGate = pc.hooks.staticGate;
|
|
226
|
+
try {
|
|
227
|
+
const meta = path.join(hp, '.hometrans');
|
|
228
|
+
fs.mkdirSync(path.join(meta, 'ui_info'), { recursive: true });
|
|
229
|
+
fs.writeFileSync(path.join(meta, 'batch_progress.json'), JSON.stringify({ ui_module: 'entry', paradigm: 'V2' }));
|
|
230
|
+
fs.writeFileSync(path.join(meta, 'ui_info', 'conversion_set.json'), JSON.stringify({
|
|
231
|
+
nodes: [{ node: 'fragment:Main', role: 'page' }, { node: 'fragment:Today', role: 'attach', host: 'fragment:Main' },
|
|
232
|
+
{ node: 'fragment:Settings', role: 'page' }],
|
|
233
|
+
plan: { groups: [{ id: 'G1', members: [{ node: 'fragment:Main' }], page_dirs: [] },
|
|
234
|
+
{ id: 'G2', members: [{ node: 'fragment:Settings' }], page_dirs: [] }] },
|
|
235
|
+
interactions: [ITEM] }));
|
|
236
|
+
const ets = path.join(hp, 'entry', 'src', 'main', 'ets', 'components');
|
|
237
|
+
fs.mkdirSync(ets, { recursive: true });
|
|
238
|
+
fs.writeFileSync(path.join(ets, 'DayForecastChart.ets'), CHART(''));
|
|
239
|
+
pc.hooks.staticGate = () => [{ mine: [], batch_level: 0 }, null];
|
|
240
|
+
const g1 = pc.check(hp, ['components/DayForecastChart.ets'], null, 'G1');
|
|
241
|
+
assert.equal(g1.interactions.gate.length, 1);
|
|
242
|
+
assert.match(pc.render(g1), /\[interactions\] in-page interactions vs \/\/ INTERACTION markers \(1 interactions\): GATE 1 \(blocking\)/);
|
|
243
|
+
assert.equal(pc.check(hp, ['components/DayForecastChart.ets'], null, 'G2').interactions.checked, 0, 'another group is not gated');
|
|
244
|
+
const before = pc.check(hp, ['components/DayForecastChart.ets']).blocking;
|
|
245
|
+
fs.writeFileSync(path.join(ets, 'DayForecastChart.ets'), MARKED);
|
|
246
|
+
const f = pc.check(hp, ['components/DayForecastChart.ets']);
|
|
247
|
+
assert.deepEqual(f.interactions.gate, []);
|
|
248
|
+
assert.equal(before - f.blocking, 1);
|
|
249
|
+
} finally {
|
|
250
|
+
pc.hooks.staticGate = realGate;
|
|
251
|
+
fs.rmSync(hp, { recursive: true, force: true });
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
test('an older conversion set (no interactions) is skipped silently', () => {
|
|
256
|
+
assert.deepEqual(loadInteractions(null), []);
|
|
257
|
+
assert.deepEqual(interactionCoverage({ items: [] }), { gate: [], checked: 0 });
|
|
258
|
+
});
|
|
@@ -245,7 +245,7 @@ partial coverage. Only a run that produced no SPEC at all aborts. See
|
|
|
245
245
|
## Gates
|
|
246
246
|
|
|
247
247
|
- **G1:** Exactly one SPEC per page in a new run, exactly one page per SPEC, no extra SPECs, and coverage of every page
|
|
248
|
-
- **G2:** H1 is `# <title> SPEC` (one space before SPEC), there is at least one scenario, scenario headings are numbered in draft order, and the final section is `## 安卓代码参考`. A `实现契约` section is rejected. Any declared page-level `contracts` container is rejected (even `{"endpoints": []}`), every non-empty but unusable `scenarios[].contracts` declaration is an error (a non-`rules` entry must yield a fact token), and every fact token of a usable declaration must appear in that scenario's `steps`, matched on token boundaries so `10` does not stand in for `1` or `0` (the authoring pass merges facts naturally; the gate proves nothing was dropped); a rule's numeric literals count as fact tokens, normalized to the shape the steps state them (thousands grouping, a sign written in words, an exponent written out), while a literal that only states how a value is printed (a zero-padded field width, a decimal-place count) is not required. Keeping the existing step count and order is a review item, not a gate claim
|
|
248
|
+
- **G2:** H1 is `# <title> SPEC` (one space before SPEC), there is at least one scenario, scenario headings are numbered in draft order, and the final section is `## 安卓代码参考`. A `实现契约` section is rejected. Any declared page-level `contracts` container is rejected (even `{"endpoints": []}`), every non-empty but unusable `scenarios[].contracts` declaration is an error (a non-`rules` entry must yield a fact token), and every fact token of a usable declaration must appear in that scenario's `steps`, matched on token boundaries so `10` does not stand in for `1` or `0` (the authoring pass merges facts naturally; the gate proves nothing was dropped); a rule's numeric literals count as fact tokens, normalized to the shape the steps state them (thousands grouping, a sign written in words, an exponent written out), while a literal that only states how a value is printed (a zero-padded field width, a decimal-place count) is not required. When a scenario declares at least one `in: "query"` or `in: "body"` parameter, its steps must contain the four-label field table (`字段名:` / `类型/编码方式:` / `默认值:` / `是否传:`), one row per query/body parameter, with `是否传` starting with 必传/非必传/不传; a path/header-only endpoint (no query/body params) is exempt. When steps describe a request body (POST/PUT/PATCH + URL + 请求体/请求参数/表单) or carry a field table without a declared body contract, G2 emits a warning; an explicit 不携带请求体 statement closes it. Keeping the existing step count and order is a review item, not a gate claim
|
|
249
249
|
- **G3:** The body contains no `file:line` (a scheme-qualified URL with `:port` is a URL, not an anchor), project symbol-table matches (except names the gate requires as fact tokens), framework type names, `dp/sp/px`/`dip` (bare or with a number), `#hex`, or assignment/comparison expressions. The same rules apply to steps carrying merged endpoint, key, field, and rule facts: write them as ordinary sentences (`字段 code 为 1001`), never as `key=value` assignments
|
|
250
250
|
- **G4:** Coverage: for behavior-enabled pages, every planned assertion must have a valid explicit `coverage.behaviors` link (with valid scenario/step indices, a restated navigation gate, a legal waiver, or a related unresolved unknown) and pass semantic review. The legacy UTG denominator remains a secondary check: every `out_edges` entry and every `is_trigger` widget is claimed by a scenario (verified with `claim_token`) or has a reason recorded in `excluded`; an `edges` claim may carry its own `claim_token` when the target stem is not derivable (Compose route, overlay name), and that token is matched verbatim in the scenario; an interaction signal follows its interaction-signal candidate disposition instead — promoted → claim, waived → exclusion, unknown or unfinished → partial with neither
|
|
251
251
|
- **G5:** Every `file:line` in `anchors` actually exists under `<source-project>` and has a valid line number
|
|
@@ -53,6 +53,21 @@ these states may be reported as complete coverage. See
|
|
|
53
53
|
[behavior-ledger.md](behavior-ledger.md) for the exact schemas, producer
|
|
54
54
|
contracts, and audits.
|
|
55
55
|
|
|
56
|
+
### Outbound (navigation) evidence
|
|
57
|
+
|
|
58
|
+
`composition.json` also carries one `outbound_evidence[]` entry per navigation edge.
|
|
59
|
+
A resolved entry names the target implementation; a partial entry records why the
|
|
60
|
+
edge could not be validated:
|
|
61
|
+
|
|
62
|
+
- `outbound-callees-missing` — the graph/query returned no callee for the edge.
|
|
63
|
+
- `outbound-dynamic-dispatch-unresolved` — the only callee is a dynamic dispatch and no qualified implementation matched.
|
|
64
|
+
- `outbound-implementation-unavailable` — neither the page/origin nor the graph registers any implementation identity (for example a sheet/overlay origin that carries only `declared_at`).
|
|
65
|
+
- `outbound-target-unresolved` — implementation identities exist, but none matches the callee's exact `qualified_name` + `file_path`.
|
|
66
|
+
- `outbound-implementation-source-unit-unavailable` — a previously resolved implementation is not a readable SourceUnit in the current snapshot, so the edge is downgraded to partial.
|
|
67
|
+
|
|
68
|
+
The matching unknown uses `reason: "outbound-unresolved"` and copies the specific
|
|
69
|
+
cause above; it keeps delivery partial until reviewed.
|
|
70
|
+
|
|
56
71
|
## HomeGraph Command Sequence
|
|
57
72
|
|
|
58
73
|
### Index Prerequisite (build if absent; no fallback allowed)
|
|
@@ -17,7 +17,7 @@ This document defines the gate identifiers enforced by a2h-page-specgen (`script
|
|
|
17
17
|
| G7 | For page SPECs, the difference between `est(P)` and the actual scenario count exceeds 2×; shared SPECs are exempt because their fixed `est` is not a scenario estimate | Add a G7 entry to `warnings` and record it in `report.md` |
|
|
18
18
|
| G8 | `deps` is non-empty but has no non-empty `deps_reason` entry | Add a G8 entry to `warnings` and record it in `report.md` |
|
|
19
19
|
|
|
20
|
-
**Request
|
|
20
|
+
**Request field tables are step text.** A table whose rows carry four labels (`字段名:` / `类型/编码方式:` / `默认值:` / `是否传:`) lives inside the request step, so G2, G3 and G6 read it as that step's own text: the parameter-name, default and value-source tokens that `contracts.endpoints[].params` declares must appear inside the table; G3's prose rules apply to every table line (a path glued to `:0` reads as a `file:line`, and `默认值=false` reads as an assignment); and the step keeps its single `- N. ` marker with the table as a top-level fenced block. **G2 requires this table when the scenario declares at least one `in: "query"` or `in: "body"` parameter**: one row per query/body field, and `是否传:` starts with `必传` / `非必传` / `不传`; a path/header-only endpoint is exempt. When no query/body contract is declared but a step still describes a request body (or carries a table), G2 emits a warning; an explicit「不携带请求体」closes it.
|
|
21
21
|
|
|
22
22
|
**Core gates**: G3, G4, and G5 are the core gates.
|
|
23
23
|
- **G3** ensures that the SPEC describes implementable business behavior rather than restating source code.
|
|
@@ -327,6 +327,8 @@ After drafting, review the following checklist:
|
|
|
327
327
|
- [ ] G3: The strict body rules also hold in steps carrying merged endpoint, key, field, and rule facts; no exempt zone exists.
|
|
328
328
|
- [ ] G2: No `实现契约` heading at any level is present; facts are merged into the consuming steps.
|
|
329
329
|
- [ ] G2: Non-empty page-level `contracts` is absent — any declared container counts, even `{"endpoints": []}`; every non-empty `scenarios[].contracts` declaration is usable and every fact token (URL, method, parameter name, response field, key, default, enum value, field name, unit) appears in that scenario's steps, and every numeric enum value appears as its own value (`10` does not cover `1` or `0`).
|
|
330
|
+
- [ ] G2: A scenario that declares an `in: "query"` or `in: "body"` parameter carries the four-label field table (`字段名:` / `类型/编码方式:` / `默认值:` / `是否传:`), one row per query/body field, with `是否传:` starting with 必传/非必传/不传; a path/header-only endpoint needs no table.
|
|
331
|
+
- [ ] G2 (warn-only): a step that describes a request body (POST/PUT/PATCH + URL + 请求体/请求参数/表单) or carries a field table without any `scenarios[].contracts.endpoints` body contract is warned; an explicit「不携带请求体」closes it.
|
|
330
332
|
- [ ] G2: The merge rewrote step text without deleting, merging, reordering, or renumbering existing steps (append-only at the end); the gate cannot verify this, so it is a review item.
|
|
331
333
|
- [ ] Contracts: Enumerations are complete, with no vague endings such as "等选项" or "之类"; every numeric literal in a rule statement that the rule can be wrong about (coefficient, offset, threshold, enum value) appears in the consuming steps in the shape the steps state it (a thousands separator groups, a sign is written in words, an exponent is written out), while display-only literals (field width, decimal-place count) are not required; non-numeric rule prose is checked against the steps by review.
|
|
332
334
|
- [ ] G4: For behavior-enabled pages, `discovery.json` contains every immutable assertion unchanged plus only validated semantic additions.
|