agentic-mobile-kit 0.7.19 → 0.14.0

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.
Files changed (69) hide show
  1. package/README.md +18 -3
  2. package/bin/cli.js +5 -3
  3. package/lib/doctor.js +31 -5
  4. package/lib/init.js +17 -22
  5. package/lib/menu.js +3 -3
  6. package/package.json +1 -1
  7. package/stacks/react-native/expo/.eas/workflows/pr-preview.yml +54 -0
  8. package/stacks/react-native/expo/AGENTS.md +30 -17
  9. package/stacks/react-native/expo/docs/amk/expo.md +11 -1
  10. package/stacks/react-native/template/.agents/skills/m-bugfix/SKILL.md +8 -5
  11. package/stacks/react-native/template/.agents/skills/m-change/SKILL.md +3 -2
  12. package/stacks/react-native/template/.agents/skills/m-continue/SKILL.md +6 -4
  13. package/stacks/react-native/template/.agents/skills/m-explore/SKILL.md +1 -1
  14. package/stacks/react-native/template/.agents/skills/m-feature/SKILL.md +29 -26
  15. package/stacks/react-native/template/.agents/skills/m-feature/build.md +35 -0
  16. package/stacks/react-native/template/.agents/skills/m-feature/plan.md +43 -0
  17. package/stacks/react-native/template/.agents/skills/m-learn/SKILL.md +3 -1
  18. package/stacks/react-native/template/.agents/skills/m-onboard/SKILL.md +3 -1
  19. package/stacks/react-native/template/.agents/skills/m-pause/SKILL.md +2 -0
  20. package/stacks/react-native/template/.agents/skills/m-prototype/SKILL.md +1 -1
  21. package/stacks/react-native/template/.agents/skills/m-release/SKILL.md +5 -4
  22. package/stacks/react-native/template/.agents/skills/m-report/SKILL.md +25 -0
  23. package/stacks/react-native/template/.agents/skills/m-review/SKILL.md +4 -3
  24. package/stacks/react-native/template/.agents/skills/m-test/SKILL.md +24 -0
  25. package/stacks/react-native/template/.agents/skills/m-test/agents/openai.yaml +3 -0
  26. package/stacks/react-native/template/.githooks/pre-commit +12 -0
  27. package/stacks/react-native/template/.github/pull_request_template.md +4 -0
  28. package/stacks/react-native/template/.github/workflows/amk-ai-deps.yml +90 -0
  29. package/stacks/react-native/template/.github/workflows/amk-ai-review.yml +82 -0
  30. package/stacks/react-native/template/.github/workflows/amk-kit-update.yml +95 -0
  31. package/stacks/react-native/template/.github/workflows/amk-ready.yml +39 -0
  32. package/stacks/react-native/template/.github/workflows/ci.yml +79 -13
  33. package/stacks/react-native/template/.github/workflows/e2e.yml +10 -1
  34. package/stacks/react-native/template/.rulesync/hooks.jsonc +3 -1
  35. package/stacks/react-native/template/.rulesync/subagents/m-device-checker.md +2 -1
  36. package/stacks/react-native/template/.rulesync/subagents/m-reviewer.md +4 -2
  37. package/stacks/react-native/template/.rulesync/subagents/m-spec-writer.md +15 -0
  38. package/stacks/react-native/template/.rulesync/subagents/m-tester.md +23 -0
  39. package/stacks/react-native/template/AGENTS.md +23 -10
  40. package/stacks/react-native/template/codemagic.yaml +82 -1
  41. package/stacks/react-native/template/docs/amk/codemagic.md +8 -0
  42. package/stacks/react-native/template/docs/amk/react-native.md +11 -1
  43. package/stacks/react-native/template/docs/amk/team-process.md +33 -1
  44. package/stacks/react-native/template/rulesync.jsonc +1 -1
  45. package/stacks/react-native/template/scripts/amk/ai-job.js +106 -0
  46. package/stacks/react-native/template/scripts/amk/autopilot.js +837 -0
  47. package/stacks/react-native/template/scripts/amk/baseline.js +19 -7
  48. package/stacks/react-native/template/scripts/amk/ci-scope.js +59 -0
  49. package/stacks/react-native/template/scripts/amk/coverage.js +111 -0
  50. package/stacks/react-native/template/scripts/amk/guard.js +42 -0
  51. package/stacks/react-native/template/scripts/amk/handoff-check.js +87 -14
  52. package/stacks/react-native/template/scripts/amk/issue.js +31 -0
  53. package/stacks/react-native/template/scripts/amk/metrics.js +164 -0
  54. package/stacks/react-native/template/scripts/amk/pr.js +244 -0
  55. package/stacks/react-native/template/scripts/amk/redact.js +57 -0
  56. package/stacks/react-native/template/scripts/amk/release-build.sh +14 -0
  57. package/stacks/react-native/template/scripts/amk/report.js +48 -11
  58. package/stacks/react-native/template/scripts/amk/rn-check.js +195 -47
  59. package/stacks/react-native/template/scripts/amk/shots.js +131 -0
  60. package/stacks/react-native/template/scripts/amk/specs.js +717 -34
  61. package/stacks/react-native/template/scripts/amk/tool-configs.js +41 -0
  62. package/stacks/react-native/template/scripts/amk/verify.sh +127 -23
  63. package/stacks/react-native/template/specs/_templates/design.md +22 -0
  64. package/stacks/react-native/template/specs/_templates/flow.yaml +2 -1
  65. package/stacks/react-native/template/specs/_templates/plan.md +54 -0
  66. package/stacks/react-native/template/specs/_templates/progress.md +1 -1
  67. package/stacks/react-native/template/specs/_templates/requirements.md +40 -0
  68. package/stacks/react-native/template/specs/_templates/test-report.md +25 -0
  69. package/stacks/react-native/template/.github/workflows/ios.yml +0 -41
