@zeeshanjamshed/ai-workflow-kit 0.0.0-stage → 0.4.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.
@@ -0,0 +1,58 @@
1
+ import { exists } from "./discovery.js";
2
+ import { safePath } from "./initialize.js";
3
+ export const engineeringModules = ['architecture', 'security', 'testing', 'git', 'workflows'];
4
+ export const rulePath = (name) => `.ai/rules/engineering-${name}.md`;
5
+ const start = '<!-- ai-workflow-kit:engineering-rules -->';
6
+ const end = '<!-- /ai-workflow-kit:engineering-rules -->';
7
+ const adapterPaths = ['AGENTS.md', 'AGENTS.override.md', 'CLAUDE.md', '.claude/CLAUDE.md', '.cursor/rules/ai-workflow-kit.mdc'];
8
+ function block(path, names, includeContext = false) {
9
+ const claude = path.endsWith('CLAUDE.md');
10
+ const prefix = path === '.claude/CLAUDE.md' ? '../' : '';
11
+ const rules = names.map(name => claude ? `@${prefix}${rulePath(name)}` : `- \`${rulePath(name)}\``);
12
+ const context = includeContext ? 'Read `.ai/rules/permissions.md` for approval and safety and `.ai/README.md` for shared project context.\n\n' : '';
13
+ return `\n\n${start}\n## Selected engineering rules\n\nBefore planning or implementing a task, load and apply the applicable rules below from the repository root. Preserve existing instructions and ask the project owner to resolve any conflict before proceeding.\n\n${context}${rules.join('\n')}\n${end}\n`;
14
+ }
15
+ export function splitRuleBlock(path, content) {
16
+ const index = content.indexOf(start);
17
+ if (index === -1 && !content.includes(end))
18
+ return { original: content, names: [] };
19
+ const original = content.slice(0, index - 2);
20
+ const suffix = content.slice(index - 2);
21
+ const names = engineeringModules.filter(name => suffix.includes(rulePath(name)));
22
+ if (!names.length || suffix !== block(path, names) && suffix !== block(path, names, true))
23
+ throw new Error(`Review the customized engineering rule block in ${path} before proceeding.`);
24
+ return { original, names };
25
+ }
26
+ export function isRuleBlockEdit(path, before, after) {
27
+ return adapterPaths.includes(path) && typeof before === 'string' && typeof after === 'string' &&
28
+ splitRuleBlock(path, before).original === splitRuleBlock(path, after).original;
29
+ }
30
+ export function ruleAdapters(project, present = (path) => exists(safePath(project.root, path))) {
31
+ return [
32
+ ['AGENTS.override.md', 'AGENTS.md'].find(present),
33
+ ['CLAUDE.md', '.claude/CLAUDE.md'].find(present),
34
+ ['.cursor/rules/ai-workflow-kit.mdc'].find(present),
35
+ ].filter(path => path !== undefined);
36
+ }
37
+ export function planRuleActivation(project, names, read, paths = ruleAdapters(project), includeContext = false) {
38
+ if (!names.length || names.some(name => !engineeringModules.includes(name)) || new Set(names).size !== names.length) {
39
+ throw new Error('Select existing modules: architecture security testing git workflows, or use rules activate all.');
40
+ }
41
+ for (const name of names)
42
+ if (!read(rulePath(name))?.trim())
43
+ throw new Error(`Missing or empty engineering module: ${rulePath(name)}`);
44
+ if (!paths.length)
45
+ throw new Error('Set up a supported instruction entry point before activating engineering rules.');
46
+ return paths.flatMap(path => {
47
+ const before = read(path);
48
+ if (before === null)
49
+ throw new Error(`Instruction file disappeared: ${path}`);
50
+ if (path.endsWith('.mdc') && !/^---\r?\n[\s\S]*?^alwaysApply:\s*true\s*$[\s\S]*?^---\s*$/m.test(before)) {
51
+ throw new Error(`Review the existing Cursor rule scope in ${path} before activation.`);
52
+ }
53
+ const { original, names: active } = splitRuleBlock(path, before);
54
+ const hasContext = active.length > 0 && before === original + block(path, active, true);
55
+ const after = original + block(path, engineeringModules.filter(name => active.includes(name) || names.includes(name)), includeContext || hasContext);
56
+ return before === after ? [] : [{ path, before, after }];
57
+ });
58
+ }
@@ -0,0 +1,18 @@
1
+ export const modules = {
2
+ architecture: 'Inspect boundaries, dependencies, contracts, and affected consumers. Reuse proven project patterns and preserve existing behavior. Keep changes cohesive and proportional to the requirement.',
3
+ security: 'Identify trust boundaries, authorization, input validation, secret handling, and failure paths. Use native safeguards and verify risky changes with a recovery plan.',
4
+ testing: 'Verify affected flows, regressions, and failure cases with relevant approved checks. Report evidence and uncertainty. Obtain approval before checks that write or affect external state.',
5
+ git: 'Inspect branch, working tree, and overlapping work before changes. Preserve other work. Obtain approval before Git writes, branch changes, shared-environment changes, or publishing.',
6
+ workflows: 'For features, verify scope and integration points. For debugging, reproduce and distinguish confirmed causes from hypotheses. For reviews, trace consumers and cite evidence. For high-risk changes, plan compatibility, sequencing, verification, and rollback before asking for approval.',
7
+ };
8
+ export const guide = `Run ai-setup onboard from the relevant checkout. Read existing agent instructions, project docs, and selected modules from ai-setup rules. Identify conflicting instructions explicitly and ask the project owner to resolve them before adopting a conflicting rule. Inspect actual manifests and source, trace critical flows to their boundaries, and sample relevant tests and conventions. In a monorepo, identify shared dependencies and examine only relevant packages. Distinguish verified facts, hypotheses, and open questions. Propose only useful knowledge records, cite source lines, and keep secrets out. Review existing knowledge for overlap. Show the proposal to the owner and wait for explicit approval before writing. Use ai-setup onboard save to review and save approved records. Recheck the code before relying on prior knowledge.`;
9
+ const skill = `---\nname: guided-project-onboarding\ndescription: Review an existing project using code evidence and propose project knowledge for approval.\n---\n\n# Guided project onboarding\n\n${guide}\n`;
10
+ export function bundledRule(name) {
11
+ return `# ${name[0].toUpperCase() + name.slice(1)}\n\n${modules[name]}\n`;
12
+ }
13
+ export function onboardingSkills(agent) {
14
+ return [
15
+ ...(agent === 'codex' ? [] : [{ path: '.claude/skills/guided-project-onboarding/SKILL.md', content: skill }]),
16
+ ...(agent === 'claude' ? [] : [{ path: '.agents/skills/guided-project-onboarding/SKILL.md', content: skill }]),
17
+ ];
18
+ }
@@ -0,0 +1,379 @@
1
+ import { checkQuickstartPrivacy, planQuickstart, printOnboardingHandoff, printQuickstart, quickstartDefaults } from "./quickstart.js";
2
+ import { engineeringModules, isRuleBlockEdit, planRuleActivation, rulePath, splitRuleBlock } from "./rule-activation.js";
3
+ import { randomUUID } from 'node:crypto';
4
+ import { closeSync, lstatSync, openSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
5
+ import { dirname, join } from 'node:path';
6
+ import { createInterface } from 'node:readline/promises';
7
+ import { stdin } from 'node:process';
8
+ import { exists, inspectGitPath, readObject } from "./discovery.js";
9
+ import { bundledVersions, install, manifestPath, safePath, sha, templates, validateChoices, version } from "./initialize.js";
10
+ const backupDir = '.ai/update-backups';
11
+ const backupIgnore = backupDir + '/.gitignore';
12
+ const owner = 'ai-workflow-kit';
13
+ function json(value) {
14
+ return JSON.stringify(value, null, 2) + '\n';
15
+ }
16
+ function read(root, path) {
17
+ const file = safePath(root, path);
18
+ if (!exists(file))
19
+ return null;
20
+ if (lstatSync(file).size > 1024 * 1024)
21
+ throw new Error(`Managed file is too large: ${path}`);
22
+ const bytes = readFileSync(file);
23
+ const text = bytes.toString('utf8');
24
+ if (!Buffer.from(text).equals(bytes))
25
+ throw new Error(`Managed file is not UTF-8: ${path}`);
26
+ return text;
27
+ }
28
+ function manifest(source) {
29
+ const raw = readObject(source ?? undefined);
30
+ if (raw?.owner !== owner || typeof raw.version !== 'string' || !bundledVersions.includes(raw.version)) {
31
+ throw new Error('A recognized setup manifest and a bundled installed version are required.');
32
+ }
33
+ const choices = validateChoices(raw.tracking, raw.adapters);
34
+ const base = new Map(templates({ ...choices, version: raw.version }).map(entry => [entry.path, entry.content]));
35
+ const files = raw.files;
36
+ if (!files || typeof files !== 'object' || Array.isArray(files))
37
+ throw new Error('Invalid manifest provenance.');
38
+ const managed = Object.entries(files).map(([path, meta]) => {
39
+ const content = base.get(path);
40
+ if (content === undefined || meta?.sha256 !== sha(content))
41
+ throw new Error(`Unrecognized baseline for ${path}`);
42
+ return { path, content };
43
+ });
44
+ if (raw.pin !== undefined && (typeof raw.pin !== 'string' || !bundledVersions.includes(raw.pin))) {
45
+ throw new Error('Manifest pin is invalid or unavailable in this bundle.');
46
+ }
47
+ return { raw, choices, managed, installed: raw.version, pin: raw.pin };
48
+ }
49
+ function plan(root, action, value) {
50
+ const before = read(root, manifestPath);
51
+ const { raw, choices, managed, installed, pin } = manifest(before);
52
+ const edits = [];
53
+ const comparisons = [];
54
+ const conflicts = [];
55
+ let next = { ...raw };
56
+ if (action === 'pin') {
57
+ if (value === 'none')
58
+ delete next.pin;
59
+ else if (value === installed || value === version)
60
+ next.pin = value;
61
+ else
62
+ throw new Error('Pin the installed version, the current bundled version, or use none.');
63
+ }
64
+ else if (action === 'repair') {
65
+ for (const { path, content } of managed) {
66
+ if (read(root, path) === null)
67
+ edits.push({ path, before: null, after: content });
68
+ }
69
+ }
70
+ else {
71
+ const target = value ?? pin ?? version;
72
+ if (target !== installed && target !== version)
73
+ throw new Error('Only the installed or current bundled version can be selected.');
74
+ if (pin && target !== pin)
75
+ throw new Error(`Version is pinned to ${pin}. Change the pin in a separate approved operation.`);
76
+ const proposed = new Map(templates({ ...choices, version: target }).map(entry => [entry.path, entry.content]));
77
+ for (const { path, content: base } of managed) {
78
+ const local = read(root, path);
79
+ const incoming = proposed.get(path);
80
+ let status;
81
+ if (incoming === undefined || local === null) {
82
+ status = 'conflict';
83
+ }
84
+ else if (local === incoming) {
85
+ status = 'matches-proposed';
86
+ }
87
+ else if (base === incoming) {
88
+ status = 'preserve-local';
89
+ }
90
+ else if (local === base) {
91
+ status = 'replace-with-bundled';
92
+ edits.push({ path, before: local, after: incoming });
93
+ }
94
+ else {
95
+ status = 'conflict';
96
+ }
97
+ if (status === 'conflict')
98
+ conflicts.push(path);
99
+ comparisons.push({ path, status });
100
+ }
101
+ if (!conflicts.length && target !== installed) {
102
+ next = { ...raw, version: target, files: Object.fromEntries(managed.map(({ path }) => [
103
+ path, { sha256: sha(proposed.get(path)) },
104
+ ])) };
105
+ }
106
+ }
107
+ if (json(raw) !== json(next))
108
+ edits.push({ path: manifestPath, before, after: json(next) });
109
+ return { installed, pin, comparisons, conflicts, edits };
110
+ }
111
+ function replace(root, edit) {
112
+ const current = read(root, edit.path);
113
+ if (current === edit.after)
114
+ return;
115
+ if (current !== edit.before)
116
+ throw new Error(`File changed since preview: ${edit.path}`);
117
+ if (edit.after === null) {
118
+ // Only a rollback of a verified kit-created repair can remove a file.
119
+ unlinkSync(safePath(root, edit.path));
120
+ }
121
+ else if (edit.before === null) {
122
+ install(root, { path: edit.path, content: edit.after });
123
+ }
124
+ else {
125
+ const file = safePath(root, edit.path);
126
+ const temporary = join(dirname(file), `.ai-setup-${randomUUID()}.tmp`);
127
+ const fd = openSync(temporary, 'wx', lstatSync(file).mode & 0o777);
128
+ try {
129
+ try {
130
+ writeFileSync(fd, edit.after);
131
+ }
132
+ finally {
133
+ closeSync(fd);
134
+ }
135
+ if (read(root, edit.path) !== edit.before)
136
+ throw new Error(`File changed since preview: ${edit.path}`);
137
+ renameSync(temporary, file);
138
+ }
139
+ finally {
140
+ if (exists(temporary))
141
+ unlinkSync(temporary);
142
+ }
143
+ }
144
+ }
145
+ function parseTransaction(source, root) {
146
+ const raw = readObject(source);
147
+ if (!raw || typeof raw.id !== 'string' || !/^[a-f\d-]{36}$/.test(raw.id) ||
148
+ typeof raw.action !== 'string' || !['update', 'repair', 'pin', 'rollback', 'activate-rules', 'quickstart', 'rollback-quickstart'].includes(raw.action) ||
149
+ !Array.isArray(raw.edits) || raw.edits.length > 20 || !raw.edits.length)
150
+ throw new Error('Invalid update journal.');
151
+ if (raw.action === 'quickstart' || raw.action === 'rollback-quickstart') {
152
+ const edits = raw.edits;
153
+ validateQuickstartEdits(root, edits, raw.action === 'rollback-quickstart');
154
+ return { id: raw.id, action: raw.action, edits };
155
+ }
156
+ const allowed = new Map();
157
+ const current = manifest(read(root, manifestPath));
158
+ const addKnown = (state) => {
159
+ for (const entry of state.managed) {
160
+ const values = allowed.get(entry.path) ?? new Set();
161
+ for (const bundled of bundledVersions) {
162
+ const file = templates({ ...state.choices, version: bundled }).find(item => item.path === entry.path);
163
+ if (file)
164
+ values.add(file.content);
165
+ }
166
+ allowed.set(entry.path, values);
167
+ }
168
+ };
169
+ addKnown(current);
170
+ const paths = new Set();
171
+ for (const { path, before, after } of raw.edits) {
172
+ if (typeof path !== 'string' || paths.has(path) || before === after)
173
+ throw new Error('Invalid or duplicate journal path.');
174
+ paths.add(path);
175
+ if (path === manifestPath) {
176
+ if (typeof before !== 'string' || typeof after !== 'string')
177
+ throw new Error('Invalid manifest edit.');
178
+ for (const candidate of [manifest(before), manifest(after)]) {
179
+ if (json(candidate.choices) !== json(current.choices) ||
180
+ json(candidate.managed.map(x => x.path)) !== json(current.managed.map(x => x.path)) ||
181
+ json(candidate.raw.preserved) !== json(current.raw.preserved))
182
+ throw new Error('Journal changes setup ownership or privacy.');
183
+ }
184
+ }
185
+ else if (['activate-rules', 'rollback'].includes(raw.action) && isRuleBlockEdit(path, before, after)) {
186
+ continue;
187
+ }
188
+ else if (!allowed.has(path) ||
189
+ [before, after].some(text => text !== null && (typeof text !== 'string' || !allowed.get(path).has(text)))) {
190
+ throw new Error('Journal contains an unmanaged file or unknown content.');
191
+ }
192
+ }
193
+ return { id: raw.id, action: raw.action, edits: raw.edits };
194
+ }
195
+ function validateQuickstartEdits(root, edits, reverse) {
196
+ const forward = reverse ? edits.map(edit => ({ path: edit.path, before: edit.after, after: edit.before })).reverse() : edits;
197
+ const manifestEdit = forward.find(edit => edit.path === manifestPath);
198
+ const installed = read(root, manifestPath);
199
+ if (manifestEdit && (manifestEdit.before !== null || installed !== null && installed !== manifestEdit.after ||
200
+ forward.at(-1) !== manifestEdit))
201
+ throw new Error('Invalid quickstart manifest change.');
202
+ const state = manifest(manifestEdit ? manifestEdit.after : installed);
203
+ const defaults = bundledVersions.flatMap(version => quickstartDefaults({ ...state.choices, version }));
204
+ const attachesRecommended = (path, before, after) => isRuleBlockEdit(path, before, after) && splitRuleBlock(path, after).names.length === engineeringModules.length;
205
+ const paths = new Set();
206
+ for (const { path, before, after } of forward) {
207
+ if (paths.has(path) || before === after || typeof after !== 'string')
208
+ throw new Error('Invalid quickstart journal edit.');
209
+ paths.add(path);
210
+ if (path === manifestPath)
211
+ continue;
212
+ if (typeof before === 'string' && attachesRecommended(path, before, after))
213
+ continue;
214
+ if (before === null && defaults.some(entry => entry.path === path &&
215
+ (entry.content === after || attachesRecommended(path, entry.content, after))))
216
+ continue;
217
+ throw new Error('Quickstart journal contains an unmanaged path or unknown content.');
218
+ }
219
+ if (manifestEdit && (state.raw.pin !== undefined || state.managed.some(({ path, content }) => !forward.some(edit => edit.path === path && edit.before === null &&
220
+ (edit.after === content || typeof edit.after === 'string' && isRuleBlockEdit(path, content, edit.after)))))) {
221
+ throw new Error('Quickstart manifest contains files outside the approved setup.');
222
+ }
223
+ return state.choices.policy;
224
+ }
225
+ async function approve() {
226
+ const input = createInterface({ input: stdin, terminal: false });
227
+ try {
228
+ console.log('Type apply to approve this operation and its backup:');
229
+ for await (const line of input)
230
+ return line.trim() === 'apply';
231
+ return false;
232
+ }
233
+ finally {
234
+ input.close();
235
+ }
236
+ }
237
+ function verifyEdits(root, edits, resume) {
238
+ for (const edit of edits) {
239
+ const current = read(root, edit.path);
240
+ if (current !== edit.before && !(resume && current === edit.after)) {
241
+ throw new Error(`File changed since preview: ${edit.path}`);
242
+ }
243
+ }
244
+ }
245
+ function checkBackupPrivacy(project) {
246
+ const { root } = project;
247
+ const ignore = read(root, backupIgnore);
248
+ if (ignore !== null && ignore !== '*\n')
249
+ throw new Error('Existing update-backup privacy rules differ.');
250
+ if (project.git.detected && inspectGitPath(root, backupDir + '/', 'tracked') !== false) {
251
+ throw new Error('The backup directory must be untracked.');
252
+ }
253
+ }
254
+ export async function update(project, action, args) {
255
+ const { root } = project;
256
+ const dry = args.includes('--dry-run');
257
+ const values = args.filter(arg => arg !== '--dry-run');
258
+ if (args.length !== values.length + Number(dry) || action !== 'activate-rules' && values.length > 1 ||
259
+ action === 'update' && values.length && !/^--version=\d+\.\d+\.\d+$/.test(values[0]) ||
260
+ ['repair', 'quickstart'].includes(action) && values.length ||
261
+ action === 'pin' && (values.length !== 1 || !/^(none|\d+\.\d+\.\d+)$/.test(values[0])) ||
262
+ action === 'rollback' && (values.length !== 1 || !/^[a-f\d-]{36}$/.test(values[0])))
263
+ throw new Error('Invalid operation arguments.');
264
+ // Keep the complete pending journal with the private backups.
265
+ const pending = backupDir + '/.pending.json';
266
+ const saved = read(root, pending);
267
+ let transaction;
268
+ let activationInputs = [];
269
+ if (saved !== null) {
270
+ transaction = parseTransaction(saved, root);
271
+ const resumeCommand = transaction.action === 'quickstart' ? 'quickstart' : 'update';
272
+ if (action !== resumeCommand || values.length)
273
+ throw new Error(`A transaction is pending. Run ai-setup ${resumeCommand} to review and resume it.`);
274
+ if (action === 'quickstart') {
275
+ printQuickstart(project, transaction.edits, [], validateQuickstartEdits(root, transaction.edits, false), true);
276
+ }
277
+ else
278
+ console.log(json({ pending: true, ...transaction }));
279
+ }
280
+ else {
281
+ let edits;
282
+ if (action === 'rollback') {
283
+ const receipt = read(root, backupDir + '/' + values[0] + '.json');
284
+ if (receipt === null)
285
+ throw new Error('Backup not found.');
286
+ const original = parseTransaction(receipt, root);
287
+ if (original.id !== values[0])
288
+ throw new Error('Backup ID does not match.');
289
+ edits = original.edits.map(edit => ({ path: edit.path, before: edit.after, after: edit.before }));
290
+ if (original.action === 'quickstart') {
291
+ action = 'rollback-quickstart';
292
+ edits.reverse();
293
+ }
294
+ else if (original.action === 'rollback-quickstart') {
295
+ throw new Error('Run quickstart to set up this project again.');
296
+ }
297
+ console.log(json({ action, backup: original.id, edits }));
298
+ }
299
+ else if (action === 'quickstart') {
300
+ const installed = read(root, manifestPath);
301
+ const setup = installed === null ? undefined : manifest(installed);
302
+ if (setup?.managed.some(({ path }) => read(root, path) === null)) {
303
+ throw new Error('A managed setup file is missing. Review ai-setup repair before running quickstart.');
304
+ }
305
+ const proposal = planQuickstart(project, path => read(root, path), setup?.choices);
306
+ edits = proposal.edits;
307
+ activationInputs = [{ path: manifestPath, content: installed },
308
+ ...[...proposal.inputs].map(([path, content]) => ({ path, content }))];
309
+ printQuickstart(project, edits, proposal.preserved, proposal.policy, false);
310
+ if (!edits.length)
311
+ printOnboardingHandoff();
312
+ }
313
+ else if (action === 'activate-rules') {
314
+ const names = values.length === 1 && values[0] === 'all' ? engineeringModules : values;
315
+ edits = planRuleActivation(project, names, path => read(root, path));
316
+ activationInputs = names.map(name => ({ path: rulePath(name), content: read(root, rulePath(name)) }));
317
+ console.log(json({ action, modules: activationInputs, edits,
318
+ review: 'Review rule contents and existing instructions for conflicts before approval.' }));
319
+ }
320
+ else {
321
+ const proposal = plan(root, action, values[0]?.replace(/^--version=/, ''));
322
+ console.log(json({ action, bundle: version, ...proposal }));
323
+ if (proposal.conflicts.length)
324
+ throw new Error('Resolve conflicts manually before updating. No files were changed.');
325
+ edits = proposal.edits;
326
+ }
327
+ if (!edits.length)
328
+ return;
329
+ transaction = { id: randomUUID(), action, edits };
330
+ }
331
+ parseTransaction(json(transaction), root);
332
+ const quick = ['quickstart', 'rollback-quickstart'].includes(transaction.action);
333
+ const quickPolicy = quick ? validateQuickstartEdits(root, transaction.edits, transaction.action === 'rollback-quickstart') : undefined;
334
+ function checkRulePrivacy() {
335
+ if (quickPolicy) {
336
+ checkQuickstartPrivacy(project, transaction.edits, quickPolicy);
337
+ return;
338
+ }
339
+ if (manifest(read(root, manifestPath)).choices.policy === 'local-only' && project.git.detected &&
340
+ transaction.edits.some(({ path, before, after }) => isRuleBlockEdit(path, before, after) &&
341
+ (inspectGitPath(root, path, 'tracked') !== false || inspectGitPath(root, path, 'ignored') !== true))) {
342
+ throw new Error('Local-only activation requires ignored, untracked instruction entry points.');
343
+ }
344
+ }
345
+ checkRulePrivacy();
346
+ verifyEdits(root, transaction.edits, saved !== null);
347
+ checkBackupPrivacy(project);
348
+ if (dry || !await approve())
349
+ return;
350
+ if (activationInputs.some(({ path, content }) => read(root, path) !== content)) {
351
+ throw new Error('A setup input changed after preview. Review a fresh plan.');
352
+ }
353
+ checkRulePrivacy();
354
+ verifyEdits(root, transaction.edits, saved !== null);
355
+ checkBackupPrivacy(project);
356
+ const journal = json(transaction);
357
+ if (Buffer.byteLength(journal) > 1024 * 1024)
358
+ throw new Error('Combined backup is too large. Review setup in smaller steps.');
359
+ install(root, { path: backupIgnore, content: '*\n' });
360
+ if (project.git.detected && inspectGitPath(root, pending, 'ignored') !== true)
361
+ throw new Error('Git does not ignore update backups.');
362
+ install(root, { path: pending, content: journal });
363
+ const ignoreEdit = transaction.action === 'quickstart' && transaction.edits.find(edit => edit.path === '.ai/.gitignore');
364
+ if (ignoreEdit)
365
+ replace(root, ignoreEdit);
366
+ if (quickPolicy && transaction.action === 'quickstart')
367
+ checkQuickstartPrivacy(project, transaction.edits, quickPolicy, true);
368
+ for (const edit of transaction.edits)
369
+ if (edit !== ignoreEdit)
370
+ replace(root, edit);
371
+ if (transaction.edits.some(edit => read(root, edit.path) !== edit.after))
372
+ throw new Error('Update verification failed.');
373
+ install(root, { path: backupDir + '/' + transaction.id + '.json', content: journal });
374
+ if (read(root, pending) === journal)
375
+ unlinkSync(safePath(root, pending));
376
+ console.log(`Verified. Backup ID: ${transaction.id}`);
377
+ if (transaction.action === 'quickstart')
378
+ printOnboardingHandoff();
379
+ }
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
2
  "name": "@zeeshanjamshed/ai-workflow-kit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.4.2",
4
+ "description": "Approval-first CLI for setting up shared project rules, onboarding skills, and handoffs for coding agents.",
5
+ "author": "Zeeshan Jamshed",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/zeeshanjamshed/ai-workflow-kit.git"
10
+ },
11
+ "homepage": "https://github.com/zeeshanjamshed/ai-workflow-kit#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/zeeshanjamshed/ai-workflow-kit/issues"
14
+ },
15
+ "keywords": [
16
+ "ai-workflow",
17
+ "coding-agents",
18
+ "cli",
19
+ "project-setup",
20
+ "claude-code",
21
+ "codex",
22
+ "cursor"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "type": "module",
28
+ "engines": {
29
+ "node": ">=22.18.0"
30
+ },
31
+ "scripts": {
32
+ "ai-setup": "node packages/cli/src/main.ts",
33
+ "test": "node --test packages/cli/tests/*.test.ts",
34
+ "build": "tsc -p tsconfig.build.json",
35
+ "typecheck": "tsc --noEmit",
36
+ "prepack": "npm run build",
37
+ "test:package": "node packages/cli/tests/package-smoke.mjs"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "22.20.5",
41
+ "typescript": "5.9.3"
42
+ },
43
+ "bin": {
44
+ "ai-setup": "dist/packages/cli/src/main.js"
45
+ },
46
+ "files": [
47
+ "dist/packages/cli/src"
48
+ ]
49
+ }