@codyswann/lisa 1.89.0 → 1.91.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.
@@ -0,0 +1,51 @@
1
+ import type { Migration, MigrationContext, MigrationResult } from "./migration.interface.js";
2
+ /**
3
+ * Migration: relocate project-specific exclusions from `audit.ignore.config.json`
4
+ * (Lisa-owned, copy-overwrite) into `audit.ignore.local.json` (project-owned,
5
+ * create-only) so they survive future Lisa postinstall runs.
6
+ *
7
+ * Without this migration, projects that add transient-dependency exclusions to
8
+ * the Lisa-owned config see them silently stripped every install, producing
9
+ * noisy diffs and tempting users to commit the regression.
10
+ *
11
+ * Mirrors the shape of `EnsureTsconfigLocalIncludesMigration`:
12
+ * - `beforeStrategies` snapshots the project's pre-strategy exclusions that
13
+ * are not in the Lisa template (i.e., project-specific additions).
14
+ * - `apply` (post-strategy) writes any snapshotted exclusions missing from
15
+ * `audit.ignore.local.json` into that file.
16
+ */
17
+ export declare class EnsureAuditIgnoreLocalExclusionsMigration implements Migration {
18
+ readonly name = "ensure-audit-ignore-local-exclusions";
19
+ readonly description = "Relocate project-specific audit exclusions from audit.ignore.config.json into audit.ignore.local.json";
20
+ private snapshot;
21
+ /**
22
+ * Snapshot project-specific exclusions that would otherwise be stripped by
23
+ * the copy-overwrite strategy. An exclusion is "project-specific" when its
24
+ * `id` is present in the project's audit.ignore.config.json but absent from
25
+ * the Lisa template for the same project type.
26
+ *
27
+ * When no valid Lisa template can be found for the detected project type the
28
+ * method returns without snapshotting anything. This is intentionally
29
+ * conservative: without a template we cannot distinguish Lisa-owned from
30
+ * project-specific exclusions, so migrating could copy Lisa-owned entries
31
+ * into audit.ignore.local.json.
32
+ * @param ctx - Migration context
33
+ */
34
+ beforeStrategies(ctx: MigrationContext): Promise<void>;
35
+ /**
36
+ * The migration applies when at least one snapshotted project-specific
37
+ * exclusion is missing from `audit.ignore.local.json`.
38
+ * @param ctx - Migration context
39
+ * @returns True when there is work to do
40
+ */
41
+ applies(ctx: MigrationContext): Promise<boolean>;
42
+ /**
43
+ * Merge snapshotted project-specific exclusions into audit.ignore.local.json,
44
+ * skipping any whose id is already present. Deduplicates within the snapshot
45
+ * itself so that duplicate source entries are only written once.
46
+ * @param ctx - Migration context
47
+ * @returns Result describing the action taken
48
+ */
49
+ apply(ctx: MigrationContext): Promise<MigrationResult>;
50
+ }
51
+ //# sourceMappingURL=ensure-audit-ignore-local-exclusions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensure-audit-ignore-local-exclusions.d.ts","sourceRoot":"","sources":["../../src/migrations/ensure-audit-ignore-local-exclusions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAChB,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAyFlC;;;;;;;;;;;;;;GAcG;AACH,qBAAa,yCAA0C,YAAW,SAAS;IACzE,QAAQ,CAAC,IAAI,0CAA0C;IACvD,QAAQ,CAAC,WAAW,2GACsF;IAE1G,OAAO,CAAC,QAAQ,CAA4B;IAE5C;;;;;;;;;;;;OAYG;IACG,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkC5D;;;;;OAKG;IACG,OAAO,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAatD;;;;;;OAMG;IACG,KAAK,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;CAkD7D"}
@@ -0,0 +1,192 @@
1
+ import * as path from "node:path";
2
+ import * as fse from "fs-extra";
3
+ import { readJson, readJsonOrNull, writeJson } from "../utils/json-utils.js";
4
+ const AUDIT_CONFIG = "audit.ignore.config.json";
5
+ const AUDIT_LOCAL = "audit.ignore.local.json";
6
+ /**
7
+ * Preferred order of project types for sourcing the Lisa audit template.
8
+ * First matching type wins.
9
+ */
10
+ const TEMPLATE_PRIORITY = [
11
+ "typescript",
12
+ "expo",
13
+ "cdk",
14
+ "nestjs",
15
+ "npm-package",
16
+ ];
17
+ /**
18
+ * Find the Lisa template audit.ignore.config.json path for the detected project.
19
+ * The Lisa-owned audit config lives under `<type>/copy-overwrite/audit.ignore.config.json`.
20
+ * Only returns a path when the file actually exists on disk; continues to the
21
+ * next priority type otherwise to avoid treating a missing template as an empty
22
+ * baseline.
23
+ * @param lisaDir - Lisa installation directory
24
+ * @param detectedTypes - Project types detected for the destination project
25
+ * @returns Template path, or null when no matching type ships one
26
+ */
27
+ async function findTemplateConfigPath(lisaDir, detectedTypes) {
28
+ for (const type of TEMPLATE_PRIORITY) {
29
+ if (!detectedTypes.includes(type)) {
30
+ continue;
31
+ }
32
+ const candidate = path.join(lisaDir, type, "copy-overwrite", AUDIT_CONFIG);
33
+ if (await fse.pathExists(candidate)) {
34
+ return candidate;
35
+ }
36
+ }
37
+ return null;
38
+ }
39
+ /**
40
+ * Extract the set of exclusion ids from a parsed audit ignore file.
41
+ * Entries missing an `id` are ignored (they cannot be de-duplicated safely).
42
+ * @param file - Parsed audit ignore file
43
+ * @returns Set of exclusion ids found in the file
44
+ */
45
+ function collectIds(file) {
46
+ if (!file || !Array.isArray(file.exclusions)) {
47
+ return new Set();
48
+ }
49
+ const ids = file.exclusions
50
+ .map(entry => entry.id)
51
+ .filter((id) => typeof id === "string" && id.length > 0);
52
+ return new Set(ids);
53
+ }
54
+ /**
55
+ * Read a project-owned local JSON file, distinguishing between a missing file
56
+ * (returns null) and a malformed file (throws). This prevents silent data loss
57
+ * when a file exists but contains invalid JSON.
58
+ * @param filePath - Path to the JSON file
59
+ * @returns Parsed content, or null when the file does not exist
60
+ */
61
+ async function readLocalJson(filePath) {
62
+ if (!(await fse.pathExists(filePath))) {
63
+ return null;
64
+ }
65
+ return readJson(filePath);
66
+ }
67
+ /**
68
+ * Migration: relocate project-specific exclusions from `audit.ignore.config.json`
69
+ * (Lisa-owned, copy-overwrite) into `audit.ignore.local.json` (project-owned,
70
+ * create-only) so they survive future Lisa postinstall runs.
71
+ *
72
+ * Without this migration, projects that add transient-dependency exclusions to
73
+ * the Lisa-owned config see them silently stripped every install, producing
74
+ * noisy diffs and tempting users to commit the regression.
75
+ *
76
+ * Mirrors the shape of `EnsureTsconfigLocalIncludesMigration`:
77
+ * - `beforeStrategies` snapshots the project's pre-strategy exclusions that
78
+ * are not in the Lisa template (i.e., project-specific additions).
79
+ * - `apply` (post-strategy) writes any snapshotted exclusions missing from
80
+ * `audit.ignore.local.json` into that file.
81
+ */
82
+ export class EnsureAuditIgnoreLocalExclusionsMigration {
83
+ name = "ensure-audit-ignore-local-exclusions";
84
+ description = "Relocate project-specific audit exclusions from audit.ignore.config.json into audit.ignore.local.json";
85
+ snapshot = [];
86
+ /**
87
+ * Snapshot project-specific exclusions that would otherwise be stripped by
88
+ * the copy-overwrite strategy. An exclusion is "project-specific" when its
89
+ * `id` is present in the project's audit.ignore.config.json but absent from
90
+ * the Lisa template for the same project type.
91
+ *
92
+ * When no valid Lisa template can be found for the detected project type the
93
+ * method returns without snapshotting anything. This is intentionally
94
+ * conservative: without a template we cannot distinguish Lisa-owned from
95
+ * project-specific exclusions, so migrating could copy Lisa-owned entries
96
+ * into audit.ignore.local.json.
97
+ * @param ctx - Migration context
98
+ */
99
+ async beforeStrategies(ctx) {
100
+ this.snapshot = [];
101
+ const projectConfigPath = path.join(ctx.projectDir, AUDIT_CONFIG);
102
+ const projectConfig = await readJsonOrNull(projectConfigPath);
103
+ if (!projectConfig || !Array.isArray(projectConfig.exclusions)) {
104
+ return;
105
+ }
106
+ const templatePath = await findTemplateConfigPath(ctx.lisaDir, ctx.detectedTypes);
107
+ const template = templatePath
108
+ ? await readJsonOrNull(templatePath)
109
+ : null;
110
+ if (!template) {
111
+ return;
112
+ }
113
+ const templateIds = collectIds(template);
114
+ const projectSpecific = projectConfig.exclusions.filter(entry => {
115
+ if (typeof entry.id !== "string" || entry.id.length === 0) {
116
+ return false;
117
+ }
118
+ return !templateIds.has(entry.id);
119
+ });
120
+ this.snapshot = projectSpecific;
121
+ }
122
+ /**
123
+ * The migration applies when at least one snapshotted project-specific
124
+ * exclusion is missing from `audit.ignore.local.json`.
125
+ * @param ctx - Migration context
126
+ * @returns True when there is work to do
127
+ */
128
+ async applies(ctx) {
129
+ if (this.snapshot.length === 0) {
130
+ return false;
131
+ }
132
+ const localPath = path.join(ctx.projectDir, AUDIT_LOCAL);
133
+ const local = await readLocalJson(localPath);
134
+ const localIds = collectIds(local);
135
+ return this.snapshot.some(entry => {
136
+ const id = entry.id;
137
+ return typeof id === "string" && !localIds.has(id);
138
+ });
139
+ }
140
+ /**
141
+ * Merge snapshotted project-specific exclusions into audit.ignore.local.json,
142
+ * skipping any whose id is already present. Deduplicates within the snapshot
143
+ * itself so that duplicate source entries are only written once.
144
+ * @param ctx - Migration context
145
+ * @returns Result describing the action taken
146
+ */
147
+ async apply(ctx) {
148
+ const localPath = path.join(ctx.projectDir, AUDIT_LOCAL);
149
+ const local = await readLocalJson(localPath);
150
+ const existing = Array.isArray(local?.exclusions) ? local.exclusions : [];
151
+ const localIds = collectIds(local);
152
+ const seenIds = new Set(localIds);
153
+ const additions = this.snapshot.filter(entry => {
154
+ const id = entry.id;
155
+ if (typeof id !== "string" || seenIds.has(id)) {
156
+ return false;
157
+ }
158
+ seenIds.add(id);
159
+ return true;
160
+ });
161
+ if (additions.length === 0) {
162
+ return { name: this.name, action: "noop" };
163
+ }
164
+ const merged = {
165
+ ...(local ?? {}),
166
+ exclusions: [...existing, ...additions],
167
+ };
168
+ const addedIds = additions
169
+ .map(entry => entry.id)
170
+ .filter((id) => typeof id === "string");
171
+ const message = `Relocated ${additions.length} exclusion(s) into audit.ignore.local.json (${addedIds.join(", ")})`;
172
+ if (ctx.dryRun) {
173
+ ctx.logger.dry(`Would relocate exclusions: ${addedIds.join(", ")}`);
174
+ return {
175
+ name: this.name,
176
+ action: "applied",
177
+ changedFiles: [AUDIT_LOCAL],
178
+ message,
179
+ };
180
+ }
181
+ await fse.ensureDir(path.dirname(localPath));
182
+ await writeJson(localPath, merged);
183
+ ctx.logger.success(message);
184
+ return {
185
+ name: this.name,
186
+ action: "applied",
187
+ changedFiles: [AUDIT_LOCAL],
188
+ message,
189
+ };
190
+ }
191
+ }
192
+ //# sourceMappingURL=ensure-audit-ignore-local-exclusions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensure-audit-ignore-local-exclusions.js","sourceRoot":"","sources":["../../src/migrations/ensure-audit-ignore-local-exclusions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAO7E,MAAM,YAAY,GAAG,0BAA0B,CAAC;AAChD,MAAM,WAAW,GAAG,yBAAyB,CAAC;AAkB9C;;;GAGG;AACH,MAAM,iBAAiB,GAA2B;IAChD,YAAY;IACZ,MAAM;IACN,KAAK;IACL,QAAQ;IACR,aAAa;CACd,CAAC;AAEF;;;;;;;;;GASG;AACH,KAAK,UAAU,sBAAsB,CACnC,OAAe,EACf,aAAqC;IAErC,KAAK,MAAM,IAAI,IAAI,iBAAiB,EAAE,CAAC;QACrC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAClC,SAAS;QACX,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;QAC3E,IAAI,MAAM,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YACpC,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAS,UAAU,CAAC,IAA4B;IAC9C,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC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EAAE,CAAC,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC;QACxD,MAAM,OAAO,GAAG,aAAa,SAAS,CAAC,MAAM,+CAA+C,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QAEnH,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;YACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,8BAA8B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACpE,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,MAAM,EAAE,SAAS;gBACjB,YAAY,EAAE,CAAC,WAAW,CAAC;gBAC3B,OAAO;aACR,CAAC;QACJ,CAAC;QAED,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;QAC7C,MAAM,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACnC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC5B,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,SAAS;YACjB,YAAY,EAAE,CAAC,WAAW,CAAC;YAC3B,OAAO;SACR,CAAC;IACJ,CAAC;CACF"}
@@ -1,5 +1,6 @@
1
1
  import type { Migration, MigrationContext, MigrationResult } from "./migration.interface.js";
