MCPcopy
hub / github.com/afar1/fieldtheory-cli / stepPickSeed

Function stepPickSeed

src/possible-wizard.ts:84–135  ·  view source on GitHub ↗
(
  prompter: Prompter,
  deps: Pick<WizardDeps, 'listSeeds'>,
)

Source from the content-addressed store, hash-verified

82];
83
84export async function stepPickSeed(
85 prompter: Prompter,
86 deps: Pick<WizardDeps, 'listSeeds'>,
87): Promise<
88 | { kind: 'picked'; seed: IdeasSeed }
89 | { kind: 'empty'; strategy: SeedStrategyHint; command: string }
90 | { kind: 'cancelled'; reason: string }
91> {
92 const seeds = deps.listSeeds();
93
94 if (seeds.length === 0) {
95 prompter.write('');
96 prompter.write('No saved seeds yet. Seeds are groups of bookmarks applied to a repo.');
97 prompter.write('Pick a strategy to gather your first seed:');
98 prompter.write('');
99 for (const [idx, hint] of SEED_STRATEGY_HINTS.entries()) {
100 prompter.write(` ${idx + 1}) ${hint.label.padEnd(8)} ${hint.description}`);
101 }
102 prompter.write('');
103 const answer = await prompter.ask('Pick a strategy [1-3] (or `q` to quit): ');
104 if (answer === 'q' || answer === 'Q') {
105 return { kind: 'cancelled', reason: 'quit-at-seed-strategy' };
106 }
107 const pick = parseIndex(answer, SEED_STRATEGY_HINTS.length);
108 if (pick === null) {
109 return { kind: 'cancelled', reason: 'invalid-strategy-pick' };
110 }
111 const hint = SEED_STRATEGY_HINTS[pick]!;
112 return { kind: 'empty', strategy: hint.key, command: hint.command };
113 }
114
115 prompter.write('');
116 prompter.write(`Pick a seed (${seeds.length} saved):`);
117 prompter.write('');
118 for (const [idx, seed] of seeds.entries()) {
119 const count = seed.artifactIds.length;
120 const frame = seed.frameId ? ` frame: ${seed.frameId}` : '';
121 const lastUsed = seed.lastUsedAt ? ` last used: ${seed.lastUsedAt.slice(0, 10)}` : '';
122 prompter.write(` ${(idx + 1).toString().padStart(2)}) ${seed.id} ${count} artifact${count === 1 ? '' : 's'}${frame}${lastUsed}`);
123 prompter.write(` ${seed.title}`);
124 }
125 prompter.write('');
126 const answer = await prompter.ask(`Pick a seed [1-${seeds.length}] (or \`q\` to quit): `);
127 if (answer === 'q' || answer === 'Q') {
128 return { kind: 'cancelled', reason: 'quit-at-seed-pick' };
129 }
130 const pick = parseIndex(answer, seeds.length);
131 if (pick === null) {
132 return { kind: 'cancelled', reason: 'invalid-seed-pick' };
133 }
134 return { kind: 'picked', seed: seeds[pick]! };
135}
136
137// ── Step 2: pick repos ─────────────────────────────────────────────────────
138

Callers 2

runPossibleWizardFunction · 0.85

Calls 4

parseIndexFunction · 0.85
listSeedsMethod · 0.80
writeMethod · 0.80
askMethod · 0.80

Tested by

no test coverage detected