@getxflow/cli 0.10.0 → 0.10.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/dist/bin.js +26 -1
- package/dist/commands/skills.js +119 -21
- package/dist/commands/update.js +6 -4
- package/dist/help.js +453 -433
- package/dist/state.js +36 -2
- package/dist/version.js +1 -1
- package/package.json +24 -24
- package/skills/xflow/SKILL.md +552 -540
package/dist/bin.js
CHANGED
|
@@ -114,7 +114,7 @@ async function run(args) {
|
|
|
114
114
|
await (0, env_1.envCheck)();
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
|
-
if (second === undefined || second === 'list'
|
|
117
|
+
if (second === undefined || second === 'list') {
|
|
118
118
|
await (0, env_1.envList)();
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
@@ -216,6 +216,27 @@ function nudge() {
|
|
|
216
216
|
(0, ui_1.note)((0, ui_1.dim)(` xflow ${latest} is out, ${version_1.CLI_VERSION} is installed: run xflow update`));
|
|
217
217
|
(0, state_1.markNudged)(latest);
|
|
218
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* The other staleness, and the one that costs more: the instructions an agent reads are
|
|
221
|
+
* older than the CLI answering it, and nothing about that is visible in the text. Louder
|
|
222
|
+
* than the notice above because it is wrong now rather than out of date soon, and it names
|
|
223
|
+
* the file, because a machine can hold a dozen copies and the wrong one gets edited.
|
|
224
|
+
*
|
|
225
|
+
* The command is skills --refresh, not update: what is out of step here is the copies, not
|
|
226
|
+
* the package, and refreshing needs no network, no npm and no rights on a global folder.
|
|
227
|
+
* The re-read is half the repair, so it is in the same breath as the command.
|
|
228
|
+
*/
|
|
229
|
+
function nudgeSkill() {
|
|
230
|
+
const stale = (0, skills_1.staleSkillCopy)(process.cwd());
|
|
231
|
+
if (stale === null)
|
|
232
|
+
return;
|
|
233
|
+
const key = `${stale} ${version_1.CLI_VERSION}`;
|
|
234
|
+
if (!(0, state_1.shouldNudgeSkill)(key))
|
|
235
|
+
return;
|
|
236
|
+
(0, ui_1.warn)(`${stale} is older than this CLI`);
|
|
237
|
+
(0, ui_1.note)((0, ui_1.dim)(' Run xflow skills --refresh, then read that file again: the refresh only writes it to disk'));
|
|
238
|
+
(0, state_1.markSkillNudged)(key);
|
|
239
|
+
}
|
|
219
240
|
async function main() {
|
|
220
241
|
const args = (0, args_1.parseArgs)(process.argv.slice(2));
|
|
221
242
|
if ((0, args_1.flagBool)(args, 'version')) {
|
|
@@ -261,6 +282,10 @@ async function main() {
|
|
|
261
282
|
finally {
|
|
262
283
|
if (!quiet)
|
|
263
284
|
nudge();
|
|
285
|
+
// Not behind the same flag: a copy out of step with the running package stays wrong
|
|
286
|
+
// whatever the command was, and when the package itself is the problem the copies
|
|
287
|
+
// match it and this says nothing anyway.
|
|
288
|
+
nudgeSkill();
|
|
264
289
|
}
|
|
265
290
|
}
|
|
266
291
|
main().then((code) => {
|
package/dist/commands/skills.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.replacePointer = replacePointer;
|
|
4
|
+
exports.copyIsStale = copyIsStale;
|
|
5
|
+
exports.staleSkillCopy = staleSkillCopy;
|
|
3
6
|
exports.installSkillQuietly = installSkillQuietly;
|
|
4
7
|
exports.skills = skills;
|
|
5
8
|
const node_fs_1 = require("node:fs");
|
|
@@ -8,6 +11,7 @@ const node_path_1 = require("node:path");
|
|
|
8
11
|
const args_1 = require("../args");
|
|
9
12
|
const errors_1 = require("../errors");
|
|
10
13
|
const prompt_1 = require("../prompt");
|
|
14
|
+
const update_1 = require("./update");
|
|
11
15
|
const ui_1 = require("../ui");
|
|
12
16
|
const AGENTS = [
|
|
13
17
|
{ id: 'claude', label: 'Claude Code', project: ['.claude', 'skills'], global: ['.claude', 'skills'] },
|
|
@@ -32,7 +36,8 @@ const POINTER = `${POINTER_MARKER}
|
|
|
32
36
|
This project is hosted on the XFlow platform and ships through the \`xflow\` CLI, not
|
|
33
37
|
through a git push. Read \`.agents/skills/xflow/SKILL.md\` before deploying, publishing,
|
|
34
38
|
rolling back, touching the database or migrations, cloud functions, schedules,
|
|
35
|
-
environment variables or production logs.
|
|
39
|
+
environment variables, file storage and uploads, connected accounts or production logs.
|
|
40
|
+
Command list: \`xflow help\`.
|
|
36
41
|
`;
|
|
37
42
|
/** The skill ships inside the package, next to dist. */
|
|
38
43
|
function skillSource() {
|
|
@@ -63,13 +68,43 @@ function writeIfChanged(path, content) {
|
|
|
63
68
|
(0, node_fs_1.writeFileSync)(path, content, 'utf-8');
|
|
64
69
|
return before === null ? 'new' : 'updated';
|
|
65
70
|
}
|
|
66
|
-
/**
|
|
67
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Our own block put back in place, or null when the file has none.
|
|
73
|
+
*
|
|
74
|
+
* The block runs from the marker to the next heading of the same level, so whatever the
|
|
75
|
+
* user wrote around it survives. Appending once was enough while the text never changed;
|
|
76
|
+
* it does change, and a pointer that names half the sections is worse than an old CLI:
|
|
77
|
+
* the agent reads it every time, unlike the skill, which at least announces its own age.
|
|
78
|
+
*/
|
|
79
|
+
function replacePointer(text) {
|
|
80
|
+
const start = text.indexOf(POINTER_MARKER);
|
|
81
|
+
if (start < 0)
|
|
82
|
+
return null;
|
|
83
|
+
// Past our own heading: the newline before it sits at start + length, so the search
|
|
84
|
+
// begins after it and the first hit is somebody else's section.
|
|
85
|
+
const after = text.indexOf('\n## ', start + POINTER_MARKER.length + 1);
|
|
86
|
+
const tail = after < 0 ? '' : `\n${text.slice(after + 1)}`;
|
|
87
|
+
return `${text.slice(0, start)}${POINTER}${tail}`;
|
|
88
|
+
}
|
|
89
|
+
/** The file belongs to the user: created only on install, rewritten only where ours is. */
|
|
90
|
+
function writePointer(base, create) {
|
|
68
91
|
const path = (0, node_path_1.join)(base, 'AGENTS.md');
|
|
69
92
|
const before = (0, node_fs_1.existsSync)(path) ? (0, node_fs_1.readFileSync)(path, 'utf-8') : null;
|
|
70
|
-
|
|
93
|
+
let next;
|
|
94
|
+
if (before === null) {
|
|
95
|
+
if (!create)
|
|
96
|
+
return null;
|
|
97
|
+
next = POINTER;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
const replaced = replacePointer(before);
|
|
101
|
+
if (replaced === null && !create)
|
|
102
|
+
return null;
|
|
103
|
+
next = replaced ?? `${before.replace(/\s*$/, '')}\n\n${POINTER}`;
|
|
104
|
+
}
|
|
105
|
+
if (before === next)
|
|
71
106
|
return null;
|
|
72
|
-
(0, node_fs_1.writeFileSync)(path,
|
|
107
|
+
(0, node_fs_1.writeFileSync)(path, next, 'utf-8');
|
|
73
108
|
return { path, state: before === null ? 'new' : 'updated' };
|
|
74
109
|
}
|
|
75
110
|
function install(base, ids, global) {
|
|
@@ -93,12 +128,79 @@ function install(base, ids, global) {
|
|
|
93
128
|
}
|
|
94
129
|
// Project-level only: these have no global equivalents.
|
|
95
130
|
if (!global) {
|
|
96
|
-
const pointer =
|
|
131
|
+
const pointer = writePointer(base, true);
|
|
97
132
|
if (pointer)
|
|
98
133
|
changes.push(pointer);
|
|
99
134
|
}
|
|
100
135
|
return changes;
|
|
101
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Every place a copy can live, deduplicated, project copies first. Two consumers read
|
|
139
|
+
* this list: the refresh below and the staleness check the nudge runs, and they have to
|
|
140
|
+
* agree on what a copy is, or one of them would report the other's work as undone.
|
|
141
|
+
*
|
|
142
|
+
* The Cursor rule is not one of the agent paths and not a plain copy either: it carries
|
|
143
|
+
* the same body under its own header, hence the flag rather than a second list.
|
|
144
|
+
*/
|
|
145
|
+
function copyPaths(base) {
|
|
146
|
+
const paths = [];
|
|
147
|
+
const seen = new Set();
|
|
148
|
+
const add = (path, rule) => {
|
|
149
|
+
if (seen.has(path))
|
|
150
|
+
return;
|
|
151
|
+
seen.add(path);
|
|
152
|
+
paths.push({ path, rule });
|
|
153
|
+
};
|
|
154
|
+
for (const agent of AGENTS)
|
|
155
|
+
add(skillPath(base, agent, false), false);
|
|
156
|
+
add((0, node_path_1.join)(base, ...CURSOR_RULE), true);
|
|
157
|
+
// A source checkout holds the skill as it is being written, not as it was published,
|
|
158
|
+
// while the home copies are read from every project on this machine. Refreshing them
|
|
159
|
+
// from here would hand a draft to every agent on the machine, and reporting them stale
|
|
160
|
+
// would nag for ever with a command we do not want run. So from a checkout the CLI
|
|
161
|
+
// minds this folder and nothing else, and both consumers of the list agree because it
|
|
162
|
+
// is decided here rather than twice.
|
|
163
|
+
if ((0, update_1.classifyPath)(__dirname) !== 'checkout') {
|
|
164
|
+
for (const agent of AGENTS)
|
|
165
|
+
add(skillPath(base, agent, true), false);
|
|
166
|
+
}
|
|
167
|
+
return paths;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Line endings are not a difference. An editor that saved a copy as CRLF would otherwise
|
|
171
|
+
* leave the machine announcing a stale skill for ever, and the refresh that "fixes" it
|
|
172
|
+
* would change nothing visible. Same normalisation the template gate uses.
|
|
173
|
+
*/
|
|
174
|
+
function copyIsStale(expected, actual) {
|
|
175
|
+
return expected.replace(/\r\n/g, '\n') !== actual.replace(/\r\n/g, '\n');
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The first installed copy whose text is not what this CLI ships, or null when every
|
|
179
|
+
* copy matches. Compared by content rather than by a version stamp: a release that left
|
|
180
|
+
* the skill alone must not declare identical copies stale, and copies old enough to
|
|
181
|
+
* carry no stamp still have to be recognised.
|
|
182
|
+
*
|
|
183
|
+
* Never throws: this runs after a command that already succeeded, and an unreadable file
|
|
184
|
+
* somewhere in a home folder is not a reason to fail it.
|
|
185
|
+
*/
|
|
186
|
+
function staleSkillCopy(base) {
|
|
187
|
+
try {
|
|
188
|
+
const present = copyPaths(base).filter((copy) => (0, node_fs_1.existsSync)(copy.path));
|
|
189
|
+
if (present.length === 0)
|
|
190
|
+
return null;
|
|
191
|
+
const skill = skillSource();
|
|
192
|
+
const rule = cursorRule(skill);
|
|
193
|
+
for (const copy of present) {
|
|
194
|
+
const expected = copy.rule ? rule : skill;
|
|
195
|
+
if (copyIsStale(expected, (0, node_fs_1.readFileSync)(copy.path, 'utf-8')))
|
|
196
|
+
return copy.path;
|
|
197
|
+
}
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
102
204
|
/**
|
|
103
205
|
* Rewrite every copy that already exists and create none: this is what xflow update
|
|
104
206
|
* calls, and it runs wherever the user happened to stand. Installing defaults here
|
|
@@ -106,24 +208,20 @@ function install(base, ids, global) {
|
|
|
106
208
|
*/
|
|
107
209
|
function refreshInstalled(base) {
|
|
108
210
|
const skill = skillSource();
|
|
211
|
+
const rule = cursorRule(skill);
|
|
109
212
|
const changes = [];
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
seen.add(path);
|
|
115
|
-
const state = writeIfChanged(path, content);
|
|
213
|
+
for (const copy of copyPaths(base)) {
|
|
214
|
+
if (!(0, node_fs_1.existsSync)(copy.path))
|
|
215
|
+
continue;
|
|
216
|
+
const state = writeIfChanged(copy.path, copy.rule ? rule : skill);
|
|
116
217
|
if (state)
|
|
117
|
-
changes.push({ path, state });
|
|
118
|
-
};
|
|
119
|
-
for (const agent of AGENTS) {
|
|
120
|
-
put(skillPath(base, agent, false), skill);
|
|
121
|
-
put(skillPath(base, agent, true), skill);
|
|
122
|
-
// The Cursor rule is not one of the agent paths: without this line it keeps the
|
|
123
|
-
// old text next to a fresh SKILL.md, and the two drift apart unnoticed.
|
|
124
|
-
if (agent.rule === true)
|
|
125
|
-
put((0, node_path_1.join)(base, ...CURSOR_RULE), cursorRule(skill));
|
|
218
|
+
changes.push({ path: copy.path, state });
|
|
126
219
|
}
|
|
220
|
+
// AGENTS.md is read on every task, unlike the lazily loaded skill, so a stale pointer
|
|
221
|
+
// there misleads more often than a stale skill. Rewritten, never created.
|
|
222
|
+
const pointer = writePointer(base, false);
|
|
223
|
+
if (pointer)
|
|
224
|
+
changes.push(pointer);
|
|
127
225
|
return changes;
|
|
128
226
|
}
|
|
129
227
|
/** Defaults plus whatever is already installed, so an update run refreshes everything. */
|
package/dist/commands/update.js
CHANGED
|
@@ -150,10 +150,12 @@ function update() {
|
|
|
150
150
|
(0, ui_1.note)((0, ui_1.dim)(' Check what is on disk now: xflow --version'));
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
153
|
-
if (after === version_1.CLI_VERSION)
|
|
153
|
+
if (after === version_1.CLI_VERSION)
|
|
154
154
|
(0, ui_1.ok)(`xflow ${after} is the latest version`);
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
else
|
|
156
|
+
(0, ui_1.ok)(`xflow ${version_1.CLI_VERSION} → ${after}`);
|
|
157
|
+
// Also when the version did not move: copies drift on their own, from a global install
|
|
158
|
+
// made by npm directly or a folder that never saw this command. The refresh writes
|
|
159
|
+
// nothing where the text already matches, so the quiet case stays quiet.
|
|
158
160
|
refreshSkill(root);
|
|
159
161
|
}
|