2
2
  export type { Migration, MigrationAction, MigrationContext, MigrationResult, } from "./migration.interface.js";
3
+ export { EnsureAuditIgnoreLocalExclusionsMigration } from "./ensure-audit-ignore-local-exclusions.js";
3
4
  export { EnsureLisaPostinstallMigration } from "./ensure-lisa-postinstall.js";
4
5
  export { EnsureTsconfigLocalIncludesMigration } from "./ensure-tsconfig-local-includes.js";
5
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EACh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SAAS,SAAS,EAAE;IAI9B;;;;OAIG;IACG,mBAAmB,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ/D;;;;OAIG;IACG,MAAM,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;CAazE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,iBAAiB,CAE3D"}
@@ -1,5 +1,7 @@
1
+ import { EnsureAuditIgnoreLocalExclusionsMigration } from "./ensure-audit-ignore-local-exclusions.js";
1
2
  import { EnsureLisaPostinstallMigration } from "./ensure-lisa-postinstall.js";
2
3
  import { EnsureTsconfigLocalIncludesMigration } from "./ensure-tsconfig-local-includes.js";
4
+ export { EnsureAuditIgnoreLocalExclusionsMigration } from "./ensure-audit-ignore-local-exclusions.js";
3
5
  export { EnsureLisaPostinstallMigration } from "./ensure-lisa-postinstall.js";
