@haaaiawd/anws 2.2.1 → 2.2.2

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.
Files changed (28) hide show
  1. package/README.md +180 -367
  2. package/bin/cli.js +112 -112
  3. package/lib/changelog.js +258 -258
  4. package/lib/copy.js +116 -109
  5. package/lib/diff.js +11 -0
  6. package/lib/manifest.js +212 -210
  7. package/lib/update.js +319 -319
  8. package/package.json +2 -1
  9. package/templates/.agents/skills/anws-system/SKILL.md +9 -7
  10. package/templates/.agents/skills/code-reviewer/SKILL.md +102 -327
  11. package/templates/.agents/skills/concept-modeler/SKILL.md +19 -17
  12. package/templates/.agents/skills/craft-authoring/SKILL.md +123 -0
  13. package/templates/.agents/skills/e2e-testing-guide/SKILL.md +59 -0
  14. package/templates/.agents/skills/system-designer/SKILL.md +6 -6
  15. package/templates/.agents/skills/system-designer/references/system-design-template.md +17 -17
  16. package/templates/.agents/skills/task-planner/SKILL.md +113 -113
  17. package/templates/.agents/skills/task-planner/references/TASK_TEMPLATE.md +82 -82
  18. package/templates/.agents/workflows/blueprint.md +284 -284
  19. package/templates/.agents/workflows/challenge.md +450 -491
  20. package/templates/.agents/workflows/change.md +263 -286
  21. package/templates/.agents/workflows/craft.md +243 -664
  22. package/templates/.agents/workflows/design-system.md +624 -624
  23. package/templates/.agents/workflows/explore.md +400 -371
  24. package/templates/.agents/workflows/forge.md +444 -413
  25. package/templates/.agents/workflows/genesis.md +342 -395
  26. package/templates/.agents/workflows/probe.md +21 -16
  27. package/templates/.agents/workflows/quickstart.md +123 -138
  28. package/templates/AGENTS.md +149 -134
