agentic-mobile-kit 0.5.6 → 0.6.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 +5 -1
- package/bin/cli.js +1 -1
- package/lib/doctor.js +1 -1
- package/lib/init.js +91 -39
- package/package.json +4 -2
- package/stacks/react-native/expo/.agents/skills/LICENSE-expo +21 -0
- package/stacks/react-native/expo/.agents/skills/THIRD_PARTY.md +11 -0
- package/stacks/react-native/expo/.agents/skills/expo-module/SKILL.md +151 -0
- package/stacks/react-native/expo/.agents/skills/expo-module/agents/openai.yaml +4 -0
- package/stacks/react-native/expo/.agents/skills/expo-module/references/config-plugin.md +90 -0
- package/stacks/react-native/expo/.agents/skills/expo-module/references/create-expo-module.md +206 -0
- package/stacks/react-native/expo/.agents/skills/expo-module/references/lifecycle.md +127 -0
- package/stacks/react-native/expo/.agents/skills/expo-module/references/module-config.md +48 -0
- package/stacks/react-native/expo/.agents/skills/expo-module/references/native-module.md +286 -0
- package/stacks/react-native/expo/.agents/skills/expo-module/references/native-view.md +171 -0
- package/stacks/react-native/expo/.agents/skills/expo-router/SKILL.md +240 -0
- package/stacks/react-native/expo/.agents/skills/expo-router/agents/openai.yaml +4 -0
- package/stacks/react-native/expo/.agents/skills/expo-router/references/form-sheet.md +253 -0
- package/stacks/react-native/expo/.agents/skills/expo-router/references/route-structure.md +229 -0
- package/stacks/react-native/expo/.agents/skills/expo-router/references/search.md +248 -0
- package/stacks/react-native/expo/.agents/skills/expo-router/references/tabs.md +433 -0
- package/stacks/react-native/expo/.agents/skills/expo-router/references/toolbar-and-headers.md +284 -0
- package/stacks/react-native/expo/.agents/skills/expo-router/references/zoom-transitions.md +158 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/SKILL.md +150 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/agents/openai.yaml +4 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/references/expo-av-to-audio.md +132 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/references/expo-av-to-video.md +160 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/references/native-tabs.md +124 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/references/new-architecture.md +79 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/references/react-19.md +79 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/references/react-compiler.md +59 -0
- package/stacks/react-native/expo/.agents/skills/expo-upgrade/references/react-navigation-to-expo-router.md +61 -0
- package/stacks/react-native/expo/.rulesync/permissions.jsonc +40 -0
- package/stacks/react-native/expo/AGENTS.md +52 -0
- package/stacks/react-native/expo/docs/ai/expo.md +35 -0
- package/stacks/react-native/expo/docs/ai/known-issues.md +32 -0
- package/stacks/react-native/template/.agents/skills/m-bugfix/SKILL.md +1 -1
- package/stacks/react-native/template/.agents/skills/m-continue/SKILL.md +1 -1
- package/stacks/react-native/template/.agents/skills/m-feature/SKILL.md +2 -2
- package/stacks/react-native/template/.agents/skills/m-release/SKILL.md +5 -5
- package/stacks/react-native/template/.agents/skills/m-review/SKILL.md +1 -1
- package/stacks/react-native/template/.githooks/pre-commit +5 -5
- package/stacks/react-native/template/.githooks/pre-push +3 -2
- package/stacks/react-native/template/.github/workflows/ci.yml +8 -3
- package/stacks/react-native/template/.github/workflows/e2e.yml +2 -0
- package/stacks/react-native/template/.github/workflows/ios.yml +2 -3
- package/stacks/react-native/template/AGENTS.md +3 -3
- package/stacks/react-native/template/codemagic.yaml +2 -1
- package/stacks/react-native/template/scripts/ai/baseline.js +201 -0
- package/stacks/react-native/template/scripts/ai/case-check.js +1 -1
- package/stacks/react-native/template/scripts/ai/guard.js +2 -1
- package/stacks/react-native/template/scripts/ai/ios-build.sh +9 -1
- package/stacks/react-native/template/scripts/ai/maestro-env.sh +20 -0
- package/stacks/react-native/template/scripts/ai/pm-run.sh +12 -0
- package/stacks/react-native/template/scripts/ai/prebuild.sh +28 -0
- package/stacks/react-native/template/scripts/ai/release-build.sh +6 -2
- package/stacks/react-native/template/scripts/ai/release-check.js +69 -15
- package/stacks/react-native/template/scripts/ai/set-version.sh +19 -1
- package/stacks/react-native/template/scripts/ai/{spec.js → specs.js} +5 -6
- package/stacks/react-native/template/scripts/ai/verify.sh +25 -7
- package/stacks/react-native/template/specs/_templates/flow.yaml +8 -0
- package/stacks/react-native/template/specs/current/README.md +2 -2
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Per-tool permission rules, generated by rulesync. A second layer: git hooks and CI are the real backstop,
|
|
2
|
+
// and Phase 0 showed Codex and the Antigravity CLI can still read .env, so keep real secrets out of the repo.
|
|
3
|
+
// Expo apps: ios/ and android/ are generated by `expo prebuild`, so they're never edited by hand.
|
|
4
|
+
{
|
|
5
|
+
"permission": {
|
|
6
|
+
"bash": {
|
|
7
|
+
"rm -rf*": "deny",
|
|
8
|
+
"git reset --hard*": "deny",
|
|
9
|
+
"git push --force*": "deny",
|
|
10
|
+
"git push -f*": "deny",
|
|
11
|
+
"git clean -f*": "deny",
|
|
12
|
+
"git commit --no-verify*": "deny",
|
|
13
|
+
"xcrun simctl erase*": "deny",
|
|
14
|
+
"npm install *": "ask",
|
|
15
|
+
"yarn add*": "ask",
|
|
16
|
+
"pnpm add*": "ask",
|
|
17
|
+
"npx expo install *": "ask",
|
|
18
|
+
"eas *": "ask",
|
|
19
|
+
"npx eas-cli*": "ask"
|
|
20
|
+
},
|
|
21
|
+
"read": {
|
|
22
|
+
".env": "deny",
|
|
23
|
+
".env.*": "deny",
|
|
24
|
+
"**/*.keystore": "deny",
|
|
25
|
+
"**/*.jks": "deny",
|
|
26
|
+
"**/*.p8": "deny",
|
|
27
|
+
"**/*.p12": "deny",
|
|
28
|
+
"**/*.mobileprovision": "deny"
|
|
29
|
+
},
|
|
30
|
+
"edit": {
|
|
31
|
+
"ios/**": "deny",
|
|
32
|
+
"android/**": "deny",
|
|
33
|
+
"package.json": "ask",
|
|
34
|
+
"app.json": "ask",
|
|
35
|
+
"app.config.*": "ask",
|
|
36
|
+
"eas.json": "ask",
|
|
37
|
+
".github/workflows/**": "ask"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<!-- KIT:START agentic-mobile-kit {{KIT_VERSION}} ci={{KIT_CI}} stack={{KIT_STACK}} (edit outside these markers; the kit updates what's inside) -->
|
|
2
|
+
# {{APP_NAME}}: instructions for AI agents
|
|
3
|
+
|
|
4
|
+
Read by Claude Code (through CLAUDE.md), Codex, Cursor, OpenCode, Kiro and Antigravity. Keep it short; details live in `docs/ai/`.
|
|
5
|
+
|
|
6
|
+
This project may also use other AI workflow frameworks (for example Superpowers, BMAD or proAgents). They keep working for everything else. When the user starts a task with an `m-` skill (`/m-feature`, `$m-feature`, …), follow that skill's steps for the whole task; where another framework's instructions differ, the `m-` skill wins.
|
|
7
|
+
|
|
8
|
+
## Project
|
|
9
|
+
|
|
10
|
+
- Expo SDK {{EXPO_SDK}}, React Native {{RN_VERSION}} ({{RN_ARCH}}), React {{REACT_VERSION}}, TypeScript {{TS_VERSION}}, Node {{NODE_VERSION}}. Package manager: {{PM}}.
|
|
11
|
+
- `ios/` and `android/` are generated by `npx expo prebuild` and aren't in git (Continuous Native Generation). The kit's scripts generate them when they need them.
|
|
12
|
+
- What the app does: `docs/ai/product.md`, and requirement by requirement, as it works now: `specs/current/`. Stack and services: `docs/ai/tech.md`. Folders and layers: `docs/ai/structure.md`. Code style: `docs/ai/conventions.md`.
|
|
13
|
+
|
|
14
|
+
## Commands
|
|
15
|
+
|
|
16
|
+
| Task | Command |
|
|
17
|
+
|---|---|
|
|
18
|
+
| Install dependencies | `sh scripts/ai/install-deps.sh` |
|
|
19
|
+
| Add a library (ask first) | `npx expo install <package>`: the version that matches the SDK |
|
|
20
|
+
| Lint, typecheck, test (each skips what the app doesn't have yet) | `sh scripts/ai/pm-run.sh lint`, `sh scripts/ai/pm-run.sh typecheck`, `sh scripts/ai/pm-run.sh test` |
|
|
21
|
+
| Check dependency versions and the app config | `npx expo install --check`, `npx expo-doctor` |
|
|
22
|
+
| Check on devices (release builds, Maestro flows, screenshots) | `sh scripts/ai/verify.sh all --spec <id>`; another iOS scheme: `--scheme <name>` |
|
|
23
|
+
| Specs: progress, format check, fold a finished feature into the living spec | `node scripts/ai/specs.js status`, `node scripts/ai/specs.js check`, `node scripts/ai/specs.js merge <id>` |
|
|
24
|
+
| Check a release before tagging it (versions, permission texts, debug leftovers) | `node scripts/ai/release-check.js` |
|
|
25
|
+
| Signed release builds (a person runs them: they use the signing keys) | `sh scripts/ai/release-build.sh android`, `sh scripts/ai/release-build.sh ios` |
|
|
26
|
+
|
|
27
|
+
## Definition of done
|
|
28
|
+
|
|
29
|
+
A task is done only when:
|
|
30
|
+
1. `sh scripts/ai/verify.sh quick` passes (lint, typecheck, tests) and you show its output from this session. In an app whose base branch already fails some of them, it passes when your change adds no new failure, and lists the old ones: leave those alone unless the task is to fix them;
|
|
31
|
+
2. UI changes were checked with `sh scripts/ai/verify.sh all --spec <id>` on both iOS and Android, and you looked at the screenshots. On Windows or Linux, that covers Android only: write in `progress.md` and the PR that iOS still needs checking on a Mac, and the PR isn't merged until a teammate with a Mac has done it;
|
|
32
|
+
3. the change stays inside the task's scope;
|
|
33
|
+
4. `specs/<id>/progress.md` is updated, when working from a spec.
|
|
34
|
+
|
|
35
|
+
Never say a check passed unless you ran it in this session.
|
|
36
|
+
|
|
37
|
+
## Rules
|
|
38
|
+
|
|
39
|
+
- Stay inside the task. Ask before touching unrelated files.
|
|
40
|
+
- Ask before adding or upgrading dependencies, and before editing `package.json`, lockfiles, `app.json`, `app.config.*`, `eas.json` or `.github/workflows/`.
|
|
41
|
+
- Never edit `ios/` or `android/`: the next prebuild overwrites them. Native settings go in `app.json` or `app.config.*`, through config plugins; native code goes in an Expo module (`expo-module` skill). Ask before adding a config plugin.
|
|
42
|
+
- Never run `eas build`, `eas submit` or `eas update`: they build, ship or publish with the team's accounts, so a person runs them.
|
|
43
|
+
- Never read, print or commit `.env` files, keystores or signing files. Secrets don't belong in this repo.
|
|
44
|
+
- Never use `git commit --no-verify`, `git push --force`, `git reset --hard` or `rm -rf`.
|
|
45
|
+
- After 2 failed attempts at the same fix, stop and report what you found.
|
|
46
|
+
- Chat is not memory: write decisions into the spec or `docs/ai/decisions.md` straight away.
|
|
47
|
+
- Follow `docs/ai/expo.md`. Before fixing a build error, check `docs/ai/known-issues.md`.
|
|
48
|
+
|
|
49
|
+
## Skills
|
|
50
|
+
|
|
51
|
+
`expo-router`, `expo-upgrade`, `expo-module` (from Expo), `react-native-best-practices`, `react-navigation` (from Callstack), in `.agents/skills/`.
|
|
52
|
+
<!-- KIT:END agentic-mobile-kit -->
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Expo rules
|
|
2
|
+
|
|
3
|
+
Rules for things AI agents commonly get wrong in Expo apps. Each one comes from a documented platform change.
|
|
4
|
+
|
|
5
|
+
## Expo changes with every SDK
|
|
6
|
+
|
|
7
|
+
- Expo APIs are renamed and moved between SDKs, so don't write them from memory. Use the docs for this app's SDK (the version is in `AGENTS.md`): `https://docs.expo.dev/versions/v<SDK>.0.0/`. `https://docs.expo.dev/llms.txt` indexes all of Expo's docs.
|
|
8
|
+
- Add libraries with `npx expo install <package>`: it picks the version that matches the SDK. `npx expo install --check` lists the ones that don't match.
|
|
9
|
+
- Upgrade the SDK as a whole with the `expo-upgrade` skill, never one Expo package at a time.
|
|
10
|
+
- Without an ESLint config (`eslint.config.js`), the first `npx expo lint` installs ESLint and writes one, changing `package.json`. Ask before running it then.
|
|
11
|
+
|
|
12
|
+
## Native projects
|
|
13
|
+
|
|
14
|
+
- `ios/` and `android/` are generated by `npx expo prebuild` and aren't in git. Never edit them: the next prebuild overwrites the change.
|
|
15
|
+
- Native settings (permissions and their texts, bundle ID, entitlements) go in `app.json` or `app.config.*`. Libraries with native setup bring a config plugin; add it to `plugins`.
|
|
16
|
+
- Native code of the app's own goes in an Expo module (`expo-module` skill), not into the generated folders.
|
|
17
|
+
- A library with native code needs a new native build: Expo Go doesn't include it. `sh scripts/ai/verify.sh` makes release builds with the current native code.
|
|
18
|
+
|
|
19
|
+
## Architecture
|
|
20
|
+
|
|
21
|
+
- React Native 0.82 and later run only the New Architecture, and so does Expo. Libraries must support it.
|
|
22
|
+
|
|
23
|
+
## Screens and layout
|
|
24
|
+
|
|
25
|
+
- Use Expo Router for navigation (`expo-router` skill). Every file in the routes folder is a screen; keep components, hooks and utilities outside it.
|
|
26
|
+
- Use `react-native-safe-area-context` for safe areas. React Native's built-in `SafeAreaView` is deprecated and iOS-only.
|
|
27
|
+
- Android draws edge to edge (Android 15 and later), so handle top and bottom insets on every screen.
|
|
28
|
+
- For apps targeting Android 16 (API 36), `onBackPressed` is no longer called. Handle back with `BackHandler` in JS.
|
|
29
|
+
- Check every UI change on both iOS and Android; behavior differs (keyboard, insets, fonts, permissions).
|
|
30
|
+
- Give every interactive element a `testID` (kebab-case, for example `dark-mode-switch`). End-to-end tools tap by `testID`. On iOS, React Native exposes a label and its control as duplicate accessibility elements, so tapping by text can hit the label: nothing happens, yet the tool reports success.
|
|
31
|
+
|
|
32
|
+
## Performance and libraries
|
|
33
|
+
|
|
34
|
+
- Prefer Expo's own modules (`expo-image`, `expo-file-system`, `expo-secure-store`, …) when one fits.
|
|
35
|
+
- Follow the `react-native-best-practices` skill for lists, re-renders, startup time and bundle size.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Known issues
|
|
2
|
+
|
|
3
|
+
Recurring errors and their fixes. Check here before debugging a build error. Remove entries that no longer apply.
|
|
4
|
+
|
|
5
|
+
## Format
|
|
6
|
+
|
|
7
|
+
### <short error text>
|
|
8
|
+
- **Cause:**
|
|
9
|
+
- **Fix:**
|
|
10
|
+
- **Prevention:**
|
|
11
|
+
|
|
12
|
+
## Entries
|
|
13
|
+
|
|
14
|
+
### A native change doesn't show up in the build
|
|
15
|
+
- **Cause:** the kit's scripts regenerate `ios/` and `android/` only when Expo's fingerprint changes. It covers the app config, config plugins and native libraries, but not, for example, a file that a config plugin reads.
|
|
16
|
+
- **Fix:** delete `ios/.amk-fingerprint` and `android/.amk-fingerprint`, then check again. The next build regenerates both folders and takes longer.
|
|
17
|
+
- **Prevention:** none needed for app config, plugin and library changes.
|
|
18
|
+
|
|
19
|
+
### Expo SDK 55: the Android release build fails with "libworklets.so … missing and no known rule to make it"
|
|
20
|
+
- **Cause:** SDK 55's `expo-modules-core` looks for `libworklets.so` in an older build-output folder (`node_modules/react-native-worklets/android/build/intermediates/cmake/release/obj/<abi>/`). `react-native-worklets` 0.7 builds it into `intermediates/cxx/RelWithDebInfo/<hash>/obj/<abi>/`. It fails without the kit too.
|
|
21
|
+
- **Fix:** move to a later Expo SDK (SDK 57 builds). Until then: build worklets once (`cd android && ./gradlew :react-native-worklets:assembleRelease`), copy each `libworklets.so` from `cxx/RelWithDebInfo/*/obj/<abi>/` to `cmake/release/obj/<abi>/`, and build again. The copy stays until `node_modules` is reinstalled.
|
|
22
|
+
- **Prevention:** upgrade the SDK.
|
|
23
|
+
|
|
24
|
+
### A library fails at build or run time right after it was added
|
|
25
|
+
- **Cause:** it was added with `npm install` or `yarn add`, so its version may not match the Expo SDK.
|
|
26
|
+
- **Fix:** `npx expo install --fix`, then `npx expo-doctor`.
|
|
27
|
+
- **Prevention:** add libraries with `npx expo install <package>`.
|
|
28
|
+
|
|
29
|
+
### "Unable to resolve module ./Name" in CI or a fresh clone, while it builds on your machine
|
|
30
|
+
- **Cause:** a file was renamed only in letter case (for example `storage.ts` to `Storage.ts`). macOS and Windows treat both names as the same file, so git kept the old name; Metro and Linux CI machines don't.
|
|
31
|
+
- **Fix:** rename it through git in two steps, then commit: `git mv src/utils/storage.ts src/utils/tmp.ts && git mv src/utils/tmp.ts src/utils/Storage.ts`.
|
|
32
|
+
- **Prevention:** rename files with `git mv`, not only in Finder or the editor.
|
|
@@ -21,5 +21,5 @@ Input: $ARGUMENTS (what's wrong, steps to reproduce, error text, screenshots, ta
|
|
|
21
21
|
5. **Make the smallest fix.** Don't refactor or touch unrelated code.
|
|
22
22
|
6. **Verify.** The new test passes, and lint, typecheck and all tests pass. Paste the output. For UI or native bugs, run `sh scripts/ai/verify.sh ios` and/or `android` and look at the screenshots.
|
|
23
23
|
7. **Two attempts at most.** If two fixes didn't work, stop. Report what you tried, what you learned and what you suspect next.
|
|
24
|
-
8. **Record it.** If this kind of error could come back, add an entry to `docs/ai/known-issues.md` (error, cause, fix, prevention). If the fix changes what the app is meant to do, not just makes it work as specified, update that requirement in `specs/current/<area>.md` in the same format, and run `node scripts/ai/
|
|
24
|
+
8. **Record it.** If this kind of error could come back, add an entry to `docs/ai/known-issues.md` (error, cause, fix, prevention). If the fix changes what the app is meant to do, not just makes it work as specified, update that requirement in `specs/current/<area>.md` in the same format, and run `node scripts/ai/specs.js check`.
|
|
25
25
|
9. **Commit** with a message ending in `Assisted-by: <tool>/<model>`. Ask the user before pushing, then open a PR with the evidence.
|
|
@@ -13,7 +13,7 @@ Input: $ARGUMENTS (a spec ID, or empty).
|
|
|
13
13
|
1. **Check git first.** Run `git fetch` and `git status`.
|
|
14
14
|
- If the branch is behind its remote, say so and ask before pulling.
|
|
15
15
|
- If there are uncommitted changes, list them; they may be half-done work.
|
|
16
|
-
2. **Find the spec.** Use the given ID; otherwise run `node scripts/ai/
|
|
16
|
+
2. **Find the spec.** Use the given ID; otherwise run `node scripts/ai/specs.js status` and take the spec in progress that was updated most recently. If unsure, ask.
|
|
17
17
|
3. **Read** `requirements.md`, `design.md`, `tasks.md` and `progress.md` in that spec folder, plus `git log --oneline -15`.
|
|
18
18
|
4. **Report back, in this order:**
|
|
19
19
|
1. any open question or blocker from the handoff;
|
|
@@ -21,7 +21,7 @@ If the input describes a bug rather than new behavior, suggest `m-bugfix` and st
|
|
|
21
21
|
1. Pick an ID: the task's ID if it has one, otherwise `YYYYMMDD-<slug>`. Copy `specs/_templates/` to `specs/<id>/`.
|
|
22
22
|
2. Read `specs/current/<area>.md` for each area this touches: it says what the app does now. In an area with no living spec yet, read the code that implements it.
|
|
23
23
|
3. **One intent.** The feature should be one thing you can say in a sentence. If it needs "and also", suggest splitting it into separate features, and ask.
|
|
24
|
-
4. Fill `requirements.md`: the goal; the requirements under `## ADDED`, `## MODIFIED` and `## REMOVED Requirements: <area>` (the format is in `specs/current/README.md`), with one SHALL per requirement and scenarios for the cases that matter; every edge-case line (or "n/a"); out of scope; open questions. Then run `node scripts/ai/
|
|
24
|
+
4. Fill `requirements.md`: the goal; the requirements under `## ADDED`, `## MODIFIED` and `## REMOVED Requirements: <area>` (the format is in `specs/current/README.md`), with one SHALL per requirement and scenarios for the cases that matter; every edge-case line (or "n/a"); out of scope; open questions. Then run `node scripts/ai/specs.js check specs/<id>/requirements.md`.
|
|
25
25
|
5. If something is unclear, ask the user **one question at a time**. Don't fill gaps with guesses.
|
|
26
26
|
6. Show the requirements and **stop until the user approves them**. Give the user these questions to check them against:
|
|
27
27
|
- Is this the problem you asked me to solve, with nothing extra in scope?
|
|
@@ -55,7 +55,7 @@ When all tasks are done:
|
|
|
55
55
|
|
|
56
56
|
## 6. Update the living spec
|
|
57
57
|
|
|
58
|
-
Run `node scripts/ai/
|
|
58
|
+
Run `node scripts/ai/specs.js merge <id>`. It applies the ADDED, MODIFIED and REMOVED requirements to `specs/current/` and notes the source of each. If it refuses, the reason is usually that a requirement listed as ADDED already exists, or one listed as MODIFIED doesn't. Fix `requirements.md` and run it again. Commit `specs/current/` with the feature, so reviewers see the change in behavior.
|
|
59
59
|
|
|
60
60
|
## 7. Review and pull request
|
|
61
61
|
|
|
@@ -21,12 +21,12 @@ Input: $ARGUMENTS (the new version such as 1.4.0, or patch, minor or major; whic
|
|
|
21
21
|
- `client.md`: for the client or product owner. Cover what's new, what's fixed, what they should test or do, and known issues.
|
|
22
22
|
|
|
23
23
|
Show all three files to the user and wait for their approval.
|
|
24
|
-
5. **Version and build numbers:** `sh scripts/ai/set-version.sh <version>` sets the iOS and Android version names. If the script stops because the project ships several apps, ask the user
|
|
25
|
-
- When CI or
|
|
26
|
-
- Otherwise every store upload needs a higher build number. Ask before changing native files. Then raise Android's `versionCode` in `android/app/build.gradle`, and set iOS with `cd ios && agvtool new-version -all <number>`. Never edit `project.pbxproj` by hand. iOS may keep its build number when the version name changes, if that's how the team works.
|
|
24
|
+
5. **Version and build numbers:** `sh scripts/ai/set-version.sh <version>` sets the iOS and Android version names; in Expo apps without native folders, `expo.version` in `app.json`. If the script stops because the project ships several apps, or computes its config in `app.config.*`, ask the user how to set each version, and set them after they confirm.
|
|
25
|
+
- When CI, fastlane or EAS sets the build numbers at build time (`release-check.js` in step 6 says so), leave them alone.
|
|
26
|
+
- Otherwise every store upload needs a higher build number. Ask before changing native files. Then raise Android's `versionCode` in `android/app/build.gradle`, and set iOS with `cd ios && agvtool new-version -all <number>`. Never edit `project.pbxproj` by hand. In Expo apps without native folders, raise `expo.ios.buildNumber` and `expo.android.versionCode` in `app.json` instead. iOS may keep its build number when the version name changes, if that's how the team works.
|
|
27
27
|
6. **Release check:** `node scripts/ai/release-check.js`. Show the output. Fix each ✗, asking first when the fix touches native config. List each ! for the user to decide.
|
|
28
28
|
7. **Release PR:** commit as `chore(release): <version>` (so the next changelog leaves it out), with `Assisted-by: <tool>/<model>`. Ask before pushing. Open a PR titled `Release <version>` with the changelog and the release-check output.
|
|
29
29
|
8. **Tag and build, after the merge.** Once the PR is merged, ask the user before tagging. Then run `git switch main && git pull && git tag v<version> && git push origin v<version>`.
|
|
30
30
|
- With Codemagic (`codemagic.yaml`; see `docs/ai/codemagic.md`), the tag starts the signed builds.
|
|
31
|
-
- With the team's own release tooling (fastlane lanes in `fastlane/`, `ios/fastlane/` or `android/fastlane/`, or release scripts in `package.json`), the user runs the lane or script that builds and uploads the release, instead of `release-build.sh`. Tell them which one; if it isn't clear, ask.
|
|
32
|
-
- Without CI, the user builds signed apps on their Mac, because signing keys stay with people. Tell them to run `sh scripts/ai/release-build.sh android [flavor]` and `sh scripts/ai/release-build.sh ios [scheme]`, and to upload the results from `.ai/release/` (Play Console, and Xcode's Organizer or Transporter). Never run these yourself or ask for the keys.
|
|
31
|
+
- With the team's own release tooling (fastlane lanes in `fastlane/`, `ios/fastlane/` or `android/fastlane/`, EAS builds set up in `eas.json`, or release scripts in `package.json`), the user runs the lane, `eas build` and `eas submit`, or the script that builds and uploads the release, instead of `release-build.sh`. Tell them which one; if it isn't clear, ask.
|
|
32
|
+
- Without CI, the user builds signed apps on their Mac, because signing keys stay with people. Tell them to run `sh scripts/ai/release-build.sh android [flavor]` and `sh scripts/ai/release-build.sh ios [scheme]`, and to upload the results from `.ai/release/` (Play Console, and Xcode's Organizer or Transporter). In Expo apps the script generates the native projects first, and iOS signing needs the Apple team in `app.json` (`expo.ios.appleTeamId`). Never run these yourself or ask for the keys.
|
|
@@ -17,7 +17,7 @@ If your tool has subagents, hand the review to the `m-reviewer` subagent, so it
|
|
|
17
17
|
- **Against the spec**, when there is one:
|
|
18
18
|
- *Complete:* every task is ticked, every requirement is implemented, and every scenario has evidence (a test or a screenshot).
|
|
19
19
|
- *Correct:* the code does what each requirement says, edge cases included, and nothing outside the agreed scope.
|
|
20
|
-
- *Coherent:* the decisions in `design.md` show up in the code, and `specs/current/` was updated (`node scripts/ai/
|
|
20
|
+
- *Coherent:* the decisions in `design.md` show up in the code, and `specs/current/` was updated (`node scripts/ai/specs.js merge <id>`) if behavior changed.
|
|
21
21
|
- **No spec:** does the diff do what was asked, and nothing unrelated?
|
|
22
22
|
- **Tests:** were tests added for new logic? Were any tests deleted, skipped or weakened?
|
|
23
23
|
- **Both platforms:** anything iOS-only or Android-only (insets, back button, permissions, keyboard)?
|
|
@@ -9,7 +9,7 @@ staged=$(git diff --cached --name-only --diff-filter=ACMR)
|
|
|
9
9
|
fail() { echo "pre-commit: $*" >&2; exit 1; }
|
|
10
10
|
|
|
11
11
|
# 1. files that must never be committed
|
|
12
|
-
if echo "$staged" | grep -E '(^|/)\.env(\..+)?$' | grep -
|
|
12
|
+
if echo "$staged" | grep -E '(^|/)\.env(\..+)?$' | grep -qvE '\.(example|sample|template)$'; then
|
|
13
13
|
fail "don't commit .env files; keep secrets out of git"
|
|
14
14
|
fi
|
|
15
15
|
if echo "$staged" | grep -qE '\.(keystore|jks|p8|p12|mobileprovision)$'; then
|
|
@@ -30,8 +30,8 @@ if command -v plutil > /dev/null; then
|
|
|
30
30
|
done
|
|
31
31
|
fi
|
|
32
32
|
|
|
33
|
-
# 4. lint the staged JS/TS files with the project's own ESLint config
|
|
34
|
-
files=$(echo "$staged" | grep -E '\.(js|jsx|ts|tsx)$' || true)
|
|
33
|
+
# 4. lint the staged JS/TS files with the project's own ESLint config (the kit's own scripts aren't the app's code)
|
|
34
|
+
files=$(echo "$staged" | grep -E '\.(js|jsx|ts|tsx)$' | grep -v '^scripts/ai/' || true)
|
|
35
35
|
if [ -n "$files" ]; then
|
|
36
36
|
if [ -x node_modules/.bin/eslint ]; then
|
|
37
37
|
# ponytail: file names with spaces aren't supported here; split on newlines if that ever matters
|
|
@@ -43,8 +43,8 @@ fi
|
|
|
43
43
|
|
|
44
44
|
# 5. spec format: requirements in force need a SHALL and a scenario (format: specs/current/README.md)
|
|
45
45
|
specs=$(echo "$staged" | grep -E '^specs/([^_/][^/]*/requirements|current/[^/]+)\.md$' | grep -v '^specs/current/README\.md$' || true)
|
|
46
|
-
if [ -n "$specs" ] && [ -f scripts/ai/
|
|
47
|
-
node scripts/ai/
|
|
46
|
+
if [ -n "$specs" ] && [ -f scripts/ai/specs.js ]; then
|
|
47
|
+
node scripts/ai/specs.js check --skip-drafts $specs || fail "fix the spec format above (format: specs/current/README.md)"
|
|
48
48
|
fi
|
|
49
49
|
|
|
50
50
|
# 6. files renamed only in letter case on macOS or Windows: git still has the old name, so other machines can't find them
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
# agentic-mobile-kit pre-push: typecheck and tests before code leaves the machine.
|
|
3
3
|
set -eu
|
|
4
4
|
[ -d node_modules ] || { echo "pre-push: dependencies aren't installed; run: sh scripts/ai/install-deps.sh" >&2; exit 1; }
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
# each passes when the app's script passes, or when all its failures were already on the base branch
|
|
6
|
+
node scripts/ai/baseline.js typecheck || { echo "pre-push: fix the new type errors above" >&2; exit 1; }
|
|
7
|
+
node scripts/ai/baseline.js test || { echo "pre-push: fix the new test failures above" >&2; exit 1; }
|
|
@@ -25,9 +25,14 @@ jobs:
|
|
|
25
25
|
with:
|
|
26
26
|
node-version: 24
|
|
27
27
|
- run: sh scripts/ai/install-deps.sh
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
|
|
28
|
+
# each passes when the app's script passes, or when all its failures were already on the base branch
|
|
29
|
+
- name: Lint, typecheck and tests
|
|
30
|
+
env:
|
|
31
|
+
AMK_BASE: ${{ github.event_name == 'pull_request' && format('origin/{0}', github.base_ref) || github.event.before }}
|
|
32
|
+
run: |
|
|
33
|
+
node scripts/ai/baseline.js lint
|
|
34
|
+
node scripts/ai/baseline.js typecheck
|
|
35
|
+
node scripts/ai/baseline.js test
|
|
31
36
|
- name: Tool configs match .rulesync/ (run "npx -y rulesync@27.0.0 generate" and commit if this fails)
|
|
32
37
|
if: hashFiles('rulesync.jsonc') != ''
|
|
33
38
|
run: npx -y rulesync@27.0.0 generate > /dev/null && git diff --exit-code -- .claude .codex .agents .antigravity
|
|
@@ -43,6 +43,8 @@ jobs:
|
|
|
43
43
|
echo "$MAESTRO_SHA256 maestro.zip" | sha256sum -c -
|
|
44
44
|
unzip -q maestro.zip -d "$HOME" && rm maestro.zip
|
|
45
45
|
echo "$HOME/maestro/bin" >> "$GITHUB_PATH"
|
|
46
|
+
- name: Generate the native project (Expo apps without android/ in git)
|
|
47
|
+
run: sh scripts/ai/prebuild.sh android
|
|
46
48
|
- name: Build release APK
|
|
47
49
|
working-directory: android
|
|
48
50
|
run: ./gradlew assembleRelease --no-daemon
|
|
@@ -33,9 +33,8 @@ jobs:
|
|
|
33
33
|
with:
|
|
34
34
|
node-version: 24
|
|
35
35
|
- run: sh scripts/ai/install-deps.sh
|
|
36
|
-
- name: Generate the native project (Expo apps without ios/)
|
|
37
|
-
|
|
38
|
-
run: npx expo prebuild --platform ios --no-install
|
|
36
|
+
- name: Generate the native project (Expo apps without ios/ in git)
|
|
37
|
+
run: sh scripts/ai/prebuild.sh ios
|
|
39
38
|
- name: Install pods
|
|
40
39
|
run: sh scripts/ai/pod-install.sh
|
|
41
40
|
- name: Build for the simulator (no signing)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- KIT:START agentic-mobile-kit {{KIT_VERSION}} ci={{KIT_CI}} (edit outside these markers; the kit updates what's inside) -->
|
|
1
|
+
<!-- KIT:START agentic-mobile-kit {{KIT_VERSION}} ci={{KIT_CI}} stack={{KIT_STACK}} (edit outside these markers; the kit updates what's inside) -->
|
|
2
2
|
# {{APP_NAME}}: instructions for AI agents
|
|
3
3
|
|
|
4
4
|
Read by Claude Code (through CLAUDE.md), Codex, Cursor, OpenCode, Kiro and Antigravity. Keep it short; details live in `docs/ai/`.
|
|
@@ -20,14 +20,14 @@ This project may also use other AI workflow frameworks (for example Superpowers,
|
|
|
20
20
|
| iOS build (simulator, no signing) | `sh scripts/ai/ios-build.sh` |
|
|
21
21
|
| Android build | `cd android && ./gradlew assembleDebug` |
|
|
22
22
|
| Check on devices (release builds, Maestro flows, screenshots) | `sh scripts/ai/verify.sh all --spec <id>`; with product flavors it checks the first unless `--flavor <name>`; another iOS scheme: `--scheme <name>` |
|
|
23
|
-
| Specs: progress, format check, fold a finished feature into the living spec | `node scripts/ai/
|
|
23
|
+
| Specs: progress, format check, fold a finished feature into the living spec | `node scripts/ai/specs.js status`, `node scripts/ai/specs.js check`, `node scripts/ai/specs.js merge <id>` |
|
|
24
24
|
| Check a release before tagging it (versions, permission texts, debug leftovers) | `node scripts/ai/release-check.js` |
|
|
25
25
|
| Signed release builds (a person runs them: they use the signing keys) | `sh scripts/ai/release-build.sh android [flavor]`, `sh scripts/ai/release-build.sh ios [scheme]` |
|
|
26
26
|
|
|
27
27
|
## Definition of done
|
|
28
28
|
|
|
29
29
|
A task is done only when:
|
|
30
|
-
1. lint, typecheck
|
|
30
|
+
1. `sh scripts/ai/verify.sh quick` passes (lint, typecheck, tests) and you show its output from this session. In an app whose base branch already fails some of them, it passes when your change adds no new failure, and lists the old ones: leave those alone unless the task is to fix them;
|
|
31
31
|
2. UI changes were checked with `sh scripts/ai/verify.sh all --spec <id>` on both iOS and Android, and you looked at the screenshots. On Windows or Linux, that covers Android only: write in `progress.md` and the PR that iOS still needs checking on a Mac, and the PR isn't merged until a teammate with a Mac has done it;
|
|
32
32
|
3. the change stays inside the task's scope;
|
|
33
33
|
4. `specs/<id>/progress.md` is updated, when working from a spec.
|
|
@@ -27,6 +27,7 @@ workflows:
|
|
|
27
27
|
script: cp "release-notes/${CM_TAG#v}/play-store.txt" release_notes.txt 2>/dev/null || true
|
|
28
28
|
- name: Build the signed app bundle
|
|
29
29
|
script: |
|
|
30
|
+
sh scripts/ai/prebuild.sh android # Expo apps without android/ in git
|
|
30
31
|
echo "sdk.dir=$ANDROID_SDK_ROOT" > android/local.properties
|
|
31
32
|
package=$(sed -n -E 's/.*applicationId( =)? "([^"]+)".*/\2/p' android/app/build.gradle* | head -1)
|
|
32
33
|
if last=$(google-play get-latest-build-number --package-name "$package") && [ -n "$last" ]; then code=$((last + 1)); else code=$BUILD_NUMBER; fi
|
|
@@ -66,7 +67,7 @@ workflows:
|
|
|
66
67
|
- name: Release check
|
|
67
68
|
script: node scripts/ai/release-check.js
|
|
68
69
|
- name: Install dependencies
|
|
69
|
-
script: sh scripts/ai/install-deps.sh && sh scripts/ai/pod-install.sh
|
|
70
|
+
script: sh scripts/ai/install-deps.sh && sh scripts/ai/prebuild.sh ios && sh scripts/ai/pod-install.sh
|
|
70
71
|
- name: Store release notes
|
|
71
72
|
script: |
|
|
72
73
|
notes="release-notes/${CM_TAG#v}/app-store.txt"
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Runs the app's lint, typecheck or test script. When it fails, it compares the problems with the base branch and
|
|
3
|
+
// passes if all of them were there already: an app that starts with lint errors or failing tests can still show
|
|
4
|
+
// that a change made nothing worse. What counts as new:
|
|
5
|
+
// lint ESLint errors in the files changed since the base, compared with those files at the base
|
|
6
|
+
// typecheck TypeScript errors (file, code, message), compared with a type check of the base
|
|
7
|
+
// test failing Jest tests and test files, compared with a test run of the base
|
|
8
|
+
// The base: AMK_BASE, else the remote's default branch, else main or master. Its merge base is checked out once
|
|
9
|
+
// into a temporary git worktree that shares node_modules, and its results are kept for the next run.
|
|
10
|
+
// Usage: node scripts/ai/baseline.js lint|typecheck|test
|
|
11
|
+
'use strict';
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const os = require('os');
|
|
14
|
+
const path = require('path');
|
|
15
|
+
const crypto = require('crypto');
|
|
16
|
+
const { spawnSync, execFileSync } = require('child_process');
|
|
17
|
+
|
|
18
|
+
const check = process.argv[2];
|
|
19
|
+
if (!['lint', 'typecheck', 'test'].includes(check)) {
|
|
20
|
+
console.error('usage: node scripts/ai/baseline.js lint|typecheck|test');
|
|
21
|
+
process.exit(2);
|
|
22
|
+
}
|
|
23
|
+
const root = process.cwd();
|
|
24
|
+
const git = (...args) => {
|
|
25
|
+
try {
|
|
26
|
+
return execFileSync('git', args, { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], maxBuffer: 2 ** 28 }).trim();
|
|
27
|
+
} catch {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const hash = s => crypto.createHash('sha1').update(s).digest('hex').slice(0, 12);
|
|
32
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
|
33
|
+
const jest = check === 'test' && /\bjest\b/.test((pkg.scripts || {}).test || '');
|
|
34
|
+
// the real path: on macOS the temp folder is behind a symlink, and test runners report real paths
|
|
35
|
+
const scratch = path.join(fs.realpathSync(os.tmpdir()), 'amk-baseline', hash(root));
|
|
36
|
+
const slash = p => p.split(path.sep).join('/');
|
|
37
|
+
// a minus b, counting duplicates
|
|
38
|
+
const minus = (a, b) => {
|
|
39
|
+
const left = [...b];
|
|
40
|
+
return a.filter(x => {
|
|
41
|
+
const i = left.indexOf(x);
|
|
42
|
+
if (i < 0) return true;
|
|
43
|
+
left.splice(i, 1);
|
|
44
|
+
return false;
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// the package.json script, through pm-run.sh, in dir (the app, or the base's worktree)
|
|
49
|
+
function runScript(dir) {
|
|
50
|
+
fs.mkdirSync(scratch, { recursive: true });
|
|
51
|
+
const json = path.join(scratch, `jest-${hash(dir)}.json`);
|
|
52
|
+
fs.rmSync(json, { force: true });
|
|
53
|
+
const r = spawnSync('sh', [path.join(root, 'scripts/ai/pm-run.sh'), check, ...(jest ? ['--json', `--outputFile=${json}`] : [])],
|
|
54
|
+
{ cwd: dir, encoding: 'utf8', env: { ...process.env, CI: 'true' }, maxBuffer: 2 ** 28 });
|
|
55
|
+
return { code: r.status, out: `${r.stdout || ''}${r.stderr || ''}`, json, dir };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// TypeScript errors without their position, which moves when lines are added above them
|
|
59
|
+
function typeErrors(r) {
|
|
60
|
+
const errors = [...r.out.matchAll(/^(\S.*?)\(\d+,\d+\): error (TS\d+): (.*)$/gm)].map(m => `${slash(m[1])}: ${m[2]} ${m[3]}`);
|
|
61
|
+
return errors.length ? errors : null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// failing tests, and test files that fail to run, from Jest's JSON report
|
|
65
|
+
function failingTests(r) {
|
|
66
|
+
let report;
|
|
67
|
+
try {
|
|
68
|
+
report = JSON.parse(fs.readFileSync(r.json, 'utf8'));
|
|
69
|
+
} catch {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
return report.testResults.flatMap(suite => {
|
|
73
|
+
const file = slash(path.relative(r.dir, suite.name));
|
|
74
|
+
const failed = (suite.assertionResults || []).filter(a => a.status === 'failed').map(a => `${file} › ${a.fullName}`);
|
|
75
|
+
return failed.length || suite.status !== 'failed' ? failed : [`${file} (the file fails to run)`];
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function baseRef() {
|
|
80
|
+
if (process.env.AMK_BASE) return process.env.AMK_BASE;
|
|
81
|
+
const remoteDefault = git('symbolic-ref', '--quiet', '--short', 'refs/remotes/origin/HEAD');
|
|
82
|
+
return [remoteDefault, 'origin/main', 'origin/master', 'main', 'master'].find(r => r && git('rev-parse', '--verify', '--quiet', `${r}^{commit}`));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// the base commit, checked out once into a temporary worktree that shares the app's node_modules
|
|
86
|
+
function baseWorktree(sha) {
|
|
87
|
+
const dir = path.join(scratch, sha);
|
|
88
|
+
if (fs.existsSync(path.join(dir, 'package.json'))) return dir;
|
|
89
|
+
for (const old of fs.readdirSync(scratch).filter(f => !f.startsWith(sha) && /^[0-9a-f]{40}/.test(f))) {
|
|
90
|
+
git('worktree', 'remove', '--force', path.join(scratch, old));
|
|
91
|
+
fs.rmSync(path.join(scratch, old), { recursive: true, force: true });
|
|
92
|
+
}
|
|
93
|
+
git('worktree', 'prune');
|
|
94
|
+
execFileSync('git', ['worktree', 'add', '--detach', '--force', dir, sha], { cwd: root, stdio: 'ignore' });
|
|
95
|
+
if (fs.existsSync(path.join(root, 'node_modules'))) fs.symlinkSync(path.join(root, 'node_modules'), path.join(dir, 'node_modules'), 'junction');
|
|
96
|
+
return dir;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function baseProblems(sha, extract) {
|
|
100
|
+
const cache = path.join(scratch, `${sha}.${check}.json`);
|
|
101
|
+
try {
|
|
102
|
+
return JSON.parse(fs.readFileSync(cache, 'utf8'));
|
|
103
|
+
} catch {}
|
|
104
|
+
const dir = baseWorktree(sha);
|
|
105
|
+
// the same check on the old code: the app's current script, which the base may not have yet (the kit adds typecheck)
|
|
106
|
+
const basePkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'));
|
|
107
|
+
if ((basePkg.scripts || {})[check] !== pkg.scripts[check]) {
|
|
108
|
+
basePkg.scripts = { ...basePkg.scripts, [check]: pkg.scripts[check] };
|
|
109
|
+
fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(basePkg, null, 2));
|
|
110
|
+
}
|
|
111
|
+
const r = runScript(dir);
|
|
112
|
+
const problems = r.code === 0 ? [] : extract(r);
|
|
113
|
+
if (problems) fs.writeFileSync(cache, JSON.stringify(problems));
|
|
114
|
+
return problems;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// ESLint errors in the files changed since the base, minus the errors those files had at the base. Errors in
|
|
118
|
+
// files the change didn't touch were there before, unless the change edits the ESLint setup itself.
|
|
119
|
+
function newLintErrors(sha) {
|
|
120
|
+
const changed = [...new Set([...git('diff', '--name-only', '--diff-filter=ACMR', sha).split('\n'),
|
|
121
|
+
...git('ls-files', '--others', '--exclude-standard').split('\n')])].filter(Boolean);
|
|
122
|
+
// the kit's own .eslintignore lines (for scripts/ai/) don't change how the app's code is checked
|
|
123
|
+
const withoutKit = t => t.split('\n').filter(l => l.trim() !== 'scripts/ai/' && !l.startsWith('# agentic-mobile-kit')).join('\n').trim();
|
|
124
|
+
const setup = changed.filter(f => /(^|\/)(\.eslintrc(\.\w+)?|eslint\.config\.\w+|\.eslintignore)$/.test(f))
|
|
125
|
+
.filter(f => path.basename(f) !== '.eslintignore' || withoutKit(git('show', `${sha}:${f}`)) !== withoutKit(fs.readFileSync(path.join(root, f), 'utf8')));
|
|
126
|
+
if (setup.length) return { reason: `the change edits the ESLint setup (${setup.join(', ')}), so any error could be new` };
|
|
127
|
+
// ESLint 8 and 9 export only package.json, so find the CLI next to it
|
|
128
|
+
let eslint;
|
|
129
|
+
try {
|
|
130
|
+
eslint = path.join(path.dirname(require.resolve('eslint/package.json', { paths: [root] })), 'bin', 'eslint.js');
|
|
131
|
+
if (!fs.existsSync(eslint)) throw new Error('no CLI');
|
|
132
|
+
} catch {
|
|
133
|
+
return { reason: 'ESLint isn\'t installed' };
|
|
134
|
+
}
|
|
135
|
+
const lint = (args, input) => {
|
|
136
|
+
const r = spawnSync(process.execPath, [eslint, '--format', 'json', ...args], { cwd: root, input, encoding: 'utf8', maxBuffer: 2 ** 28 });
|
|
137
|
+
try {
|
|
138
|
+
return JSON.parse(r.stdout);
|
|
139
|
+
} catch {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const errors = results => (results || []).flatMap(f => f.messages.filter(m => m.severity === 2).map(m => `${m.ruleId || 'parsing'}: ${m.message}`));
|
|
144
|
+
const files = changed.filter(f => /\.(js|jsx|ts|tsx)$/.test(f) && !f.startsWith('scripts/ai/') && fs.existsSync(path.join(root, f)));
|
|
145
|
+
const results = files.length ? lint(files) : [];
|
|
146
|
+
if (!results) return { reason: 'ESLint gave no report' };
|
|
147
|
+
const fresh = [];
|
|
148
|
+
for (const result of results) {
|
|
149
|
+
const file = slash(path.relative(root, result.filePath));
|
|
150
|
+
const now = errors([result]);
|
|
151
|
+
if (!now.length) continue;
|
|
152
|
+
let before = [];
|
|
153
|
+
if (git('rev-parse', '--verify', '--quiet', `${sha}:${file}`)) {
|
|
154
|
+
const text = execFileSync('git', ['show', `${sha}:${file}`], { cwd: root, encoding: 'utf8', maxBuffer: 2 ** 28 });
|
|
155
|
+
before = errors(lint(['--stdin', '--stdin-filename', file], text));
|
|
156
|
+
}
|
|
157
|
+
fresh.push(...minus(now, before).map(p => `${file}: ${p}`));
|
|
158
|
+
}
|
|
159
|
+
return { fresh, files: files.length };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const now = runScript(root);
|
|
163
|
+
process.stdout.write(now.out);
|
|
164
|
+
if (now.code === 0) process.exit(0);
|
|
165
|
+
|
|
166
|
+
const base = baseRef();
|
|
167
|
+
const sha = base && git('merge-base', 'HEAD', base);
|
|
168
|
+
if (!sha) {
|
|
169
|
+
console.log(`${check}: failed, and there's no base branch to compare with (set AMK_BASE)`);
|
|
170
|
+
process.exit(1);
|
|
171
|
+
}
|
|
172
|
+
const label = `${base} (${sha.slice(0, 7)})`;
|
|
173
|
+
let fresh;
|
|
174
|
+
let summary;
|
|
175
|
+
if (check === 'lint') {
|
|
176
|
+
const r = newLintErrors(sha);
|
|
177
|
+
if (r.reason) {
|
|
178
|
+
console.log(`lint: failed, and it can't be compared with ${label}: ${r.reason}`);
|
|
179
|
+
process.exit(1);
|
|
180
|
+
}
|
|
181
|
+
fresh = r.fresh;
|
|
182
|
+
summary = `lint: failed, but the ${r.files} file(s) changed since ${label} have no new errors: the failures were there already`;
|
|
183
|
+
} else {
|
|
184
|
+
const extract = check === 'typecheck' ? typeErrors : failingTests;
|
|
185
|
+
const mine = check === 'test' && !jest ? null : extract(now);
|
|
186
|
+
const old = mine && baseProblems(sha, extract);
|
|
187
|
+
if (!mine || !old) {
|
|
188
|
+
console.log(`${check}: failed, and it can't be compared with ${label}: ${check === 'test' && !jest ? 'only Jest results can be compared' : 'its output couldn\'t be read'}`);
|
|
189
|
+
process.exit(1);
|
|
190
|
+
}
|
|
191
|
+
fresh = minus(mine, old);
|
|
192
|
+
summary = `${check}: ${mine.length} problem(s), all already on ${label}: this change adds none`;
|
|
193
|
+
}
|
|
194
|
+
if (!fresh.length) {
|
|
195
|
+
console.log(summary);
|
|
196
|
+
process.exit(0);
|
|
197
|
+
}
|
|
198
|
+
console.log(`${check}: ${fresh.length} new compared with ${label}:`);
|
|
199
|
+
for (const p of fresh.slice(0, 30)) console.log(` ${p}`);
|
|
200
|
+
if (fresh.length > 30) console.log(` … and ${fresh.length - 30} more`);
|
|
201
|
+
process.exit(1);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
const { execFileSync } = require('child_process');
|
|
8
8
|
|
|
9
|
-
const tracked = execFileSync('git', ['ls-files', '-z'], { encoding: 'utf8', maxBuffer:
|
|
9
|
+
const tracked = execFileSync('git', ['ls-files', '-z'], { encoding: 'utf8', maxBuffer: 2 ** 30 }).split('\0').filter(Boolean);
|
|
10
10
|
const listings = new Map();
|
|
11
11
|
const names = dir => {
|
|
12
12
|
if (!listings.has(dir)) { try { listings.set(dir, new Set(fs.readdirSync(dir || '.'))); } catch { listings.set(dir, null); } }
|
|
@@ -22,7 +22,8 @@ const paths = [];
|
|
|
22
22
|
})(payload, '');
|
|
23
23
|
|
|
24
24
|
const destructive = /\brm\s+(-[a-z]*r[a-z]*f|-[a-z]*f[a-z]*r|-r\s+-f|-f\s+-r)\b|git\s+reset\s+--hard|git\s+push\s+(.*\s)?(--force|-f)\b|git\s+clean\s+-[a-z]*f|--no-verify|xcrun\s+simctl\s+erase/;
|
|
25
|
-
|
|
25
|
+
// example files (.env.example, .env.local.example, .env.sample, .env.template) aren't secrets
|
|
26
|
+
const secretFile = /(^|[\s/'"=])\.env(?![\w.-]*\.(?:example|sample|template)(?=$|[\s'";|&)]))(\.[\w.-]+)?(?=$|[\s'";|&)])|\.(keystore|jks|p8|p12|mobileprovision)\b/;
|
|
26
27
|
|
|
27
28
|
const block = reason => { process.stderr.write(`Blocked by scripts/ai/guard.js: ${reason}\n`); process.exit(2); };
|
|
28
29
|
for (const c of commands) {
|
|
@@ -15,7 +15,15 @@ if [ "$config" = Release ]; then
|
|
|
15
15
|
[ -n "$config" ] || config=Release
|
|
16
16
|
fi
|
|
17
17
|
|
|
18
|
+
# only this Mac's simulator architecture: a Release build would otherwise compile Intel and Apple silicon both,
|
|
19
|
+
# and fail to link libraries that ship without an Intel simulator slice. Not when the project or a pod excludes it
|
|
20
|
+
# for the simulator (Google's ML Kit pods exclude arm64): then Xcode builds what the project allows.
|
|
21
|
+
arch=x86_64
|
|
22
|
+
[ "$(sysctl -n hw.optional.arm64 2> /dev/null)" != 1 ] || arch=arm64
|
|
23
|
+
set -- ARCHS="$arch"
|
|
24
|
+
! grep -rqsE "EXCLUDED_ARCHS\[sdk=iphonesimulator\*\]\"? = [^;]*$arch" ios/*.xcodeproj/project.pbxproj "ios/Pods/Target Support Files" || set --
|
|
25
|
+
|
|
18
26
|
xcodebuild -workspace "$workspace" -scheme "$scheme" -configuration "$config" \
|
|
19
27
|
-sdk iphonesimulator -destination 'generic/platform=iOS Simulator' \
|
|
20
|
-
-derivedDataPath ios/DerivedData CODE_SIGNING_ALLOWED=NO -quiet build
|
|
28
|
+
-derivedDataPath ios/DerivedData "$@" CODE_SIGNING_ALLOWED=NO -quiet build
|
|
21
29
|
echo "iOS simulator build OK ($scheme, $config)"
|