agentic-mobile-kit 0.2.0 → 0.2.1
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 +6 -0
- package/bin/cli.js +5 -0
- package/lib/doctor.js +167 -0
- package/lib/init.js +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,12 @@ npx agentic-mobile-kit init
|
|
|
13
13
|
npx agentic-mobile-kit init --tools claude,codex,antigravity # choose your AI tools
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
Then check the project and your machine, with a fix for each problem:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npx agentic-mobile-kit doctor
|
|
20
|
+
```
|
|
21
|
+
|
|
16
22
|
`init` never overwrites your files. It adds its section to an existing `AGENTS.md` between `KIT` markers, and it's safe to run again. Undo it with git.
|
|
17
23
|
|
|
18
24
|
## What it adds
|
package/bin/cli.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const { version } = require('../package.json');
|
|
3
3
|
const { init, printSummary, InitError, TOOLS } = require('../lib/init');
|
|
4
|
+
const { doctor, printDoctor } = require('../lib/doctor');
|
|
4
5
|
|
|
5
6
|
const [cmd, ...rest] = process.argv.slice(2);
|
|
6
7
|
const flag = name => {
|
|
@@ -12,9 +13,11 @@ const help = `agentic-mobile-kit ${version}
|
|
|
12
13
|
|
|
13
14
|
Usage:
|
|
14
15
|
npx agentic-mobile-kit init [--tools claude,codex,antigravity] [--pm yarn|npm|pnpm|bun]
|
|
16
|
+
npx agentic-mobile-kit doctor
|
|
15
17
|
|
|
16
18
|
Commands:
|
|
17
19
|
init Install the kit into a bare React Native project (run in the app's root).
|
|
20
|
+
doctor Check the project and this machine, with a fix for each problem.
|
|
18
21
|
|
|
19
22
|
Options:
|
|
20
23
|
--tools AI tools your team uses: ${Object.keys(TOOLS).join(', ')} (default: claude,codex,antigravity)
|
|
@@ -31,6 +34,8 @@ if (cmd === '--version' || cmd === '-v') {
|
|
|
31
34
|
console.error(`init stopped: ${e.message}`);
|
|
32
35
|
process.exitCode = 1;
|
|
33
36
|
}
|
|
37
|
+
} else if (cmd === 'doctor') {
|
|
38
|
+
if (printDoctor(doctor(process.cwd())) > 0) process.exitCode = 1;
|
|
34
39
|
} else {
|
|
35
40
|
console.log(help);
|
|
36
41
|
if (cmd && cmd !== 'help' && cmd !== '--help' && cmd !== '-h') process.exitCode = 1;
|
package/lib/doctor.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// `agentic-mobile-kit doctor`: checks the project and this machine, and says how to fix each problem.
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const { execFileSync, spawnSync } = require('child_process');
|
|
7
|
+
|
|
8
|
+
const RULESYNC = 'rulesync@27.0.0';
|
|
9
|
+
|
|
10
|
+
// run a command; return trimmed stdout, or null if it isn't installed or fails
|
|
11
|
+
function run(cmd, args, opts = {}) {
|
|
12
|
+
try { return execFileSync(cmd, args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], timeout: 60000, ...opts }).trim(); } catch { return null; }
|
|
13
|
+
}
|
|
14
|
+
const version = s => (String(s || '').match(/(\d+)\.(\d+)(?:\.(\d+))?/) || []).slice(1).map(n => Number(n || 0));
|
|
15
|
+
const atLeast = (v, min) => { for (let i = 0; i < 3; i++) { if ((v[i] || 0) !== min[i]) return (v[i] || 0) > min[i]; } return true; };
|
|
16
|
+
const read = (cwd, f) => { try { return fs.readFileSync(path.join(cwd, f), 'utf8'); } catch { return null; } };
|
|
17
|
+
|
|
18
|
+
const ok = (label, detail = '') => ({ level: 'ok', label, detail });
|
|
19
|
+
const warn = (label, fix) => ({ level: 'warn', label, fix });
|
|
20
|
+
const fail = (label, fix) => ({ level: 'fail', label, fix });
|
|
21
|
+
|
|
22
|
+
function projectChecks(cwd, opts) {
|
|
23
|
+
const out = [];
|
|
24
|
+
const agents = read(cwd, 'AGENTS.md');
|
|
25
|
+
if (!agents || !/<!-- KIT:START/.test(agents) || !fs.existsSync(path.join(cwd, '.agents/skills/m-feature/SKILL.md'))) {
|
|
26
|
+
out.push(fail('Kit installed', 'run: npx agentic-mobile-kit init'));
|
|
27
|
+
return out; // the rest needs the kit
|
|
28
|
+
}
|
|
29
|
+
out.push(ok('Kit installed'));
|
|
30
|
+
|
|
31
|
+
const lines = agents.split('\n').length;
|
|
32
|
+
const bytes = Buffer.byteLength(agents);
|
|
33
|
+
out.push(lines <= 150 && bytes <= 8192
|
|
34
|
+
? ok('AGENTS.md size', `${lines} lines`)
|
|
35
|
+
: warn(`AGENTS.md is ${lines} lines / ${bytes} bytes`, 'keep it under 150 lines and 8 KB; tools truncate or ignore long files. Move details to docs/ai/'));
|
|
36
|
+
|
|
37
|
+
const hooksPath = run('git', ['config', 'core.hooksPath'], { cwd });
|
|
38
|
+
out.push(hooksPath === '.githooks'
|
|
39
|
+
? ok('Git hooks active')
|
|
40
|
+
: fail('Git hooks not active on this clone', 'run: git config core.hooksPath .githooks (your package manager\'s install does this too)'));
|
|
41
|
+
|
|
42
|
+
const tracked = (run('git', ['ls-files'], { cwd }) || '').split('\n').filter(f => /(^|\/)\.env(\.(?!example$)[\w.-]+)?$/.test(f));
|
|
43
|
+
out.push(tracked.length ? fail(`Secret files tracked by git: ${tracked.join(', ')}`, 'git rm --cached them, rotate the secrets, keep them out of the repo') : ok('No .env files in git'));
|
|
44
|
+
|
|
45
|
+
const claudeLink = path.join(cwd, '.claude/skills');
|
|
46
|
+
if (fs.existsSync(path.join(cwd, '.claude/settings.json'))) {
|
|
47
|
+
out.push(fs.existsSync(path.join(claudeLink, 'm-feature/SKILL.md'))
|
|
48
|
+
? ok('Claude Code skills link')
|
|
49
|
+
: fail('.claude/skills link missing or broken', 'run: ln -sfn ../.agents/skills .claude/skills (on Windows, enable git symlinks)'));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!opts.skipNetwork && fs.existsSync(path.join(cwd, 'rulesync.jsonc'))) {
|
|
53
|
+
const env = Object.fromEntries(Object.entries(process.env).filter(([k]) => !/^npm_(config|package|lifecycle)_/i.test(k)));
|
|
54
|
+
const r = spawnSync('npx', ['-y', RULESYNC, 'generate', '--check'], { cwd, env, encoding: 'utf8', timeout: 120000 });
|
|
55
|
+
out.push(r.status === 0
|
|
56
|
+
? ok('Tool configs match .rulesync/')
|
|
57
|
+
: warn('Tool configs out of date with .rulesync/', `run: npx -y ${RULESYNC} generate, then commit`));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const unfilled = ['product', 'tech', 'structure', 'conventions'].filter(n => {
|
|
61
|
+
const t = read(cwd, `docs/ai/${n}.md`);
|
|
62
|
+
return t !== null && t.replace(/<!--[\s\S]*?-->/g, '').replace(/^#.*$/gm, '').trim() === '';
|
|
63
|
+
});
|
|
64
|
+
out.push(unfilled.length
|
|
65
|
+
? warn(`docs/ai not filled in: ${unfilled.join(', ')}`, 'describe the app there; agents build better with it')
|
|
66
|
+
: ok('docs/ai filled in'));
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function machineChecks(cwd) {
|
|
71
|
+
const out = [];
|
|
72
|
+
const node = version(process.versions.node);
|
|
73
|
+
out.push(node[0] >= 20 ? ok('Node', process.versions.node) : fail(`Node ${process.versions.node}`, 'install Node 20 or newer'));
|
|
74
|
+
|
|
75
|
+
const pm = fs.existsSync(path.join(cwd, 'yarn.lock')) ? 'yarn' : fs.existsSync(path.join(cwd, 'pnpm-lock.yaml')) ? 'pnpm' : 'npm';
|
|
76
|
+
out.push(run(pm, ['--version'], { cwd }) ? ok(`Package manager (${pm})`) : fail(`${pm} not found`, pm === 'npm' ? 'install Node' : 'run: corepack enable'));
|
|
77
|
+
out.push(fs.existsSync(path.join(cwd, 'node_modules')) ? ok('Dependencies installed') : fail('Dependencies not installed', 'run: sh scripts/ai/install-deps.sh'));
|
|
78
|
+
|
|
79
|
+
// iOS (macOS only)
|
|
80
|
+
if (process.platform === 'darwin') {
|
|
81
|
+
const xcode = run('xcodebuild', ['-version']);
|
|
82
|
+
out.push(xcode ? ok('Xcode', xcode.split('\n')[0]) : fail('Xcode not found', 'install Xcode from the App Store, then: sudo xcode-select -s /Applications/Xcode.app'));
|
|
83
|
+
out.push(run('pod', ['--version']) ? ok('CocoaPods') : fail('CocoaPods not found', 'install it: brew install cocoapods'));
|
|
84
|
+
if (fs.existsSync(path.join(cwd, 'ios'))) {
|
|
85
|
+
out.push(fs.existsSync(path.join(cwd, 'ios/Pods')) ? ok('iOS pods installed') : warn('iOS pods not installed', 'run: cd ios && pod install'));
|
|
86
|
+
}
|
|
87
|
+
const sims = run('xcrun', ['simctl', 'list', 'devices', 'available']);
|
|
88
|
+
out.push(sims && /iPhone/.test(sims) ? ok('iPhone simulator available') : warn('No iPhone simulator', 'add one in Xcode > Settings > Components / Window > Devices and Simulators'));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Android
|
|
92
|
+
const sdk = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT || path.join(os.homedir(), 'Library/Android/sdk');
|
|
93
|
+
const adb = path.join(sdk, 'platform-tools/adb');
|
|
94
|
+
out.push(fs.existsSync(adb) ? ok('Android SDK', sdk) : fail('Android SDK not found', 'install Android Studio, or set ANDROID_HOME'));
|
|
95
|
+
const avds = run(path.join(sdk, 'emulator/emulator'), ['-list-avds']);
|
|
96
|
+
out.push(avds ? ok('Android emulator', avds.split('\n')[0]) : warn('No Android emulator', 'create one in Android Studio > Device Manager'));
|
|
97
|
+
const java = spawnSync('java', ['-version'], { encoding: 'utf8' });
|
|
98
|
+
const jv = version((java.stderr || '').match(/version "([^"]+)"/)?.[1]);
|
|
99
|
+
out.push(jv[0] >= 17 ? ok('Java', jv.join('.')) : fail(java.error ? 'Java not found' : `Java ${jv.join('.')}`, 'install JDK 17 (e.g. the one bundled with Android Studio)'));
|
|
100
|
+
|
|
101
|
+
// tools the checks use
|
|
102
|
+
const maestro = run('maestro', ['--version']);
|
|
103
|
+
const ciMaestro = (read(cwd, '.github/workflows/e2e.yml') || '').match(/MAESTRO_VERSION:\s*([\d.]+)/)?.[1];
|
|
104
|
+
if (!maestro) out.push(warn('Maestro not installed (needed by verify.sh)', 'install: curl -fsSL https://get.maestro.mobile.dev | bash'));
|
|
105
|
+
else {
|
|
106
|
+
const mv = (maestro.split('\n').pop() || '').trim();
|
|
107
|
+
out.push(ciMaestro && mv !== ciMaestro
|
|
108
|
+
? warn(`Maestro ${mv} here, ${ciMaestro} in CI`, `use the same version: MAESTRO_VERSION=${ciMaestro} curl -fsSL https://get.maestro.mobile.dev | bash`)
|
|
109
|
+
: ok('Maestro', mv));
|
|
110
|
+
}
|
|
111
|
+
out.push(run('gitleaks', ['version']) ? ok('gitleaks') : warn('gitleaks not installed', 'pre-commit falls back to a basic secret check; install: brew install gitleaks'));
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function aiToolChecks(cwd) {
|
|
116
|
+
const out = [];
|
|
117
|
+
const home = os.homedir();
|
|
118
|
+
const real = fs.realpathSync(cwd);
|
|
119
|
+
|
|
120
|
+
if (process.env.ANTHROPIC_API_KEY) {
|
|
121
|
+
out.push(warn('ANTHROPIC_API_KEY is set in this shell', 'Claude Code bills this API key instead of your Claude subscription; unset it if that isn\'t intended'));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const codexCfg = read(home, '.codex/config.toml');
|
|
125
|
+
if (codexCfg !== null && fs.existsSync(path.join(cwd, '.codex'))) {
|
|
126
|
+
const trusted = [cwd, real].some(p => codexCfg.includes(`[projects."${p}"]`) && new RegExp(`\\[projects\\."${p.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&')}"\\][^\\[]*trust_level\\s*=\\s*"trusted"`).test(codexCfg));
|
|
127
|
+
out.push(trusted
|
|
128
|
+
? ok('Codex trusts this project', 'its hooks still need approving once in Codex')
|
|
129
|
+
: warn('Codex doesn\'t trust this project yet', 'open the project in Codex once, trust it and approve its hooks; until then the guard hook is off in Codex'));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const agy = run('agy', ['--version']);
|
|
133
|
+
if (agy) {
|
|
134
|
+
out.push(atLeast(version(agy), [1, 3, 0]) ? ok('Antigravity CLI', agy) : warn(`Antigravity CLI ${agy}`, 'update: agy update (versions before 1.3 ignore AGENTS.md)'));
|
|
135
|
+
let trusted = false;
|
|
136
|
+
try { trusted = (JSON.parse(read(home, '.gemini/antigravity-cli/settings.json') || '{}').trustedWorkspaces || []).some(p => p === cwd || p === real); } catch {}
|
|
137
|
+
out.push(trusted ? ok('Antigravity trusts this project') : warn('Antigravity doesn\'t trust this project yet', 'open it in Antigravity once and trust the folder'));
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function doctor(cwd, opts = {}) {
|
|
143
|
+
return [
|
|
144
|
+
['Project', projectChecks(cwd, opts)],
|
|
145
|
+
['This machine', machineChecks(cwd)],
|
|
146
|
+
['AI tools', aiToolChecks(cwd)],
|
|
147
|
+
];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function printDoctor(sections, log = console.log) {
|
|
151
|
+
const icon = { ok: '✓', warn: '!', fail: '✗' };
|
|
152
|
+
let failures = 0;
|
|
153
|
+
let warnings = 0;
|
|
154
|
+
for (const [title, checks] of sections) {
|
|
155
|
+
log(`\n${title}`);
|
|
156
|
+
for (const c of checks) {
|
|
157
|
+
if (c.level === 'fail') failures++;
|
|
158
|
+
if (c.level === 'warn') warnings++;
|
|
159
|
+
log(` ${icon[c.level]} ${c.label}${c.detail ? ` (${c.detail})` : ''}`);
|
|
160
|
+
if (c.fix) log(` → ${c.fix}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
log(`\n${failures} problem(s), ${warnings} warning(s).`);
|
|
164
|
+
return failures;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
module.exports = { doctor, printDoctor, projectChecks };
|
package/lib/init.js
CHANGED
|
@@ -151,10 +151,13 @@ function init(cwd, opts = {}) {
|
|
|
151
151
|
const pkgFile = path.join(cwd, 'package.json');
|
|
152
152
|
const scripts = (pkg.scripts = pkg.scripts || {});
|
|
153
153
|
let pkgChanged = false;
|
|
154
|
-
|
|
154
|
+
// only TypeScript projects get typecheck: tsc fails ("no inputs") in JavaScript apps that merely have typescript installed
|
|
155
|
+
const hasTs = git(cwd, 'ls-files', '*.ts', '*.tsx').split('\n').some(f => f && !f.endsWith('.d.ts'));
|
|
156
|
+
if (!scripts.typecheck && deps.typescript && hasTs) { scripts.typecheck = 'tsc --noEmit'; pkgChanged = true; }
|
|
155
157
|
const hooksCmd = 'git config core.hooksPath .githooks || true';
|
|
156
158
|
if (!(scripts.postinstall || '').includes('core.hooksPath')) {
|
|
157
|
-
|
|
159
|
+
// parentheses keep the existing script's failure behavior: `a && b || true` would hide a failing `a`
|
|
160
|
+
scripts.postinstall = scripts.postinstall ? `${scripts.postinstall} && (${hooksCmd})` : hooksCmd;
|
|
158
161
|
pkgChanged = true;
|
|
159
162
|
}
|
|
160
163
|
if (pkgChanged) { fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`); report.merged.push('package.json (scripts)'); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentic-mobile-kit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "One setup for AI-assisted mobile development that works the same in Claude Code, Codex, Cursor, OpenCode, Kiro and Antigravity. Early development.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "prakashpro1",
|