@@ -6,4 +6,36 @@
6
6
  - Run at most 2 or 3 agents in parallel per person.
7
7
  - Don't use "skip permissions", "YOLO" or auto-run modes in any tool.
8
8
  - Keep secrets out of the repo folder; inject them at run time.
9
- - Review the metrics and the `m-learn` changes (`git log --grep 'chore(learn)'`) once a month. Re-check `AGENTS.md` and `docs/amk/` after every React Native, Xcode or Android Gradle Plugin upgrade, and after switching AI models.
9
+ - Review the metrics (`node scripts/amk/metrics.js`) and the `m-learn` changes (`git log --grep 'chore(learn)'`) once a month, and run `m-learn review` for what reviews keep finding. Re-check `AGENTS.md` and `docs/amk/` after every React Native, Xcode or Android Gradle Plugin upgrade, and after switching AI models.
10
+
11
+ ## Settings for the agents
12
+
13
+ - Feature mode: ask
14
+ <!-- What /m-feature does, given no task, when docs/amk/product.md plans several features without a spec: ask (offer
15
+ both), feature-by-feature (each with its own approvals), or plan-all (plan every feature first, approved in
16
+ batches, then /m-feature build). -->
17
+ - Reviewers: team
18
+ <!-- team: another person approves each pull request, and the build turns on auto-merge (pr.js automerge), so it
19
+ merges once approved and green; only where main requires an approval, else a person merges it. solo: GitHub doesn't let you approve your own pull request, so you review it and
20
+ add the amk-ready label, which turns on auto-merge (.github/workflows/amk-ready.yml); a new commit takes the
21
+ label off again. Create the label once: gh label create amk-ready. Branch protection: docs/branch-protection.md in
22
+ the kit. -->
23
+ - Merge method:
24
+ <!-- merge, squash or rebase, for auto-merge; empty: the first the repository allows, in that order. -->
25
+ - Open PRs before the build waits: 5
26
+ <!-- node scripts/amk/autopilot.js starts no new planned feature while this many of the plan's pull requests wait for
27
+ review. -->
28
+ - First PR review: off
29
+ <!-- on: once the plan's first pull request is open, autopilot.js builds nothing new until a person approves or merges it,
30
+ so a wrong pattern doesn't spread over every feature. -->
31
+ - Blocked questions as issues: off
32
+ <!-- on: a feature the unattended build blocks gets a GitHub issue "Blocked: <id>" with its question, and m-continue
33
+ reads the answer there. Off by default: clients often watch their private repositories, and agents don't message
34
+ clients. -->
35
+ - Sentry adds amk-fix: off
36
+ <!-- on: an issue Sentry's GitHub integration labels amk-fix (an alert rule can) joins the overnight bug queue
37
+ (autopilot.js), like one a team member labels. Off: only people who can label issues queue bugs. -->
38
+ - Variables for unattended runs: none
39
+ <!-- autopilot.js gives each session only PATH, HOME, the tool's sign-in, GH_TOKEN, what builds need (LANG, JAVA_HOME,
40
+ ANDROID_HOME, SSH_AUTH_SOCK, a package registry token, proxies) and the AMK_ settings. Names of other variables
41
+ the app's build needs, comma-separated (autopilot.js check shows a build failing without them). -->
@@ -1,4 +1,4 @@
1
- // Generates per-tool permissions, hooks and subagents from .rulesync/. Run: npx -y rulesync@27.0.0 generate
1
+ // Generates per-tool permissions, hooks and subagents from .rulesync/. Run: npx -y rulesync@27.0.0 generate && node scripts/amk/tool-configs.js
2
2
  // Commit the generated files. Rules and skills don't go through rulesync (AGENTS.md and .agents/skills are shared).
