@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.
- package/dist/cjs/commands/docs.cjs +17 -9
- package/dist/cjs/commands/docs.js +8 -2
- package/dist/cjs/commands/docs.js.map +1 -1
- package/dist/cjs/commands/docs.native.js +23 -14
- package/dist/cjs/commands/docs.native.js.map +1 -1
- package/dist/cjs/commands/sync.cjs +51 -34
- package/dist/cjs/commands/sync.js +54 -35
- package/dist/cjs/commands/sync.js.map +1 -1
- package/dist/cjs/commands/sync.native.js +56 -39
- package/dist/cjs/commands/sync.native.js.map +1 -1
- package/dist/esm/commands/docs.js +8 -2
- package/dist/esm/commands/docs.js.map +1 -1
- package/dist/esm/commands/docs.mjs +17 -9
- package/dist/esm/commands/docs.mjs.map +1 -1
- package/dist/esm/commands/docs.native.js +23 -14
- package/dist/esm/commands/docs.native.js.map +1 -1
- package/dist/esm/commands/sync.js +54 -35
- package/dist/esm/commands/sync.js.map +1 -1
- package/dist/esm/commands/sync.mjs +51 -34
- package/dist/esm/commands/sync.mjs.map +1 -1
- package/dist/esm/commands/sync.native.js +56 -39
- package/dist/esm/commands/sync.native.js.map +1 -1
- package/package.json +5 -5
- package/src/commands/docs.ts +24 -11
- package/src/commands/sync.ts +96 -69
- package/types/commands/docs.d.ts.map +1 -1
- package/types/commands/sync.d.ts +12 -1
- package/types/commands/sync.d.ts.map +1 -1
package/src/commands/sync.ts
CHANGED
|
@@ -26,24 +26,20 @@ const TAKEOUT_FILE = '.takeout'
|
|
|
26
26
|
|
|
27
27
|
function getSyncPrompt(): string {
|
|
28
28
|
try {
|
|
29
|
-
// find
|
|
29
|
+
// find monorepo root by looking for packages/docs
|
|
30
30
|
const currentDir = dirname(fileURLToPath(import.meta.url))
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
// go up directories until we find
|
|
34
|
-
while (
|
|
35
|
-
const
|
|
36
|
-
if (existsSync(
|
|
37
|
-
|
|
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
|
-
|
|
39
|
+
monorepoRoot = dirname(monorepoRoot)
|
|
43
40
|
}
|
|
44
41
|
|
|
45
|
-
|
|
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
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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: '
|
|
150
|
-
label: '
|
|
151
|
-
hint: '
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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
|
-
|
|
211
|
-
console.info()
|
|
236
|
+
console.info(pc.dim('You will be asked to confirm important decisions.'))
|
|
237
|
+
console.info()
|
|
212
238
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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;
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/commands/docs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAujBH,eAAO,MAAM,WAAW,qDAYtB,CAAA"}
|
package/types/commands/sync.d.ts
CHANGED
|
@@ -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<
|
|
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;
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AAAA;;GAEG;AA8FH,eAAO,MAAM,WAAW;;;;;;;;;;;EA2OtB,CAAA"}
|