package/lib/manifest.js CHANGED
@@ -1,210 +1,212 @@
1
- 'use strict';
2
-
3
- const { getTarget } = require('./adapters');
4
-
5
- /**
6
- * MANAGED_FILES — anws 托管文件清单
7
- *
8
- * 此数组列出 anws 包负责管理的所有文件路径(相对于目标项目根目录)。
9
- */
10
- const RESOURCE_REGISTRY = [
11
- { id: 'blueprint', type: 'workflow', source: '.agents/workflows/blueprint.md', fileName: 'blueprint.md' },
12
- { id: 'challenge', type: 'workflow', source: '.agents/workflows/challenge.md', fileName: 'challenge.md' },
13
- { id: 'change', type: 'workflow', source: '.agents/workflows/change.md', fileName: 'change.md' },
14
- { id: 'craft', type: 'workflow', source: '.agents/workflows/craft.md', fileName: 'craft.md' },
15
- { id: 'design-system', type: 'workflow', source: '.agents/workflows/design-system.md', fileName: 'design-system.md' },
16
- { id: 'explore', type: 'workflow', source: '.agents/workflows/explore.md', fileName: 'explore.md' },
17
- { id: 'forge', type: 'workflow', source: '.agents/workflows/forge.md', fileName: 'forge.md' },
18
- { id: 'genesis', type: 'workflow', source: '.agents/workflows/genesis.md', fileName: 'genesis.md' },
19
- { id: 'probe', type: 'workflow', source: '.agents/workflows/probe.md', fileName: 'probe.md' },
20
- { id: 'quickstart', type: 'workflow', source: '.agents/workflows/quickstart.md', fileName: 'quickstart.md' },
21
- { id: 'upgrade', type: 'workflow', source: '.agents/workflows/upgrade.md', fileName: 'upgrade.md' },
22
- { id: 'anws-system', type: 'skill', source: '.agents/skills/anws-system/SKILL.md', fileName: 'anws-system/SKILL.md', targets: ['codex', 'trae'] },
23
- { id: 'concept-modeler', type: 'skill', source: '.agents/skills/concept-modeler/SKILL.md', fileName: 'concept-modeler/SKILL.md' },
24
- { id: 'code-reviewer', type: 'skill', source: '.agents/skills/code-reviewer/SKILL.md', fileName: 'code-reviewer/SKILL.md' },
25
- { id: 'design-reviewer', type: 'skill', source: '.agents/skills/design-reviewer/SKILL.md', fileName: 'design-reviewer/SKILL.md' },
26
- { id: 'nexus-mapper', type: 'skill', source: '.agents/skills/nexus-mapper/SKILL.md', fileName: 'nexus-mapper/SKILL.md' },
27
- { id: 'nexus-mapper-language-customization', type: 'skill', source: '.agents/skills/nexus-mapper/references/language-customization.md', fileName: 'nexus-mapper/references/language-customization.md' },
28
- { id: 'nexus-mapper-output-schema', type: 'skill', source: '.agents/skills/nexus-mapper/references/output-schema.md', fileName: 'nexus-mapper/references/output-schema.md' },
29
- { id: 'nexus-mapper-probe-protocol', type: 'skill', source: '.agents/skills/nexus-mapper/references/probe-protocol.md', fileName: 'nexus-mapper/references/probe-protocol.md' },
30
- { id: 'nexus-mapper-extract-ast', type: 'skill', source: '.agents/skills/nexus-mapper/scripts/extract_ast.py', fileName: 'nexus-mapper/scripts/extract_ast.py' },
31
- { id: 'nexus-mapper-git-detective', type: 'skill', source: '.agents/skills/nexus-mapper/scripts/git_detective.py', fileName: 'nexus-mapper/scripts/git_detective.py' },
32
- { id: 'nexus-mapper-languages', type: 'skill', source: '.agents/skills/nexus-mapper/scripts/languages.json', fileName: 'nexus-mapper/scripts/languages.json' },
33
- { id: 'nexus-mapper-query-graph', type: 'skill', source: '.agents/skills/nexus-mapper/scripts/query_graph.py', fileName: 'nexus-mapper/scripts/query_graph.py' },
34
- { id: 'nexus-mapper-requirements', type: 'skill', source: '.agents/skills/nexus-mapper/scripts/requirements.txt', fileName: 'nexus-mapper/scripts/requirements.txt' },
35
- { id: 'report-template', type: 'skill', source: '.agents/skills/report-template/SKILL.md', fileName: 'report-template/SKILL.md' },
36
- { id: 'report-template-reference', type: 'skill', source: '.agents/skills/report-template/references/REPORT_TEMPLATE.md', fileName: 'report-template/references/REPORT_TEMPLATE.md' },
37
- { id: 'runtime-inspector', type: 'skill', source: '.agents/skills/runtime-inspector/SKILL.md', fileName: 'runtime-inspector/SKILL.md' },
38
- { id: 'sequential-thinking', type: 'skill', source: '.agents/skills/sequential-thinking/SKILL.md', fileName: 'sequential-thinking/SKILL.md' },
39
- { id: 'spec-writer', type: 'skill', source: '.agents/skills/spec-writer/SKILL.md', fileName: 'spec-writer/SKILL.md' },
40
- { id: 'spec-writer-prd-template', type: 'skill', source: '.agents/skills/spec-writer/references/prd_template.md', fileName: 'spec-writer/references/prd_template.md' },
41
- { id: 'system-architect', type: 'skill', source: '.agents/skills/system-architect/SKILL.md', fileName: 'system-architect/SKILL.md' },
42
- { id: 'system-architect-rfc-template', type: 'skill', source: '.agents/skills/system-architect/references/rfc_template.md', fileName: 'system-architect/references/rfc_template.md' },
43
- { id: 'system-designer', type: 'skill', source: '.agents/skills/system-designer/SKILL.md', fileName: 'system-designer/SKILL.md' },
44
- { id: 'system-designer-detail-template', type: 'skill', source: '.agents/skills/system-designer/references/system-design-detail-template.md', fileName: 'system-designer/references/system-design-detail-template.md' },
45
- { id: 'system-designer-template', type: 'skill', source: '.agents/skills/system-designer/references/system-design-template.md', fileName: 'system-designer/references/system-design-template.md' },
46
- { id: 'task-planner', type: 'skill', source: '.agents/skills/task-planner/SKILL.md', fileName: 'task-planner/SKILL.md' },
47
- { id: 'task-planner-template', type: 'skill', source: '.agents/skills/task-planner/references/TASK_TEMPLATE.md', fileName: 'task-planner/references/TASK_TEMPLATE.md' },
48
- { id: 'task-reviewer', type: 'skill', source: '.agents/skills/task-reviewer/SKILL.md', fileName: 'task-reviewer/SKILL.md' },
49
- { id: 'tech-evaluator', type: 'skill', source: '.agents/skills/tech-evaluator/SKILL.md', fileName: 'tech-evaluator/SKILL.md' },
50
- { id: 'tech-evaluator-adr-template', type: 'skill', source: '.agents/skills/tech-evaluator/references/ADR_TEMPLATE.md', fileName: 'tech-evaluator/references/ADR_TEMPLATE.md' }
51
- ];
52
-
53
- function toArray(value) {
54
- return Array.isArray(value) ? value : [value];
55
- }
56
-
57
- function toProjectionFileName(resource, projectionType, targetId) {
58
- if ((targetId === 'codex' || targetId === 'trae') && projectionType === 'skills' && resource.type === 'workflow') {
59
- return `anws-system/references/${resource.id}.md`;
60
- }
61
- if (projectionType === 'commands') {
62
- return `${resource.id}.md`;
63
- }
64
- if (projectionType === 'prompts') {
65
- return targetId === 'copilot' ? `${resource.id}.prompt.md` : `${resource.id}.md`;
66
- }
67
- if (projectionType === 'agents') {
68
- return `${resource.id}.md`;
69
- }
70
- return resource.fileName;
71
- }
72
-
73
- function buildProjectionEntries(targetId) {
74
- const target = getTarget(targetId);
75
- const typeMap = target.projectionTypes;
76
-
77
- return RESOURCE_REGISTRY.flatMap((resource) => {
78
- if (resource.targets && !resource.targets.includes(target.id)) {
79
- return [];
80
- }
81
- const projectionTypes = typeMap[resource.type];
82
- if (!projectionTypes) {
83
- return [];
84
- }
85
-
86
- return toArray(projectionTypes).map((projectionType) => {
87
- const outputFileName = toProjectionFileName(resource, projectionType, target.id);
88
- return {
89
- ...resource,
90
- projectionType,
91
- outputRoot: target.projections[projectionType],
92
- outputPath: `${target.projections[projectionType]}/${outputFileName}`
93
- };
94
- });
95
- });
96
- }
97
-
98
- function buildManagedManifest(targetIds = ['antigravity']) {
99
- return toArray(targetIds).flatMap((targetId) => {
100
- const target = getTarget(targetId);
101
- const entries = buildProjectionEntries(target.id).map((entry) => ({
102
- ...entry,
103
- targetId: target.id,
104
- targetLabel: target.label,
105
- ownershipKey: `${target.id}:${entry.outputPath}`
106
- }));
107
-
108
- if (!target.rootAgentFile) {
109
- return entries;
110
- }
111
-
112
- return [
113
- {
114
- id: 'root-agents',
115
- type: 'root',
116
- source: 'AGENTS.md',
117
- fileName: 'AGENTS.md',
118
- projectionType: 'rootAgentFile',
119
- outputRoot: '.',
120
- outputPath: 'AGENTS.md',
121
- targetId: target.id,
122
- targetLabel: target.label,
123
- ownershipKey: `${target.id}:AGENTS.md`
124
- },
125
- ...entries
126
- ];
127
- });
128
- }
129
-
130
- function buildProjectionPlan(targetIds = ['antigravity'], resources = RESOURCE_REGISTRY) {
131
- return toArray(targetIds).map((targetId) => {
132
- const target = getTarget(targetId);
133
- const typeMap = target.projectionTypes;
134
- const projectionEntries = resources.flatMap((resource) => {
135
- if (resource.targets && !resource.targets.includes(target.id)) {
136
- return [];
137
- }
138
- const projectionTypes = typeMap[resource.type];
139
- if (!projectionTypes) {
140
- return [];
141
- }
142
-
143
- return toArray(projectionTypes).map((projectionType) => {
144
- const outputFileName = toProjectionFileName(resource, projectionType, target.id);
145
- const outputPath = `${target.projections[projectionType]}/${outputFileName}`;
146
- return {
147
- ...resource,
148
- projectionType,
149
- outputRoot: target.projections[projectionType],
150
- outputPath,
151
- targetId: target.id,
152
- targetLabel: target.label,
153
- ownershipKey: `${target.id}:${outputPath}`
154
- };
155
- });
156
- });
157
-
158
- const managedFiles = target.rootAgentFile
159
- ? ['AGENTS.md', ...projectionEntries.map((item) => item.outputPath)]
160
- : projectionEntries.map((item) => item.outputPath);
161
-
162
- return {
163
- target,
164
- targetId: target.id,
165
- targetLabel: target.label,
166
- managedFiles,
167
- userProtectedFiles: buildUserProtectedFiles(target.id),
168
- projectionEntries,
169
- ownership: projectionEntries.map((item) => item.ownershipKey)
170
- };
171
- });
172
- }
173
-
174
- function buildManagedFiles(targetId = 'antigravity') {
175
- return buildManagedManifest(targetId).map((item) => item.outputPath);
176
- }
177
-
178
- function buildUserProtectedFiles(targetId = 'antigravity') {
179
- const target = getTarget(targetId);
180
- return target.rootAgentFile ? ['AGENTS.md'] : [];
181
- }
182
-
183
- function findByType(type) {
184
- return RESOURCE_REGISTRY.filter((item) => item.type === type);
185
- }
186
-
187
- const MANAGED_FILES = buildManagedFiles('antigravity');
188
-
189
- /**
190
- * USER_PROTECTED_FILES — 用户保护文件
191
- *
192
- * 这些文件在项目初始化后通常会包含特定于项目的配置。
193
- * anws update 默认会跳过这些文件。
194
- */
195
- const USER_PROTECTED_FILES = buildUserProtectedFiles('antigravity');
196
-
197
- module.exports = {
198
- RESOURCE_REGISTRY,
199
- buildManagedManifest,
200
- buildProjectionPlan,
201
- buildManagedFiles,
202
- buildProjectionEntries,
203
- buildUserProtectedFiles,
204
- findByType,
205
- MANAGED_FILES,
206
- USER_PROTECTED_FILES
207
- };
208
-
209
-
210
-
1
+ 'use strict';
2
+
3
+ const { getTarget } = require('./adapters');
4
+
5
+ /**
6
+ * MANAGED_FILES — anws 托管文件清单
7
+ *
8
+ * 此数组列出 anws 包负责管理的所有文件路径(相对于目标项目根目录)。
9
+ */
10
+ const RESOURCE_REGISTRY = [
11
+ { id: 'blueprint', type: 'workflow', source: '.agents/workflows/blueprint.md', fileName: 'blueprint.md' },
12
+ { id: 'challenge', type: 'workflow', source: '.agents/workflows/challenge.md', fileName: 'challenge.md' },
13
+ { id: 'change', type: 'workflow', source: '.agents/workflows/change.md', fileName: 'change.md' },
14
+ { id: 'craft', type: 'workflow', source: '.agents/workflows/craft.md', fileName: 'craft.md' },
15
+ { id: 'design-system', type: 'workflow', source: '.agents/workflows/design-system.md', fileName: 'design-system.md' },
16
+ { id: 'explore', type: 'workflow', source: '.agents/workflows/explore.md', fileName: 'explore.md' },
17
+ { id: 'forge', type: 'workflow', source: '.agents/workflows/forge.md', fileName: 'forge.md' },
18
+ { id: 'genesis', type: 'workflow', source: '.agents/workflows/genesis.md', fileName: 'genesis.md' },
19
+ { id: 'probe', type: 'workflow', source: '.agents/workflows/probe.md', fileName: 'probe.md' },
20
+ { id: 'quickstart', type: 'workflow', source: '.agents/workflows/quickstart.md', fileName: 'quickstart.md' },
21
+ { id: 'upgrade', type: 'workflow', source: '.agents/workflows/upgrade.md', fileName: 'upgrade.md' },
22
+ { id: 'anws-system', type: 'skill', source: '.agents/skills/anws-system/SKILL.md', fileName: 'anws-system/SKILL.md', targets: ['codex', 'trae'] },
23
+ { id: 'concept-modeler', type: 'skill', source: '.agents/skills/concept-modeler/SKILL.md', fileName: 'concept-modeler/SKILL.md' },
24
+ { id: 'code-reviewer', type: 'skill', source: '.agents/skills/code-reviewer/SKILL.md', fileName: 'code-reviewer/SKILL.md' },
25
+ { id: 'design-reviewer', type: 'skill', source: '.agents/skills/design-reviewer/SKILL.md', fileName: 'design-reviewer/SKILL.md' },
26
+ { id: 'nexus-mapper', type: 'skill', source: '.agents/skills/nexus-mapper/SKILL.md', fileName: 'nexus-mapper/SKILL.md' },
27
+ { id: 'nexus-mapper-language-customization', type: 'skill', source: '.agents/skills/nexus-mapper/references/language-customization.md', fileName: 'nexus-mapper/references/language-customization.md' },
28
+ { id: 'nexus-mapper-output-schema', type: 'skill', source: '.agents/skills/nexus-mapper/references/output-schema.md', fileName: 'nexus-mapper/references/output-schema.md' },
29
+ { id: 'nexus-mapper-probe-protocol', type: 'skill', source: '.agents/skills/nexus-mapper/references/probe-protocol.md', fileName: 'nexus-mapper/references/probe-protocol.md' },
30
+ { id: 'nexus-mapper-extract-ast', type: 'skill', source: '.agents/skills/nexus-mapper/scripts/extract_ast.py', fileName: 'nexus-mapper/scripts/extract_ast.py' },
31
+ { id: 'nexus-mapper-git-detective', type: 'skill', source: '.agents/skills/nexus-mapper/scripts/git_detective.py', fileName: 'nexus-mapper/scripts/git_detective.py' },
32
+ { id: 'nexus-mapper-languages', type: 'skill', source: '.agents/skills/nexus-mapper/scripts/languages.json', fileName: 'nexus-mapper/scripts/languages.json' },
33
+ { id: 'nexus-mapper-query-graph', type: 'skill', source: '.agents/skills/nexus-mapper/scripts/query_graph.py', fileName: 'nexus-mapper/scripts/query_graph.py' },
34
+ { id: 'nexus-mapper-requirements', type: 'skill', source: '.agents/skills/nexus-mapper/scripts/requirements.txt', fileName: 'nexus-mapper/scripts/requirements.txt' },
35
+ { id: 'report-template', type: 'skill', source: '.agents/skills/report-template/SKILL.md', fileName: 'report-template/SKILL.md' },
36
+ { id: 'report-template-reference', type: 'skill', source: '.agents/skills/report-template/references/REPORT_TEMPLATE.md', fileName: 'report-template/references/REPORT_TEMPLATE.md' },
37
+ { id: 'runtime-inspector', type: 'skill', source: '.agents/skills/runtime-inspector/SKILL.md', fileName: 'runtime-inspector/SKILL.md' },
38
+ { id: 'sequential-thinking', type: 'skill', source: '.agents/skills/sequential-thinking/SKILL.md', fileName: 'sequential-thinking/SKILL.md' },
39
+ { id: 'spec-writer', type: 'skill', source: '.agents/skills/spec-writer/SKILL.md', fileName: 'spec-writer/SKILL.md' },
40
+ { id: 'spec-writer-prd-template', type: 'skill', source: '.agents/skills/spec-writer/references/prd_template.md', fileName: 'spec-writer/references/prd_template.md' },
41
+ { id: 'system-architect', type: 'skill', source: '.agents/skills/system-architect/SKILL.md', fileName: 'system-architect/SKILL.md' },
42
+ { id: 'system-architect-rfc-template', type: 'skill', source: '.agents/skills/system-architect/references/rfc_template.md', fileName: 'system-architect/references/rfc_template.md' },
43
+ { id: 'system-designer', type: 'skill', source: '.agents/skills/system-designer/SKILL.md', fileName: 'system-designer/SKILL.md' },
44
+ { id: 'system-designer-detail-template', type: 'skill', source: '.agents/skills/system-designer/references/system-design-detail-template.md', fileName: 'system-designer/references/system-design-detail-template.md' },
45
+ { id: 'system-designer-template', type: 'skill', source: '.agents/skills/system-designer/references/system-design-template.md', fileName: 'system-designer/references/system-design-template.md' },
46
+ { id: 'task-planner', type: 'skill', source: '.agents/skills/task-planner/SKILL.md', fileName: 'task-planner/SKILL.md' },
47
+ { id: 'task-planner-template', type: 'skill', source: '.agents/skills/task-planner/references/TASK_TEMPLATE.md', fileName: 'task-planner/references/TASK_TEMPLATE.md' },
48
+ { id: 'task-reviewer', type: 'skill', source: '.agents/skills/task-reviewer/SKILL.md', fileName: 'task-reviewer/SKILL.md' },
49
+ { id: 'tech-evaluator', type: 'skill', source: '.agents/skills/tech-evaluator/SKILL.md', fileName: 'tech-evaluator/SKILL.md' },
50
+ { id: 'tech-evaluator-adr-template', type: 'skill', source: '.agents/skills/tech-evaluator/references/ADR_TEMPLATE.md', fileName: 'tech-evaluator/references/ADR_TEMPLATE.md' },
51
+ { id: 'e2e-testing-guide', type: 'skill', source: '.agents/skills/e2e-testing-guide/SKILL.md', fileName: 'e2e-testing-guide/SKILL.md' },
52
+ { id: 'craft-authoring', type: 'skill', source: '.agents/skills/craft-authoring/SKILL.md', fileName: 'craft-authoring/SKILL.md' }
53
+ ];
54
+
55
+ function toArray(value) {
56
+ return Array.isArray(value) ? value : [value];
57
+ }
58
+
59
+ function toProjectionFileName(resource, projectionType, targetId) {
60
+ if ((targetId === 'codex' || targetId === 'trae') && projectionType === 'skills' && resource.type === 'workflow') {
61
+ return `anws-system/references/${resource.id}.md`;
62
+ }
63
+ if (projectionType === 'commands') {
64
+ return `${resource.id}.md`;
65
+ }
66
+ if (projectionType === 'prompts') {
67
+ return targetId === 'copilot' ? `${resource.id}.prompt.md` : `${resource.id}.md`;
68
+ }
69
+ if (projectionType === 'agents') {
70
+ return `${resource.id}.md`;
71
+ }
72
+ return resource.fileName;
73
+ }
74
+
75
+ function buildProjectionEntries(targetId) {
76
+ const target = getTarget(targetId);
77
+ const typeMap = target.projectionTypes;
78
+
79
+ return RESOURCE_REGISTRY.flatMap((resource) => {
80
+ if (resource.targets && !resource.targets.includes(target.id)) {
81
+ return [];
82
+ }
83
+ const projectionTypes = typeMap[resource.type];
84
+ if (!projectionTypes) {
85
+ return [];
86
+ }
87
+
88
+ return toArray(projectionTypes).map((projectionType) => {
89
+ const outputFileName = toProjectionFileName(resource, projectionType, target.id);
90
+ return {
91
+ ...resource,
92
+ projectionType,
93
+ outputRoot: target.projections[projectionType],
94
+ outputPath: `${target.projections[projectionType]}/${outputFileName}`
95
+ };
96
+ });
97
+ });
98
+ }
99
+
100
+ function buildManagedManifest(targetIds = ['antigravity']) {
101
+ return toArray(targetIds).flatMap((targetId) => {
102
+ const target = getTarget(targetId);
103
+ const entries = buildProjectionEntries(target.id).map((entry) => ({
104
+ ...entry,
105
+ targetId: target.id,
106
+ targetLabel: target.label,
107
+ ownershipKey: `${target.id}:${entry.outputPath}`
108
+ }));
109
+
110
+ if (!target.rootAgentFile) {
111
+ return entries;
112
+ }
113
+
114
+ return [
115
+ {
116
+ id: 'root-agents',
117
+ type: 'root',
118
+ source: 'AGENTS.md',
119
+ fileName: 'AGENTS.md',
120
+ projectionType: 'rootAgentFile',
121
+ outputRoot: '.',
122
+ outputPath: 'AGENTS.md',
123
+ targetId: target.id,
124
+ targetLabel: target.label,
125
+ ownershipKey: `${target.id}:AGENTS.md`
126
+ },
127
+ ...entries
128
+ ];
129
+ });
130
+ }
131
+
132
+ function buildProjectionPlan(targetIds = ['antigravity'], resources = RESOURCE_REGISTRY) {
133
+ return toArray(targetIds).map((targetId) => {
134
+ const target = getTarget(targetId);
135
+ const typeMap = target.projectionTypes;
136
+ const projectionEntries = resources.flatMap((resource) => {
137
+ if (resource.targets && !resource.targets.includes(target.id)) {
138
+ return [];
139
+ }
140
+ const projectionTypes = typeMap[resource.type];
141
+ if (!projectionTypes) {
142
+ return [];
143
+ }
144
+
145
+ return toArray(projectionTypes).map((projectionType) => {
146
+ const outputFileName = toProjectionFileName(resource, projectionType, target.id);
147
+ const outputPath = `${target.projections[projectionType]}/${outputFileName}`;
148
+ return {
149
+ ...resource,
150
+ projectionType,
151
+ outputRoot: target.projections[projectionType],
152
+ outputPath,
153
+ targetId: target.id,
154
+ targetLabel: target.label,
155
+ ownershipKey: `${target.id}:${outputPath}`
156
+ };
157
+ });
158
+ });
159
+
160
+ const managedFiles = target.rootAgentFile
161
+ ? ['AGENTS.md', ...projectionEntries.map((item) => item.outputPath)]
162
+ : projectionEntries.map((item) => item.outputPath);
163
+
164
+ return {
165
+ target,
166
+ targetId: target.id,
167
+ targetLabel: target.label,
168
+ managedFiles,
169
+ userProtectedFiles: buildUserProtectedFiles(target.id),
170
+ projectionEntries,
171
+ ownership: projectionEntries.map((item) => item.ownershipKey)
172
+ };
173
+ });
174
+ }
175
+
176
+ function buildManagedFiles(targetId = 'antigravity') {
177
+ return buildManagedManifest(targetId).map((item) => item.outputPath);
178
+ }
179
+
180
+ function buildUserProtectedFiles(targetId = 'antigravity') {
181
+ const target = getTarget(targetId);
182
+ return target.rootAgentFile ? ['AGENTS.md'] : [];
183
+ }
184
+
185
+ function findByType(type) {
186
+ return RESOURCE_REGISTRY.filter((item) => item.type === type);
187
+ }
188
+
189
+ const MANAGED_FILES = buildManagedFiles('antigravity');
190
+
191
+ /**
192
+ * USER_PROTECTED_FILES — 用户保护文件
193
+ *
194
+ * 这些文件在项目初始化后通常会包含特定于项目的配置。
195
+ * anws update 默认会跳过这些文件。
196
+ */
197
+ const USER_PROTECTED_FILES = buildUserProtectedFiles('antigravity');
198
+
199
+ module.exports = {
200
+ RESOURCE_REGISTRY,
201
+ buildManagedManifest,
202
+ buildProjectionPlan,
203
+ buildManagedFiles,
204
+ buildProjectionEntries,
205
+ buildUserProtectedFiles,
206
+ findByType,
207
+ MANAGED_FILES,
208
+ USER_PROTECTED_FILES
209
+ };
210
+
211
+
212
+