3
3
  {
4
4
  "targets": ["claudecode", "codexcli", "antigravity-ide", "antigravity-cli"],
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env node
2
+ // The AI jobs in CI (.github/workflows/amk-ai-review.yml and amk-ai-deps.yml, added with --ci github,ai): who may start
3
+ // one, and when it stops. GitHub's own variables (GITHUB_EVENT_PATH, GITHUB_REPOSITORY, GITHUB_WORKFLOW_REF, …) and gh
4
+ // (GH_TOKEN) tell it the rest.
5
+ // node scripts/amk/ai-job.js gate <job> go=true or go=false, as a GitHub Actions output, and why:
6
+ // - only a person with write access to the repository starts one; for the dependency job (deps), Dependabot or
7
+ // Renovate too. Never the AI jobs' own app or another bot, and never a commit an AI job's fix made (its
8
+ // "AMK-Agent-Fix: <job>" trailer)
9
+ // - not while the job is paused: an open issue "AI job paused: <job>" (close it to resume the job)
10
+ // - the loop guard: not after 3 of its fix commits in a row on the branch, nor after 6 runs in the last hour; the
11
+ // dependency job once per failed CI run
12
+ // - nothing when docs/amk/team-process.md, where its settings are, can't be read
13
+ // node scripts/amk/ai-job.js after <job> <result> after a run that went: a third failure in a row (a timeout or a
14
+ // cancel counts; a run that didn't go doesn't) pauses the job, opening that issue
15
+ 'use strict';
16
+ const fs = require('fs');
17
+ const path = require('path');
18
+ const { spawnSync } = require('child_process');
19
+
20
+ const ROOT = path.join(__dirname, '..', '..');
21
+ const BOTS = { deps: ['dependabot[bot]', 'renovate[bot]'] };
22
+ const IN_A_ROW = 3;
23
+ const PER_HOUR = 6;
24
+ const trailer = job => new RegExp(`^AMK-Agent-Fix: ${job}\\b`, 'm');
25
+ const paused = job => `AI job paused: ${job}`;
26
+
27
+ // gh, as JSON or text; a test passes its own
28
+ const ghReal = args => {
29
+ const r = spawnSync('gh', args, { encoding: 'utf8', maxBuffer: 2 ** 26, timeout: 60000 });
30
+ if (r.status !== 0) return null;
31
+ try { return JSON.parse(r.stdout); } catch { return r.stdout.trim(); }
32
+ };
33
+ function context(env = process.env, gh = ghReal) {
34
+ let event = {};
35
+ try { event = JSON.parse(fs.readFileSync(env.GITHUB_EVENT_PATH, 'utf8')); } catch {}
36
+ return { event, gh, env, repo: env.GITHUB_REPOSITORY, workflow: path.basename(String(env.GITHUB_WORKFLOW_REF || '').split('@')[0]), now: Date.now(),
37
+ settings: fs.existsSync(path.join(ROOT, 'docs/amk/team-process.md')) };
38
+ }
39
+
40
+ function gate(job, c) {
41
+ const no = why => ({ go: false, why });
42
+ if (!c.settings) return no('docs/amk/team-process.md can\'t be read, so the job does nothing');
43
+ const open = c.gh(['issue', 'list', '--repo', c.repo, '--state', 'open', '--search', `"${paused(job)}" in:title`, '--json', 'title']);
44
+ if (!Array.isArray(open)) return no('its state can\'t be read (gh), so the job does nothing');
45
+ if (open.some(i => i.title === paused(job))) return no(`paused: close the issue "${paused(job)}" to resume it`);
46
+ // who started it, and on which branch and commit
47
+ const run = c.event.workflow_run;
48
+ const pr = c.event.pull_request || {};
49
+ const who = run ? (run.triggering_actor || run.actor || {}).login : (c.event.sender || {}).login;
50
+ const branch = run ? run.head_branch : (pr.head || {}).ref;
51
+ const sha = run ? run.head_sha : (pr.head || {}).sha;
52
+ if (!who) return no('nobody started it');
53
+ if (run && (run.head_repository || {}).full_name !== c.repo) return no('a change from another repository');
54
+ if (/\[bot\]$/.test(who) && !(BOTS[job] || []).includes(who)) return no(`started by ${who}, a bot`);
55
+ if (!/\[bot\]$/.test(who)) {
56
+ const p = c.gh(['api', `repos/${c.repo}/collaborators/${encodeURIComponent(who)}/permission`, '--jq', '.permission']);
57
+ if (!['admin', 'maintain', 'write'].includes(p)) return no(`${who} doesn't have write access to the repository`);
58
+ }
59
+ if (job === 'deps' && !(BOTS.deps || []).includes(who)) return no(`not a dependency update (started by ${who})`);
60
+ // the branch's latest commits: an AI fix's own commit doesn't start a job, and 3 in a row stop it
61
+ const commits = (sha && c.gh(['api', `repos/${c.repo}/commits?sha=${sha}&per_page=${IN_A_ROW + 1}`, '--jq', '[.[].commit.message]'])) || [];
62
+ if (commits.length && trailer('[a-z-]+').test(commits[0]) && job !== 'deps') return no('the latest commit is an AI job\'s fix');
63
+ let row = 0;
64
+ while (row < commits.length && trailer(job).test(commits[row])) row++;
65
+ if (row >= IN_A_ROW) return no(`${row} of its fix commits in a row on ${branch}: a person takes it from here`);
66
+ if (job === 'deps' && commits.some(m => m.includes(`(CI run ${run.id})`))) return no(`CI run ${run.id} was fixed once already`);
67
+ const since = new Date(c.now - 3600e3).toISOString();
68
+ const recent = c.gh(['run', 'list', '--repo', c.repo, '--workflow', c.workflow, '--created', `>=${since}`, '--json', 'databaseId', '--limit', '50']) || [];
69
+ if (recent.length > PER_HOUR) return no(`${recent.length} runs in the last hour: it waits`);
70
+ return { go: true, why: `started by ${who} on ${branch}` };
71
+ }
72
+
73
+ // after a run that went: a third failure in a row (runs that didn't go left out) pauses the job
74
+ function after(job, result, c) {
75
+ if (result === 'success') return { paused: false };
76
+ const runs = c.gh(['run', 'list', '--repo', c.repo, '--workflow', c.workflow, '--status', 'completed', '--json', 'databaseId', '--limit', '10']) || [];
77
+ const results = [];
78
+ for (const r of runs) {
79
+ if (String(r.databaseId) === String(c.env.GITHUB_RUN_ID)) continue;
80
+ const jobs = (c.gh(['run', 'view', String(r.databaseId), '--repo', c.repo, '--json', 'jobs']) || {}).jobs || [];
81
+ const j = jobs.find(x => x.name === job);
82
+ if (!j || j.conclusion === 'skipped') continue;
83
+ results.push(j.conclusion);
84
+ if (results.length >= IN_A_ROW - 1) break;
85
+ }
86
+ if (results.length < IN_A_ROW - 1 || results.some(r => r === 'success')) return { paused: false };
87
+ const body = `The AI job "${job}" failed ${IN_A_ROW} times in a row (the last one: ${result}), so it paused itself: it starts no run until this issue is closed. Look at its runs (the Actions tab, workflow ${c.workflow}), fix what fails, then close this issue to resume it.`;
88
+ c.gh(['issue', 'create', '--repo', c.repo, '--title', paused(job), '--body', body]);
89
+ return { paused: true };
90
+ }
91
+
92
+ module.exports = { gate, after, context, IN_A_ROW, PER_HOUR };
93
+
94
+ if (require.main === module) {
95
+ const [cmd, job, result] = process.argv.slice(2);
96
+ if (!['gate', 'after'].includes(cmd) || !job) { console.error('usage: node scripts/amk/ai-job.js gate <job> | after <job> <result>'); process.exit(2); }
97
+ const c = context();
98
+ if (cmd === 'gate') {
99
+ const g = gate(job, c);
100
+ console.error(`${job}: ${g.go ? 'goes' : 'does nothing'}: ${g.why}`);
101
+ console.log(`go=${g.go}`);
102
+ } else {
103
+ const a = after(job, result || 'failure', c);
104
+ console.log(a.paused ? `${job} paused itself after ${IN_A_ROW} failures in a row: an issue says so` : `${job}: ${result}`);
105
+ }
106
+ }