@sabaiway/agent-workflow-kit 20.0.0 → 20.0.1

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 CHANGED
@@ -4,6 +4,24 @@ Semantically versioned ([semver](https://semver.org)), newest first. The `versio
4
4
  is the current release. `upgrade` mode reads a project's `docs/ai/.workflow-version` and applies
5
5
  every `migrations/<version>-<slug>.md` newer than it, in semver order.
6
6
 
7
+ ## 20.0.1 — `init` removes the folders it leaves empty in the kit home (AD-217)
8
+
9
+ **A refresh no longer asks you to delete folders by hand.** `init` removes from an existing kit home every file in
10
+ the kit's folders that the package does not carry, but it kept the folders themselves and printed `kept <folder> (a
11
+ directory the package does not carry — yours to remove by hand)` for the topmost such folder of each tree, on every
12
+ run. Moving to 20.0.0, which ships no test suites, left 70 empty folders and 26 such lines. Now:
13
+
14
+ - After removing the files, `init` removes each folder the package does not carry that is left empty, children first,
15
+ with one `removed <folder> (not in the package)` line for the topmost folder of each removed tree. The next run over
16
+ the same home prints nothing for it.
17
+ - A folder that still holds something stays, with one `kept <folder> (a directory the package does not carry that
18
+ still holds an entry)` line for the topmost such folder of each tree. A symlink the package does not carry stays the owner's, unchanged.
19
+ - The removal is a single non-recursive `rmdir` behind the same guards as the file removal; a failure is reported by
20
+ folder and cause and fails the install, like a file that cannot be removed.
21
+
22
+ Your next `npx @sabaiway/agent-workflow-kit@latest init` removes the empty folders earlier refreshes left. Contract:
23
+ upgrade-delivery revision 10.
24
+
7
25
  ## 20.0.0 — the kit's text lives in kit files and one kit block; one upgrade moves your project once (AD-216)
8
26
 
9
27
  **Your project's own files can no longer lose the kit's updates.** Until now the kit kept its standing text inside
package/README.md CHANGED
@@ -207,7 +207,7 @@ other agent). The manual path works identically but **isn't reflected in install
207
207
  <summary><b>What <code>init</code> touches — and how to undo it</b></summary>
208
208
 
209
209
  `init` **never deletes your project settings**, and it installs only into a new or empty folder or an existing kit home: any other `--dir` is refused before anything is written. In an existing kit home it removes every file in the kit's
210
- `references/`, `tools/`, `migrations/`, `launchers/` and `bridges/` folders that the package does not carry, a file you put there included, one reported line per file. It writes its own namespaced slots, then
210
+ `references/`, `tools/`, `migrations/`, `launchers/` and `bridges/` folders that the package does not carry, a file you put there included, one reported line per file, and then each folder there that is left empty. It writes its own namespaced slots, then
211
211
  refreshes the other npm core members so a returning `init` leaves **no stale core member**:
212
212
 
213
213
  | Path | What |
package/SKILL.md CHANGED
@@ -3,7 +3,7 @@ name: agent-workflow-kit
3
3
  description: Deploy or upgrade a portable AI-agent memory-and-workflow system in any project. Use when the user wants to bootstrap `docs/ai/` + an entry-point `AGENTS.md` (+ `CLAUDE.md` alias) + cap/archive/index enforcement in a new or existing repo, set up the Memory Map and session protocols, install the docs-rotation pre-commit hook, or run `/agent-workflow-kit` / `/agent-workflow-kit upgrade`. Triggers on phrases like "set up the memory system", "deploy the AI workflow here", "bootstrap docs/ai", "upgrade the workflow". New to the epic, story and task tier? Run `/agent-workflow-kit tier`. A typed decision with a confidence from Jev? Run `/agent-workflow-kit jev`.
4
4
  disable-model-invocation: true
5
5
  metadata:
6
- version: '20.0.0'
6
+ version: '20.0.1'
7
7
  ---
8
8
 
9
9
  # agent-workflow-kit
package/bin/install.mjs CHANGED
@@ -293,7 +293,7 @@ Installs/refreshes the kit at ~/.claude/skills/agent-workflow-kit
293
293
  stays /agent-workflow-kit setup, opt-in); once placed, init refreshes them from the kit's
294
294
  own bundled copies — local files only, never a downgrade — and --no-bridges skips that
295
295
  refresh. init never deletes your project settings; in an existing kit home it removes each
296
- file in its folders that the package does not carry, one line each. If the
296
+ file in its folders that the package does not carry and each folder left empty. If the
297
297
  installed kit is newer than the version you ran, init refuses (no network — it compares
298
298
  the version on disk) and points you at @latest; --allow-downgrade overrides that
299
299
  refusal (distinct from --force, which is launcher-only).
package/capability.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "schema": 1,
4
4
  "name": "agent-workflow-kit",
5
5
  "kind": "composition-root",
6
- "version": "20.0.0",
6
+ "version": "20.0.1",
7
7
  "provides": [],
8
8
  "roles": {},
9
9
  "detect": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sabaiway/agent-workflow-kit",
3
- "version": "20.0.0",
3
+ "version": "20.0.1",
4
4
  "description": "Portable, cross-agent memory & workflow for AI coding agents — Claude Code, Codex, Cursor, Devin Desktop. One command deploys an AGENTS.md entry point + docs/ai context with cap/archive/index enforcement into any repo.",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -1,4 +1,4 @@
1
- import { lstatSync, readdirSync, readFileSync, unlinkSync } from 'node:fs';
1
+ import { lstatSync, readdirSync, readFileSync, rmdirSync, unlinkSync } from 'node:fs';
2
2
  import { resolve, sep } from 'node:path';
3
3
  import { assertContainedRealPath } from './fs-safe.mjs';
4
4
  import { lstatNoFollowRead } from './fs-read-nofollow.mjs';
@@ -107,9 +107,7 @@ const readTree = (root, entry, reports, directoryOnly = false) => {
107
107
  return entries;
108
108
  };
109
109
 
110
- // The walk lists a directory before its children, so a kept directory's line covers the directories beneath it.
111
- const planSubtree = (carried, installed, orphans, reports) => {
112
- const keptDirectories = [];
110
+ const planSubtree = (carried, installed, orphans, directories, reports) => {
113
111
  for (const [path, kind] of installed) {
114
112
  if (carried.has(path)) {
115
113
  const packageKind = carried.get(path);
@@ -121,10 +119,9 @@ const planSubtree = (carried, installed, orphans, reports) => {
121
119
  }
122
120
  } else if (kind === 'file') {
123
121
  orphans.push(path);
124
- } else if (kind === 'directory' && keptDirectories.some((kept) => path.startsWith(`${kept}/`))) {
125
- continue;
122
+ } else if (kind === 'directory') {
123
+ directories.push(path);
126
124
  } else {
127
- if (kind === 'directory') keptDirectories.push(path);
128
125
  reports.push({
129
126
  ok: true,
130
127
  line: `${PREFIX} kept ${path} (a ${kind} the package does not carry — yours to remove by hand)`,
@@ -151,9 +148,50 @@ const removeOrphan = (home, path, remove) => {
151
148
  }
152
149
  };
153
150
 
151
+ const removeEmptyDirectory = (home, path, remove) => {
152
+ const absolute = resolve(home, path);
153
+ try {
154
+ remove.assertContainedRealPath(home, absolute);
155
+ const stat = remove.lstatNoFollowRead(absolute);
156
+ if (stat === null) {
157
+ return { state: 'absent' };
158
+ }
159
+ if (!stat.isDirectory()) {
160
+ throw new Error('the path is no longer a real directory');
161
+ }
162
+ remove.rmdirSync(absolute);
163
+ return { state: 'removed' };
164
+ } catch (error) {
165
+ const settled = { ENOTEMPTY: 'kept', EEXIST: 'kept', ENOENT: 'absent' }[error.code];
166
+ return settled ? { state: settled } : { state: 'failed', report: reportFailure(path, error) };
167
+ }
168
+ };
169
+
170
+ // The walk lists a directory before its children: reversed, a child is removed before its parent.
171
+ const removeEmptyDirectories = (home, directories, remove) => {
172
+ const outcomes = new Map([...directories].reverse().map((path) => [path, removeEmptyDirectory(home, path, remove)]));
173
+ const isTop = (path) => !directories.some((other) => path.startsWith(`${other}/`));
174
+ return directories.flatMap((path) => {
175
+ const { state, report } = outcomes.get(path);
176
+ if (state === 'failed') {
177
+ return [report];
178
+ }
179
+ if (!isTop(path) || state === 'absent') {
180
+ return [];
181
+ }
182
+ return [{
183
+ ok: true,
184
+ line: state === 'removed'
185
+ ? `${PREFIX} removed ${path} (not in the package)`
186
+ : `${PREFIX} kept ${path} (a directory the package does not carry that still holds an entry)`,
187
+ }];
188
+ });
189
+ };
190
+
154
191
  export const prunePayload = ({ packageRoot, home, payload }, deps = {}) => {
155
192
  const reports = [];
156
193
  const orphans = [];
194
+ const directories = [];
157
195
  for (const entry of new Set(payload)) {
158
196
  const path = entry.split(sep).join('/');
159
197
  const carried = readTree(packageRoot, path, reports, true);
@@ -161,7 +199,7 @@ export const prunePayload = ({ packageRoot, home, payload }, deps = {}) => {
161
199
  continue;
162
200
  }
163
201
  const installed = readTree(home, path, reports);
164
- planSubtree(carried, installed, orphans, reports);
202
+ planSubtree(carried, installed, orphans, directories, reports);
165
203
  }
166
204
  if (reports.some((report) => !report.ok)) {
167
205
  return finishReport(reports);
@@ -170,9 +208,11 @@ export const prunePayload = ({ packageRoot, home, payload }, deps = {}) => {
170
208
  assertContainedRealPath: deps.assertContainedRealPath ?? assertContainedRealPath,
171
209
  lstatNoFollowRead: deps.lstatNoFollowRead ?? lstatNoFollowRead,
172
210
  unlinkSync: deps.unlinkSync ?? unlinkSync,
211
+ rmdirSync: deps.rmdirSync ?? rmdirSync,
173
212
  };
174
213
  for (const path of orphans) {
175
214
  reports.push(...removeOrphan(home, path, remove));
176
215
  }
216
+ reports.push(...removeEmptyDirectories(home, directories, remove));
177
217
  return finishReport(reports);
178
218
  };