@haaaiawd/anws 2.2.1 → 2.2.3

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 (41) hide show
  1. package/README.md +39 -226
  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 +3 -1
  7. package/lib/update.js +319 -319
  8. package/package.json +2 -1
  9. package/templates/.agents/skills/anws-system/SKILL.md +108 -106
  10. package/templates/.agents/skills/code-reviewer/SKILL.md +63 -288
  11. package/templates/.agents/skills/concept-modeler/SKILL.md +179 -176
  12. package/templates/.agents/skills/craft-authoring/SKILL.md +123 -0
  13. package/templates/.agents/skills/design-reviewer/SKILL.md +190 -176
  14. package/templates/.agents/skills/e2e-testing-guide/SKILL.md +204 -0
  15. package/templates/.agents/skills/nexus-mapper/SKILL.md +321 -306
  16. package/templates/.agents/skills/report-template/SKILL.md +92 -85
  17. package/templates/.agents/skills/runtime-inspector/SKILL.md +12 -12
  18. package/templates/.agents/skills/sequential-thinking/SKILL.md +225 -216
  19. package/templates/.agents/skills/spec-writer/SKILL.md +9 -9
  20. package/templates/.agents/skills/spec-writer/references/prd_template.md +6 -6
  21. package/templates/.agents/skills/system-architect/SKILL.md +678 -620
  22. package/templates/.agents/skills/system-designer/SKILL.md +599 -532
  23. package/templates/.agents/skills/system-designer/references/system-design-detail-template.md +5 -5
  24. package/templates/.agents/skills/system-designer/references/system-design-template.md +45 -45
  25. package/templates/.agents/skills/task-planner/SKILL.md +601 -531
  26. package/templates/.agents/skills/task-planner/references/TASK_TEMPLATE.md +97 -97
  27. package/templates/.agents/skills/task-reviewer/SKILL.md +388 -363
  28. package/templates/.agents/skills/tech-evaluator/SKILL.md +144 -135
  29. package/templates/.agents/skills/tech-evaluator/references/ADR_TEMPLATE.md +80 -78
  30. package/templates/.agents/workflows/blueprint.md +130 -130
  31. package/templates/.agents/workflows/challenge.md +450 -491
  32. package/templates/.agents/workflows/change.md +215 -238
  33. package/templates/.agents/workflows/craft.md +243 -664
  34. package/templates/.agents/workflows/design-system.md +32 -32
  35. package/templates/.agents/workflows/explore.md +78 -49
  36. package/templates/.agents/workflows/forge.md +455 -422
  37. package/templates/.agents/workflows/genesis.md +127 -180
  38. package/templates/.agents/workflows/probe.md +243 -238
  39. package/templates/.agents/workflows/quickstart.md +23 -38
  40. package/templates/.agents/workflows/upgrade.md +10 -10
  41. package/templates/AGENTS.md +49 -34
package/README.md CHANGED
@@ -1,9 +1,10 @@
1
+
1
2
  <div align="center">
2
3
 
3
4
  <img src="assets/logo-cli.png" width="260" alt="Anws">
