agentic-mobile-kit 0.6.1 → 0.6.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.
package/README.md CHANGED
@@ -9,19 +9,17 @@ Tested with Claude Code, Codex and Antigravity. `--tools` also sets up Cursor, O
9
9
  1. In your app's root folder, on a clean git branch, run:
10
10
 
11
11
  ```sh
12
- npx agentic-mobile-kit init
12
+ npx agentic-mobile-kit
13
13
  ```
14
14
 
15
- If the app uses CI, add `--ci github`, `--ci codemagic` or both. To pick AI tools, add `--tools claude,codex,antigravity`, which is the default. `--help` lists every option.
15
+ It asks what to do, one step at a time: install with the recommended setup (Claude Code, Codex and Antigravity, no CI), or choose the AI tools and CI. There's nothing to `npm install`: the kit copies its files into the app and isn't a dependency. If you ran `npm i agentic-mobile-kit`, commit or undo that first, because the kit needs a clean working tree.
16
16
 
17
- 2. Check the project and your machine. `doctor` lists each problem with its fix:
18
-
19
- ```sh
20
- npx agentic-mobile-kit doctor
21
- ```
17
+ 2. Run it again and choose **Check this project and machine**. It lists each problem with its fix.
22
18
 
23
19
  3. Fill in `docs/ai/product.md`, `tech.md`, `structure.md` and `conventions.md`, then commit and open a PR.
24
20
 
21
+ Each choice prints the command it runs, for scripts and CI: `init` (with `--ci github`, `--ci codemagic` or `--tools claude,codex,antigravity`), `sync`, `doctor` and `uninstall`. `--help` lists every option.
22
+
25
23
  `init` never overwrites your files, is safe to run again, and can be undone with git. The [team guide](docs/team-guide.md#setup) lists everything it changes.
26
24
 
27
25
  ## How work flows
@@ -49,6 +47,8 @@ Apps that already use Superpowers, BMAD, proAgents or similar keep them as they
49
47
 
50
48
  ## Update or remove
51
49
 
50
+ Run `npx agentic-mobile-kit` in an app that has the kit. It offers to update it, add CI, check the setup or remove the kit, and tells you when a newer version is out. The same as commands:
51
+
52
52
  ```sh
53
53
  npx agentic-mobile-kit@latest sync # update the kit's files, merging in your own changes
54
54
  npx agentic-mobile-kit uninstall # remove the kit; files you changed are kept and listed
package/bin/cli.js CHANGED
@@ -2,17 +2,12 @@
2
2
  const { version } = require('../package.json');
3
3
  const { init, sync, uninstall, printSummary, printSync, printUninstall, InitError, TOOLS, CI } = require('../lib/init');
4
4
  const { doctor, printDoctor } = require('../lib/doctor');
5
-
6
- const [cmd, ...rest] = process.argv.slice(2);
7
- const flag = name => {
8
- const i = rest.indexOf(`--${name}`);
9
- return i >= 0 ? rest[i + 1] : undefined;
10
- };
11
- const list = name => (flag(name) ? flag(name).split(',').map(s => s.trim()).filter(Boolean) : undefined);
5
+ const { menu } = require('../lib/menu');
12
6
 
13
7
  const help = `agentic-mobile-kit ${version}
14
8
 
15
9
  Usage:
10
+ npx agentic-mobile-kit In a terminal: pick what to do in this app, step by step
16
11
  npx agentic-mobile-kit init [--tools claude,codex,antigravity] [--ci github,codemagic] [--pm yarn|npm|pnpm|bun]
17
12
  npx agentic-mobile-kit sync [--ci github,codemagic] [--from <version>]
18
13
  npx agentic-mobile-kit uninstall [--from <version>]
@@ -39,19 +34,32 @@ function run(name, fn) {
39
34
  }
40
35
  }
41
36
 