4
6
  export { EnsureTsconfigLocalIncludesMigration } from "./ensure-tsconfig-local-includes.js";
5
7
  /**
@@ -14,6 +16,7 @@ export class MigrationRegistry {
14
16
  constructor(migrations) {
15
17
  this.migrations = migrations ?? [
16
18
  new EnsureTsconfigLocalIncludesMigration(),
19
+ new EnsureAuditIgnoreLocalExclusionsMigration(),
17
20
  new EnsureLisaPostinstallMigration(),
18
21
  ];
19
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,oCAAoC,EAAE,MAAM,qCAAqC,CAAC;AAa3F,OAAO,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,oCAAoC,EAAE,MAAM,qCAAqC,CAAC;AAE3F;;GAEG;AACH,MAAM,OAAO,iBAAiB;IACX,UAAU,CAAuB;IAElD;;;OAGG;IACH,YAAY,UAAiC;QAC3C,IAA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AAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC1C,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,IAAI,iBAAiB,EAAE,CAAC;AACjC,CAAC"}
package/package.json CHANGED
@@ -78,7 +78,7 @@
78
78
  "lodash": ">=4.18.1"
79
79
  },
80
80
  "name": "@codyswann/lisa",
81
- "version": "1.89.0",
81
+ "version": "1.91.0",
82
82
  "description": "Claude Code governance framework that applies guardrails, guidance, and automated enforcement to projects",
83
83
  "main": "dist/index.js",
84
84
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "1.89.0",
3
+ "version": "1.91.0",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -50,6 +50,7 @@ Git Discipline:
50
50
  - Prefix git push with `GIT_SSH_COMMAND="ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=5"`.
51
51
  - Never commit directly to an environment branch (dev, staging, main).
52
52
  - Never use --no-verify or attempt to bypass a git hook.
53
+ - Never bypass branch protection. Never use `--admin`, `--force`, or any other flag to merge a PR that has failing CI checks. If CI fails, fix it. If you cannot fix it, escalate to the human. There are zero exceptions. "Green in CI" is the definition of done — not "green locally." A PR is not complete until CI passes on the actual PR branch.
53
54
  - Never stash changes you cannot commit. Either fix whatever is preventing the commit or fail out and let the human know why.
54
55
  - Never add "BREAKING CHANGE" to a commit message unless there is actually a breaking change.
55
56
  - When opening a PR, watch the PR. If any status checks fail, fix them. For all bot code reviews, if the feedback is valid, implement it and push the change to the PR. Then resolve the feedback. If the feedback is not valid, reply to the feedback explaining why it's not valid and then resolve the feedback. Do this in a loop until the PR is able to be merged and then merge it.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "1.89.0",
3
+ "version": "1.91.0",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "1.89.0",
3
+ "version": "1.91.0",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -0,0 +1,140 @@
1
+ ---
2
+ name: playwright-ci-debugging
3
+ description: Debug Playwright E2E tests that pass locally but fail in CI (or vice versa) in Expo web projects. Covers local reproduction, network interception, CI environment discovery, commit SHA verification, and robust interaction patterns that eliminate flake. Use this skill when a Playwright test is failing in CI, a test is flaky, a PR is blocked by E2E checks, or you need to investigate CI-specific test behavior. Trigger on mentions of CI failure, failing Playwright test, flaky E2E test, or debugging E2E in CI.
4
+ ---
5
+
6
+ # Debugging Playwright E2E Failures in CI
7
+
8
+ The authoring-side rules (selectors, testID forwarding, naming) are in the `playwright-selectors` skill. This skill is for the other half of the job: when a test fails in CI and you need to find out why.
9
+
10
+ ## Debugging Order
11
+
12
+ When a Playwright E2E test fails in CI, follow this exact order.
13
+
14
+ ### 1. Reproduce locally first — before anything else
15
+
16
+ Start the project's dev server, then run the failing test in isolation:
17
+
18
+ ```bash
19
+ # Start the dev server (discover the script from package.json — commonly `start`, `dev`, `start:dev`, or `web`)
20
+ <pkg-manager> run <dev-script>
21
+
22
+ # In another terminal, run the exact failing test with no retries
23
+ BASE_URL=http://localhost:8081/ npx playwright test <file> --grep "<test name>" --retries=0
24
+ ```
25
+
26
+ `--retries=0` is critical — retries mask flake. `--grep` isolates the single failing test so you're not waiting on a full suite.
27
+
28
+ **Do NOT read source code, CI logs, or theorize until you can reproduce locally.** Most CI failures reproduce locally if you run the same test against the same served build. Guessing from logs is slow and usually wrong.
29
+
30
+ ### 2. Intercept the network request
31
+
32
+ When a test involves an API call, set up a Playwright response listener and inspect the status code and response body. A 400/500 response tells you everything.
33
+
34
+ ```typescript
35
+ page.on("response", async (response) => {
36
+ if (response.url().includes("/api/")) {
37
+ console.log(response.status(), response.url(), await response.text());
38
+ }
39
+ });
40
+ ```
41
+
42
+ UI failures are often downstream of a failed API call. The network log is cheaper evidence than the DOM.
43
+
44
+ ### 3. If it doesn't reproduce locally, understand the CI environment first
45
+
46
+ CI runs against a different environment than your laptop. Before changing anything:
47
+
48
+ - Find the CI job that runs Playwright (usually `.github/workflows/*.yml`).
49
+ - Identify which `.env.*` file it loads — this varies by target branch (e.g., dev → `.env.development`, staging → `.env.staging`).
50
+ - Note that CI typically builds a static web bundle (`expo export --platform web`) then serves it on `localhost:8081` via `serve dist`. It is NOT hitting your dev server. Timing, bundling, and env vars all differ.
51
+ - Reproduce the CI setup locally: build the static bundle, serve it the same way, then run the test. If it now fails locally, you've isolated an env/build difference.
52
+
53
+ ### 4. Verify commit SHA before trusting CI results
54
+
55
+ After pushing, confirm the CI run's `headSha` matches your latest commit:
56
+
57
+ ```bash
58
+ gh run list --branch "$(git branch --show-current)" --limit 1 --json headSha,status,conclusion
59
+ git rev-parse HEAD
60
+ ```
61
+
62
+ Bots (review-response, auto-update, dependabot) can push commits between your push and the CI run, overwriting your changes. A green check on a stale SHA tells you nothing about your fix.
63
+
64
+ ## Patterns That Eliminate Flake
65
+
66
+ ### Never use fixed waits before interactions
67
+
68
+ `waitForTimeout()` as the sole wait before a click is a silent failure waiting to happen — animations and rendering take variable time, especially on slower CI runners. Poll for the expected state, then act.
69
+
70
+ ```typescript
71
+ // BAD — fixed wait; click silently fails if element not yet visible
72
+ await clickVisibleText(page, "Translate");
73
+ await page.waitForTimeout(1000);
74
+ await clickVisibleText(page, "Spanish");
75
+
76
+ // GOOD — poll for visibility, then click
77
+ await clickVisibleText(page, "Translate");
78
+ await expect
79
+ .poll(() => hasVisibleText(page, "Spanish"), { timeout: TIMEOUT.expect })
80
+ .toBe(true);
81
+ await clickVisibleText(page, "Spanish");
82
+ ```
83
+
84
+ ### Never silently swallow click return values
85
+
86
+ Any helper that can return `false` on a missed click (e.g., `clickVisibleText`) should either have its return value asserted or be preceded by a visibility poll. A click that silently returns `false` is a hidden test bug — the test proceeds as if the click happened and fails downstream with a confusing error.
87
+
88
+ ```typescript
89
+ // BAD — return value ignored; test continues on failed click
90
+ await clickVisibleText(page, "Submit");
91
+
92
+ // GOOD — assert the click happened
93
+ expect(await clickVisibleText(page, "Submit")).toBe(true);
94
+
95
+ // GOOD — precede with visibility poll
96
+ await expect
97
+ .poll(() => hasVisibleText(page, "Submit"), { timeout: TIMEOUT.expect })
98
+ .toBe(true);
99
+ await clickVisibleText(page, "Submit");
100
+ ```
101
+
102
+ ### E2E tests must not depend on external API success
103
+
104
+ Any test that calls an external service (AWS Bedrock, third-party APIs, rate-limited providers) must handle the failure case. Tests should verify UI behavior, not external service uptime. If an external call might fail, the test must accept both outcomes or skip the dependent assertion.
105
+
106
+ ```typescript
107
+ // BAD — assumes translation always succeeds
108
+ await expect
109
+ .poll(() => hasVisibleText(page, "Show Original"), { timeout: TIMEOUT.expect })
110
+ .toBe(true);
111
+
112
+ // GOOD — handle both success and failure
113
+ await expect
114
+ .poll(
115
+ async () =>
116
+ (await hasVisibleText(page, "Show Original")) ||
117
+ (await hasVisibleText(page, "Translate")),
118
+ { timeout: TIMEOUT.expect }
119
+ )
120
+ .toBe(true);
121
+
122
+ const translated = await hasVisibleText(page, "Show Original");
123
+ if (!translated) return; // External API failed; skip downstream assertions
124
+ ```
125
+
126
+ The alternative — mocking the external call — is a valid approach when the goal is to test the UI's handling of a successful response. Pick one strategy per test and commit to it.
127
+
128
+ ### E2E assertions must not depend on specific test data
129
+
130
+ Do not assert specific text (e.g., "No lists detected") when the test user's data state varies across environments. If a zero-row state could have different empty-state messages depending on the user's data, either check for multiple possible states or skip the assertion entirely.
131
+
132
+ See the `playwright-selectors` skill's "Data independence" section for authoring patterns that avoid this class of bug in the first place.
133
+
134
+ ## Escalation
135
+
136
+ If you've worked through steps 1–4 and still cannot explain the failure:
137
+
138
+ - Do NOT disable, skip, or `.fixme` the test to unblock the PR.
139
+ - Do NOT use `--admin` or force-merge to bypass the check.
140
+ - Escalate to a human with: the failing test name, your local reproduction attempt, the network trace, and the commit SHA verification. A real flake that cannot be root-caused is a legitimate reason to pause; it is never a reason to merge red.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-nestjs",
3
- "version": "1.89.0",
3
+ "version": "1.91.0",
4
4
  "description": "NestJS-specific skills (GraphQL, TypeORM) and hooks (migration write-protection)",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "1.89.0",
3
+ "version": "1.91.0",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "1.89.0",
3
+ "version": "1.91.0",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -50,6 +50,7 @@ Git Discipline:
50
50
  - Prefix git push with `GIT_SSH_COMMAND="ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=5"`.
51
51
  - Never commit directly to an environment branch (dev, staging, main).
52
52
  - Never use --no-verify or attempt to bypass a git hook.
53
+ - Never bypass branch protection. Never use `--admin`, `--force`, or any other flag to merge a PR that has failing CI checks. If CI fails, fix it. If you cannot fix it, escalate to the human. There are zero exceptions. "Green in CI" is the definition of done — not "green locally." A PR is not complete until CI passes on the actual PR branch.
53
54
  - Never stash changes you cannot commit. Either fix whatever is preventing the commit or fail out and let the human know why.
54
55
  - Never add "BREAKING CHANGE" to a commit message unless there is actually a breaking change.
55
56
  - When opening a PR, watch the PR. If any status checks fail, fix them. For all bot code reviews, if the feedback is valid, implement it and push the change to the PR. Then resolve the feedback. If the feedback is not valid, reply to the feedback explaining why it's not valid and then resolve the feedback. Do this in a loop until the PR is able to be merged and then merge it.
@@ -0,0 +1,140 @@
1
+ ---
2
+ name: playwright-ci-debugging
3
+ description: Debug Playwright E2E tests that pass locally but fail in CI (or vice versa) in Expo web projects. Covers local reproduction, network interception, CI environment discovery, commit SHA verification, and robust interaction patterns that eliminate flake. Use this skill when a Playwright test is failing in CI, a test is flaky, a PR is blocked by E2E checks, or you need to investigate CI-specific test behavior. Trigger on mentions of CI failure, failing Playwright test, flaky E2E test, or debugging E2E in CI.
4
+ ---
5
+
6
+ # Debugging Playwright E2E Failures in CI
7
+
8
+ The authoring-side rules (selectors, testID forwarding, naming) are in the `playwright-selectors` skill. This skill is for the other half of the job: when a test fails in CI and you need to find out why.
9
+
10
+ ## Debugging Order
11
+
12
+ When a Playwright E2E test fails in CI, follow this exact order.
13
+
14
+ ### 1. Reproduce locally first — before anything else
15
+
16
+ Start the project's dev server, then run the failing test in isolation:
17
+
18
+ ```bash
19
+ # Start the dev server (discover the script from package.json — commonly `start`, `dev`, `start:dev`, or `web`)
20
+ <pkg-manager> run <dev-script>
21
+
22
+ # In another terminal, run the exact failing test with no retries
23
+ BASE_URL=http://localhost:8081/ npx playwright test <file> --grep "<test name>" --retries=0
24
+ ```
25
+
26
+ `--retries=0` is critical — retries mask flake. `--grep` isolates the single failing test so you're not waiting on a full suite.
27
+
28
+ **Do NOT read source code, CI logs, or theorize until you can reproduce locally.** Most CI failures reproduce locally if you run the same test against the same served build. Guessing from logs is slow and usually wrong.
29
+
30
+ ### 2. Intercept the network request
31
+
32
+ When a test involves an API call, set up a Playwright response listener and inspect the status code and response body. A 400/500 response tells you everything.
33
+
34
+ ```typescript
35
+ page.on("response", async (response) => {
36
+ if (response.url().includes("/api/")) {
37
+ console.log(response.status(), response.url(), await response.text());
38
+ }
39
+ });
40
+ ```
41
+
42
+ UI failures are often downstream of a failed API call. The network log is cheaper evidence than the DOM.
43
+
44
+ ### 3. If it doesn't reproduce locally, understand the CI environment first
45
+
46
+ CI runs against a different environment than your laptop. Before changing anything:
47
+
48
+ - Find the CI job that runs Playwright (usually `.github/workflows/*.yml`).
49
+ - Identify which `.env.*` file it loads — this varies by target branch (e.g., dev → `.env.development`, staging → `.env.staging`).
50
+ - Note that CI typically builds a static web bundle (`expo export --platform web`) then serves it on `localhost:8081` via `serve dist`. It is NOT hitting your dev server. Timing, bundling, and env vars all differ.
51
+ - Reproduce the CI setup locally: build the static bundle, serve it the same way, then run the test. If it now fails locally, you've isolated an env/build difference.
52
+
53
+ ### 4. Verify commit SHA before trusting CI results
54
+
55
+ After pushing, confirm the CI run's `headSha` matches your latest commit:
56
+
57
+ ```bash
58
+ gh run list --branch "$(git branch --show-current)" --limit 1 --json headSha,status,conclusion
59
+ git rev-parse HEAD
60
+ ```
61
+
62
+ Bots (review-response, auto-update, dependabot) can push commits between your push and the CI run, overwriting your changes. A green check on a stale SHA tells you nothing about your fix.
63
+
64
+ ## Patterns That Eliminate Flake
65
+
66
+ ### Never use fixed waits before interactions
67
+
68
+ `waitForTimeout()` as the sole wait before a click is a silent failure waiting to happen — animations and rendering take variable time, especially on slower CI runners. Poll for the expected state, then act.
69
+
70
+ ```typescript
71
+ // BAD — fixed wait; click silently fails if element not yet visible
72
+ await clickVisibleText(page, "Translate");
73
+ await page.waitForTimeout(1000);
74
+ await clickVisibleText(page, "Spanish");
75
+
76
+ // GOOD — poll for visibility, then click
77
+ await clickVisibleText(page, "Translate");
78
+ await expect
79
+ .poll(() => hasVisibleText(page, "Spanish"), { timeout: TIMEOUT.expect })
80
+ .toBe(true);
81
+ await clickVisibleText(page, "Spanish");
82
+ ```
83
+
84
+ ### Never silently swallow click return values
85
+
86
+ Any helper that can return `false` on a missed click (e.g., `clickVisibleText`) should either have its return value asserted or be preceded by a visibility poll. A click that silently returns `false` is a hidden test bug — the test proceeds as if the click happened and fails downstream with a confusing error.
87
+
88
+ ```typescript
89
+ // BAD — return value ignored; test continues on failed click
90
+ await clickVisibleText(page, "Submit");
91
+
92
+ // GOOD — assert the click happened
93
+ expect(await clickVisibleText(page, "Submit")).toBe(true);
94
+
95
+ // GOOD — precede with visibility poll
96
+ await expect
97
+ .poll(() => hasVisibleText(page, "Submit"), { timeout: TIMEOUT.expect })
98
+ .toBe(true);
99
+ await clickVisibleText(page, "Submit");
100
+ ```
101
+
102
+ ### E2E tests must not depend on external API success
103
+
104
+ Any test that calls an external service (AWS Bedrock, third-party APIs, rate-limited providers) must handle the failure case. Tests should verify UI behavior, not external service uptime. If an external call might fail, the test must accept both outcomes or skip the dependent assertion.
105
+
106
+ ```typescript
107
+ // BAD — assumes translation always succeeds
108
+ await expect
109
+ .poll(() => hasVisibleText(page, "Show Original"), { timeout: TIMEOUT.expect })
110
+ .toBe(true);
111
+
112
+ // GOOD — handle both success and failure
113
+ await expect
114
+ .poll(
115
+ async () =>
116
+ (await hasVisibleText(page, "Show Original")) ||
117
+ (await hasVisibleText(page, "Translate")),
118
+ { timeout: TIMEOUT.expect }
119
+ )
120
+ .toBe(true);
121
+
122
+ const translated = await hasVisibleText(page, "Show Original");
123
+ if (!translated) return; // External API failed; skip downstream assertions
124
+ ```
125
+
126
+ The alternative — mocking the external call — is a valid approach when the goal is to test the UI's handling of a successful response. Pick one strategy per test and commit to it.
127
+
128
+ ### E2E assertions must not depend on specific test data
129
+
130
+ Do not assert specific text (e.g., "No lists detected") when the test user's data state varies across environments. If a zero-row state could have different empty-state messages depending on the user's data, either check for multiple possible states or skip the assertion entirely.
131
+
132
+ See the `playwright-selectors` skill's "Data independence" section for authoring patterns that avoid this class of bug in the first place.
133
+
134
+ ## Escalation
135
+
136
+ If you've worked through steps 1–4 and still cannot explain the failure:
137
+
138
+ - Do NOT disable, skip, or `.fixme` the test to unblock the PR.
139
+ - Do NOT use `--admin` or force-merge to bypass the check.
140
+ - Escalate to a human with: the failing test name, your local reproduction attempt, the network trace, and the commit SHA verification. A real flake that cannot be root-caused is a legitimate reason to pause; it is never a reason to merge red.