4
5
 
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
- [![Version](https://img.shields.io/badge/version-v2.2.1-7FB5B6)](https://github.com/Haaaiawd/ANWS/releases)
6
+ [![License: MIT](https://opensource.org/licenses/MIT)](https://opensource.org/licenses/MIT)
7
+ [![Version](https://img.shields.io/badge/version-v2.2.2-7FB5B6)](https://github.com/Haaaiawd/ANWS/releases)
7
8
  [![Targets](https://img.shields.io/badge/Targets-Windsurf%20%7C%20Claude%20Code%20%7C%20Copilot%20%7C%20Cursor%20%7C%20Codex%20Preview%20%7C%20OpenCode%20%7C%20Trae%20%7C%20Qoder%20%7C%20Kilo%20Code-blueviolet)](https://github.com/Haaaiawd/ANWS)
8
9
 
9
10
  [English](./README.md) | [中文](./README_CN.md)
@@ -39,13 +40,10 @@ Modern AI coding sessions fail in predictable ways:
39
40
 
40
41
  - **Architecture drift**
41
42
  - different sessions generate incompatible structures
42
-
43
43
  - **Context amnesia**
44
44
  - a fresh chat loses system decisions, trade-offs, and task state
45
-
46
45
  - **Planning collapse**
47
46
  - code gets written before requirements and interfaces are stabilized
48
-
49
47
  - **Unsafe upgrades**
50
48
  - workflow files change over time, but existing projects cannot be updated cleanly
51
49
 
@@ -58,79 +56,13 @@ Anws addresses those problems with:
58
56
 
59
57
  ---
60
58
 
61
- ## What's New in v2.2.0
59
+ ## What's New in v2.2.2
62
60
 
63
- `v2.2.0` closes the loop between design review, task review, implementation, and upgrade safety.
61
+ **v2.2.2** centers the **`/forge`** chain: **`/forge` AUTO** keeps checkpoint ceremony with **`AUTO`** signatures; **`code-reviewer`** follows **wave cadence** (typically **once per wave** at the wave’s last task, with a **~2–3 wave** catch-up if long skipped—not after every task by default); **`e2e-testing-guide`** is **guide first**, then live browser steps when tooling exists—otherwise **guide-only**, never claim “tested” without evidence. **`/change`** handles doc/task backflow only—it **does not run `code-reviewer`** (static fidelity stays in **`/forge` §3.4.5** and **`/challenge`**).
64
62
 
65
- - **Closed-loop challenge review**
66
- - `/challenge` now combines `design-reviewer`, `task-reviewer`, and `code-reviewer`
67
- - implementation drift is reviewed against PRD, Architecture, ADR, System Design, and `05_TASKS.md`
68
- - findings are written into `07_CHALLENGE_REPORT.md` with contract-first severity semantics
63
+ **v2.2.0** shipped closed-loop **challenge**, explicit contract closure, **`code-reviewer`** as static evidence, forge challenge-report gates, and **`e2e-testing-guide`**. Full history: **[RELEASE_NOTES.md](../RELEASE_NOTES.md)** · [GitHub Releases](https://github.com/Haaaiawd/ANWS/releases).
69
64
 
70
- - **Code fidelity evidence layer**
71
- - new `code-reviewer` skill checks Contract Drift, Task Drift, Test Drift, Missing Change Backflow, and foundational test gaps
72
- - the review is static and evidence-based, so it does not pretend runtime validation has passed
73
-
74
- - **Contract closure across workflows**
75
- - `blueprint`, `task-planner`, `task-reviewer`, `challenge`, `change`, and `forge` now carry public contract coverage explicitly
76
- - API, CLI, config, file format, error, persistence, and verification responsibilities are tracked as first-class workflow concerns
77
-
78
- - **Forge verification gate**
79
- - `/forge` reads the latest `07_CHALLENGE_REPORT.md` before implementation work continues
80
- - unresolved Critical findings block forge; unresolved High findings require explicit human sign-off
81
- - high-risk implementation waves can run `code-reviewer` before manual verification
82
-
83
- ---
84
-
85
- ## What's New in v2.0.0
86
-
87
- `v2.0.0` is a **major release**. It is not just a template refresh; it upgrades the project protocol.
88
-
89
- - **Unified architecture root**
90
- - move from split legacy roots to `.anws/`
91
- - standardize versioned docs and changelog storage
92
-
93
- - **Controlled `AGENTS.md` updates**
94
- - marker-based merge for modern files
95
- - automatic migration for recognized legacy files
96
- - safe preservation for unrecognized legacy files
97
-
98
- - **Multi-target projection model**
99
- - one canonical source
100
- - multiple target IDE layouts
101
- - no fake sharing of physical files across targets
102
-
103
- - **Codex projection strategy update**
104
- - Codex is now treated as **Preview**
105
- - because Codex prompts are no longer available, Anws now packages workflow guidance into `.codex/skills/anws-system/`
106
- - `SKILL.md` is the navigation shell for the bundle
107
- - workflow details, including `/quickstart`, now live under `references/*.md`
108
-
109
- - **Trae / Qoder / Kilo Code support**
110
- - Trae follows the same skills-only bundle family as Codex via `.trae/skills/anws-system/`
111
- - Qoder adds native `.qoder/commands/` + `.qoder/skills/`
112
- - Kilo Code adds native `.kilocode/workflows/` + `.kilocode/skills/`
113
-
114
- - **OpenCode support**
115
- - adds native projection support for `.opencode/commands/` and `.opencode/skills/`
116
- - `init`, `update`, manifest ownership, drift detection, and diff flows all understand OpenCode
117
-
118
- - **Stronger `anws update` semantics**
119
- - install-lock aware
120
- - directory-scan fallback
121
- - drift detection
122
- - target-by-target update summary
123
-
124
- - **Built-in ecosystem integration**
125
- - integrates `nexus-skills`
126
- - adopts `nexus-mapper` as the structural analysis backbone for `/probe`
127
- - completes the workflow rename from legacy `/scout` to `/probe`
128
-
129
- - **Branded CLI experience**
130
- - unified logo
131
- - confirmation UI
132
- - changelog generation
133
- - release-oriented terminal output
65
+ **v2.0.0** was the protocol-level major (unified **`.anws/`**, controlled **`AGENTS.md`**, multi-target projection). See **[RELEASE_NOTES.md](../RELEASE_NOTES.md)** for the complete major changelog.
134
66
 
135
67
  ---
136
68
 
@@ -146,7 +78,6 @@ anws init
146
78
 
147
79
  - **Requirement**
148
80
  - Node.js `>= 18`
149
-
150
81
  - **Install behavior**
151
82
  - `anws init` installs one or more target projections into their native folders
152
83
  - example: `anws init --target windsurf,opencode`
@@ -158,194 +89,76 @@ cd your-project
158
89
  anws update
159
90
  ```
160
91
 
161
- - **Preview mode**
162
- - `anws update --check` previews grouped diffs without writing files
163
-
92
+ - **Update flags**
93
+ - `anws update --check` and `anws update --target` are removed; run `anws update` once to refresh all matched targets
164
94
  - **State source**
165
95
  - `anws update` reads `.anws/install-lock.json`
166
96
  - if the lock is missing or invalid, it falls back to directory scan
167
97
  - if lock drift is detected, directory scan becomes the effective source for the current update
168
98
  - a real `anws update` can rebuild `.anws/install-lock.json` from detected targets when fallback is active
169
-
170
99
  - **`AGENTS.md` behavior**
171
100
  - marker-based file -> update stable sections, preserve `AUTO` block
172
101
  - recognized legacy file -> migrate into new marker-based structure
173
102
  - unrecognized legacy file -> warn and preserve unchanged
174
-
175
103
  - **Legacy migration**
176
104
  - if a project still has `.agent/`, the CLI can guide migration to `.agents/`
177
105
  - after successful migration, interactive mode can also ask whether to delete the old `.agent/`
178
-
179
106
  - **Upgrade record**
180
107
  - every successful update refreshes `.anws/changelog/`
181
108
  - target state is written back to `.anws/install-lock.json`
182
109
 
183
110
  ---
184
111
 
185
- ## Migration Notes for Existing Users
112
+ ## Feature demos
186
113
 
187
- If you used older Anws / Antigravity layouts, `v2.0.0` matters because:
114
+ What using Anws looks like in practice: architecture-first **`/genesis`**, **human-in-the-loop** requirement alignment, and **skill** orchestration.
188
115
 
189
- - **Directory protocol changed**
190
- - old references to `genesis/` and `anws/changelog/` are replaced by `.anws/`
191
-
192
- - **`AGENTS.md` is no longer “always skip”**
193
- - it is now a controlled managed file with merge / migrate / preserve semantics
116
+ **Deep Thinking & Architecture Design**
117
+ <img src="assets/genesis工作流演示.jpg" width="800" alt="Genesis Workflow">
194
118
 
195
- - **Target installation is explicit**
196
- - Anws now models target IDEs as first-class projections
119
+ **Interactive Requirement Alignment**
120
+ <img src="assets/与人类交互确认细节.jpg" width="800" alt="Human Interaction">
197
121
 
198
- If you maintain old docs or release notes, update those references before publishing new project templates.
122
+ **Autonomous Skill Invocation**
123
+ <img src="assets/自主调用skills.jpg" width="800" alt="Skills Execution">
199
124
 
200
125
  ---
201
126
 
202
- ## Compatibility
203
-
204
- Anws keeps a **single canonical workflow / skill source**, then projects it into the native directory structure expected by each tool.
205
- Every supported target now receives:
206
-
207
- - a root `AGENTS.md`
208
- - a target-native `skills/` projection
209
- - one target-native workflow entry surface, depending on the tool:
210
- - `workflows`
211
- - `commands`
212
- - `prompts`
213
- - aggregated `skills` for Codex / Trae skills-only bundles
214
-
215
- | Environment | Status | Layout |
216
- | --- | --- | --- |
217
- | **Windsurf** | ✅ Full Support | `AGENTS.md` + `.windsurf/workflows/` + `.windsurf/skills/` |
218
- | **Antigravity** | ✅ Full Support | `.agents/workflows/` + `.agents/skills/` + `AGENTS.md` |
219
- | **Claude Code** | ✅ Full Support | `AGENTS.md` + `.claude/commands/` + `.claude/skills/` |
220
- | **GitHub Copilot** | ✅ Full Support | `AGENTS.md` + `.github/prompts/` + `.github/skills/` |
221
- | **Cursor** | ✅ Supported | `AGENTS.md` + `.cursor/commands/` + `.cursor/skills/` |
222
- | **Codex** | ⚠️ Preview | `AGENTS.md` + `.codex/skills/anws-system/` + `.codex/skills/<skill>/` |
223
- | **OpenCode** | ✅ Supported | `AGENTS.md` + `.opencode/commands/` + `.opencode/skills/` |
224
- | **Trae** | ✅ Supported | `AGENTS.md` + `.trae/skills/anws-system/` + `.trae/skills/<skill>/` |
225
- | **Qoder** | ✅ Supported | `AGENTS.md` + `.qoder/commands/` + `.qoder/skills/` |
226
- | **Kilo Code** | ✅ Supported | `AGENTS.md` + `.kilocode/workflows/` + `.kilocode/skills/` |
127
+ ## Philosophy
227
128
 
228
- ---
229
-
230
- ## Recommended Workflow
129
+ **1. Docs first—specs keep you in command**
130
+ PRD, architecture, tasks, and design land in the repo before code does—so the project doesn’t drift in aimless “vibe runs.” Scope and progress live in `.anws/`, `05_TASKS.md`, and **`AGENTS.md`**: you stay **in control of the system**, not whichever chat window is open.
231
131
 
232
- Use Anws as a lifecycle, not just a folder pack.
132
+ **2. Full autonomy inside the rails**
133
+ **`/forge` AUTO** is delegation with checkpoints: keep moving inside agreed contracts. **Code review**, **e2e-testing-guide**, and the rest of the template gates keep runs **auditable** and **bounded**. When a wave is executing, it’s reasonable to **walk away—coffee, a walk**—because confidence comes from the spec and gates, not from staring at the model.
233
134
 
234
- | Command | Purpose | Input | Output |
235
- | --- | --- | --- | --- |
236
- | **`/quickstart`** | Route the user through the correct workflow path | Auto-detected state | Full orchestration |
237
- | `/genesis` | Start from zero with PRD and architecture | Vague idea | PRD, architecture, ADRs |
238
- | `/probe` | Analyze a legacy codebase before change | Existing code | Risk report |
239
- | `/design-system` | Design one system in depth | Architecture overview | System design doc |
240
- | `/challenge` | Review design, tasks, and implementation fidelity with adversarial pressure | Docs / tasks / code | Challenge report |
241
- | `/blueprint` | Break architecture into executable work | PRD + architecture | `05_TASKS.md` |
242
- | `/forge` | Turn approved tasks into code with challenge-report and contract gates | Tasks + review state | Working implementation |
243
- | `/change` | Modify an existing task only | Small scoped change | Updated task/design docs |
244
- | `/explore` | Research ambiguous or strategic topics | Topic | Exploration report |
245
- | `/craft` | Create workflows, skills, and prompts | Creation request | Reusable assets |
246
- | `/upgrade` | Route post-update upgrade work | Update changelog | Change or genesis path |
135
+ **Iteration is the product**
136
+ **`/challenge`** isn’t a one-time rubber stamp; it’s repeated adversarial passes. **Good products and clear ideas are sharpened over cycles**—same as real shipping: each round pulls design, tasks, and implementation back into alignment.
247
137
 
248
138
  ---
249
139
 
250
- ## Core Principles
251
-
252
- ### 1. Versioned Architecture
253
-
254
- - architecture is **evolved**, not silently edited
255
- - major structural changes move from `.anws/v1` to `.anws/v2`
256
- - ADRs preserve the reason behind the shape of the system
257
-
258
- ### 2. Filesystem as Memory
259
-
260
- - `AGENTS.md` is the recovery anchor
261
- - `.anws/v{N}/` stores durable architecture context
262
- - `.anws/changelog/` records upgrade history for future sessions
263
-
264
- ### 3. Thinking Before Coding
265
-
266
- - workflows force staged reasoning before implementation
267
- - the built-in `sequential-thinking` skill standardizes deep analysis
268
- - review steps exist to catch drift before code lands
140
+ ## Recommended Workflow
269
141
 
270
- ---
142
+ Use Anws as a lifecycle, not just a folder pack.
271
143
 
272
- ## Project Layout
273
144
 
274
- ```bash
275
- your-project/
276
- ├── .anws/
277
- │ ├── install-lock.json
278
- │ ├── changelog/
279
- │ └── v{N}/
280
- ├── AGENTS.md
281
- ├── .windsurf/
282
- ├── workflows/
283
- └── skills/
284
- ├── .agents/
285
- │ ├── workflows/
286
- └── skills/
287
- ├── .cursor/
288
- │ ├── commands/
289
- │ └── skills/
290
- ├── .claude/
291
- │ ├── commands/
292
- │ └── skills/
293
- ├── .github/
294
- │ ├── prompts/
295
- │ └── skills/
296
- ├── .opencode/
297
- │ ├── commands/
298
- │ └── skills/
299
- ├── .qoder/
300
- │ ├── commands/
301
- │ └── skills/
302
- ├── .kilocode/
303
- │ ├── workflows/
304
- │ └── skills/
305
- ├── .trae/
306
- │ └── skills/
307
- │ ├── anws-system/
308
- │ │ ├── SKILL.md
309
- │ │ └── references/
310
- │ └── <skill>/
311
- │ └── SKILL.md
312
- └── .codex/
313
- ├── skills/
314
- │ ├── anws-system/
315
- │ │ ├── SKILL.md
316
- │ │ └── references/
317
- │ └── <skill>/
318
- │ └── SKILL.md
319
- ```
145
+ | Command | Purpose | Input | Output |
146
+ | ----------------- | --------------------------------------------------------------------------- | --------------------- | ------------------------ |
147
+ | **`/quickstart`** | Route the user through the correct workflow path | Auto-detected state | Full orchestration |
148
+ | `/genesis` | Start from zero with PRD and architecture | Vague idea | PRD, architecture, ADRs |
149
+ | `/probe` | Analyze a legacy codebase before change | Existing code | Risk report |
150
+ | `/design-system` | Design one system in depth | Architecture overview | System design doc |
151
+ | `/challenge` | Review design, tasks, and implementation fidelity with adversarial pressure | Docs / tasks / code | Challenge report |
152
+ | `/blueprint` | Break architecture into executable work | PRD + architecture | `05_TASKS.md` |
153
+ | `/forge` | Turn approved tasks into code with challenge-report and contract gates | Tasks + review state | Working implementation |
154
+ | `/change` | In-version task/contract tweaks (controlled expansion: few new tasks) | Small scoped change | Updated task/design docs |
155
+ | `/explore` | Research ambiguous or strategic topics | Topic | Exploration report |
156
+ | `/craft` | Create workflows, skills, and prompts | Creation request | Reusable assets |
157
+ | `/upgrade` | Route post-update upgrade work | Update changelog | Change or genesis path |
320
158
 
321
- > One source model. Multiple target layouts. Explicit ownership on disk.
322
159
 
323
160
  ---
324
161
 
325
- ## Built with Itself
326
-
327
- Anws is dogfooded on its own development.
328
-
329
- - **Architecture design**
330
- - the CLI itself was designed through `/genesis`
331
-
332
- - **Task decomposition**
333
- - implementation work was planned through `/blueprint`
334
-
335
- - **Execution**
336
- - code and doc changes were driven through `/forge`
337
-
338
- This repository is both the product and a working reference implementation.
339
-
340
- **Deep Thinking & Architecture Design**
341
- <img src="assets/genesis工作流演示.jpg" width="800" alt="Genesis Workflow">
342
-
343
- **Interactive Requirement Alignment**
344
- <img src="assets/与人类交互确认细节.jpg" width="800" alt="Human Interaction">
345
-
346
- **Autonomous Skill Invocation**
347
- <img src="assets/自主调用skills.jpg" width="800" alt="Skills Execution">
348
-
349
162
  ## Contributing
350
163
 
351
164
  Contributions are welcome. Before opening a PR, make sure changes align with the spec-driven workflow and the target projection model.
package/bin/cli.js CHANGED
@@ -1,112 +1,112 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- const { parseArgs } = require('node:util');
5
- const path = require('node:path');
6
- const { listTargets, getTarget } = require('../lib/adapters');
7
- const { blank, error, info, logo } = require('../lib/output');
8
-
9
- // ─── 版本号从 package.json 读取 ─────────────────────────────────────────────
10
- const { version } = require(path.join(__dirname, '..', 'package.json'));
11
- const TARGET_IDS = listTargets().map((target) => target.id);
12
-
13
- // ─── 帮助文本 ─────────────────────────────────────────────────────────────────
14
- const HELP = `
15
- USAGE
16
- anws <command> [options]
17
-
18
- COMMANDS
19
- init Install one or more target AI IDE workflow projections
20
- update Scan installed targets from install-lock or directory layout and update them
21
-
22
- OPTIONS
23
- -v, --version Print version number
24
- -h, --help Show this help message
25
- --target Target AI IDE(s) for init, comma-separated (${TARGET_IDS.join(', ')})
26
-
27
- SUPPORTED TARGETS
28
- windsurf workflows + skills
29
- antigravity workflows + skills
30
- cursor commands + skills
31
- claude commands + skills
32
- copilot prompts + skills
33
- codex preview, skills-only bundle via anws-system
34
- opencode commands + skills
35
- trae skills-only bundle via anws-system
36
- qoder commands + skills
37
- kilo workflows + skills
38
-
39
- EXAMPLES
40
- anws init # Choose target IDEs and install their managed workflow projections
41
- anws init --target windsurf,codex,opencode
42
- anws update # One-click update for all matched targets from install-lock, fallback scan, or drift repair
43
- `.trimStart();
44
-
45
- // ─── 参数解析 ─────────────────────────────────────────────────────────────────
46
- const { values, positionals } = parseArgs({
47
- args: process.argv.slice(2),
48
- options: {
49
- version: { type: 'boolean', short: 'v', default: false },
50
- help: { type: 'boolean', short: 'h', default: false },
51
- yes: { type: 'boolean', short: 'y', default: false },
52
- target: { type: 'string' },
53
- check: { type: 'boolean', default: false },
54
- },
55
- strict: false,
56
- allowPositionals: true,
57
- });
58
-
59
- if (values.yes) {
60
- global.__ANWS_FORCE_YES = true;
61
- }
62
-
63
- if (values.target !== undefined) {
64
- const targetIds = values.target.split(',').map((item) => item.trim()).filter(Boolean);
65
- targetIds.forEach((targetId) => getTarget(targetId));
66
- global.__ANWS_TARGET_IDS = Array.from(new Set(targetIds));
67
- }
68
-
69
- // ─── 命令路由 ─────────────────────────────────────────────────────────────────
70
- async function main() {
71
- if (values.version) {
72
- console.log(version);
73
- process.exit(0);
74
- }
75
-
76
- if (values.help || positionals.length === 0) {
77
- logo();
78
- blank();
79
- console.log(HELP.trimEnd());
80
- process.exit(0);
81
- }
82
-
83
- const command = positionals[0];
84
-
85
- switch (command) {
86
- case 'init':
87
- await require('../lib/init')();
88
- break;
89
-
90
- case 'update':
91
- if (values.target !== undefined) {
92
- error('`anws update --target` has been removed. Use `anws update` to update all matched targets.');
93
- process.exit(1);
94
- }
95
- if (values.check) {
96
- error('`anws update --check` has been removed. Use `anws update` directly.');
97
- process.exit(1);
98
- }
99
- await require('../lib/update')();
100
- break;
101
-
102
- default:
103
- error(`Unknown command: "${command}"`);
104
- info('Run `anws --help` to see available commands.');
105
- process.exit(1);
106
- }
107
- }
108
-
109
- main().catch((err) => {
110
- error(`Unexpected error: ${err.message}`);
111
- process.exit(1);
112
- });
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const { parseArgs } = require('node:util');
5
+ const path = require('node:path');
6
+ const { listTargets, getTarget } = require('../lib/adapters');
7
+ const { blank, error, info, logo } = require('../lib/output');
8
+
9
+ // ─── 版本号从 package.json 读取 ─────────────────────────────────────────────
10
+ const { version } = require(path.join(__dirname, '..', 'package.json'));
11
+ const TARGET_IDS = listTargets().map((target) => target.id);
12
+
13
+ // ─── 帮助文本 ─────────────────────────────────────────────────────────────────
14
+ const HELP = `
15
+ USAGE
16
+ anws <command> [options]
17
+
18
+ COMMANDS
19
+ init Install one or more target AI IDE workflow projections
20
+ update Scan installed targets from install-lock or directory layout and update them
21
+
22
+ OPTIONS
23
+ -v, --version Print version number
24
+ -h, --help Show this help message
25
+ --target Target AI IDE(s) for init, comma-separated (${TARGET_IDS.join(', ')})
26
+
27
+ SUPPORTED TARGETS
28
+ windsurf workflows + skills
29
+ antigravity workflows + skills
30
+ cursor commands + skills
31
+ claude commands + skills
32
+ copilot prompts + skills
33
+ codex preview, skills-only bundle via anws-system
34
+ opencode commands + skills
35
+ trae skills-only bundle via anws-system
36
+ qoder commands + skills
37
+ kilo workflows + skills
38
+
39
+ EXAMPLES
40
+ anws init # Choose target IDEs and install their managed workflow projections
41
+ anws init --target windsurf,codex,opencode
42
+ anws update # One-click update for all matched targets from install-lock, fallback scan, or drift repair
43
+ `.trimStart();
44
+
45
+ // ─── 参数解析 ─────────────────────────────────────────────────────────────────
46
+ const { values, positionals } = parseArgs({
47
+ args: process.argv.slice(2),
48
+ options: {
49
+ version: { type: 'boolean', short: 'v', default: false },
50
+ help: { type: 'boolean', short: 'h', default: false },
51
+ yes: { type: 'boolean', short: 'y', default: false },
52
+ target: { type: 'string' },
53
+ check: { type: 'boolean', default: false },
54
+ },
55
+ strict: false,
56
+ allowPositionals: true,
57
+ });
58
+
59
+ if (values.yes) {
60
+ global.__ANWS_FORCE_YES = true;
61
+ }
62
+
63
+ if (values.target !== undefined) {
64
+ const targetIds = values.target.split(',').map((item) => item.trim()).filter(Boolean);
65
+ targetIds.forEach((targetId) => getTarget(targetId));
66
+ global.__ANWS_TARGET_IDS = Array.from(new Set(targetIds));
67
+ }
68
+
69
+ // ─── 命令路由 ─────────────────────────────────────────────────────────────────
70
+ async function main() {
71
+ if (values.version) {
72
+ console.log(version);
73
+ process.exit(0);
74
+ }
75
+
76
+ if (values.help || positionals.length === 0) {
77
+ logo();
78
+ blank();
79
+ console.log(HELP.trimEnd());
80
+ process.exit(0);
81
+ }
82
+
83
+ const command = positionals[0];
84
+
85
+ switch (command) {
86
+ case 'init':
87
+ await require('../lib/init')();
88
+ break;
89
+
90
+ case 'update':
91
+ if (values.target !== undefined) {
92
+ error('`anws update --target` has been removed. Use `anws update` to update all matched targets.');
93
+ process.exit(1);
94
+ }
95
+ if (values.check) {
96
+ error('`anws update --check` has been removed. Use `anws update` directly.');
97
+ process.exit(1);
98
+ }
99
+ await require('../lib/update')();
100
+ break;
101
+
102
+ default:
103
+ error(`Unknown command: "${command}"`);
104
+ info('Run `anws --help` to see available commands.');
105
+ process.exit(1);
106
+ }
107
+ }
108
+
109
+ main().catch((err) => {
110
+ error(`Unexpected error: ${err.message}`);
111
+ process.exit(1);
112
+ });