@zeeshanjamshed/ai-workflow-kit 0.0.0-stage → 0.4.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/LICENSE +21 -0
- package/README.md +172 -2
- package/dist/packages/cli/src/context.js +101 -0
- package/dist/packages/cli/src/coordination.js +147 -0
- package/dist/packages/cli/src/discovery.js +144 -0
- package/dist/packages/cli/src/full-standards.js +68 -0
- package/dist/packages/cli/src/initialize.js +250 -0
- package/dist/packages/cli/src/instructions.js +18 -0
- package/dist/packages/cli/src/main.js +62 -0
- package/dist/packages/cli/src/onboarding.js +168 -0
- package/dist/packages/cli/src/quickstart.js +124 -0
- package/dist/packages/cli/src/reports.js +58 -0
- package/dist/packages/cli/src/rule-activation.js +74 -0
- package/dist/packages/cli/src/setup-assets.js +18 -0
- package/dist/packages/cli/src/setup.js +51 -0
- package/dist/packages/cli/src/update.js +400 -0
- package/package.json +47 -4
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { fullStandards } from "./full-standards.js";
|
|
2
|
+
import { diagnose } from "./reports.js";
|
|
3
|
+
import { inspectGitPath } from "./discovery.js";
|
|
4
|
+
import { manifestPath, sha, statePath, templates, version } from "./initialize.js";
|
|
5
|
+
import { engineeringModules, planRuleActivation, ruleAdapters, rulePath, splitRuleBlock } from "./rule-activation.js";
|
|
6
|
+
import { bundledRule, onboardingSkills } from "./setup-assets.js";
|
|
7
|
+
const adapters = ['codex', 'claude', 'cursor'];
|
|
8
|
+
const ignore = '.ai/.gitignore';
|
|
9
|
+
const modules = engineeringModules.map(name => ({ path: rulePath(name), content: bundledRule(name) }));
|
|
10
|
+
const skills = onboardingSkills('both');
|
|
11
|
+
const recommended = { preset: 'quickstart', onboarding: true };
|
|
12
|
+
export function quickstartDefaults(choices) {
|
|
13
|
+
return [...templates({ ...choices, agents: adapters }), ...modules, ...skills, ...fullStandards];
|
|
14
|
+
}
|
|
15
|
+
export function planQuickstart(project, read, installed, options = recommended) {
|
|
16
|
+
if (!installed && read(statePath) !== null) {
|
|
17
|
+
throw new Error('An initialization is pending. Finish ai-setup init before running quickstart.');
|
|
18
|
+
}
|
|
19
|
+
const choices = installed ?? { policy: options.policy ?? 'mixed', agents: adapters };
|
|
20
|
+
const base = templates({ ...choices, agents: adapters });
|
|
21
|
+
const optional = options.preset === 'full' ? fullStandards : options.preset === 'quickstart' ? modules : [];
|
|
22
|
+
const defaults = [...base, ...optional, ...(options.onboarding ? skills : [])];
|
|
23
|
+
const edits = new Map();
|
|
24
|
+
const inputs = new Map();
|
|
25
|
+
const snapshot = path => {
|
|
26
|
+
const content = read(path);
|
|
27
|
+
inputs.set(path, content);
|
|
28
|
+
return content;
|
|
29
|
+
};
|
|
30
|
+
const projected = path => edits.get(path)?.after ?? snapshot(path);
|
|
31
|
+
const preserved = [];
|
|
32
|
+
const hasFull = ruleAdapters(project).some(path => splitRuleBlock(path, snapshot(path) ?? '').full);
|
|
33
|
+
for (const { path, content } of defaults) {
|
|
34
|
+
if (path === 'AGENTS.md' && snapshot('AGENTS.override.md') !== null ||
|
|
35
|
+
path === 'CLAUDE.md' && snapshot('.claude/CLAUDE.md') !== null ||
|
|
36
|
+
path === '.cursor/rules/ai-workflow-kit.mdc' && projected('AGENTS.md') !== null && snapshot('AGENTS.override.md') === null && snapshot(path) === null)
|
|
37
|
+
continue;
|
|
38
|
+
const before = snapshot(path);
|
|
39
|
+
if (before === null)
|
|
40
|
+
edits.set(path, { path, before, after: content });
|
|
41
|
+
else {
|
|
42
|
+
if (path === ignore && before !== content)
|
|
43
|
+
throw new Error('Existing .ai/.gitignore conflicts with the setup privacy policy.');
|
|
44
|
+
if (!installed && path === '.ai/config.yaml' && before !== content) {
|
|
45
|
+
throw new Error('Existing .ai/config.yaml has no recognized manifest. Review its setup and privacy choices.');
|
|
46
|
+
}
|
|
47
|
+
if (optional === fullStandards && fullStandards.some(entry => entry.path === path) && before !== content && !hasFull) {
|
|
48
|
+
throw new Error(`Existing Full Engineering file differs: ${path}. Preserve it and reconcile the conflict before retrying.`);
|
|
49
|
+
}
|
|
50
|
+
if (!before.trim() && modules.some(module => module.path === path))
|
|
51
|
+
throw new Error(`Existing engineering rule is empty: ${path}`);
|
|
52
|
+
preserved.push(path);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
{
|
|
56
|
+
const paths = ruleAdapters(project, path => projected(path) !== null);
|
|
57
|
+
const isCustom = (name) => {
|
|
58
|
+
const content = projected(rulePath(name));
|
|
59
|
+
if (!content?.trim())
|
|
60
|
+
throw new Error(`Missing or empty selected rule: ${rulePath(name)}`);
|
|
61
|
+
return content !== bundledRule(name);
|
|
62
|
+
};
|
|
63
|
+
const selected = options.preset === 'quickstart' ? engineeringModules : [];
|
|
64
|
+
for (const edit of planRuleActivation(project, selected, projected, paths, true, options.preset === 'full' ? isCustom : undefined, options.preset === 'minimal')) {
|
|
65
|
+
edits.set(edit.path, { ...edit, before: edits.get(edit.path)?.before === null ? null : edit.before });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!installed) {
|
|
69
|
+
const managed = base.filter(({ path }) => edits.get(path)?.before === null);
|
|
70
|
+
edits.set(manifestPath, { path: manifestPath, before: null, after: JSON.stringify({
|
|
71
|
+
owner: 'ai-workflow-kit', version, tracking: choices.policy, adapters,
|
|
72
|
+
files: Object.fromEntries(managed.map(({ path, content }) => [path, { sha256: sha(content) }])),
|
|
73
|
+
preserved,
|
|
74
|
+
}, null, 2) + '\n' });
|
|
75
|
+
}
|
|
76
|
+
return { edits: [...edits.values()], inputs, preserved, policy: choices.policy };
|
|
77
|
+
}
|
|
78
|
+
export function checkQuickstartPrivacy(project, edits, policy, applying = false) {
|
|
79
|
+
if (!project.git.detected)
|
|
80
|
+
return;
|
|
81
|
+
const { root } = project;
|
|
82
|
+
const willIgnore = !applying && edits.some(edit => edit.path === ignore && edit.before === null && edit.after !== null);
|
|
83
|
+
const privatePaths = policy === 'local-only' ? edits.map(edit => edit.path)
|
|
84
|
+
: policy === 'mixed' ? ['.ai/knowledge/', '.ai/decisions/', '.ai/tasks/'] : [];
|
|
85
|
+
for (const path of privatePaths) {
|
|
86
|
+
if (inspectGitPath(root, path, 'tracked') !== false ||
|
|
87
|
+
!(willIgnore && path.startsWith('.ai/')) && inspectGitPath(root, path, 'ignored') !== true) {
|
|
88
|
+
throw new Error(`Private path must be ignored and untracked: ${path}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (policy !== 'local-only') {
|
|
92
|
+
for (const { path } of edits) {
|
|
93
|
+
if (inspectGitPath(root, path, 'ignored') !== false)
|
|
94
|
+
throw new Error(`Git must allow tracking for ${path}.`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export function printQuickstart(project, edits, preserved, policy, resumed, label = 'Quickstart') {
|
|
99
|
+
console.log(`${label}: ${project.root} (${project.classification}, ${policy} tracking)`);
|
|
100
|
+
if (project.workspaceMarkers.length || project.packageWorkspaces)
|
|
101
|
+
console.log(' Workspace detected. Setup is scoped to the repository root.');
|
|
102
|
+
const { findings } = diagnose(project);
|
|
103
|
+
for (const finding of findings.slice(0, 3))
|
|
104
|
+
console.log(` Check: ${finding}`);
|
|
105
|
+
if (findings.length > 3)
|
|
106
|
+
console.log(' Run ai-setup doctor for the remaining findings.');
|
|
107
|
+
if (resumed)
|
|
108
|
+
console.log('Resume the saved quickstart plan:');
|
|
109
|
+
for (const { path, before } of edits)
|
|
110
|
+
console.log(` ${before === null ? 'Add' : 'Link rules in'} ${path}`);
|
|
111
|
+
if (preserved.length)
|
|
112
|
+
console.log(`Keep ${preserved.length} existing files, including any customized modules or skills.`);
|
|
113
|
+
if (edits.length)
|
|
114
|
+
console.log('Review existing instructions for conflicts. Applying saves an ignored recovery journal and backup.');
|
|
115
|
+
else
|
|
116
|
+
console.log('Setup is already complete.');
|
|
117
|
+
}
|
|
118
|
+
export function printOnboardingHandoff(withSkill = true) {
|
|
119
|
+
if (!withSkill) {
|
|
120
|
+
console.log('Next: use ai-setup onboard for a read-only inventory. Skill installation and any knowledge writes require separate approval.');
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
console.log('Next: start Claude Code or Codex here and run guided-project-onboarding. Review and approve knowledge separately.');
|
|
124
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isAbsolute, posix } from 'node:path';
|
|
2
|
+
import { projectPathExists, readObject, readProjectFile } from "./discovery.js";
|
|
3
|
+
const index = '.ai/README.md';
|
|
4
|
+
const manifest = '.ai/setup-manifest.json';
|
|
5
|
+
const entries = ['CLAUDE.md', 'AGENTS.md', '.cursor/rules/ai-workflow-kit.mdc'];
|
|
6
|
+
export function preview(project) {
|
|
7
|
+
const paths = [index, manifest, ...entries];
|
|
8
|
+
return {
|
|
9
|
+
project,
|
|
10
|
+
files: paths.map(path => ({
|
|
11
|
+
path,
|
|
12
|
+
action: projectPathExists(project.root, path) ? 'review-existing' : 'candidate-add',
|
|
13
|
+
})),
|
|
14
|
+
next: [
|
|
15
|
+
'Review candidates with the selected agent and confirm project and tool requirements.',
|
|
16
|
+
'Confirm enabled adapters and whether AI records should be tracked, ignored, or mixed.',
|
|
17
|
+
'Review exact contents, existing instructions, and backups before approving any writes.',
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function diagnose(project) {
|
|
22
|
+
const findings = [];
|
|
23
|
+
const read = (path) => readProjectFile(project.root, path);
|
|
24
|
+
if (project.git.detected && project.git.dirty === undefined)
|
|
25
|
+
findings.push('Git status unavailable. Check the repository and Git installation.');
|
|
26
|
+
if (project.classification === 'initialized') {
|
|
27
|
+
if (!project.version || !readObject(read(manifest)))
|
|
28
|
+
findings.push('Manifest is invalid or lacks a version. Review setup provenance.');
|
|
29
|
+
if (!read(index))
|
|
30
|
+
findings.push('Project knowledge index is missing or unreadable. Review the .ai setup.');
|
|
31
|
+
if (project.agents.every(agent => !agent.paths.some(path => /\.md$|\.cursor\/rules$/.test(path)))) {
|
|
32
|
+
findings.push('No recognized instruction entry point. Review the enabled adapters.');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const docs = new Set([index, ...project.docs.filter(path => /\.md$/i.test(path)),
|
|
36
|
+
...project.agents.flatMap(agent => agent.paths.filter(path => /\.md$/i.test(path)))]);
|
|
37
|
+
for (const path of docs) {
|
|
38
|
+
const source = read(path);
|
|
39
|
+
if (!source)
|
|
40
|
+
continue;
|
|
41
|
+
for (const match of source.replace(/^```[^\n]*\n[\s\S]*?^```[ \t]*$/gm, '').matchAll(/\]\(<?([^\s)>#]+)(?:#[^\s)>]*)?>?\)/g)) {
|
|
42
|
+
const target = match[1];
|
|
43
|
+
if (!/\.md$/i.test(target) || /^[a-z][a-z\d+.-]*:|^\/\//i.test(target) || isAbsolute(target))
|
|
44
|
+
continue;
|
|
45
|
+
let decoded;
|
|
46
|
+
try {
|
|
47
|
+
decoded = decodeURIComponent(target);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const resolved = posix.normalize(posix.join(posix.dirname(path), decoded));
|
|
53
|
+
if (!projectPathExists(project.root, resolved))
|
|
54
|
+
findings.push(`Check Markdown link in ${path}: ${target}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return { project, findings: [...new Set(findings)] };
|
|
58
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { fullIndex } from "./full-standards.js";
|
|
2
|
+
import { exists } from "./discovery.js";
|
|
3
|
+
import { safePath } from "./initialize.js";
|
|
4
|
+
export const engineeringModules = ['architecture', 'security', 'testing', 'git', 'workflows'];
|
|
5
|
+
export const rulePath = (name) => `.ai/rules/engineering-${name}.md`;
|
|
6
|
+
const start = '<!-- ai-workflow-kit:engineering-rules -->';
|
|
7
|
+
const end = '<!-- /ai-workflow-kit:engineering-rules -->';
|
|
8
|
+
export const adapterPaths = ['AGENTS.md', 'AGENTS.override.md', 'CLAUDE.md', '.claude/CLAUDE.md', '.cursor/rules/ai-workflow-kit.mdc'];
|
|
9
|
+
function block(path, names, includeContext = false, full = false) {
|
|
10
|
+
const claude = path.endsWith('CLAUDE.md');
|
|
11
|
+
const prefix = path === '.claude/CLAUDE.md' ? '../' : '';
|
|
12
|
+
const rules = names.map(name => claude ? `@${prefix}${rulePath(name)}` : `- \`${rulePath(name)}\``);
|
|
13
|
+
const safety = 'Get explicit approval before writes or side effects. For known breaking changes obtain three distinct explicit confirmations. Use native safeguards.';
|
|
14
|
+
if (!full && !names.length) {
|
|
15
|
+
return `\n\n${start}\n## Project safety\n\n${safety} Read .ai/rules/permissions.md and .ai/README.md before planning.\n${end}\n`;
|
|
16
|
+
}
|
|
17
|
+
if (full) {
|
|
18
|
+
const nav = claude ? `@${prefix}${fullIndex}` : `Read \`${fullIndex}\` at task start.`;
|
|
19
|
+
const custom = rules.length ? `\nPreviously selected project-customized rules:\n\n${rules.join('\n')}\n` : '';
|
|
20
|
+
return `\n\n${start}\n## Full Engineering\n\n${safety} Read .ai/rules/permissions.md and .ai/README.md before planning. Load only applicable detailed modules; keep existing project instructions and ask the owner to resolve conflicts.\n\n${nav}\n${custom}${end}\n`;
|
|
21
|
+
}
|
|
22
|
+
const context = includeContext ? 'Read `.ai/rules/permissions.md` for approval and safety and `.ai/README.md` for shared project context.\n\n' : '';
|
|
23
|
+
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`;
|
|
24
|
+
}
|
|
25
|
+
export function splitRuleBlock(path, content) {
|
|
26
|
+
const index = content.indexOf(start);
|
|
27
|
+
if (index === -1 && !content.includes(end))
|
|
28
|
+
return { original: content, names: [], full: false };
|
|
29
|
+
const original = content.slice(0, index - 2);
|
|
30
|
+
const suffix = content.slice(index - 2);
|
|
31
|
+
const names = engineeringModules.filter(name => suffix.includes(rulePath(name)));
|
|
32
|
+
if (suffix === block(path, [], true))
|
|
33
|
+
return { original, names, full: false, minimal: true };
|
|
34
|
+
if (suffix === block(path, names, true, true))
|
|
35
|
+
return { original, names, full: true };
|
|
36
|
+
if (!names.length || suffix !== block(path, names) && suffix !== block(path, names, true))
|
|
37
|
+
throw new Error(`Review the customized engineering rule block in ${path} before proceeding.`);
|
|
38
|
+
return { original, names, full: false };
|
|
39
|
+
}
|
|
40
|
+
export function isRuleBlockEdit(path, before, after) {
|
|
41
|
+
return adapterPaths.includes(path) && typeof before === 'string' && typeof after === 'string' &&
|
|
42
|
+
splitRuleBlock(path, before).original === splitRuleBlock(path, after).original;
|
|
43
|
+
}
|
|
44
|
+
export function ruleAdapters(project, present = (path) => exists(safePath(project.root, path))) {
|
|
45
|
+
return [
|
|
46
|
+
['AGENTS.override.md', 'AGENTS.md'].find(present),
|
|
47
|
+
['CLAUDE.md', '.claude/CLAUDE.md'].find(present),
|
|
48
|
+
['.cursor/rules/ai-workflow-kit.mdc'].find(present),
|
|
49
|
+
].filter(path => path !== undefined);
|
|
50
|
+
}
|
|
51
|
+
export function planRuleActivation(project, names, read, paths = ruleAdapters(project), includeContext = false, full, minimal = false) {
|
|
52
|
+
if ((!minimal && !full && !names.length) || names.some(name => !engineeringModules.includes(name)) || new Set(names).size !== names.length) {
|
|
53
|
+
throw new Error('Select existing modules: architecture security testing git workflows, or use rules activate all.');
|
|
54
|
+
}
|
|
55
|
+
for (const name of names)
|
|
56
|
+
if (!read(rulePath(name))?.trim())
|
|
57
|
+
throw new Error(`Missing or empty engineering module: ${rulePath(name)}`);
|
|
58
|
+
if (!paths.length)
|
|
59
|
+
throw new Error('Set up a supported instruction entry point before activating engineering rules.');
|
|
60
|
+
return paths.flatMap(path => {
|
|
61
|
+
const before = read(path);
|
|
62
|
+
if (before === null)
|
|
63
|
+
throw new Error(`Instruction file disappeared: ${path}`);
|
|
64
|
+
if (path.endsWith('.mdc') && !/^---\r?\n[\s\S]*?^alwaysApply:\s*true\s*$[\s\S]*?^---\s*$/m.test(before)) {
|
|
65
|
+
throw new Error(`Review the existing Cursor rule scope in ${path} before activation.`);
|
|
66
|
+
}
|
|
67
|
+
const { original, names: active, full: activeFull } = splitRuleBlock(path, before);
|
|
68
|
+
const hasContext = active.length > 0 && before === original + block(path, active, true);
|
|
69
|
+
if (activeFull && !full || minimal && (active.length || before !== original))
|
|
70
|
+
return [];
|
|
71
|
+
const after = full ? original + block(path, active.filter(full), true, true) : original + block(path, engineeringModules.filter(name => active.includes(name) || names.includes(name)), includeContext || hasContext);
|
|
72
|
+
return before === after ? [] : [{ path, before, after }];
|
|
73
|
+
});
|
|
74
|
+
}
|
|
@@ -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,51 @@
|
|
|
1
|
+
import { createInterface } from 'node:readline/promises';
|
|
2
|
+
import { stdin } from 'node:process';
|
|
3
|
+
import { exists } from "./discovery.js";
|
|
4
|
+
import { safePath, validateChoices } from "./initialize.js";
|
|
5
|
+
import { update } from "./update.js";
|
|
6
|
+
const presets = ['minimal', 'quickstart', 'full'];
|
|
7
|
+
export async function setup(project, command, args) {
|
|
8
|
+
const dry = args.includes('--dry-run');
|
|
9
|
+
const flags = args.filter(arg => arg !== '--dry-run');
|
|
10
|
+
const presetFlag = flags.find(arg => arg.startsWith('--preset='));
|
|
11
|
+
const trackingFlag = flags.find(arg => arg.startsWith('--tracking='));
|
|
12
|
+
const onboarding = flags.filter(arg => arg === '--onboarding' || arg === '--no-onboarding');
|
|
13
|
+
if (args.length !== flags.length + Number(dry) || onboarding.length > 1 ||
|
|
14
|
+
flags.length !== Number(Boolean(presetFlag)) + Number(Boolean(trackingFlag)) + onboarding.length ||
|
|
15
|
+
command === 'full' && presetFlag)
|
|
16
|
+
throw new Error('Use setup [--preset=minimal|quickstart|full] [--onboarding|--no-onboarding] [--tracking=POLICY] [--dry-run].');
|
|
17
|
+
const pending = exists(safePath(project.root, '.ai/update-backups/.pending.json'));
|
|
18
|
+
const input = createInterface({ input: stdin, terminal: false });
|
|
19
|
+
const lines = input[Symbol.asyncIterator]();
|
|
20
|
+
const ask = async (prompt) => {
|
|
21
|
+
console.log(prompt);
|
|
22
|
+
return (await lines.next()).value?.trim();
|
|
23
|
+
};
|
|
24
|
+
try {
|
|
25
|
+
const approval = async () => await ask('Type apply to approve this operation and its backup:') === 'apply';
|
|
26
|
+
if (pending) {
|
|
27
|
+
if (flags.length)
|
|
28
|
+
throw new Error('Resume with ai-setup setup or ai-setup setup --dry-run to review the saved plan.');
|
|
29
|
+
await update(project, 'quickstart', dry ? ['--dry-run'] : [], undefined, approval);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const selected = command === 'full' ? 'full' : presetFlag?.slice(9) ??
|
|
33
|
+
(dry ? 'quickstart' : await ask('Choose a preset (minimal, quickstart, full):'));
|
|
34
|
+
if (!selected || !presets.includes(selected))
|
|
35
|
+
throw new Error('Choose minimal, quickstart, or full.');
|
|
36
|
+
const skill = onboarding.at(0) ?? (command === 'full' || dry || presetFlag ? '--no-onboarding'
|
|
37
|
+
: await ask('Install guided onboarding skills for Claude Code and Codex? (yes/no)'));
|
|
38
|
+
if (!skill || !['yes', 'no', '--onboarding', '--no-onboarding'].includes(skill))
|
|
39
|
+
throw new Error('Choose yes or no for skill installation.');
|
|
40
|
+
const initialized = project.classification === 'initialized';
|
|
41
|
+
if (initialized && trackingFlag)
|
|
42
|
+
throw new Error('Existing setup tracking is preserved. Omit --tracking.');
|
|
43
|
+
const tracking = trackingFlag?.slice(11) ?? (initialized || command === 'full' || dry || presetFlag ? 'mixed'
|
|
44
|
+
: await ask('Tracking (mixed, tracked, local-only). Mixed keeps knowledge, decisions, and task records out of Git:'));
|
|
45
|
+
const { policy } = validateChoices(tracking, []);
|
|
46
|
+
await update(project, 'quickstart', dry ? ['--dry-run'] : [], { preset: selected, onboarding: skill === 'yes' || skill === '--onboarding', policy }, approval);
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
input.close();
|
|
50
|
+
}
|
|
51
|
+
}
|