@aperant/framework 0.6.7 → 0.7.0
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/CHANGELOG.md +60 -0
- package/dist/cli/commands/ci-watch.d.mts.map +1 -1
- package/dist/cli/commands/ci-watch.mjs +39 -1
- package/dist/cli/commands/ci-watch.mjs.map +1 -1
- package/dist/cli/commands/health-check.mjs +1 -1
- package/dist/cli/commands/health-check.mjs.map +1 -1
- package/dist/cli/commands/init.d.mts +10 -1
- package/dist/cli/commands/init.d.mts.map +1 -1
- package/dist/cli/commands/init.mjs +94 -4
- package/dist/cli/commands/init.mjs.map +1 -1
- package/dist/cli/commands/route.d.mts.map +1 -1
- package/dist/cli/commands/route.mjs +37 -2
- package/dist/cli/commands/route.mjs.map +1 -1
- package/dist/cli/commands/task.d.mts.map +1 -1
- package/dist/cli/commands/task.mjs +48 -0
- package/dist/cli/commands/task.mjs.map +1 -1
- package/dist/cli/help.d.mts.map +1 -1
- package/dist/cli/help.mjs +1 -0
- package/dist/cli/help.mjs.map +1 -1
- package/dist/cli/host/detect.d.mts +122 -9
- package/dist/cli/host/detect.d.mts.map +1 -1
- package/dist/cli/host/detect.mjs +132 -0
- package/dist/cli/host/detect.mjs.map +1 -1
- package/dist/cli/install/legacy-paths.d.mts +38 -0
- package/dist/cli/install/legacy-paths.d.mts.map +1 -0
- package/dist/cli/install/legacy-paths.mjs +69 -0
- package/dist/cli/install/legacy-paths.mjs.map +1 -0
- package/dist/cli/install/runtime-migrate.d.mts +84 -0
- package/dist/cli/install/runtime-migrate.d.mts.map +1 -0
- package/dist/cli/install/runtime-migrate.mjs +244 -0
- package/dist/cli/install/runtime-migrate.mjs.map +1 -0
- package/dist/cli/route/drift-detect.d.mts +20 -0
- package/dist/cli/route/drift-detect.d.mts.map +1 -0
- package/dist/cli/route/drift-detect.mjs +107 -0
- package/dist/cli/route/drift-detect.mjs.map +1 -0
- package/dist/cli/util/aperant-section.d.mts +34 -0
- package/dist/cli/util/aperant-section.d.mts.map +1 -0
- package/dist/cli/util/aperant-section.mjs +127 -0
- package/dist/cli/util/aperant-section.mjs.map +1 -0
- package/dist/cli/util/copy.d.mts +28 -1
- package/dist/cli/util/copy.d.mts.map +1 -1
- package/dist/cli/util/copy.mjs +43 -55
- package/dist/cli/util/copy.mjs.map +1 -1
- package/dist/cli/util/semver.d.mts +17 -0
- package/dist/cli/util/semver.d.mts.map +1 -0
- package/dist/cli/util/semver.mjs +29 -0
- package/dist/cli/util/semver.mjs.map +1 -0
- package/dist/cli/util/skill-installs.d.mts +65 -9
- package/dist/cli/util/skill-installs.d.mts.map +1 -1
- package/dist/cli/util/skill-installs.mjs +130 -21
- package/dist/cli/util/skill-installs.mjs.map +1 -1
- package/dist/cli/util/version-preflight.d.mts +44 -0
- package/dist/cli/util/version-preflight.d.mts.map +1 -0
- package/dist/cli/util/version-preflight.mjs +66 -0
- package/dist/cli/util/version-preflight.mjs.map +1 -0
- package/package.json +1 -1
- package/skills/apt-close-task/SKILL.md +5 -0
- package/skills/apt-ship/SKILL.md +16 -4
- package/skills/apt-spar/SKILL.md +36 -11
- package/skills/apt-update/SKILL.md +26 -1
- package/skills/apt-watch-ci/SKILL.md +4 -1
- package/src/cli/commands/ci-watch.mjs +39 -1
- package/src/cli/commands/health-check.mjs +1 -1
- package/src/cli/commands/init.mjs +102 -2
- package/src/cli/commands/route.mjs +38 -2
- package/src/cli/commands/task.mjs +49 -0
- package/src/cli/help.mjs +1 -0
- package/src/cli/host/detect.mjs +135 -0
- package/src/cli/install/legacy-paths.mjs +69 -0
- package/src/cli/install/runtime-migrate.mjs +252 -0
- package/src/cli/route/drift-detect.mjs +107 -0
- package/src/cli/util/aperant-section.mjs +136 -0
- package/src/cli/util/copy.mjs +43 -56
- package/src/cli/util/semver.mjs +28 -0
- package/src/cli/util/skill-installs.mjs +134 -21
- package/src/cli/util/version-preflight.mjs +65 -0
- package/templates/aperant-claude-md-appendix.md +37 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* util/aperant-section.mjs — generator for the CLAUDE.md / AGENTS.md
|
|
3
|
+
* "## Aperant Framework" section (FRAMEWORK-BUG-023).
|
|
4
|
+
*
|
|
5
|
+
* Replaces the previously-hardcoded `APT_SECTION` constant in copy.mjs.
|
|
6
|
+
* The skill TABLE is rebuilt from `discoverSkills` (filesystem source of
|
|
7
|
+
* truth — same helper the router uses at runtime) so install and runtime
|
|
8
|
+
* can never disagree about the catalog.
|
|
9
|
+
*
|
|
10
|
+
* Curated-doc risk: the appendix template
|
|
11
|
+
* (`templates/aperant-claude-md-appendix.md`) still contains hand-written
|
|
12
|
+
* sub-sections — "Fast Path Guarantee", "Discoverability —
|
|
13
|
+
* `apt-tools modes list`", "Feature Registry", "Config". These are small
|
|
14
|
+
* (~30 lines), rarely change, and rot would be visible (sections about
|
|
15
|
+
* non-existent features). Acceptable tradeoff per plan §Approach (c).
|
|
16
|
+
*/
|
|
17
|
+
import { readFileSync } from 'node:fs';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
import { getTrustedSkillSources } from '../config/load.mjs';
|
|
20
|
+
import { discoverSkills } from '../route/skill-discover.mjs';
|
|
21
|
+
const SECTION_START = '<!-- APT:framework-start -->';
|
|
22
|
+
const SECTION_END = '<!-- APT:framework-end -->';
|
|
23
|
+
const SECTION_HEADING = '## Aperant Framework';
|
|
24
|
+
const APPENDIX_REL_PATH = ['templates', 'aperant-claude-md-appendix.md'];
|
|
25
|
+
/**
|
|
26
|
+
* Escape a SKILL `description` for safe inclusion as a markdown table cell.
|
|
27
|
+
* The only character we have to defend against is the pipe (`|`) — it
|
|
28
|
+
* terminates the table column. `apt:triage` ships with a literal `|` in
|
|
29
|
+
* its description, so this is a live case, not a theoretical one.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} text
|
|
32
|
+
* @returns {string}
|
|
33
|
+
*/
|
|
34
|
+
function escapePipes(text) {
|
|
35
|
+
return text.replace(/\|/g, '\\|');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Deterministic sort: the bare `apt` router skill first, then ASCII-sorted
|
|
39
|
+
* by `name`. The router goes first so the generated table mirrors the user's
|
|
40
|
+
* mental model — the entry point, then everything reachable from it.
|
|
41
|
+
*
|
|
42
|
+
* @param {{ name: string }} a
|
|
43
|
+
* @param {{ name: string }} b
|
|
44
|
+
* @returns {number}
|
|
45
|
+
*/
|
|
46
|
+
function sortSkills(a, b) {
|
|
47
|
+
if (a.name === 'apt' && b.name !== 'apt')
|
|
48
|
+
return -1;
|
|
49
|
+
if (b.name === 'apt' && a.name !== 'apt')
|
|
50
|
+
return 1;
|
|
51
|
+
return a.name.localeCompare(b.name);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Build the full "## Aperant Framework" section, wrapped in the
|
|
55
|
+
* `<!-- APT:framework-* -->` markers.
|
|
56
|
+
*
|
|
57
|
+
* @param {Object} opts
|
|
58
|
+
* @param {string} opts.canonicalRoot Absolute path to the framework root
|
|
59
|
+
* (the directory that contains
|
|
60
|
+
* `templates/aperant-claude-md-appendix.md`).
|
|
61
|
+
* @param {string} opts.targetDir Project root (passed to discoverSkills).
|
|
62
|
+
* @param {string} [opts.cli] Host CLI label (forwarded to
|
|
63
|
+
* getTrustedSkillSources so the install
|
|
64
|
+
* root for the runtime is included).
|
|
65
|
+
* @returns {string} The full section, including markers
|
|
66
|
+
* and trailing newline before the
|
|
67
|
+
* end-marker. No leading newline.
|
|
68
|
+
*/
|
|
69
|
+
export function buildAptSection({ canonicalRoot, targetDir, cli }) {
|
|
70
|
+
const trustedSkillSources = getTrustedSkillSources(targetDir, cli);
|
|
71
|
+
const discovered = discoverSkills({ targetDir, trustedSkillSources });
|
|
72
|
+
const skills = discovered.skills
|
|
73
|
+
.filter((s) => s.user_invocable === true && s.internal === false)
|
|
74
|
+
.slice()
|
|
75
|
+
.sort(sortSkills);
|
|
76
|
+
const rows = skills.map((s) => `| \`/${s.name}\` | ${escapePipes(s.description)} |`);
|
|
77
|
+
const tableBlock = [
|
|
78
|
+
'### Available Skills',
|
|
79
|
+
'| Skill | Description |',
|
|
80
|
+
'|-------|-------------|',
|
|
81
|
+
...rows,
|
|
82
|
+
].join('\n');
|
|
83
|
+
const appendixPath = join(canonicalRoot, ...APPENDIX_REL_PATH);
|
|
84
|
+
let appendix;
|
|
85
|
+
try {
|
|
86
|
+
appendix = readFileSync(appendixPath, 'utf-8').replace(/\n+$/, '');
|
|
87
|
+
}
|
|
88
|
+
catch (cause) {
|
|
89
|
+
const err = new Error(`aperant-section: template not found at ${appendixPath} — re-install the framework package`, { cause });
|
|
90
|
+
err.code = 'aperant-section.template-missing';
|
|
91
|
+
throw err;
|
|
92
|
+
}
|
|
93
|
+
const body = [SECTION_HEADING, '', appendix, '', tableBlock].join('\n');
|
|
94
|
+
return `${SECTION_START}\n${body}\n${SECTION_END}`;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Extract the `/apt:<slug>` (or bare `/apt`) row IDs from the
|
|
98
|
+
* `<!-- APT:framework-* -->` section of an existing instruction file.
|
|
99
|
+
* Returns `[]` when the file has no APT section.
|
|
100
|
+
*
|
|
101
|
+
* Used by `injectInstructionFile` to detect foreign rows that would be
|
|
102
|
+
* silently clobbered by a regeneration — see `--force-overwrite-catalog`.
|
|
103
|
+
*
|
|
104
|
+
* @param {string} text Full instruction-file contents.
|
|
105
|
+
* @returns {string[]} Row IDs in file order, e.g. `['/apt', '/apt:quick', …]`.
|
|
106
|
+
*/
|
|
107
|
+
export function extractAptSectionRowIds(text) {
|
|
108
|
+
const match = text.match(/<!-- APT:framework-start -->([\s\S]*?)<!-- APT:framework-end -->/);
|
|
109
|
+
if (!match)
|
|
110
|
+
return [];
|
|
111
|
+
// Strip HTML comments (including multiline) before scanning for row IDs so
|
|
112
|
+
// that commented-out example rows don't trigger false-positive foreign-row exits.
|
|
113
|
+
const section = match[1].replace(/<!--[\s\S]*?-->/g, '');
|
|
114
|
+
const ids = [];
|
|
115
|
+
// Match table rows whose first cell is `/apt` or `/apt:<slug>` wrapped in
|
|
116
|
+
// backticks. The leading `|` plus optional whitespace anchors us to a
|
|
117
|
+
// markdown table cell; the trailing backtick + ` |` anchors the column
|
|
118
|
+
// boundary so we don't match prose mentions like "the `/apt` router".
|
|
119
|
+
const rowRe = /^\|\s*`(\/apt(?::[a-z0-9-]+)?)`\s*\|/gm;
|
|
120
|
+
let m = rowRe.exec(section);
|
|
121
|
+
while (m !== null) {
|
|
122
|
+
ids.push(m[1]);
|
|
123
|
+
m = rowRe.exec(section);
|
|
124
|
+
}
|
|
125
|
+
return ids;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=aperant-section.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aperant-section.mjs","sourceRoot":"","sources":["../../../src/cli/util/aperant-section.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAE5D,MAAM,aAAa,GAAG,8BAA8B,CAAA;AACpD,MAAM,WAAW,GAAG,4BAA4B,CAAA;AAChD,MAAM,eAAe,GAAG,sBAAsB,CAAA;AAC9C,MAAM,iBAAiB,GAAG,CAAC,WAAW,EAAE,+BAA+B,CAAC,CAAA;AAExE;;;;;;;;GAQG;AACH,SAAS,WAAW,CAAC,IAAI;IACxB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AAClC,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,UAAU,CAAC,CAAC,EAAE,CAAC;IACvB,IAAI,CAAC,CAAC,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,IAAI,K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|
-
|
|
2
|
+
/**
|
|
3
|
+
* Write the (already-generated) APT section into `filePath`. Creates the
|
|
4
|
+
* file if missing; replaces the section in-place if the markers are
|
|
5
|
+
* present.
|
|
6
|
+
*
|
|
7
|
+
* FRAMEWORK-BUG-023 — before overwriting an existing section, extract the
|
|
8
|
+
* row IDs in the on-disk file and compare to the row IDs in the freshly
|
|
9
|
+
* generated section. If the file contains rows that are NOT in the
|
|
10
|
+
* generated set ("foreign rows"), the regen would silently clobber them.
|
|
11
|
+
* In that case we abort and let the caller surface a structured error.
|
|
12
|
+
* The `--force-overwrite-catalog` escape hatch flips `force: true`.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} filePath
|
|
15
|
+
* @param {Object} opts
|
|
16
|
+
* @param {string} opts.aptSection Output of buildAptSection() — wrapped
|
|
17
|
+
* in `<!-- APT:framework-* -->` markers.
|
|
18
|
+
* @param {boolean} [opts.force=false]
|
|
19
|
+
* Bypass the foreign-row check.
|
|
20
|
+
* @returns {{ status: 'created' | 'updated' | 'aborted-foreign-rows', written: boolean, foreignRowIds?: string[] }}
|
|
21
|
+
*/
|
|
22
|
+
export function injectInstructionFile(filePath: string, { aptSection, force }: {
|
|
23
|
+
aptSection: string;
|
|
24
|
+
force?: boolean | undefined;
|
|
25
|
+
}): {
|
|
26
|
+
status: "created" | "updated" | "aborted-foreign-rows";
|
|
27
|
+
written: boolean;
|
|
28
|
+
foreignRowIds?: string[];
|
|
29
|
+
};
|
|
3
30
|
//# sourceMappingURL=copy.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy.d.mts","sourceRoot":"","sources":["../../../src/cli/util/copy.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"copy.d.mts","sourceRoot":"","sources":["../../../src/cli/util/copy.mjs"],"names":[],"mappings":"AAwBA,4DAWC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,gDARW,MAAM,yBAEd;IAAqB,UAAU,EAAvB,MAAM;IAES,KAAK;CAE5B,GAAU;IAAE,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,sBAAsB,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CA0BlH"}
|
package/dist/cli/util/copy.mjs
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* copy.mjs — filesystem copy + instruction-file injection helpers (C29).
|
|
3
3
|
*
|
|
4
|
-
* `copyDirRecursive` is a pure leaf
|
|
5
|
-
* CLAUDE.md / AGENTS.md "<!-- APT:framework-* -->" section
|
|
4
|
+
* `copyDirRecursive` is a pure leaf. `injectInstructionFile` owns the
|
|
5
|
+
* CLAUDE.md / AGENTS.md "<!-- APT:framework-* -->" section write path.
|
|
6
|
+
*
|
|
7
|
+
* The APT section TEXT is no longer assembled here — it is generated by
|
|
8
|
+
* `util/aperant-section.mjs#buildAptSection` and passed in (FRAMEWORK-BUG-023).
|
|
9
|
+
* Callers compute the section once (from the filesystem skill catalog) and
|
|
10
|
+
* hand it to this helper. The defensive foreign-row check stays in this
|
|
11
|
+
* file so the read/compare/write happens atomically against `filePath`.
|
|
6
12
|
*/
|
|
7
13
|
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, } from 'node:fs';
|
|
8
14
|
import { join } from 'node:path';
|
|
15
|
+
import { extractAptSectionRowIds } from './aperant-section.mjs';
|
|
9
16
|
export function copyDirRecursive(src, dest) {
|
|
10
17
|
mkdirSync(dest, { recursive: true });
|
|
11
18
|
for (const entry of readdirSync(src, { withFileTypes: true })) {
|
|
@@ -19,63 +26,44 @@ export function copyDirRecursive(src, dest) {
|
|
|
19
26
|
}
|
|
20
27
|
}
|
|
21
28
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
| \`/apt:stress-test\` | Scenario simulation to catch gaps in plans |
|
|
44
|
-
| \`/apt:ship\` | Create PR with QA scores and decision traceability |
|
|
45
|
-
| \`/apt:pause\` | Human-initiated session handoff — save state when YOU need to stop (not for agent-initiated bailouts) |
|
|
46
|
-
| \`/apt:resume\` | Restore context from a paused session and route to next action |
|
|
47
|
-
| \`/apt:docs\` | Generate/update documentation verified against the actual codebase |
|
|
48
|
-
| \`/apt:setup\` | Change framework preferences (verification style, multi-model, branching) |
|
|
49
|
-
|
|
50
|
-
### Feature Registry
|
|
51
|
-
The feature registry (\`.aperant/features/\`) is a living inventory of every interactive
|
|
52
|
-
feature in the app. It's the source of truth for what to verify and review.
|
|
53
|
-
|
|
54
|
-
- **Created by:** \`/apt:scan\` (initial scan or full refresh)
|
|
55
|
-
- **Updated by:** \`/apt:execute\` post-step (\`apt-tools features-audit --apply-stubs\` auto-registers new UI/core/hook/IPC files per the docs-coherence policy)
|
|
56
|
-
- **Consumed by:** \`/apt:verify-proof\` (generates test cases from registry)
|
|
57
|
-
- **Checked by:** \`/apt:review\` Pass 6 (flags unregistered new components, applies stubs for auto-update policies)
|
|
58
|
-
|
|
59
|
-
Run \`/apt:scan\` after setting up Aperant on a brownfield project, or after major changes.
|
|
60
|
-
|
|
61
|
-
### Config
|
|
62
|
-
- Settings: \`.aperant/config.json\` (run \`/apt:setup\` to change)
|
|
63
|
-
- Features: \`.aperant/features/\` (feature registry -- run \`/apt:scan\` to create)
|
|
64
|
-
- State: \`.aperant/state.json\` (execution state)
|
|
65
|
-
- Evidence: \`.aperant/proof/\` (proof reports and screenshots)
|
|
66
|
-
- Prompts: \`.aperant/prompts/\` (agent prompt templates)
|
|
67
|
-
<!-- APT:framework-end -->`;
|
|
68
|
-
export function injectInstructionFile(filePath) {
|
|
29
|
+
/**
|
|
30
|
+
* Write the (already-generated) APT section into `filePath`. Creates the
|
|
31
|
+
* file if missing; replaces the section in-place if the markers are
|
|
32
|
+
* present.
|
|
33
|
+
*
|
|
34
|
+
* FRAMEWORK-BUG-023 — before overwriting an existing section, extract the
|
|
35
|
+
* row IDs in the on-disk file and compare to the row IDs in the freshly
|
|
36
|
+
* generated section. If the file contains rows that are NOT in the
|
|
37
|
+
* generated set ("foreign rows"), the regen would silently clobber them.
|
|
38
|
+
* In that case we abort and let the caller surface a structured error.
|
|
39
|
+
* The `--force-overwrite-catalog` escape hatch flips `force: true`.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} filePath
|
|
42
|
+
* @param {Object} opts
|
|
43
|
+
* @param {string} opts.aptSection Output of buildAptSection() — wrapped
|
|
44
|
+
* in `<!-- APT:framework-* -->` markers.
|
|
45
|
+
* @param {boolean} [opts.force=false]
|
|
46
|
+
* Bypass the foreign-row check.
|
|
47
|
+
* @returns {{ status: 'created' | 'updated' | 'aborted-foreign-rows', written: boolean, foreignRowIds?: string[] }}
|
|
48
|
+
*/
|
|
49
|
+
export function injectInstructionFile(filePath, { aptSection, force = false }) {
|
|
69
50
|
const existing = existsSync(filePath) ? readFileSync(filePath, 'utf-8') : '';
|
|
70
51
|
if (existing.includes('<!-- APT:framework-start -->')) {
|
|
71
|
-
|
|
72
|
-
|
|
52
|
+
if (!force) {
|
|
53
|
+
const existingIds = new Set(extractAptSectionRowIds(existing));
|
|
54
|
+
const generatedIds = new Set(extractAptSectionRowIds(aptSection));
|
|
55
|
+
const foreignRowIds = [...existingIds].filter((id) => !generatedIds.has(id));
|
|
56
|
+
if (foreignRowIds.length > 0) {
|
|
57
|
+
return { status: 'aborted-foreign-rows', written: false, foreignRowIds };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const updated = existing.replace(/<!-- APT:framework-start -->[\s\S]*?<!-- APT:framework-end -->/, aptSection);
|
|
73
61
|
writeFileSync(filePath, updated, 'utf-8');
|
|
74
|
-
return 'updated';
|
|
62
|
+
return { status: 'updated', written: true };
|
|
75
63
|
}
|
|
76
|
-
// Append
|
|
64
|
+
// Append (greenfield create — no foreign-row concern).
|
|
77
65
|
const separator = existing.length > 0 ? '\n\n' : '';
|
|
78
|
-
writeFileSync(filePath, existing + separator +
|
|
79
|
-
return 'created';
|
|
66
|
+
writeFileSync(filePath, existing + separator + aptSection + '\n', 'utf-8');
|
|
67
|
+
return { status: 'created', written: true };
|
|
80
68
|
}
|
|
81
69
|
//# sourceMappingURL=copy.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy.mjs","sourceRoot":"","sources":["../../../src/cli/util/copy.mjs"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"copy.mjs","sourceRoot":"","sources":["../../../src/cli/util/copy.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACN,YAAY,EACZ,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,aAAa,GACb,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAE/D,MAAM,UAAU,gBAAgB,CAAC,GAAG,EAAE,IAAI;IACzC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACpC,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;QACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;QACvC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACzB,gBAAgB,CAAC,OAAO,EAAE,QA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,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;IACnD,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,IAAI,EAAE,OAAO,CAAC,CAAA;IAC1E,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;AAC5C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare two semver-shape strings. Returns -1 / 0 / 1. Ignores
|
|
3
|
+
* pre-release + build metadata (sufficient for "min version" checks
|
|
4
|
+
* where we only care about the MAJOR.MINOR.PATCH triple).
|
|
5
|
+
*
|
|
6
|
+
* @param {string} a
|
|
7
|
+
* @param {string} b
|
|
8
|
+
* @returns {-1 | 0 | 1}
|
|
9
|
+
*/
|
|
10
|
+
export function compareVersions(a: string, b: string): -1 | 0 | 1;
|
|
11
|
+
/**
|
|
12
|
+
* util/semver.mjs — shared semver helpers used by route/drift-detect.mjs
|
|
13
|
+
* and util/version-preflight.mjs. Extracted to avoid duplication (QUA-002).
|
|
14
|
+
*/
|
|
15
|
+
/** Semver-shape pattern — mirrors install/update-chips.mjs:64. */
|
|
16
|
+
export const SEMVER_RE: RegExp;
|
|
17
|
+
//# sourceMappingURL=semver.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semver.d.mts","sourceRoot":"","sources":["../../../src/cli/util/semver.mjs"],"names":[],"mappings":"AAQA;;;;;;;;GAQG;AACH,mCAJW,MAAM,KACN,MAAM,GACJ,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAYtB;AA3BD;;;GAGG;AAEH,kEAAkE;AAClE,+BAAmF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* util/semver.mjs — shared semver helpers used by route/drift-detect.mjs
|
|
3
|
+
* and util/version-preflight.mjs. Extracted to avoid duplication (QUA-002).
|
|
4
|
+
*/
|
|
5
|
+
/** Semver-shape pattern — mirrors install/update-chips.mjs:64. */
|
|
6
|
+
export const SEMVER_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
7
|
+
/**
|
|
8
|
+
* Compare two semver-shape strings. Returns -1 / 0 / 1. Ignores
|
|
9
|
+
* pre-release + build metadata (sufficient for "min version" checks
|
|
10
|
+
* where we only care about the MAJOR.MINOR.PATCH triple).
|
|
11
|
+
*
|
|
12
|
+
* @param {string} a
|
|
13
|
+
* @param {string} b
|
|
14
|
+
* @returns {-1 | 0 | 1}
|
|
15
|
+
*/
|
|
16
|
+
export function compareVersions(a, b) {
|
|
17
|
+
const pa = a.split(/[-+]/, 1)[0].split('.').map(Number);
|
|
18
|
+
const pb = b.split(/[-+]/, 1)[0].split('.').map(Number);
|
|
19
|
+
for (let i = 0; i < 3; i++) {
|
|
20
|
+
const av = pa[i] ?? 0;
|
|
21
|
+
const bv = pb[i] ?? 0;
|
|
22
|
+
if (av < bv)
|
|
23
|
+
return -1;
|
|
24
|
+
if (av > bv)
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=semver.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semver.mjs","sourceRoot":"","sources":["../../../src/cli/util/semver.mjs"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,kEAAkE;AAClE,MAAM,CAAC,MAAM,SAAS,GAAG,0DAA0D,CAAA;AAEnF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,CAAC,EAAE,CAAC;IACnC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IACvD,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QACrB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QACrB,IAAI,EAAE,GAAG,EAAE;YAAE,OAAO,CAAC,CAAC,CAAA;QACtB,IAAI,EAAE,GAAG,EAAE;YAAE,OAAO,CAAC,CAAA;IACtB,CAAC;IACD,OAAO,CAAC,CAAA;AACT,CAAC"}
|
|
@@ -1,14 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} SkillInstallSurface
|
|
3
|
+
* @property {string} host Backward-compat host id.
|
|
4
|
+
* @property {string} runtime Canonical runtime id (from RUNTIMES).
|
|
5
|
+
* @property {string} install_root Absolute path of the runtime install root.
|
|
6
|
+
* @property {string} manifest_path Absolute path of apt-file-manifest.json.
|
|
7
|
+
* @property {string|null} legacy_version_file Absolute path of the legacy .apt-version stamp, or null.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Return one install-surface descriptor per runtime in `RUNTIMES`.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} projectDir
|
|
13
|
+
* @returns {SkillInstallSurface[]}
|
|
14
|
+
*/
|
|
15
|
+
export function getSkillInstallSurfaces(projectDir: string): SkillInstallSurface[];
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {Object} SkillInstallState
|
|
18
|
+
* @property {string} host
|
|
19
|
+
* @property {string} runtime
|
|
20
|
+
* @property {string} install_root
|
|
21
|
+
* @property {string} manifest_path
|
|
22
|
+
* @property {string|null} legacy_version_file
|
|
23
|
+
* @property {boolean} installed
|
|
24
|
+
* @property {string|null} installed_version
|
|
25
|
+
* @property {boolean} stale
|
|
26
|
+
* @property {'manifest' | 'manifest-malformed' | 'legacy_version_file' | null} source
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Read each surface's install state. See the file header for the
|
|
30
|
+
* precedence rules.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} projectDir
|
|
33
|
+
* @param {string} frameworkVersion
|
|
34
|
+
* @returns {SkillInstallState[]}
|
|
35
|
+
*/
|
|
36
|
+
export function readSkillInstallState(projectDir: string, frameworkVersion: string): SkillInstallState[];
|
|
37
|
+
export type SkillInstallSurface = {
|
|
38
|
+
/**
|
|
39
|
+
* Backward-compat host id.
|
|
40
|
+
*/
|
|
3
41
|
host: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Canonical runtime id (from RUNTIMES).
|
|
44
|
+
*/
|
|
45
|
+
runtime: string;
|
|
46
|
+
/**
|
|
47
|
+
* Absolute path of the runtime install root.
|
|
48
|
+
*/
|
|
49
|
+
install_root: string;
|
|
50
|
+
/**
|
|
51
|
+
* Absolute path of apt-file-manifest.json.
|
|
52
|
+
*/
|
|
53
|
+
manifest_path: string;
|
|
54
|
+
/**
|
|
55
|
+
* Absolute path of the legacy .apt-version stamp, or null.
|
|
56
|
+
*/
|
|
57
|
+
legacy_version_file: string | null;
|
|
58
|
+
};
|
|
59
|
+
export type SkillInstallState = {
|
|
60
|
+
host: string;
|
|
61
|
+
runtime: string;
|
|
62
|
+
install_root: string;
|
|
63
|
+
manifest_path: string;
|
|
64
|
+
legacy_version_file: string | null;
|
|
7
65
|
installed: boolean;
|
|
8
66
|
installed_version: string | null;
|
|
9
67
|
stale: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
skills_dir: string;
|
|
13
|
-
}[];
|
|
68
|
+
source: "manifest" | "manifest-malformed" | "legacy_version_file" | null;
|
|
69
|
+
};
|
|
14
70
|
//# sourceMappingURL=skill-installs.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill-installs.d.mts","sourceRoot":"","sources":["../../../src/cli/util/skill-installs.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"skill-installs.d.mts","sourceRoot":"","sources":["../../../src/cli/util/skill-installs.mjs"],"names":[],"mappings":"AA+CA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,oDAHW,MAAM,GACJ,mBAAmB,EAAE,CAgBjC;AAED;;;;;;;;;;;GAWG;AAEH;;;;;;;GAOG;AACH,kDAJW,MAAM,oBACN,MAAM,GACJ,iBAAiB,EAAE,CAoD/B;;;;;UApGa,MAAM;;;;aACN,MAAM;;;;kBACN,MAAM;;;;mBACN,MAAM;;;;yBACN,MAAM,GAAC,IAAI;;;UA2BX,MAAM;aACN,MAAM;kBACN,MAAM;mBACN,MAAM;yBACN,MAAM,GAAC,IAAI;eACX,OAAO;uBACP,MAAM,GAAC,IAAI;WACX,OAAO;YACP,UAAU,GAAG,oBAAoB,GAAG,qBAAqB,GAAG,IAAI"}
|
|
@@ -1,34 +1,143 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* skill-installs.mjs — shared skill install surfaces per
|
|
2
|
+
* skill-installs.mjs — shared skill install surfaces per runtime (BUG-022).
|
|
3
|
+
*
|
|
4
|
+
* Source of truth for "what does the framework have installed on this
|
|
5
|
+
* project, per runtime, and is it current?" — the post-022 implementation
|
|
6
|
+
* is manifest-aware:
|
|
7
|
+
*
|
|
8
|
+
* 1. Per surface, prefer `apt-file-manifest.json` (the v0.6.7+ runtime
|
|
9
|
+
* manifest). When present and valid, `framework_version` is the
|
|
10
|
+
* authoritative answer.
|
|
11
|
+
* 2. Manifest present but malformed → reported as `installed: true`,
|
|
12
|
+
* `stale: true`, `source: 'manifest-malformed'`. Don't silently
|
|
13
|
+
* report healthy.
|
|
14
|
+
* 3. Else fall back to `legacy_version_file` (the pre-manifest
|
|
15
|
+
* `.apt-version` stamp; only defined for codex via
|
|
16
|
+
* `LEGACY_INSTALL_PATHS` today). `source: 'legacy_version_file'`.
|
|
17
|
+
* 4. Else → not installed for this surface.
|
|
18
|
+
*
|
|
19
|
+
* The surface array is derived from `RUNTIMES` (single source of truth in
|
|
20
|
+
* `runtime-detect.mjs`) so adding a new runtime there auto-extends every
|
|
21
|
+
* downstream diagnostic. The legacy fallback path is only populated for
|
|
22
|
+
* runtimes that declare a legacy topology in `LEGACY_INSTALL_PATHS`.
|
|
23
|
+
*
|
|
24
|
+
* Backward-compat: `host` field stays `'claude-code'` for the claude
|
|
25
|
+
* runtime (the statusline chip + several other consumers key on this
|
|
26
|
+
* exact string). The new `runtime` field exposes the descriptor id
|
|
27
|
+
* (`'claude'`, `'codex'`, …) for callers that want the canonical name.
|
|
3
28
|
*/
|
|
4
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
29
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
5
30
|
import { join, resolve } from 'node:path';
|
|
31
|
+
import { LEGACY_INSTALL_PATHS } from '../install/legacy-paths.mjs';
|
|
32
|
+
import { MANIFEST_FILENAME, readManifest } from '../install/manifest.mjs';
|
|
33
|
+
import { RUNTIMES } from '../install/runtime-detect.mjs';
|
|
34
|
+
/**
|
|
35
|
+
* Map a runtime descriptor id to the `host` value historical consumers
|
|
36
|
+
* expect. The Claude runtime is the only one with a non-identity mapping
|
|
37
|
+
* (`'claude' → 'claude-code'`) — every other id is its own host string.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} runtimeId
|
|
40
|
+
* @returns {string}
|
|
41
|
+
*/
|
|
42
|
+
function hostFor(runtimeId) {
|
|
43
|
+
return runtimeId === 'claude' ? 'claude-code' : runtimeId;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @typedef {Object} SkillInstallSurface
|
|
47
|
+
* @property {string} host Backward-compat host id.
|
|
48
|
+
* @property {string} runtime Canonical runtime id (from RUNTIMES).
|
|
49
|
+
* @property {string} install_root Absolute path of the runtime install root.
|
|
50
|
+
* @property {string} manifest_path Absolute path of apt-file-manifest.json.
|
|
51
|
+
* @property {string|null} legacy_version_file Absolute path of the legacy .apt-version stamp, or null.
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* Return one install-surface descriptor per runtime in `RUNTIMES`.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} projectDir
|
|
57
|
+
* @returns {SkillInstallSurface[]}
|
|
58
|
+
*/
|
|
6
59
|
export function getSkillInstallSurfaces(projectDir) {
|
|
7
60
|
const root = resolve(projectDir);
|
|
8
|
-
return
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}));
|
|
61
|
+
return RUNTIMES.map((descriptor) => {
|
|
62
|
+
const install_root = join(root, descriptor.installRoot);
|
|
63
|
+
const legacyTopology = LEGACY_INSTALL_PATHS[descriptor.id];
|
|
64
|
+
const legacy_version_file = legacyTopology ? join(root, legacyTopology.version_file) : null;
|
|
65
|
+
return {
|
|
66
|
+
host: hostFor(descriptor.id),
|
|
67
|
+
runtime: descriptor.id,
|
|
68
|
+
install_root,
|
|
69
|
+
manifest_path: join(install_root, MANIFEST_FILENAME),
|
|
70
|
+
legacy_version_file,
|
|
71
|
+
};
|
|
72
|
+
});
|
|
21
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* @typedef {Object} SkillInstallState
|
|
76
|
+
* @property {string} host
|
|
77
|
+
* @property {string} runtime
|
|
78
|
+
* @property {string} install_root
|
|
79
|
+
* @property {string} manifest_path
|
|
80
|
+
* @property {string|null} legacy_version_file
|
|
81
|
+
* @property {boolean} installed
|
|
82
|
+
* @property {string|null} installed_version
|
|
83
|
+
* @property {boolean} stale
|
|
84
|
+
* @property {'manifest' | 'manifest-malformed' | 'legacy_version_file' | null} source
|
|
85
|
+
*/
|
|
86
|
+
/**
|
|
87
|
+
* Read each surface's install state. See the file header for the
|
|
88
|
+
* precedence rules.
|
|
89
|
+
*
|
|
90
|
+
* @param {string} projectDir
|
|
91
|
+
* @param {string} frameworkVersion
|
|
92
|
+
* @returns {SkillInstallState[]}
|
|
93
|
+
*/
|
|
22
94
|
export function readSkillInstallState(projectDir, frameworkVersion) {
|
|
23
95
|
return getSkillInstallSurfaces(projectDir).map((surface) => {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
96
|
+
const manifestExists = existsSync(surface.manifest_path);
|
|
97
|
+
if (manifestExists) {
|
|
98
|
+
const manifest = readManifest(surface.install_root);
|
|
99
|
+
if (manifest && typeof manifest.framework_version === 'string') {
|
|
100
|
+
return {
|
|
101
|
+
...surface,
|
|
102
|
+
installed: true,
|
|
103
|
+
installed_version: manifest.framework_version,
|
|
104
|
+
stale: manifest.framework_version !== frameworkVersion,
|
|
105
|
+
source: /** @type {const} */ ('manifest'),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
// Manifest file present but parser rejected it (malformed JSON,
|
|
109
|
+
// missing required fields, …). Don't silently report healthy.
|
|
110
|
+
return {
|
|
111
|
+
...surface,
|
|
112
|
+
installed: true,
|
|
113
|
+
installed_version: null,
|
|
114
|
+
stale: true,
|
|
115
|
+
source: /** @type {const} */ ('manifest-malformed'),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (surface.legacy_version_file && existsSync(surface.legacy_version_file)) {
|
|
119
|
+
try {
|
|
120
|
+
if (statSync(surface.legacy_version_file).isFile()) {
|
|
121
|
+
const version = readFileSync(surface.legacy_version_file, 'utf-8').trim();
|
|
122
|
+
return {
|
|
123
|
+
...surface,
|
|
124
|
+
installed: true,
|
|
125
|
+
installed_version: version,
|
|
126
|
+
stale: version !== frameworkVersion,
|
|
127
|
+
source: /** @type {const} */ ('legacy_version_file'),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
/* fall through to "not installed" */
|
|
133
|
+
}
|
|
134
|
+
}
|
|
27
135
|
return {
|
|
28
136
|
...surface,
|
|
29
|
-
installed:
|
|
30
|
-
installed_version,
|
|
31
|
-
stale:
|
|
137
|
+
installed: false,
|
|
138
|
+
installed_version: null,
|
|
139
|
+
stale: false,
|
|
140
|
+
source: null,
|
|
32
141
|
};
|
|
33
142
|
});
|
|
34
143
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill-installs.mjs","sourceRoot":"","sources":["../../../src/cli/util/skill-installs.mjs"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"skill-installs.mjs","sourceRoot":"","sources":["../../../src/cli/util/skill-installs.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAExD;;;;;;;GAOG;AACH,SAAS,OAAO,CAAC,SAAS;IACzB,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAA;AAC1D,CAAC;AAED;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,UAAU;IACjD,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAChC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;QAClC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,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