42
- if (cmd === '--version' || cmd === '-v') {
43
- console.log(version);
44
- } else if (cmd === 'init') {
45
- run('init', () => {
46
- printSummary(init(process.cwd(), { tools: list('tools'), ci: list('ci'), pm: flag('pm') }));
47
- });
48
- } else if (cmd === 'sync') {
49
- run('sync', () => printSync(sync(process.cwd(), { from: flag('from'), ci: list('ci'), pm: flag('pm') })));
50
- } else if (cmd === 'uninstall') {
51
- run('uninstall', () => printUninstall(uninstall(process.cwd(), { from: flag('from'), pm: flag('pm') })));
52
- } else if (cmd === 'doctor') {
53
- if (printDoctor(doctor(process.cwd())) > 0) process.exitCode = 1;
54
- } else {
55
- console.log(help);
56
- if (cmd && cmd !== 'help' && cmd !== '--help' && cmd !== '-h') process.exitCode = 1;
37
+ function main([cmd, ...rest]) {
38
+ const flag = name => {
39
+ const i = rest.indexOf(`--${name}`);
40
+ return i >= 0 ? rest[i + 1] : undefined;
41
+ };
42
+ const list = name => (flag(name) ? flag(name).split(',').map(s => s.trim()).filter(Boolean) : undefined);
43
+
44
+ if (cmd === '--version' || cmd === '-v') {
45
+ console.log(version);
46
+ } else if (cmd === 'init') {
47
+ run('init', () => {
48
+ printSummary(init(process.cwd(), { tools: list('tools'), ci: list('ci'), pm: flag('pm') }));
49
+ });
50
+ } else if (cmd === 'sync') {
51
+ run('sync', () => printSync(sync(process.cwd(), { from: flag('from'), ci: list('ci'), pm: flag('pm') })));
52
+ } else if (cmd === 'uninstall') {
53
+ run('uninstall', () => printUninstall(uninstall(process.cwd(), { from: flag('from'), pm: flag('pm') })));
54
+ } else if (cmd === 'doctor') {
55
+ if (printDoctor(doctor(process.cwd())) > 0) process.exitCode = 1;
56
+ } else {
57
+ console.log(help);
58
+ if (cmd && cmd !== 'help' && cmd !== '--help' && cmd !== '-h') process.exitCode = 1;
59
+ }
57
60
  }
61
+
62
+ // no command: the menu, but only for a person at a terminal. CI and AI agents get the help instead of a question
63
+ const args = process.argv.slice(2);
64
+ if (!args.length && process.stdin.isTTY && process.stdout.isTTY) menu(process.cwd()).then(chosen => chosen && main(chosen));
65
+ else main(args);
package/lib/init.js CHANGED
@@ -82,18 +82,19 @@ function detectPm(cwd, forced) {
82
82
  return pms.npm;
83
83
  }
84
84
 
85
+ // the app's folder first: in the wrong folder, "run git init" would be the wrong advice
85
86
  function checkProject(cwd) {
87
+ const pkgFile = path.join(cwd, 'package.json');
88
+ if (!fs.existsSync(pkgFile)) throw new InitError('No package.json here. Run this in the root of your React Native app.');
89
+ const pkg = readJson(pkgFile);
90
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
91
+ if (!deps['react-native']) throw new InitError('This is not a React Native project (no "react-native" dependency).');
86
92
  try { git(cwd, 'rev-parse', '--is-inside-work-tree'); } catch {
87
93
  throw new InitError('This folder is not a git repository. Run "git init" and commit first; git is how init can be undone.');
88
94
  }
89
95
  if (git(cwd, 'status', '--porcelain')) {
90
96
  throw new InitError('You have uncommitted changes. Commit or stash them first, so this can be undone with git.');
91
97
  }
92
- const pkgFile = path.join(cwd, 'package.json');
93
- if (!fs.existsSync(pkgFile)) throw new InitError('No package.json here. Run this in the root of your React Native app.');
94
- const pkg = readJson(pkgFile);
95
- const deps = { ...pkg.dependencies, ...pkg.devDependencies };
96
- if (!deps['react-native']) throw new InitError('This is not a React Native project (no "react-native" dependency).');
97
98
  const stack = detectStack(cwd, deps);
98
99
  if (stack === 'bare' && (!fs.existsSync(path.join(cwd, 'ios')) || !fs.existsSync(path.join(cwd, 'android')))) {
99
100
  throw new InitError('No ios/ and android/ folders found, and this isn\'t an Expo app. The kit supports bare React Native and Expo apps.');
@@ -504,11 +505,10 @@ function finish(cwd, { pkg, deps, tools, files, stack, skipGenerate }) {
504
505
  }
505
506
 
506
507
  function init(cwd, opts = {}) {
508
+ const { pkg, deps, stack } = checkProject(cwd);
507
509
  // monorepos: git runs hooks from the repository root, and GitHub reads workflows only there
508
- let prefix = '';
509
- try { prefix = git(cwd, 'rev-parse', '--show-prefix').replace(/\/$/, ''); } catch {}
510
+ const prefix = git(cwd, 'rev-parse', '--show-prefix').replace(/\/$/, '');
510
511
  if (prefix) throw new InitError(`This app is in a subfolder of its git repository (${prefix}), as in a monorepo. The kit doesn't support that yet: git runs hooks from the repository root, and GitHub reads workflows only there.`);
511
- const { pkg, deps, stack } = checkProject(cwd);
512
512
  const pm = detectPm(cwd, opts.pm);
513
513
  const tools = opts.tools || TESTED;
514
514
  for (const t of tools) if (!TOOLS[t]) throw new InitError(`Unknown tool "${t}". Choose from: ${Object.keys(TOOLS).join(', ')}.`);
@@ -592,7 +592,9 @@ function sync(cwd, opts = {}) {
592
592
  const { done, generated, generateError } = finish(cwd, { pkg, deps, tools, files: newFiles, stack, skipGenerate: opts.skipGenerate });
593
593
  report.added.push(...done.created);
594
594
  report.updated.push(...done.merged);
595
- return { report, warnings: done.warnings, from, to: KIT_VERSION, tools, generated, generateError };
595
+ // it started from a clean working tree, so git shows everything it changed (tool configs too)
596
+ const changed = git(cwd, 'status', '--porcelain') !== '';
597
+ return { report, warnings: done.warnings, from, to: KIT_VERSION, tools, changed, generated, generateError };
596
598
  }
597
599
 
598
600
  // what rulesync generates from the project's kit sources, regenerated in an empty folder: [[path, text]]
@@ -695,17 +697,17 @@ function printSummary({ report, warnings = [], values, tools, ci, generated, gen
695
697
  more.forEach((m, i) => log(` ${i + 3}. ${m}`));
696
698
  }
697
699
 
698
- function printSync({ report, warnings = [], from, to, generated, generateError }, log = console.log) {
699
- log(`agentic-mobile-kit updated from ${from} to ${to}.`);
700
+ function printSync({ report, warnings = [], from, to, changed, generated, generateError }, log = console.log) {
701
+ log(from === to ? `agentic-mobile-kit is already ${to}.` : `agentic-mobile-kit updated from ${from} to ${to}.`);
700
702
  const lines = [
701
703
  ['updated', report.updated], ['added', report.added], ['removed', report.removed],
702
704
  ['merged with your changes', report.merged], ['CONFLICTS, resolve the <<<<<<< markers', report.conflicts], ['left alone', report.kept],
703
705
  ];
704
706
  for (const [label, files] of lines) if (files.length) log(` ${label}: ${files.join(', ')}`);
705
- if (!Object.values(report).some(a => a.length)) log(' Nothing to change.');
707
+ if (!changed) log(' Nothing changed.');
706
708
  for (const w of warnings) log(` ! ${w}`);
707
709
  if (!generated) log(` ! could not generate tool configs; run: npx -y ${RULESYNC} generate\n${generateError.replace(/^/gm, ' ')}`);
708
- log('\nReview it with "git diff", run the checks, then commit on a branch and open a PR.');
710
+ if (changed) log('\nReview it with "git diff", run the checks, then commit on a branch and open a PR.');
709
711
  }
710
712
 
711
713
  function printUninstall({ report }, log = console.log) {
@@ -715,4 +717,7 @@ function printUninstall({ report }, log = console.log) {
715
717
  log('\nReview it with "git status" and "git diff", then commit. Undo it with git if you change your mind.');
716
718
  }
717
719
 
718
- module.exports = { init, sync, uninstall, printSummary, printSync, printUninstall, InitError, TOOLS, CI, KIT_VERSION, tool, hookManager, hooksWired };
720
+ module.exports = {
721
+ init, sync, uninstall, printSummary, printSync, printUninstall, InitError, TOOLS, TESTED, CI, KIT_VERSION, tool, cleanEnv,
722
+ hookManager, hooksWired, checkProject, recorded, installedCi,
723
+ };
package/lib/menu.js ADDED
@@ -0,0 +1,149 @@
1
+ 'use strict';
2
+ // `npx agentic-mobile-kit` with no command, in a terminal: what the kit can do in this app, asked one step at a time.
3
+ // It returns the command to run and prints it, so people learn the commands that scripts, CI and agents use.
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const readline = require('readline');
7
+ const { checkProject, recorded, installedCi, InitError, TOOLS, TESTED, CI, KIT_VERSION, tool, cleanEnv } = require('./init');
8
+
9
+ const NAMES = { claude: 'Claude Code', codex: 'Codex', antigravity: 'Antigravity', cursor: 'Cursor', opencode: 'OpenCode', kiro: 'Kiro' };
10
+ const CI_NAMES = { github: 'GitHub Actions', codemagic: 'Codemagic' };
11
+ const CI_LABELS = { github: 'GitHub Actions: checks on every pull request', codemagic: 'Codemagic: signed store builds' };
12
+ const and = a => (a.length > 1 ? `${a.slice(0, -1).join(', ')} and ${a[a.length - 1]}` : a[0]);
13
+ const newer = (a, b) => a.localeCompare(b, 'en', { numeric: true }) > 0;
14
+ class Closed extends Error {}
15
+
16
+ // the version npm installs now; null when that can't be checked (offline, no npm)
17
+ function latestVersion(cwd) {
18
+ const r = tool('npm', ['view', 'agentic-mobile-kit', 'version'], { cwd, env: cleanEnv(), encoding: 'utf8', timeout: 8000 });
19
+ const v = (r.stdout || '').trim();
20
+ return r.status === 0 && /^\d+\.\d+\.\d+$/.test(v) ? v : null;
21
+ }
22
+
23
+ async function menu(cwd, { input = process.stdin, output = process.stdout, latest = latestVersion } = {}) {
24
+ const rl = readline.createInterface({ input, output });
25
+ // Ctrl-C ends the menu, like Ctrl-D (readline alone would only pause)
26
+ rl.on('SIGINT', () => rl.close());
27
+ let closed = false;
28
+ rl.on('close', () => { closed = true; });
29
+ const lines = rl[Symbol.asyncIterator]();
30
+ const say = s => output.write(`${s}\n`);
31
+ const ask = async q => {
32
+ // piped answers can outlast the input, which closes readline
33
+ if (closed) output.write(q);
34
+ else {
35
+ rl.setPrompt(q);
36
+ rl.prompt();
37
+ }
38
+ const { value, done } = await lines.next();
39
+ if (done) throw new Closed();
40
+ return value.trim();
41
+ };
42
+ const show = (question, items) => {
43
+ say(`\n${question}`);
44
+ items.forEach((it, i) => say(` ${i + 1}. ${it.label}`));
45
+ };
46
+ // one item: Enter takes the default, anything else is asked again
47
+ const pick = async (question, items, def = 0) => {
48
+ show(question, items);
49
+ for (;;) {
50
+ const item = items[Number((await ask(`Choose 1-${items.length} [${def + 1}]: `)) || def + 1) - 1];
51
+ if (item) return item;
52
+ }
53
+ };
54
+ const pickSome = async (question, items, defaults) => {
55
+ show(question, items);
56
+ const def = items.flatMap((it, i) => (defaults.includes(it.value) ? [i + 1] : [])).join(',');
57
+ for (;;) {
58
+ const chosen = ((await ask(`Numbers, separated by commas [${def}]: `)) || def).split(/[\s,]+/).filter(Boolean).map(n => items[Number(n) - 1]);
59
+ if (chosen.length && chosen.every(Boolean)) return items.filter(it => chosen.includes(it)).map(it => it.value);
60
+ }
61
+ };
62
+ const yes = async (question, def) => {
63
+ const a = (await ask(`${question} [${def ? 'Y/n' : 'y/N'}]: `)).toLowerCase();
64
+ return a ? a.startsWith('y') : def;
65
+ };
66
+ const ciItems = groups => [...groups.map(g => ({ label: CI_LABELS[g], value: [g] })), ...(groups.length > 1 ? [{ label: 'Both', value: groups }] : [])];
67
+
68
+ try {
69
+ say(`agentic-mobile-kit ${KIT_VERSION}`);
70
+ // npx can run an older copy it keeps in its cache
71
+ const next = latest(cwd);
72
+ if (next && newer(next, KIT_VERSION) && await yes(`Version ${next} is out. Use it?`, true)) {
73
+ rl.close();
74
+ process.exitCode = tool('npx', ['-y', `agentic-mobile-kit@${next}`], { cwd, stdio: 'inherit', env: cleanEnv() }).status ?? 1;
75
+ return null;
76
+ }
77
+
78
+ let problem = '';
79
+ try { checkProject(cwd); } catch (e) {
80
+ if (!(e instanceof InitError)) throw e;
81
+ problem = e.message;
82
+ }
83
+ let agents = '';
84
+ try { agents = fs.readFileSync(path.join(cwd, 'AGENTS.md'), 'utf8'); } catch {}
85
+ const doctor = { label: 'Check this project and machine (doctor)', args: ['doctor'] };
86
+ const quit = { label: 'Quit', args: null };
87
+ let items;
88
+ let def = 0;
89
+ if (!/<!-- KIT:START/.test(agents)) {
90
+ say('The kit isn\'t installed here.');
91
+ items = [
92
+ { label: `Install it for ${and(TESTED.map(t => NAMES[t]))}, without CI (init)`, args: ['init'], changes: true },
93
+ {
94
+ label: 'Install it and choose the AI tools and CI',
95
+ changes: true,
96
+ steps: async () => {
97
+ const tools = await pickSome('Which AI tools does your team use?',
98
+ Object.keys(TOOLS).map(t => ({ value: t, label: `${NAMES[t]}${TESTED.includes(t) ? '' : ' (not tested yet)'}` })), TESTED);
99
+ const ci = (await pick('Set up CI? Only if the app uses it.', [{ label: 'No CI', value: [] }, ...ciItems(Object.keys(CI))])).value;
100
+ return ['init', ...(String(tools) === String(TESTED) ? [] : ['--tools', tools.join(',')]), ...(ci.length ? ['--ci', ci.join(',')] : [])];
101
+ },
102
+ },
103
+ doctor, quit,
104
+ ];
105
+ } else {
106
+ const from = recorded(agents).version;
107
+ const ci = installedCi(cwd, agents);
108
+ const missing = Object.keys(CI).filter(g => !ci.includes(g));
109
+ const update = !from || newer(KIT_VERSION, from);
110
+ say(`Kit ${from || '(an early version)'} is installed here. CI: ${ci.length ? and(ci.map(g => CI_NAMES[g])) : 'none'}.`);
111
+ if (from && newer(from, KIT_VERSION)) problem ||= `This app has kit ${from}, newer than this copy (${KIT_VERSION}). Run: npx agentic-mobile-kit@latest`;
112
+ items = [
113
+ { label: update ? `Update the kit${from ? ` from ${from}` : ''} to ${KIT_VERSION} (sync)` : 'Sync the kit again; it\'s up to date (sync)', args: ['sync'], changes: true },
114
+ missing.length && {
115
+ label: `Add CI: ${missing.map(g => CI_NAMES[g]).join(' or ')}${update ? ', and update the kit' : ''} (sync --ci)`,
116
+ changes: true,
117
+ steps: async () => ['sync', '--ci', (missing.length > 1 ? (await pick('Which CI?', ciItems(missing))).value : missing).join(',')],
118
+ },
119
+ doctor,
120
+ { label: 'Remove the kit (uninstall)', args: ['uninstall'], changes: true, confirm: 'Remove the kit from this app? Files you changed are kept, and git can undo it.' },
121
+ quit,
122
+ ].filter(Boolean);
123
+ def = update ? 0 : items.indexOf(doctor);
124
+ }
125
+ // installing, updating and removing need a clean git repository: say why they aren't offered
126
+ if (problem) {
127
+ say(`! ${problem}`);
128
+ items = items.filter(it => !it.changes);
129
+ def = 0;
130
+ }
131
+
132
+ const choice = await pick('What would you like to do?', items, def);
133
+ if (choice.confirm && !(await yes(choice.confirm, false))) {
134
+ say('Nothing changed.');
135
+ return null;
136
+ }
137
+ const args = choice.steps ? await choice.steps() : choice.args;
138
+ if (args) say(`\nRunning: npx agentic-mobile-kit ${args.join(' ')}\n`);
139
+ return args;
140
+ } catch (e) {
141
+ if (!(e instanceof Closed)) throw e;
142
+ say('');
143
+ return null;
144
+ } finally {
145
+ rl.close();
146
+ }
147
+ }
148
+
149
+ module.exports = { menu };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-mobile-kit",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "One setup for AI-assisted development of React Native apps, bare or Expo: shared rules and workflows for Claude Code, Codex and Antigravity, git hooks, device checks with screenshots, and release tooling for the App Store and Google Play.",
5
5
  "license": "MIT",
6
6
  "author": "prakashpro1",