@take-out/cli 0.0.50 → 0.0.51

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.
@@ -26,24 +26,20 @@ const TAKEOUT_FILE = '.takeout'
26
26
 
27
27
  function getSyncPrompt(): string {
28
28
  try {
29
- // find package root by looking for package.json
29
+ // find monorepo root by looking for packages/docs
30
30
  const currentDir = dirname(fileURLToPath(import.meta.url))
31
- let packageRoot = currentDir
32
-
33
- // go up directories until we find package.json with name @take-out/cli
34
- while (packageRoot !== parse(packageRoot).root) {
35
- const pkgPath = join(packageRoot, 'package.json')
36
- if (existsSync(pkgPath)) {
37
- const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
38
- if (pkg.name === '@take-out/cli') {
39
- break
40
- }
31
+ let monorepoRoot = currentDir
32
+
33
+ // go up directories until we find packages/docs/sync-prompt.md
34
+ while (monorepoRoot !== parse(monorepoRoot).root) {
35
+ const promptPath = join(monorepoRoot, 'packages', 'docs', 'sync-prompt.md')
36
+ if (existsSync(promptPath)) {
37
+ return readFileSync(promptPath, 'utf-8')
41
38
  }
42
- packageRoot = dirname(packageRoot)
39
+ monorepoRoot = dirname(monorepoRoot)
43
40
  }
44
41
 
45
- const promptPath = join(packageRoot, 'docs', 'sync-prompt.md')
46
- return readFileSync(promptPath, 'utf-8')
42
+ throw new Error('Could not find sync-prompt.md in packages/docs')
47
43
  } catch (error) {
48
44
  throw new Error(
49
45
  `Could not load sync prompt: ${error instanceof Error ? error.message : 'Unknown error'}`
@@ -103,71 +99,99 @@ export const syncCommand = defineCommand({
103
99
  name: 'sync',
104
100
  description: 'Sync your fork with the latest Takeout repository',
105
101
  },
106
- async run() {
102
+ args: {
103
+ auto: {
104
+ type: 'boolean',
105
+ description: 'Auto-run with claude-code without prompts (for non-TTY environments)',
106
+ default: false,
107
+ },
108
+ print: {
109
+ type: 'boolean',
110
+ description: 'Print the sync prompt and exit',
111
+ default: false,
112
+ },
113
+ },
114
+ async run({ args }) {
115
+ const isAuto = args.auto
116
+ const isPrint = args.print
107
117
  showStep('Takeout Repository Sync')
108
118
  console.info()
109
119
 
110
- showInfo('Takeout sync uses AI to intelligently merge upstream changes')
111
- console.info()
112
- console.info(pc.gray('How it works:'))
113
- console.info(pc.gray(' Analyzes commits from upstream Takeout repository'))
114
- console.info(pc.gray(' • Determines which changes are relevant to your fork'))
115
- console.info(pc.gray(' • Applies changes while preserving your customizations'))
116
- console.info(pc.gray(' • Handles package ejection automatically'))
117
- console.info(pc.gray(' • Asks for your input when decisions are needed'))
118
- console.info()
120
+ if (!isAuto && !isPrint) {
121
+ showInfo('Takeout sync uses AI to intelligently merge upstream changes')
122
+ console.info()
123
+ console.info(pc.gray('How it works:'))
124
+ console.info(pc.gray(' • Analyzes commits from upstream Takeout repository'))
125
+ console.info(pc.gray(' • Determines which changes are relevant to your fork'))
126
+ console.info(pc.gray(' • Applies changes while preserving your customizations'))
127
+ console.info(pc.gray(' • Handles package ejection automatically'))
128
+ console.info(pc.gray(' • Asks for your input when decisions are needed'))
129
+ console.info()
130
+ }
119
131
 
120
132
  // check what tools are available
121
133
  const hasClaudeCode = checkToolAvailable('claude')
122
134
  const hasCursor = checkToolAvailable('cursor-agent')
123
135
  const hasAider = checkToolAvailable('aider')
124
136
 
125
- const options: Array<{
126
- value: string
127
- label: string
128
- hint: string
129
- }> = []
137
+ // handle --auto mode
138
+ let choice: string
139
+ if (isAuto) {
140
+ if (!hasClaudeCode) {
141
+ showError('--auto requires claude CLI to be installed')
142
+ process.exit(1)
143
+ }
144
+ choice = 'claude-code'
145
+ } else if (isPrint) {
146
+ choice = 'show-prompt'
147
+ } else {
148
+ const options: Array<{
149
+ value: string
150
+ label: string
151
+ hint: string
152
+ }> = []
153
+
154
+ if (hasClaudeCode) {
155
+ options.push({
156
+ value: 'claude-code',
157
+ label: 'Claude Code (recommended)',
158
+ hint: 'Run sync automatically with Claude Code CLI',
159
+ })
160
+ }
130
161
 
131
- if (hasClaudeCode) {
132
- options.push({
133
- value: 'claude-code',
134
- label: 'Claude Code (recommended)',
135
- hint: 'Run sync automatically with Claude Code CLI',
136
- })
137
- }
162
+ if (hasCursor) {
163
+ options.push({
164
+ value: 'cursor',
165
+ label: 'Cursor Agent',
166
+ hint: 'Run sync automatically with Cursor CLI',
167
+ })
168
+ }
138
169
 
139
- if (hasCursor) {
140
- options.push({
141
- value: 'cursor',
142
- label: 'Cursor Agent',
143
- hint: 'Run sync automatically with Cursor CLI',
144
- })
145
- }
170
+ if (hasAider) {
171
+ options.push({
172
+ value: 'aider',
173
+ label: 'Aider',
174
+ hint: 'Run sync automatically with Aider CLI',
175
+ })
176
+ }
146
177
 
147
- if (hasAider) {
148
178
  options.push({
149
- value: 'aider',
150
- label: 'Aider',
151
- hint: 'Run sync automatically with Aider CLI',
179
+ value: 'show-prompt',
180
+ label: 'Show prompt (copy & paste manually)',
181
+ hint: 'Display the full prompt to use with any LLM',
152
182
  })
153
- }
154
183
 
155
- options.push({
156
- value: 'show-prompt',
157
- label: 'Show prompt (copy & paste manually)',
158
- hint: 'Display the full prompt to use with any LLM',
159
- })
184
+ choice = await promptSelect<string>('How would you like to sync?', options)
160
185
 
161
- const choice = await promptSelect<string>('How would you like to sync?', options)
186
+ if (choice === 'cancel') {
187
+ console.info()
188
+ showInfo('Sync cancelled')
189
+ return
190
+ }
162
191
 
163
- if (choice === 'cancel') {
164
192
  console.info()
165
- showInfo('Sync cancelled')
166
- return
167
193
  }
168
194
 
169
- console.info()
170
-
171
195
  // fetch upstream to get the target SHA before syncing
172
196
  console.info(pc.dim('Fetching upstream repository...'))
173
197
  if (!ensureUpstreamRemote()) {
@@ -202,18 +226,21 @@ export const syncCommand = defineCommand({
202
226
  } else if (choice === 'claude-code') {
203
227
  showInfo('Starting Claude Code with sync prompt...')
204
228
  console.info()
205
- console.info(
206
- pc.dim(
207
- 'Note: Claude Code will run in headless mode and make changes automatically.'
229
+
230
+ if (!isAuto) {
231
+ console.info(
232
+ pc.dim(
233
+ 'Note: Claude Code will run in headless mode and make changes automatically.'
234
+ )
208
235
  )
209
- )
210
- console.info(pc.dim('You will be asked to confirm important decisions.'))
211
- console.info()
236
+ console.info(pc.dim('You will be asked to confirm important decisions.'))
237
+ console.info()
212
238
 
213
- const shouldContinue = await confirmContinue('Continue with Claude Code?', true)
214
- if (!shouldContinue) {
215
- showInfo('Sync cancelled')
216
- return
239
+ const shouldContinue = await confirmContinue('Continue with Claude Code?', true)
240
+ if (!shouldContinue) {
241
+ showInfo('Sync cancelled')
242
+ return
243
+ }
217
244
  }
218
245
 
219
246
  // write prompt to temp file to avoid shell escaping issues
@@ -1 +1 @@
1
- {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/commands/docs.ts"],"names":[],"mappings":"AAAA;;GAEG;AA0iBH,eAAO,MAAM,WAAW,qDAYtB,CAAA"}
1
+ {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/commands/docs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAujBH,eAAO,MAAM,WAAW,qDAYtB,CAAA"}
@@ -1,5 +1,16 @@
1
1
  /**
2
2
  * Sync command - sync fork with upstream Takeout repository
3
3
  */
4
- export declare const syncCommand: import("citty").CommandDef<import("citty").ArgsDef>;
4
+ export declare const syncCommand: import("citty").CommandDef<{
5
+ auto: {
6
+ type: "boolean";
7
+ description: string;
8
+ default: false;
9
+ };
10
+ print: {
11
+ type: "boolean";
12
+ description: string;
13
+ default: false;
14
+ };
15
+ }>;
5
16
  //# sourceMappingURL=sync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkGH,eAAO,MAAM,WAAW,qDA4MtB,CAAA"}
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AAAA;;GAEG;AA8FH,eAAO,MAAM,WAAW;;;;;;;;;;;EA2OtB,CAAA"}