@haaaiawd/anws 2.0.2 → 2.0.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.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <img src="assets/logo-cli.png" width="260" alt="Anws">
4
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.0.2-7FB5B6)](https://github.com/Haaaiawd/Anws/releases)
6
+ [![Version](https://img.shields.io/badge/version-v2.0.3-7FB5B6)](https://github.com/Haaaiawd/Anws/releases)
7
7
  [![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
8
 
9
9
  [English](./README.md) | [中文](./README_CN.md)
@@ -140,6 +140,7 @@ anws update
140
140
  - **State source**
141
141
  - `anws update` reads `.anws/install-lock.json`
142
142
  - if the lock is missing or invalid, it falls back to directory scan
143
+ - if lock drift is detected, directory scan becomes the effective source for the current update
143
144
  - a real `anws update` can rebuild `.anws/install-lock.json` from detected targets when fallback is active
144
145
 
145
146
  - **`AGENTS.md` behavior**
package/bin/cli.js CHANGED
@@ -40,7 +40,7 @@ SUPPORTED TARGETS
40
40
  EXAMPLES
41
41
  anws init # Choose target IDEs and install their managed workflow projections
42
42
  anws init --target windsurf,codex,opencode
43
- anws update # Update all matched targets from install-lock or directory scan fallback
43
+ anws update # Update all matched targets from install-lock, fallback scan, or drift repair
44
44
  anws update --check # Preview grouped changes per target without writing files
45
45
  `.trimStart();
46
46
 
@@ -170,10 +170,14 @@ async function detectInstallState(cwd) {
170
170
  const fallbackReason = !needsFallback
171
171
  ? null
172
172
  : (!lockResult.exists ? 'missing_lock' : 'invalid_lock');
173
- const selectedTargets = lockTargets.length > 0
174
- ? lockTargets.map((item) => item.targetId)
175
- : scannedTargets.map((item) => item.id);
176
173
  const drift = detectLockDrift(lockResult.lock, scannedTargets);
174
+ const shouldPreferScannedTargets = needsFallback || drift.hasDrift || lockTargets.length === 0;
175
+ const selectedTargets = shouldPreferScannedTargets
176
+ ? scannedTargets.map((item) => item.id)
177
+ : lockTargets.map((item) => item.targetId);
178
+ const stateSource = needsFallback
179
+ ? 'directory_scan_fallback'
180
+ : (drift.hasDrift ? 'directory_scan_drift' : 'install_lock');
177
181
 
178
182
  return {
179
183
  lockResult,
@@ -182,8 +186,8 @@ async function detectInstallState(cwd) {
182
186
  drift,
183
187
  needsFallback,
184
188
  fallbackReason,
185
- stateSource: needsFallback ? 'directory_scan_fallback' : 'install_lock',
186
- canRebuildLock: needsFallback && selectedTargets.length > 0
189
+ stateSource,
190
+ canRebuildLock: (needsFallback || drift.hasDrift) && selectedTargets.length > 0
187
191
  };
188
192
  }
189
193
 
package/lib/update.js CHANGED
@@ -129,7 +129,7 @@ async function update(options = {}) {
129
129
  blank();
130
130
  }
131
131
  printTargetSelection(installState, targetContexts.map((context) => context.target));
132
- if (!check && installState.needsFallback && selectedTargetIds.length > 0) {
132
+ if (!check && installState.canRebuildLock && selectedTargetIds.length > 0) {
133
133
  const generatedAt = new Date().toISOString();
134
134
  await writeInstallLock(cwd, createInstallLock({
135
135
  cliVersion: version,
@@ -217,11 +217,14 @@ async function update(options = {}) {
217
217
  }
218
218
  });
219
219
  const generatedAt = new Date().toISOString();
220
+ const existingLockTargets = installState.canRebuildLock
221
+ ? []
222
+ : (installState.lockResult.lock?.targets || []);
220
223
  await writeInstallLock(cwd, createInstallLock({
221
224
  cliVersion: version,
222
225
  generatedAt,
223
226
  targets: dedupeTargets([
224
- ...(installState.lockResult.lock?.targets || []),
227
+ ...existingLockTargets,
225
228
  ...successfulTargets
226
229
  ]),
227
230
  lastUpdateSummary: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haaaiawd/anws",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "Anws — A spec-driven workflow framework for AI-assisted development. Empowers prompt engineers to build production-ready software through structured PRD → Architecture → Task decomposition. Works with Claude Code, GitHub Copilot, Cursor, Windsurf, and any tool that reads AGENTS.md.",
5
5
  "keywords": [
6
6
  "anws",