@buaa_smat/hometrans 0.1.13 → 0.1.14
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 +164 -112
- package/agents/build-fixer.md +384 -394
- package/agents/code-reviewer.md +240 -240
- package/agents/logic-coder.md +199 -199
- package/agents/logic-context-builder.md +194 -194
- package/agents/review-fixer.md +405 -405
- package/agents/self-test-fixer.md +296 -296
- package/agents/self-tester.md +393 -392
- package/agents/spec-generator.md +540 -540
- package/dist/cli/config-store.js +84 -8
- package/dist/cli/config.js +3 -3
- package/dist/cli/env-vars.js +129 -0
- package/dist/cli/init.js +272 -272
- package/dist/cli/uninstall.js +152 -17
- package/dist/context/index.js +10 -197
- package/env-requirements.json +3 -3
- package/package.json +1 -1
- package/resource/choose_editor.png +0 -0
- package/resource/common_config.png +0 -0
- package/resource/integration_test_config.png +0 -0
- package/resource/set_env.png +0 -0
- package/resource/ui_align_config.png +0 -0
- package/skills/hmos-batch-ui-align/SKILL.md +108 -98
- package/skills/hmos-batch-ui-align/references/conversion-procedure.md +180 -180
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
- package/skills/hmos-batch-ui-align/references/mvvm/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
- package/skills/hmos-batch-ui-align/references/mvvm/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
- package/skills/hmos-batch-ui-align/references/mvvm/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
- package/skills/hmos-batch-ui-align/references/mvvm/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
- package/skills/hmos-batch-ui-align/references/mvvm/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
- package/skills/hmos-batch-ui-align/references/mvvm/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
- package/skills/hmos-batch-ui-align/references/mvvm/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
- package/skills/hmos-batch-ui-align/references/mvvm/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
- package/skills/hmos-batch-ui-align/references/mvvm/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
- package/skills/hmos-batch-ui-align/references/mvvm/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
- package/skills/hmos-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -911
- package/skills/hmos-batch-ui-align/references/mvvm/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
- package/skills/hmos-batch-ui-align/references/mvvm//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
- package/skills/hmos-convert-pipeline/SKILL.md +429 -415
- package/skills/hmos-fix-build-errors/SKILL.md +272 -273
- package/skills/hmos-fix-build-errors/references/arkts-strict-patterns.md +219 -219
- package/skills/hmos-fix-build-errors/references/known-patterns.md +157 -157
- package/skills/hmos-fix-build-errors/references/rdb-entity-pattern.md +131 -131
- package/skills/hmos-incremental-ui-align/SKILL.md +219 -200
- package/skills/hmos-incremental-ui-align/diff_analysis.md +52 -52
- package/skills/hmos-incremental-ui-align/page_align.md +62 -62
- package/skills/hmos-incremental-ui-align/readme.md +237 -230
- package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +2 -2
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217V1.md +911 -911
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
- package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +3 -3
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
- package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +37 -37
- package/skills/hmos-integration-test/SKILL.md +380 -369
- package/skills/hmos-integration-test/readme.md +309 -309
- package/skills/hmos-resources-convert/SKILL.md +623 -623
- package/skills/hmos-resources-convert/references/conversion-rules.md +663 -663
- package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +388 -388
- package/skills/hmos-resources-convert/references/resource-mapping-rules.md +457 -457
- package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +513 -513
- package/skills/hmos-spec-generate/SKILL.md +331 -331
- package/skills/hmos-spec-generate/references/android-platform-tokens.md +105 -105
- package/skills/hmos-spec-generate/references/spec-sample-1.md +78 -78
- package/skills/hmos-spec-generate/references/spec-sample-2.md +58 -58
- package/skills/hmos-spec-generate/references/spec-sample-3.md +116 -116
- package/skills/hmos-spec-generate/references/step4-report-template.md +33 -33
- package/tools/test-tools/autotest/README.md +33 -17
- package/tools/test-tools/autotest/self_test_runner.py +109 -15
- package/resource/hometrans_config.png +0 -0
- package/skills/hmos-incremental-ui-align/config-example.json +0 -11
- package/tools/test-tools/autotest/config.yaml.example +0 -58
|
@@ -1,332 +1,332 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: hmos-spec-generate
|
|
3
|
-
description: "Generate atomic-scenario requirement specs (markdown) from raw .txt requirement batches for Android-to-HarmonyOS migration. Reads a single .txt holding multiple REQ blocks (blank-line separated), explores the Android code graph via GitNexus, writes per-REQ trace files first then synthesizes specs from the trace. Triggers: spec generation, generate spec, requirement to spec, atomic scenarios, scenario decomposition, decompose scenarios, req to spec, code-trace-first, batch req txt."
|
|
4
|
-
license: MIT
|
|
5
|
-
allowed-tools:
|
|
6
|
-
- Read
|
|
7
|
-
- Write
|
|
8
|
-
- Edit
|
|
9
|
-
- Bash
|
|
10
|
-
- Glob
|
|
11
|
-
- Grep
|
|
12
|
-
- Skill
|
|
13
|
-
- AskUserQuestion
|
|
14
|
-
- TaskCreate
|
|
15
|
-
- TaskList
|
|
16
|
-
- TaskUpdate
|
|
17
|
-
- mcp__gitnexus__query
|
|
18
|
-
- mcp__gitnexus__context
|
|
19
|
-
- mcp__gitnexus__impact
|
|
20
|
-
- mcp__gitnexus__cypher
|
|
21
|
-
- mcp__gitnexus__list_repos
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
# Spec Generator Skill
|
|
25
|
-
|
|
26
|
-
Produce atomic-scenario requirement specs from Android source code for Android-to-HarmonyOS migration. The input is a single `.txt` carrying multiple REQ blocks (blank-line separated); each block is processed end-to-end (3.1 → 3.5) before the next block starts.
|
|
27
|
-
|
|
28
|
-
This skill uses GitNexus as the code-graph backend: the `gitnexus-cli` skill for index management, and `mcp__gitnexus__*` tools for code queries. Spec synthesis MUST go through a trace file written in 3.3 — never synthesize from conversation context.
|
|
29
|
-
|
|
30
|
-
## Expected Input
|
|
31
|
-
|
|
32
|
-
- `
|
|
33
|
-
- `
|
|
34
|
-
- `
|
|
35
|
-
|
|
36
|
-
**Caller example**:
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Expected Output
|
|
45
|
-
|
|
46
|
-
- One markdown spec per REQ block, written to `<
|
|
47
|
-
- One intermediate code-trace file per REQ block, written to `<
|
|
48
|
-
- Both files overwrite if they already exist.
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## Principles
|
|
53
|
-
|
|
54
|
-
Rules the final spec MUST obey:
|
|
55
|
-
|
|
56
|
-
1. Decompose the requirement into atomic scenarios — their union reconstitutes the full requirement.
|
|
57
|
-
2. Each atomic scenario corresponds to one happy path OR one boundary / exception path.
|
|
58
|
-
3. Atomic scenarios MUST be exhaustive and mutually non-redundant.
|
|
59
|
-
4. The spec MUST contain a requirement-level semantic description, scenario-level semantic descriptions, and scenario flow descriptions.
|
|
60
|
-
5. Scenario flow descriptions MUST contain both a trigger action sequence and the corresponding logical execution steps.
|
|
61
|
-
6. The spec MUST NOT contain any Android-related knowledge, design, or code-level description. See `references/android-platform-tokens.md` for the full strip list and Chinese replacement vocabulary.
|
|
62
|
-
7. When `REQ_DESC` disagrees with the Android code implementation, the spec follows `REQ_DESC`; discrepancies are summarized at the end of the spec in user-facing language.
|
|
63
|
-
8. **Coverage rule** — scenarios MUST cover ALL UI entries discovered in code, not just those explicitly mentioned in `REQ_DESC`. If the trace's Scope / Boundary section enumerates N entries and `REQ_DESC` only mentions M < N, the spec still produces scenarios for all N. Missing entries here = missing scenarios in the spec.
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## Method Discipline
|
|
68
|
-
|
|
69
|
-
Cross-cutting disciplines for trace exploration (3.1 → 3.3), verified in 3.4 Review.
|
|
70
|
-
|
|
71
|
-
### Multi-layer claim
|
|
72
|
-
|
|
73
|
-
**Rule**: A user-observable behavior on Android is typically carried by multiple source layers. Every claim in the trace MUST enumerate each relevant layer's state — either a `file:line` hit, or an explicit `N/A: <reason>` saying why that layer does not carry it. This applies to both positive claims ("this behavior is wired at X") and negative ones ("Y does not exist"). Omitting a layer = layer not checked, never = layer not present.
|
|
74
|
-
|
|
75
|
-
Android source layers:
|
|
76
|
-
|
|
77
|
-
| Layer | Examples |
|
|
78
|
-
|---|---|
|
|
79
|
-
| **code** | Java / Kotlin / Compose source (`.java`, `.kt`) — click handlers, ViewModels, Services, Repositories, DAOs, Workers |
|
|
80
|
-
| **resource** | `res/layout/*.xml`, `res/menu/*.xml`, `res/drawable/*.xml`, `res/values/*.xml`, `res/xml/*.xml` (preference screens), `res/navigation/*.xml` |
|
|
81
|
-
| **manifest** | `AndroidManifest.xml` (activity / service / receiver / provider / permission / intent-filter / foreground-service-type declarations); `build.gradle` flavor or `buildConfig` flags when behavior is build-gated |
|
|
82
|
-
|
|
83
|
-
### Replayable fact
|
|
84
|
-
|
|
85
|
-
**Rule**: Every fact in the trace MUST be **replayable verbatim** from a tool response. `file:line` anchors come from `mcp__gitnexus__context` / `cypher` results or the line-number prefix of a `Read` output. Phrases with counts or ordering ("called N times", "first X then Y", "synchronously then asynchronously", "again") MUST be derivable from precise tool-driven counting and sequencing (e.g. `mcp__gitnexus__cypher` aggregating callers, or repeated `mcp__gitnexus__impact` calls). Delete any fact that cannot be replayed.
|
|
86
|
-
|
|
87
|
-
**Common failure mode**: Hallucinate detail by analogy with common patterns ("synchronous write then asynchronous overwrite", "set X again"); estimate a line number from a `mcp__gitnexus__context` snippet and drift to a neighbouring symbol; make negative assertions from intuition instead of reverse-lookup with `mcp__gitnexus__impact` / `cypher` / `Grep`.
|
|
88
|
-
|
|
89
|
-
---
|
|
90
|
-
|
|
91
|
-
## References
|
|
92
|
-
|
|
93
|
-
External resources Read on demand (not pre-loaded). Loading these too early wastes context budget; load each only at the step that needs it.
|
|
94
|
-
|
|
95
|
-
| File | When to read |
|
|
96
|
-
|---|---|
|
|
97
|
-
| `references/spec-sample-1.md` | 3.5 Synthesize — boundary-and-happy-path decomposition style |
|
|
98
|
-
| `references/spec-sample-2.md` | 3.5 Synthesize — nested sub-bullet decomposition style |
|
|
99
|
-
| `references/spec-sample-3.md` | 3.5 Synthesize — shared-mechanic + per-value decomposition for enumerated multi-entry settings |
|
|
100
|
-
| `references/android-platform-tokens.md` | 3.5 Synthesize — platform-token strip list + Chinese replacement vocabulary |
|
|
101
|
-
| `references/step4-report-template.md` | Step 4 — summary report output format |
|
|
102
|
-
|
|
103
|
-
Mimic the samples' voice, scenario granularity, and structure — NOT their vocabulary or domain. The samples happen to use consumer-app domains (music / video); this skill applies to any Android application domain.
|
|
104
|
-
|
|
105
|
-
---
|
|
106
|
-
|
|
107
|
-
## Workflow
|
|
108
|
-
|
|
109
|
-
### Step 0 — Validate inputs and parse REQ blocks
|
|
110
|
-
|
|
111
|
-
1. Verify `
|
|
112
|
-
2. Verify `
|
|
113
|
-
3. Ensure `
|
|
114
|
-
4. **Parse the input `.txt`** (UTF-8):
|
|
115
|
-
- Split into REQ blocks by blank lines. Each block: first non-blank line = `title`, remaining non-blank lines = `body`.
|
|
116
|
-
- If a block has empty `body`, mark it for skip with reason `empty body`; do not abort the whole batch.
|
|
117
|
-
- If the file yields zero blocks, stop and report.
|
|
118
|
-
5. **Distill a feature slug** for each block:
|
|
119
|
-
- Summarize the REQ into a `<feature>` phrase. **≤ 20 characters, in the REQ's own language.**
|
|
120
|
-
- Sanitize illegal filesystem characters (`< > : " / \ | ? *` and ASCII control chars) by replacing each with `-`.
|
|
121
|
-
- Different REQ blocks should produce different features. Titles already encode the top-level category (e.g. `Settings-UI-...` vs `Settings-Lyrics-...`); retain enough category context in the slug to keep distinct.
|
|
122
|
-
- The slug is the filename stem for both the trace (`.trace/<feature>.md`) and the spec (`<feature>-SPEC.md`).
|
|
123
|
-
|
|
124
|
-
Step 0 output: an ordered list of `(title, body, feature)` tuples plus a skip list. Proceed directly to Step 1.
|
|
125
|
-
|
|
126
|
-
### Step 1 — Confirm the Android project is a Git repo
|
|
127
|
-
|
|
128
|
-
Run `git rev-parse --is-inside-work-tree` inside `
|
|
129
|
-
|
|
130
|
-
- Output is `true` → proceed to Step 2.
|
|
131
|
-
- Otherwise → STOP. Tell the user:
|
|
132
|
-
|
|
133
|
-
> `
|
|
134
|
-
>
|
|
135
|
-
> ```
|
|
136
|
-
> cd <
|
|
137
|
-
> git init && git add . && git commit -m "init"
|
|
138
|
-
> ```
|
|
139
|
-
>
|
|
140
|
-
> then re-invoke this skill.
|
|
141
|
-
|
|
142
|
-
Do NOT auto-`init` / `add` / `commit` the user's project. Do NOT modify `git config`.
|
|
143
|
-
|
|
144
|
-
### Step 2 — Ensure GitNexus has a fresh index for the project
|
|
145
|
-
|
|
146
|
-
GitNexus exposes two surfaces:
|
|
147
|
-
|
|
148
|
-
- **Index management** (`status`, `analyze`) → invoke the `gitnexus-cli` skill (CLI wrapper, returns text).
|
|
149
|
-
- **Code queries** (`query`, `context`, `impact`, `cypher`, `list_repos`) → call `mcp__gitnexus__*` tools directly.
|
|
150
|
-
|
|
151
|
-
Procedure:
|
|
152
|
-
|
|
153
|
-
1. Invoke `gitnexus-cli` skill with `status` against `
|
|
154
|
-
2. Decide based on the output:
|
|
155
|
-
- **Not registered** or **stale** → invoke `gitnexus-cli` with `analyze`, wait for completion.
|
|
156
|
-
- **Fresh** → proceed.
|
|
157
|
-
3. Obtain `<repo-id>` via `mcp__gitnexus__list_repos()`; find the entry whose `path` matches `
|
|
158
|
-
|
|
159
|
-
**Hard fail policy** — any of the following stops the skill and surfaces the error to the user; do NOT degrade to `Read` + `Grep`:
|
|
160
|
-
|
|
161
|
-
- `gitnexus-cli` skill is unavailable → ask the user to run `/setup` first.
|
|
162
|
-
- `gitnexus-cli status` or `analyze` returns an error → surface the error verbatim.
|
|
163
|
-
- `mcp__gitnexus__list_repos` returns no matching entry → ask the user to verify that `analyze` registered the project.
|
|
164
|
-
- Any `mcp__gitnexus__*` call in Step 3 fails unexpectedly → surface the error; stop the skill.
|
|
165
|
-
|
|
166
|
-
> All `mcp__gitnexus__*` calls in Step 3 MUST carry `repo=<repo-id>` (or equivalent scope parameter). Cross-repo results poison the trace.
|
|
167
|
-
|
|
168
|
-
### Step 3 — Process each REQ block end-to-end
|
|
169
|
-
|
|
170
|
-
Iterate the `(title, body, feature)` tuples from Step 0 in order. For each tuple, run **3.1 → 3.5** in full before starting the next. Do NOT batch code exploration across REQ blocks.
|
|
171
|
-
|
|
172
|
-
Order matters: build the trace from Android source first, then synthesize the spec from the trace. Spec synthesis (3.5) MUST `Read` the trace written in 3.3 / 3.4 — recalling from conversation context causes scenario drift and `file:line` fabrication.
|
|
173
|
-
|
|
174
|
-
#### 3.1 Read
|
|
175
|
-
|
|
176
|
-
- Use the parsed `body` directly (already loaded in Step 0). If the tuple is marked `skip: empty body`, skip to the next tuple and record in Step 4 report.
|
|
177
|
-
- Extract from `body`: UI path / page anchors (if any), primary user intent, key entities (data models, persistence key names, setting names), explicit boundary conditions (default values, toggle states, error messages, length limits).
|
|
178
|
-
- For dependent REQs (body mentions "depends on X" or similar), note the dependency for the 3.3 trace's `Core business entities` section.
|
|
179
|
-
|
|
180
|
-
#### 3.2 Recall — Locate entry points (dual-path union)
|
|
181
|
-
|
|
182
|
-
Run both paths in parallel within the same turn (emit all mcp calls together); the deduplicated union is the recall result. All mcp calls MUST carry `repo=<repo-id>`.
|
|
183
|
-
|
|
184
|
-
| Path | Approach | Value |
|
|
185
|
-
|---|---|---|
|
|
186
|
-
| **Path 1 · By-concept lookup** | For each entity / UI anchor / intent verb from 3.1, call `mcp__gitnexus__query({ query: "<concept>", repo: "<repo-id>" })` and `mcp__gitnexus__context({ name: "<symbol>", repo: "<repo-id>" })` to find candidate symbols (Activities / Fragments / Composables / ViewModels / Services / Repositories / DAOs). Cross-validate symbol name, file path, and context against `REQ_DESC`. | Direct hits: pages obviously implementing the REQ; data models named after REQ entities. |
|
|
187
|
-
| **Path 2 · Reverse-by-usage** | Take the most discriminative keyword (a settings key literal, a persistence column / preference key, a unique business term). `query` → candidate symbol → `mcp__gitnexus__impact({ name: "<symbol>", repo: "<repo-id>" })` returns callers (nested). Walk callers upward until hitting an `Activity` / `Fragment` / `@Composable` host. That host is an entry point. If the walk passes through intermediate dialog / popup / bottom-sheet / inner-composable components that directly reference the target key, record each as a **separate entry point** — these represent distinct user-facing surfaces within the host. | Covers structural blind spots Path 1 misses: deeply nested consumers, pass-through navigation pages, manifest-declared receivers. |
|
|
188
|
-
|
|
189
|
-
**Behavioral REQ anchor extraction**: when `REQ_DESC` has no explicit literal keyword (e.g. "after track-change X refreshes synchronously"), extract anchors as `(action verb, affected entity)` tuples — e.g. `(track-change, X)` — and feed both into Path 1's `query` and Path 2's seed symbol search.
|
|
190
|
-
|
|
191
|
-
**Both paths hit zero** → ask the user via `AskUserQuestion` whether to manually specify an entry point. If declined → write `status: no_recall` in the trace, skip 3.3 / 3.4 / 3.5, flag in Step 4 report. Do NOT fabricate entry points.
|
|
192
|
-
|
|
193
|
-
**Terse REQ handling** — if the REQ body has fewer than ~20 substantive characters, OR contains only topical keywords (e.g. "multi-device", "landscape/portrait") with no concrete action verb / entity:
|
|
194
|
-
|
|
195
|
-
1. **MUST** run two broad enumeration passes (both mandatory, not optional):
|
|
196
|
-
- **Pass A · Feature code**: `mcp__gitnexus__cypher` enumeration — find all Activity / Fragment / Composable hosts whose `configChanges` manifest attribute is non-default (for orientation / resize cases) or whose layout has a resource qualifier matching the REQ topic (e.g. `-land`, `-sw600dp`, `-night`).
|
|
197
|
-
- **Pass B · Settings breadth**: For EACH distinct keyword in the REQ body, run `mcp__gitnexus__query` + `Grep` to enumerate ALL settings / configuration screens that reference that keyword or a semantically related term. Terse REQs frequently span multiple unrelated settings pages; anchoring on the single most obvious page is the primary failure mode. The union of Pass A and Pass B is the recall result.
|
|
198
|
-
2. If ≥3 plausible candidates → list them in the trace's `Status` section as `candidate_hosts: [...]` and proceed normally.
|
|
199
|
-
3. If <3 candidates → invoke `AskUserQuestion`: show the candidate list, ask which are in-scope for this REQ. Do NOT silently guess.
|
|
200
|
-
4. Mark in trace `Status` block: `terse_req: true` (this signal feeds 3.4 review).
|
|
201
|
-
5. **3.4 Review MUST verify**: every settings screen discovered in Pass B has at least one Entry or Touched-entry in the trace. A discovered-but-untraced screen → fail review, return to 3.3.
|
|
202
|
-
|
|
203
|
-
**Clarification triggers** (interrupt 3.2 / 3.3 with `AskUserQuestion`):
|
|
204
|
-
|
|
205
|
-
- `REQ_DESC` contains ambiguous phrases ("any entry point", "related pages", "all related locations") AND the trace cannot map them to a unique set of components.
|
|
206
|
-
- Path 1 + Path 2 both return zero, before writing `no_recall`.
|
|
207
|
-
- Deviations from `REQ_DESC` exceed five AND touch core behavior (REQ may be stale; confirm before proceeding).
|
|
208
|
-
|
|
209
|
-
#### 3.3 Trace — Explore code and write `<
|
|
210
|
-
|
|
211
|
-
The trace file is the sole machine-readable contract delivered to 3.5. Exploration and writing form a single unit.
|
|
212
|
-
|
|
213
|
-
**Exploration checklist — execution order** (all mcp calls carry `repo: "<repo-id>"`):
|
|
214
|
-
|
|
215
|
-
| Step | Action | Tool |
|
|
216
|
-
|---|---|---|
|
|
217
|
-
| 1 | Survey candidate symbols for each anchor from 3.1 | `mcp__gitnexus__query` / `context` |
|
|
218
|
-
| 2 | Full call chain (callers / callees, up and down) | `mcp__gitnexus__impact` |
|
|
219
|
-
| 3 | Cross-class graph traversal / reverse-lookup state writers / aggregation | `mcp__gitnexus__cypher` |
|
|
220
|
-
| 4 | Exact literal positioning (settings keys, DAO columns, intent actions, preference `android:key`) | `Grep` |
|
|
221
|
-
| 5 | Final `file:line` verification / zero-hit counter-evidence | `Read` (small window) / `Grep` |
|
|
222
|
-
|
|
223
|
-
**Exploration dimensions — information coverage** (orthogonal to the checklist; checklist = order, dimensions = what to capture). Apply each to every recall entry:
|
|
224
|
-
|
|
225
|
-
- **Trigger code** — UI control + event callback (click / long-press / swipe / lifecycle / broadcast receiver) invoking the REQ behavior. Fill Entry's `code` and `resource` layer fields.
|
|
226
|
-
- **End-to-end call chain** — trigger → ViewModel / UseCase → Service / Repository → data source. Fill Entry's `data_flow`; each hop carries `file:line`.
|
|
227
|
-
- **State writes & persistence** — every state mutation (state holders, DAO inserts, preference / DataStore / MMKV puts, file writes). Record key / column names verbatim.
|
|
228
|
-
- **Side effects / cross-boundary** — broadcasts, bound services, notifications, App Widget IPC, content providers, accessibility events.
|
|
229
|
-
- **Manifest declarations / build flags** — activity / service / receiver registration, intent filters, permissions, foreground service types, build flavor / `buildConfig` gates. Fill Entry's `manifest` field — `N/A: <reason>` if none.
|
|
230
|
-
- **Deviations from `REQ_DESC`** — every gap (default values, copy strings, behavior, hidden entries, validation rules). Feeds Principle 7.
|
|
231
|
-
- **Application scope / boundary · Exhaustive entry enumeration** — ALL UI paths touching this feature / state, beyond REQ text. For state keys: reverse-lookup writers + lift to UI hosts. For readers: enumerate consumers + non-consumers. One field block per entry; omitted here = scenario omitted in spec.
|
|
232
|
-
- **Consumer list & non-consumers** — who reads this state, plus which UI surfaces explicitly do NOT. Non-consumer claims use the structured field block (`claim` / `closure_layers` / `tools` / `zero_hits`).
|
|
233
|
-
|
|
234
|
-
**Trace file template** (write to `<
|
|
235
|
-
|
|
236
|
-
```markdown
|
|
237
|
-
# Code trace · <feature>
|
|
238
|
-
|
|
239
|
-
## Status
|
|
240
|
-
status: ok | no_recall | error
|
|
241
|
-
repo-id: <repo-id>
|
|
242
|
-
backend: gitnexus
|
|
243
|
-
|
|
244
|
-
## Recalled entry points (Path 1 + Path 2 union, deduplicated)
|
|
245
|
-
- Entry 1: <UI path / page name> — file:line — recalled by: path 1 | path 2 | both
|
|
246
|
-
- ...
|
|
247
|
-
|
|
248
|
-
## Entry · <name>
|
|
249
|
-
- claim: <user-observable behavior in one sentence>
|
|
250
|
-
- layers:
|
|
251
|
-
- code: <file:line> # required; hit or `N/A: <reason>`
|
|
252
|
-
- resource: <file:line> | N/A: <reason> # layout / menu / drawable / values / xml-preferences / navigation
|
|
253
|
-
- manifest: <file:line> | N/A: <reason> # AndroidManifest entry / build.gradle flag
|
|
254
|
-
- interaction: <state writes, persistence keys (verbatim), in-memory mutations>
|
|
255
|
-
- data_flow: <trigger → ViewModel / Service / Repo → data source, each hop with file:line>
|
|
256
|
-
|
|
257
|
-
## Entry · <name 2> ... Entry · <name N>
|
|
258
|
-
(each entry repeats the claim / layers / interaction / data_flow field block)
|
|
259
|
-
|
|
260
|
-
## Implicit triggers (non-UI state changes that activate this feature)
|
|
261
|
-
- Trigger: <track-change / Pro status change / permission change / foreground-background switch / network change / lyrics document change / current track is null> — <file:line> — behavior: <one sentence>
|
|
262
|
-
- (write "None" if no implicit trigger applies)
|
|
263
|
-
|
|
264
|
-
## Core business entities (data model / persistence key / state machine)
|
|
265
|
-
- Entity X: <file:line + field list + semantics>
|
|
266
|
-
- For dependent REQs: <dependency-key-name> sourced from feature `<depended-feature>` at file:line
|
|
267
|
-
- ...
|
|
268
|
-
|
|
269
|
-
## Cross-entry shared declarations
|
|
270
|
-
- <AndroidManifest.xml / build.gradle entries with file:line, shared across multiple entries>
|
|
271
|
-
- ... (write "None" explicitly if no cross-entry declaration applies; per-entry manifest facts live in each Entry's `manifest` layer field)
|
|
272
|
-
|
|
273
|
-
## Deviations from REQ_DESC
|
|
274
|
-
1. <REQ says A; but code at file:line behaves as B>
|
|
275
|
-
2. ...
|
|
276
|
-
(empty → write "None" explicitly to confirm the check was performed)
|
|
277
|
-
|
|
278
|
-
## Scope / Boundary — Exhaustive entry enumeration
|
|
279
|
-
### Touched entries (all UI paths, not limited to REQ_DESC mentions)
|
|
280
|
-
(each touched entry uses the same `claim` / `layers` / `interaction` / `data_flow` field block as the Entry template above)
|
|
281
|
-
|
|
282
|
-
### Consumers (who reads this state / data)
|
|
283
|
-
- Consumer: <component name> — file:line
|
|
284
|
-
|
|
285
|
-
### Non-consumers (boundary counter-examples with evidence)
|
|
286
|
-
- claim: <e.g. "App widget does not read this key">
|
|
287
|
-
closure_layers: [code, resource, manifest]
|
|
288
|
-
tools: [Grep "<pattern>", mcp__gitnexus__cypher "<...>", Read "<path>"]
|
|
289
|
-
zero_hits: <verbatim zero-hit evidence — file globs searched, regex used, hit count>
|
|
290
|
-
|
|
291
|
-
## Same-source cross-reference (if applicable)
|
|
292
|
-
- This REQ shares behavior with feature `<other-feature>` (e.g. the same setting exposed under multiple settings paths).
|
|
293
|
-
Both specs are generated independently and reference each other in their deviation sections.
|
|
294
|
-
- (write "None" if not applicable)
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
#### 3.4 Review — No fabrication, no omission, method-discipline compliant
|
|
298
|
-
|
|
299
|
-
Run the checks below against the trace from 3.3; every check must pass before proceeding to 3.5.
|
|
300
|
-
|
|
301
|
-
- **No fabrication** — every declared `file:line` actually exists (sample-verify via `mcp__gitnexus__context` or `Read`); every behavioral claim is source-supported; every boundary claim has tool evidence.
|
|
302
|
-
- **No omission** — every detail in `REQ_DESC` has a counterpart in the trace (Entry / behavior / deviation). If REQ mentions a feature code does not implement, record as deviation, not omission.
|
|
303
|
-
- **Method-discipline compliance** (Multi-layer claim + Replayable fact) — sample-verify random `file:line` anchors via `mcp__gitnexus__context` / `Read` (≥1 line drift → fail); sample-verify every count / ordering phrase against source (unreplayable → fail); every Entry / Touched-entry has all three layer fields filled (hit or `N/A: <reason>`); every Non-consumer claim has all four structured fields (`claim` / `closure_layers` / `tools` / `zero_hits`).
|
|
304
|
-
- **Implicit triggers coverage** — the trace's `Implicit triggers` section is present and explicitly filled (≥1 trigger OR `None`). Absence of the section = fail review.
|
|
305
|
-
- **Trace section presence audit** — every trace MUST contain these H2 sections (with `None` if truly empty; absence = fail): `Status` / `Recalled entry points` / per `Entry` (all 4 fields: `claim` / `layers` / `interaction` / `data_flow`) / `Implicit triggers` / `Core business entities` / `Cross-entry shared declarations` / `Deviations from REQ_DESC` / `Scope / Boundary` / `Same-source cross-reference`.
|
|
306
|
-
|
|
307
|
-
Any check failing → return to 3.3 (rewrite / supplement / fix). Judge convergence yourself; no external iteration cap. All checks pass → proceed to 3.5.
|
|
308
|
-
|
|
309
|
-
#### 3.5 Synthesize — Write the final spec
|
|
310
|
-
|
|
311
|
-
`Read` the trace from 3.3 / 3.4, then synthesize the spec following `## Principles` and the style references under `references/`. Write to `<
|
|
312
|
-
|
|
313
|
-
**Synthesis discipline**:
|
|
314
|
-
|
|
315
|
-
- **Implicit triggers coverage** — every entry in the trace's `Implicit triggers` section MUST appear in the spec as an independent scenario OR as a main step within an existing scenario. Listed in trace but absent from spec = scenario omission. (Extends Principle 8 to non-UI triggers.)
|
|
316
|
-
- **Shared-mechanic factoring** — for enumerated-value settings (three-way / four-way / radio-group) accessible from multiple entry points, factor the shared menu interaction across all entries into ONE scenario; give each enum value its OWN runtime-semantics scenario. Do NOT split the mechanical scenario per entry point, and do NOT bundle "user picks X" with "what X does" in the same scenario per value.
|
|
317
|
-
- **Binary-toggle anti-pattern** — a binary on/off switch is ONE trigger; write ONE scenario for the toggle (both directions), with linked-control side-effects as sub-bullets. Write SEPARATE scenarios for each state's runtime rendering (e.g. "when ON, cover rotates" / "when OFF, cover is static"). Do NOT split "turn on" / "turn off" into independent scenes.
|
|
318
|
-
- **Same-source cross-reference** — if the trace's `Same-source cross-reference` section is non-empty, append a short note at the end of the spec referencing the other `<feature>-SPEC.md` (e.g. "This setting also exists under `<other-feature>-SPEC.md` with identical behavior").
|
|
319
|
-
- **REQ-vs-code-string arbitration** — code's user-facing strings (toast / notification / dialog / snackbar / error) that conflict with `REQ_DESC` are **deviation evidence**, NOT authoritative facts. Author spec body per `REQ_DESC` phrasing; record the conflicting string + `file:line` in trace's `Deviations`. Do NOT copy code strings verbatim into the spec.
|
|
320
|
-
|
|
321
|
-
After writing, proceed to the next REQ block.
|
|
322
|
-
|
|
323
|
-
### Step 4 — Summary report
|
|
324
|
-
|
|
325
|
-
Once all REQ blocks are processed (or skipped with warnings), produce a brief report following `references/step4-report-template.md`. The template defines the per-block table format, skipped-block list, and aggregates. Keep the in-session reply within ~40 lines; per-block detail belongs in spec / trace files.
|
|
326
|
-
|
|
327
|
-
---
|
|
328
|
-
|
|
329
|
-
## Forbidden
|
|
330
|
-
|
|
331
|
-
- **No nested LLM-agent skill calls** — no `gitnexus-exploring`, no `gitnexus-debugging`, no `gitnexus-refactoring`, no `gitnexus-impact-analysis`. They override this SKILL's instructions and cause role drift. **Exception**: `gitnexus-cli` is a CLI wrapper (not an LLM agent); using it for index management is allowed.
|
|
1
|
+
---
|
|
2
|
+
name: hmos-spec-generate
|
|
3
|
+
description: "Generate atomic-scenario requirement specs (markdown) from raw .txt requirement batches for Android-to-HarmonyOS migration. Reads a single .txt holding multiple REQ blocks (blank-line separated), explores the Android code graph via GitNexus, writes per-REQ trace files first then synthesizes specs from the trace. Triggers: spec generation, generate spec, requirement to spec, atomic scenarios, scenario decomposition, decompose scenarios, req to spec, code-trace-first, batch req txt."
|
|
4
|
+
license: MIT
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Edit
|
|
9
|
+
- Bash
|
|
10
|
+
- Glob
|
|
11
|
+
- Grep
|
|
12
|
+
- Skill
|
|
13
|
+
- AskUserQuestion
|
|
14
|
+
- TaskCreate
|
|
15
|
+
- TaskList
|
|
16
|
+
- TaskUpdate
|
|
17
|
+
- mcp__gitnexus__query
|
|
18
|
+
- mcp__gitnexus__context
|
|
19
|
+
- mcp__gitnexus__impact
|
|
20
|
+
- mcp__gitnexus__cypher
|
|
21
|
+
- mcp__gitnexus__list_repos
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
# Spec Generator Skill
|
|
25
|
+
|
|
26
|
+
Produce atomic-scenario requirement specs from Android source code for Android-to-HarmonyOS migration. The input is a single `.txt` carrying multiple REQ blocks (blank-line separated); each block is processed end-to-end (3.1 → 3.5) before the next block starts.
|
|
27
|
+
|
|
28
|
+
This skill uses GitNexus as the code-graph backend: the `gitnexus-cli` skill for index management, and `mcp__gitnexus__*` tools for code queries. Spec synthesis MUST go through a trace file written in 3.3 — never synthesize from conversation context.
|
|
29
|
+
|
|
30
|
+
## Expected Input
|
|
31
|
+
|
|
32
|
+
- `requirement_description_file`: absolute path to a single `.txt` file containing one or more REQ blocks separated by blank lines. Within each block, the first line is the REQ title (often a dash-separated settings path like `Settings-UserInterface-ImmersionMode`), and the remaining lines are the body (behavior, default values, toggles). Required.
|
|
33
|
+
- `android_project_dir`: absolute path to the Android project root (must be inside a Git repo). Required.
|
|
34
|
+
- `spec_output_dir`: absolute path to the directory where spec files will be written (will be created if missing). Required.
|
|
35
|
+
|
|
36
|
+
**Caller example**:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
requirement_description_file: C:\proj\reqs\req-batch2-zh.txt
|
|
40
|
+
android_project_dir: C:\proj\SaltPlayer\
|
|
41
|
+
spec_output_dir: C:\proj\specs-out\
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Expected Output
|
|
45
|
+
|
|
46
|
+
- One markdown spec per REQ block, written to `<spec_output_dir>/<feature>-SPEC.md`. `<feature>` is the ≤ 20-character slug distilled in 3.1 (use the REQ's own language for the slug; ASCII / kebab-case acceptable when shorter).
|
|
47
|
+
- One intermediate code-trace file per REQ block, written to `<spec_output_dir>/.trace/<feature>.md` (same slug). 3.5 synthesis MUST `Read` this file rather than recalling from conversation context.
|
|
48
|
+
- Both files overwrite if they already exist.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Principles
|
|
53
|
+
|
|
54
|
+
Rules the final spec MUST obey:
|
|
55
|
+
|
|
56
|
+
1. Decompose the requirement into atomic scenarios — their union reconstitutes the full requirement.
|
|
57
|
+
2. Each atomic scenario corresponds to one happy path OR one boundary / exception path.
|
|
58
|
+
3. Atomic scenarios MUST be exhaustive and mutually non-redundant.
|
|
59
|
+
4. The spec MUST contain a requirement-level semantic description, scenario-level semantic descriptions, and scenario flow descriptions.
|
|
60
|
+
5. Scenario flow descriptions MUST contain both a trigger action sequence and the corresponding logical execution steps.
|
|
61
|
+
6. The spec MUST NOT contain any Android-related knowledge, design, or code-level description. See `references/android-platform-tokens.md` for the full strip list and Chinese replacement vocabulary.
|
|
62
|
+
7. When `REQ_DESC` disagrees with the Android code implementation, the spec follows `REQ_DESC`; discrepancies are summarized at the end of the spec in user-facing language.
|
|
63
|
+
8. **Coverage rule** — scenarios MUST cover ALL UI entries discovered in code, not just those explicitly mentioned in `REQ_DESC`. If the trace's Scope / Boundary section enumerates N entries and `REQ_DESC` only mentions M < N, the spec still produces scenarios for all N. Missing entries here = missing scenarios in the spec.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Method Discipline
|
|
68
|
+
|
|
69
|
+
Cross-cutting disciplines for trace exploration (3.1 → 3.3), verified in 3.4 Review.
|
|
70
|
+
|
|
71
|
+
### Multi-layer claim
|
|
72
|
+
|
|
73
|
+
**Rule**: A user-observable behavior on Android is typically carried by multiple source layers. Every claim in the trace MUST enumerate each relevant layer's state — either a `file:line` hit, or an explicit `N/A: <reason>` saying why that layer does not carry it. This applies to both positive claims ("this behavior is wired at X") and negative ones ("Y does not exist"). Omitting a layer = layer not checked, never = layer not present.
|
|
74
|
+
|
|
75
|
+
Android source layers:
|
|
76
|
+
|
|
77
|
+
| Layer | Examples |
|
|
78
|
+
|---|---|
|
|
79
|
+
| **code** | Java / Kotlin / Compose source (`.java`, `.kt`) — click handlers, ViewModels, Services, Repositories, DAOs, Workers |
|
|
80
|
+
| **resource** | `res/layout/*.xml`, `res/menu/*.xml`, `res/drawable/*.xml`, `res/values/*.xml`, `res/xml/*.xml` (preference screens), `res/navigation/*.xml` |
|
|
81
|
+
| **manifest** | `AndroidManifest.xml` (activity / service / receiver / provider / permission / intent-filter / foreground-service-type declarations); `build.gradle` flavor or `buildConfig` flags when behavior is build-gated |
|
|
82
|
+
|
|
83
|
+
### Replayable fact
|
|
84
|
+
|
|
85
|
+
**Rule**: Every fact in the trace MUST be **replayable verbatim** from a tool response. `file:line` anchors come from `mcp__gitnexus__context` / `cypher` results or the line-number prefix of a `Read` output. Phrases with counts or ordering ("called N times", "first X then Y", "synchronously then asynchronously", "again") MUST be derivable from precise tool-driven counting and sequencing (e.g. `mcp__gitnexus__cypher` aggregating callers, or repeated `mcp__gitnexus__impact` calls). Delete any fact that cannot be replayed.
|
|
86
|
+
|
|
87
|
+
**Common failure mode**: Hallucinate detail by analogy with common patterns ("synchronous write then asynchronous overwrite", "set X again"); estimate a line number from a `mcp__gitnexus__context` snippet and drift to a neighbouring symbol; make negative assertions from intuition instead of reverse-lookup with `mcp__gitnexus__impact` / `cypher` / `Grep`.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## References
|
|
92
|
+
|
|
93
|
+
External resources Read on demand (not pre-loaded). Loading these too early wastes context budget; load each only at the step that needs it.
|
|
94
|
+
|
|
95
|
+
| File | When to read |
|
|
96
|
+
|---|---|
|
|
97
|
+
| `references/spec-sample-1.md` | 3.5 Synthesize — boundary-and-happy-path decomposition style |
|
|
98
|
+
| `references/spec-sample-2.md` | 3.5 Synthesize — nested sub-bullet decomposition style |
|
|
99
|
+
| `references/spec-sample-3.md` | 3.5 Synthesize — shared-mechanic + per-value decomposition for enumerated multi-entry settings |
|
|
100
|
+
| `references/android-platform-tokens.md` | 3.5 Synthesize — platform-token strip list + Chinese replacement vocabulary |
|
|
101
|
+
| `references/step4-report-template.md` | Step 4 — summary report output format |
|
|
102
|
+
|
|
103
|
+
Mimic the samples' voice, scenario granularity, and structure — NOT their vocabulary or domain. The samples happen to use consumer-app domains (music / video); this skill applies to any Android application domain.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Workflow
|
|
108
|
+
|
|
109
|
+
### Step 0 — Validate inputs and parse REQ blocks
|
|
110
|
+
|
|
111
|
+
1. Verify `requirement_description_file` exists and is a file. If not, stop and report.
|
|
112
|
+
2. Verify `android_project_dir` exists and is a directory. If not, stop and report.
|
|
113
|
+
3. Ensure `spec_output_dir` exists (create if missing). Ensure `<spec_output_dir>/.trace/` exists (create if missing).
|
|
114
|
+
4. **Parse the input `.txt`** (UTF-8):
|
|
115
|
+
- Split into REQ blocks by blank lines. Each block: first non-blank line = `title`, remaining non-blank lines = `body`.
|
|
116
|
+
- If a block has empty `body`, mark it for skip with reason `empty body`; do not abort the whole batch.
|
|
117
|
+
- If the file yields zero blocks, stop and report.
|
|
118
|
+
5. **Distill a feature slug** for each block:
|
|
119
|
+
- Summarize the REQ into a `<feature>` phrase. **≤ 20 characters, in the REQ's own language.**
|
|
120
|
+
- Sanitize illegal filesystem characters (`< > : " / \ | ? *` and ASCII control chars) by replacing each with `-`.
|
|
121
|
+
- Different REQ blocks should produce different features. Titles already encode the top-level category (e.g. `Settings-UI-...` vs `Settings-Lyrics-...`); retain enough category context in the slug to keep distinct.
|
|
122
|
+
- The slug is the filename stem for both the trace (`.trace/<feature>.md`) and the spec (`<feature>-SPEC.md`).
|
|
123
|
+
|
|
124
|
+
Step 0 output: an ordered list of `(title, body, feature)` tuples plus a skip list. Proceed directly to Step 1.
|
|
125
|
+
|
|
126
|
+
### Step 1 — Confirm the Android project is a Git repo
|
|
127
|
+
|
|
128
|
+
Run `git rev-parse --is-inside-work-tree` inside `android_project_dir`.
|
|
129
|
+
|
|
130
|
+
- Output is `true` → proceed to Step 2.
|
|
131
|
+
- Otherwise → STOP. Tell the user:
|
|
132
|
+
|
|
133
|
+
> `android_project_dir` is not a Git repository. GitNexus indexes by Git identity. Please run:
|
|
134
|
+
>
|
|
135
|
+
> ```
|
|
136
|
+
> cd <android_project_dir>
|
|
137
|
+
> git init && git add . && git commit -m "init"
|
|
138
|
+
> ```
|
|
139
|
+
>
|
|
140
|
+
> then re-invoke this skill.
|
|
141
|
+
|
|
142
|
+
Do NOT auto-`init` / `add` / `commit` the user's project. Do NOT modify `git config`.
|
|
143
|
+
|
|
144
|
+
### Step 2 — Ensure GitNexus has a fresh index for the project
|
|
145
|
+
|
|
146
|
+
GitNexus exposes two surfaces:
|
|
147
|
+
|
|
148
|
+
- **Index management** (`status`, `analyze`) → invoke the `gitnexus-cli` skill (CLI wrapper, returns text).
|
|
149
|
+
- **Code queries** (`query`, `context`, `impact`, `cypher`, `list_repos`) → call `mcp__gitnexus__*` tools directly.
|
|
150
|
+
|
|
151
|
+
Procedure:
|
|
152
|
+
|
|
153
|
+
1. Invoke `gitnexus-cli` skill with `status` against `android_project_dir`.
|
|
154
|
+
2. Decide based on the output:
|
|
155
|
+
- **Not registered** or **stale** → invoke `gitnexus-cli` with `analyze`, wait for completion.
|
|
156
|
+
- **Fresh** → proceed.
|
|
157
|
+
3. Obtain `<repo-id>` via `mcp__gitnexus__list_repos()`; find the entry whose `path` matches `android_project_dir`; take its `repo` (or equivalent identifier) field.
|
|
158
|
+
|
|
159
|
+
**Hard fail policy** — any of the following stops the skill and surfaces the error to the user; do NOT degrade to `Read` + `Grep`:
|
|
160
|
+
|
|
161
|
+
- `gitnexus-cli` skill is unavailable → ask the user to run `/setup` first.
|
|
162
|
+
- `gitnexus-cli status` or `analyze` returns an error → surface the error verbatim.
|
|
163
|
+
- `mcp__gitnexus__list_repos` returns no matching entry → ask the user to verify that `analyze` registered the project.
|
|
164
|
+
- Any `mcp__gitnexus__*` call in Step 3 fails unexpectedly → surface the error; stop the skill.
|
|
165
|
+
|
|
166
|
+
> All `mcp__gitnexus__*` calls in Step 3 MUST carry `repo=<repo-id>` (or equivalent scope parameter). Cross-repo results poison the trace.
|
|
167
|
+
|
|
168
|
+
### Step 3 — Process each REQ block end-to-end
|
|
169
|
+
|
|
170
|
+
Iterate the `(title, body, feature)` tuples from Step 0 in order. For each tuple, run **3.1 → 3.5** in full before starting the next. Do NOT batch code exploration across REQ blocks.
|
|
171
|
+
|
|
172
|
+
Order matters: build the trace from Android source first, then synthesize the spec from the trace. Spec synthesis (3.5) MUST `Read` the trace written in 3.3 / 3.4 — recalling from conversation context causes scenario drift and `file:line` fabrication.
|
|
173
|
+
|
|
174
|
+
#### 3.1 Read
|
|
175
|
+
|
|
176
|
+
- Use the parsed `body` directly (already loaded in Step 0). If the tuple is marked `skip: empty body`, skip to the next tuple and record in Step 4 report.
|
|
177
|
+
- Extract from `body`: UI path / page anchors (if any), primary user intent, key entities (data models, persistence key names, setting names), explicit boundary conditions (default values, toggle states, error messages, length limits).
|
|
178
|
+
- For dependent REQs (body mentions "depends on X" or similar), note the dependency for the 3.3 trace's `Core business entities` section.
|
|
179
|
+
|
|
180
|
+
#### 3.2 Recall — Locate entry points (dual-path union)
|
|
181
|
+
|
|
182
|
+
Run both paths in parallel within the same turn (emit all mcp calls together); the deduplicated union is the recall result. All mcp calls MUST carry `repo=<repo-id>`.
|
|
183
|
+
|
|
184
|
+
| Path | Approach | Value |
|
|
185
|
+
|---|---|---|
|
|
186
|
+
| **Path 1 · By-concept lookup** | For each entity / UI anchor / intent verb from 3.1, call `mcp__gitnexus__query({ query: "<concept>", repo: "<repo-id>" })` and `mcp__gitnexus__context({ name: "<symbol>", repo: "<repo-id>" })` to find candidate symbols (Activities / Fragments / Composables / ViewModels / Services / Repositories / DAOs). Cross-validate symbol name, file path, and context against `REQ_DESC`. | Direct hits: pages obviously implementing the REQ; data models named after REQ entities. |
|
|
187
|
+
| **Path 2 · Reverse-by-usage** | Take the most discriminative keyword (a settings key literal, a persistence column / preference key, a unique business term). `query` → candidate symbol → `mcp__gitnexus__impact({ name: "<symbol>", repo: "<repo-id>" })` returns callers (nested). Walk callers upward until hitting an `Activity` / `Fragment` / `@Composable` host. That host is an entry point. If the walk passes through intermediate dialog / popup / bottom-sheet / inner-composable components that directly reference the target key, record each as a **separate entry point** — these represent distinct user-facing surfaces within the host. | Covers structural blind spots Path 1 misses: deeply nested consumers, pass-through navigation pages, manifest-declared receivers. |
|
|
188
|
+
|
|
189
|
+
**Behavioral REQ anchor extraction**: when `REQ_DESC` has no explicit literal keyword (e.g. "after track-change X refreshes synchronously"), extract anchors as `(action verb, affected entity)` tuples — e.g. `(track-change, X)` — and feed both into Path 1's `query` and Path 2's seed symbol search.
|
|
190
|
+
|
|
191
|
+
**Both paths hit zero** → ask the user via `AskUserQuestion` whether to manually specify an entry point. If declined → write `status: no_recall` in the trace, skip 3.3 / 3.4 / 3.5, flag in Step 4 report. Do NOT fabricate entry points.
|
|
192
|
+
|
|
193
|
+
**Terse REQ handling** — if the REQ body has fewer than ~20 substantive characters, OR contains only topical keywords (e.g. "multi-device", "landscape/portrait") with no concrete action verb / entity:
|
|
194
|
+
|
|
195
|
+
1. **MUST** run two broad enumeration passes (both mandatory, not optional):
|
|
196
|
+
- **Pass A · Feature code**: `mcp__gitnexus__cypher` enumeration — find all Activity / Fragment / Composable hosts whose `configChanges` manifest attribute is non-default (for orientation / resize cases) or whose layout has a resource qualifier matching the REQ topic (e.g. `-land`, `-sw600dp`, `-night`).
|
|
197
|
+
- **Pass B · Settings breadth**: For EACH distinct keyword in the REQ body, run `mcp__gitnexus__query` + `Grep` to enumerate ALL settings / configuration screens that reference that keyword or a semantically related term. Terse REQs frequently span multiple unrelated settings pages; anchoring on the single most obvious page is the primary failure mode. The union of Pass A and Pass B is the recall result.
|
|
198
|
+
2. If ≥3 plausible candidates → list them in the trace's `Status` section as `candidate_hosts: [...]` and proceed normally.
|
|
199
|
+
3. If <3 candidates → invoke `AskUserQuestion`: show the candidate list, ask which are in-scope for this REQ. Do NOT silently guess.
|
|
200
|
+
4. Mark in trace `Status` block: `terse_req: true` (this signal feeds 3.4 review).
|
|
201
|
+
5. **3.4 Review MUST verify**: every settings screen discovered in Pass B has at least one Entry or Touched-entry in the trace. A discovered-but-untraced screen → fail review, return to 3.3.
|
|
202
|
+
|
|
203
|
+
**Clarification triggers** (interrupt 3.2 / 3.3 with `AskUserQuestion`):
|
|
204
|
+
|
|
205
|
+
- `REQ_DESC` contains ambiguous phrases ("any entry point", "related pages", "all related locations") AND the trace cannot map them to a unique set of components.
|
|
206
|
+
- Path 1 + Path 2 both return zero, before writing `no_recall`.
|
|
207
|
+
- Deviations from `REQ_DESC` exceed five AND touch core behavior (REQ may be stale; confirm before proceeding).
|
|
208
|
+
|
|
209
|
+
#### 3.3 Trace — Explore code and write `<spec_output_dir>/.trace/<feature>.md`
|
|
210
|
+
|
|
211
|
+
The trace file is the sole machine-readable contract delivered to 3.5. Exploration and writing form a single unit.
|
|
212
|
+
|
|
213
|
+
**Exploration checklist — execution order** (all mcp calls carry `repo: "<repo-id>"`):
|
|
214
|
+
|
|
215
|
+
| Step | Action | Tool |
|
|
216
|
+
|---|---|---|
|
|
217
|
+
| 1 | Survey candidate symbols for each anchor from 3.1 | `mcp__gitnexus__query` / `context` |
|
|
218
|
+
| 2 | Full call chain (callers / callees, up and down) | `mcp__gitnexus__impact` |
|
|
219
|
+
| 3 | Cross-class graph traversal / reverse-lookup state writers / aggregation | `mcp__gitnexus__cypher` |
|
|
220
|
+
| 4 | Exact literal positioning (settings keys, DAO columns, intent actions, preference `android:key`) | `Grep` |
|
|
221
|
+
| 5 | Final `file:line` verification / zero-hit counter-evidence | `Read` (small window) / `Grep` |
|
|
222
|
+
|
|
223
|
+
**Exploration dimensions — information coverage** (orthogonal to the checklist; checklist = order, dimensions = what to capture). Apply each to every recall entry:
|
|
224
|
+
|
|
225
|
+
- **Trigger code** — UI control + event callback (click / long-press / swipe / lifecycle / broadcast receiver) invoking the REQ behavior. Fill Entry's `code` and `resource` layer fields.
|
|
226
|
+
- **End-to-end call chain** — trigger → ViewModel / UseCase → Service / Repository → data source. Fill Entry's `data_flow`; each hop carries `file:line`.
|
|
227
|
+
- **State writes & persistence** — every state mutation (state holders, DAO inserts, preference / DataStore / MMKV puts, file writes). Record key / column names verbatim.
|
|
228
|
+
- **Side effects / cross-boundary** — broadcasts, bound services, notifications, App Widget IPC, content providers, accessibility events.
|
|
229
|
+
- **Manifest declarations / build flags** — activity / service / receiver registration, intent filters, permissions, foreground service types, build flavor / `buildConfig` gates. Fill Entry's `manifest` field — `N/A: <reason>` if none.
|
|
230
|
+
- **Deviations from `REQ_DESC`** — every gap (default values, copy strings, behavior, hidden entries, validation rules). Feeds Principle 7.
|
|
231
|
+
- **Application scope / boundary · Exhaustive entry enumeration** — ALL UI paths touching this feature / state, beyond REQ text. For state keys: reverse-lookup writers + lift to UI hosts. For readers: enumerate consumers + non-consumers. One field block per entry; omitted here = scenario omitted in spec.
|
|
232
|
+
- **Consumer list & non-consumers** — who reads this state, plus which UI surfaces explicitly do NOT. Non-consumer claims use the structured field block (`claim` / `closure_layers` / `tools` / `zero_hits`).
|
|
233
|
+
|
|
234
|
+
**Trace file template** (write to `<spec_output_dir>/.trace/<feature>.md`):
|
|
235
|
+
|
|
236
|
+
```markdown
|
|
237
|
+
# Code trace · <feature>
|
|
238
|
+
|
|
239
|
+
## Status
|
|
240
|
+
status: ok | no_recall | error
|
|
241
|
+
repo-id: <repo-id>
|
|
242
|
+
backend: gitnexus
|
|
243
|
+
|
|
244
|
+
## Recalled entry points (Path 1 + Path 2 union, deduplicated)
|
|
245
|
+
- Entry 1: <UI path / page name> — file:line — recalled by: path 1 | path 2 | both
|
|
246
|
+
- ...
|
|
247
|
+
|
|
248
|
+
## Entry · <name>
|
|
249
|
+
- claim: <user-observable behavior in one sentence>
|
|
250
|
+
- layers:
|
|
251
|
+
- code: <file:line> # required; hit or `N/A: <reason>`
|
|
252
|
+
- resource: <file:line> | N/A: <reason> # layout / menu / drawable / values / xml-preferences / navigation
|
|
253
|
+
- manifest: <file:line> | N/A: <reason> # AndroidManifest entry / build.gradle flag
|
|
254
|
+
- interaction: <state writes, persistence keys (verbatim), in-memory mutations>
|
|
255
|
+
- data_flow: <trigger → ViewModel / Service / Repo → data source, each hop with file:line>
|
|
256
|
+
|
|
257
|
+
## Entry · <name 2> ... Entry · <name N>
|
|
258
|
+
(each entry repeats the claim / layers / interaction / data_flow field block)
|
|
259
|
+
|
|
260
|
+
## Implicit triggers (non-UI state changes that activate this feature)
|
|
261
|
+
- Trigger: <track-change / Pro status change / permission change / foreground-background switch / network change / lyrics document change / current track is null> — <file:line> — behavior: <one sentence>
|
|
262
|
+
- (write "None" if no implicit trigger applies)
|
|
263
|
+
|
|
264
|
+
## Core business entities (data model / persistence key / state machine)
|
|
265
|
+
- Entity X: <file:line + field list + semantics>
|
|
266
|
+
- For dependent REQs: <dependency-key-name> sourced from feature `<depended-feature>` at file:line
|
|
267
|
+
- ...
|
|
268
|
+
|
|
269
|
+
## Cross-entry shared declarations
|
|
270
|
+
- <AndroidManifest.xml / build.gradle entries with file:line, shared across multiple entries>
|
|
271
|
+
- ... (write "None" explicitly if no cross-entry declaration applies; per-entry manifest facts live in each Entry's `manifest` layer field)
|
|
272
|
+
|
|
273
|
+
## Deviations from REQ_DESC
|
|
274
|
+
1. <REQ says A; but code at file:line behaves as B>
|
|
275
|
+
2. ...
|
|
276
|
+
(empty → write "None" explicitly to confirm the check was performed)
|
|
277
|
+
|
|
278
|
+
## Scope / Boundary — Exhaustive entry enumeration
|
|
279
|
+
### Touched entries (all UI paths, not limited to REQ_DESC mentions)
|
|
280
|
+
(each touched entry uses the same `claim` / `layers` / `interaction` / `data_flow` field block as the Entry template above)
|
|
281
|
+
|
|
282
|
+
### Consumers (who reads this state / data)
|
|
283
|
+
- Consumer: <component name> — file:line
|
|
284
|
+
|
|
285
|
+
### Non-consumers (boundary counter-examples with evidence)
|
|
286
|
+
- claim: <e.g. "App widget does not read this key">
|
|
287
|
+
closure_layers: [code, resource, manifest]
|
|
288
|
+
tools: [Grep "<pattern>", mcp__gitnexus__cypher "<...>", Read "<path>"]
|
|
289
|
+
zero_hits: <verbatim zero-hit evidence — file globs searched, regex used, hit count>
|
|
290
|
+
|
|
291
|
+
## Same-source cross-reference (if applicable)
|
|
292
|
+
- This REQ shares behavior with feature `<other-feature>` (e.g. the same setting exposed under multiple settings paths).
|
|
293
|
+
Both specs are generated independently and reference each other in their deviation sections.
|
|
294
|
+
- (write "None" if not applicable)
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
#### 3.4 Review — No fabrication, no omission, method-discipline compliant
|
|
298
|
+
|
|
299
|
+
Run the checks below against the trace from 3.3; every check must pass before proceeding to 3.5.
|
|
300
|
+
|
|
301
|
+
- **No fabrication** — every declared `file:line` actually exists (sample-verify via `mcp__gitnexus__context` or `Read`); every behavioral claim is source-supported; every boundary claim has tool evidence.
|
|
302
|
+
- **No omission** — every detail in `REQ_DESC` has a counterpart in the trace (Entry / behavior / deviation). If REQ mentions a feature code does not implement, record as deviation, not omission.
|
|
303
|
+
- **Method-discipline compliance** (Multi-layer claim + Replayable fact) — sample-verify random `file:line` anchors via `mcp__gitnexus__context` / `Read` (≥1 line drift → fail); sample-verify every count / ordering phrase against source (unreplayable → fail); every Entry / Touched-entry has all three layer fields filled (hit or `N/A: <reason>`); every Non-consumer claim has all four structured fields (`claim` / `closure_layers` / `tools` / `zero_hits`).
|
|
304
|
+
- **Implicit triggers coverage** — the trace's `Implicit triggers` section is present and explicitly filled (≥1 trigger OR `None`). Absence of the section = fail review.
|
|
305
|
+
- **Trace section presence audit** — every trace MUST contain these H2 sections (with `None` if truly empty; absence = fail): `Status` / `Recalled entry points` / per `Entry` (all 4 fields: `claim` / `layers` / `interaction` / `data_flow`) / `Implicit triggers` / `Core business entities` / `Cross-entry shared declarations` / `Deviations from REQ_DESC` / `Scope / Boundary` / `Same-source cross-reference`.
|
|
306
|
+
|
|
307
|
+
Any check failing → return to 3.3 (rewrite / supplement / fix). Judge convergence yourself; no external iteration cap. All checks pass → proceed to 3.5.
|
|
308
|
+
|
|
309
|
+
#### 3.5 Synthesize — Write the final spec
|
|
310
|
+
|
|
311
|
+
`Read` the trace from 3.3 / 3.4, then synthesize the spec following `## Principles` and the style references under `references/`. Write to `<spec_output_dir>/<feature>-SPEC.md` (overwrite if exists).
|
|
312
|
+
|
|
313
|
+
**Synthesis discipline**:
|
|
314
|
+
|
|
315
|
+
- **Implicit triggers coverage** — every entry in the trace's `Implicit triggers` section MUST appear in the spec as an independent scenario OR as a main step within an existing scenario. Listed in trace but absent from spec = scenario omission. (Extends Principle 8 to non-UI triggers.)
|
|
316
|
+
- **Shared-mechanic factoring** — for enumerated-value settings (three-way / four-way / radio-group) accessible from multiple entry points, factor the shared menu interaction across all entries into ONE scenario; give each enum value its OWN runtime-semantics scenario. Do NOT split the mechanical scenario per entry point, and do NOT bundle "user picks X" with "what X does" in the same scenario per value.
|
|
317
|
+
- **Binary-toggle anti-pattern** — a binary on/off switch is ONE trigger; write ONE scenario for the toggle (both directions), with linked-control side-effects as sub-bullets. Write SEPARATE scenarios for each state's runtime rendering (e.g. "when ON, cover rotates" / "when OFF, cover is static"). Do NOT split "turn on" / "turn off" into independent scenes.
|
|
318
|
+
- **Same-source cross-reference** — if the trace's `Same-source cross-reference` section is non-empty, append a short note at the end of the spec referencing the other `<feature>-SPEC.md` (e.g. "This setting also exists under `<other-feature>-SPEC.md` with identical behavior").
|
|
319
|
+
- **REQ-vs-code-string arbitration** — code's user-facing strings (toast / notification / dialog / snackbar / error) that conflict with `REQ_DESC` are **deviation evidence**, NOT authoritative facts. Author spec body per `REQ_DESC` phrasing; record the conflicting string + `file:line` in trace's `Deviations`. Do NOT copy code strings verbatim into the spec.
|
|
320
|
+
|
|
321
|
+
After writing, proceed to the next REQ block.
|
|
322
|
+
|
|
323
|
+
### Step 4 — Summary report
|
|
324
|
+
|
|
325
|
+
Once all REQ blocks are processed (or skipped with warnings), produce a brief report following `references/step4-report-template.md`. The template defines the per-block table format, skipped-block list, and aggregates. Keep the in-session reply within ~40 lines; per-block detail belongs in spec / trace files.
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Forbidden
|
|
330
|
+
|
|
331
|
+
- **No nested LLM-agent skill calls** — no `gitnexus-exploring`, no `gitnexus-debugging`, no `gitnexus-refactoring`, no `gitnexus-impact-analysis`. They override this SKILL's instructions and cause role drift. **Exception**: `gitnexus-cli` is a CLI wrapper (not an LLM agent); using it for index management is allowed.
|
|
332
332
|
- **No modification of the Android project** — `.gradle`, `AndroidManifest.xml`, source files. This skill is read-only.
|