@webpieces/pr-gate 0.3.354 → 0.3.356

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 (70) hide show
  1. package/package.json +7 -2
  2. package/src/dashboard/dashboard.d.ts +12 -3
  3. package/src/dashboard/dashboard.js +136 -129
  4. package/src/dashboard/dashboard.js.map +1 -1
  5. package/src/index.d.ts +2 -1
  6. package/src/index.js +4 -4
  7. package/src/index.js.map +1 -1
  8. package/src/scripts/commands/finish-update-command.d.ts +10 -0
  9. package/src/scripts/commands/finish-update-command.js +51 -0
  10. package/src/scripts/commands/finish-update-command.js.map +1 -0
  11. package/src/scripts/commands/finish-upsert-pr-command.d.ts +22 -0
  12. package/src/scripts/commands/finish-upsert-pr-command.js +131 -0
  13. package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -0
  14. package/src/scripts/commands/start-update-command.d.ts +9 -0
  15. package/src/scripts/commands/start-update-command.js +67 -0
  16. package/src/scripts/commands/start-update-command.js.map +1 -0
  17. package/src/scripts/commands/start-upsert-pr-command.d.ts +15 -0
  18. package/src/scripts/commands/start-upsert-pr-command.js +73 -0
  19. package/src/scripts/commands/start-upsert-pr-command.js.map +1 -0
  20. package/src/scripts/git-finishUpsertPr.d.ts +1 -1
  21. package/src/scripts/git-finishUpsertPr.js +11 -109
  22. package/src/scripts/git-finishUpsertPr.js.map +1 -1
  23. package/src/scripts/git-gatherInfo.d.ts +15 -1
  24. package/src/scripts/git-gatherInfo.js +79 -61
  25. package/src/scripts/git-gatherInfo.js.map +1 -1
  26. package/src/scripts/pr-gate-app.d.ts +25 -0
  27. package/src/scripts/pr-gate-app.js +56 -0
  28. package/src/scripts/pr-gate-app.js.map +1 -0
  29. package/src/scripts/workflow/branch-naming.d.ts +11 -8
  30. package/src/scripts/workflow/branch-naming.js +30 -21
  31. package/src/scripts/workflow/branch-naming.js.map +1 -1
  32. package/src/scripts/workflow/build-affected.d.ts +21 -30
  33. package/src/scripts/workflow/build-affected.js +57 -63
  34. package/src/scripts/workflow/build-affected.js.map +1 -1
  35. package/src/scripts/workflow/cleanTmp.d.ts +6 -1
  36. package/src/scripts/workflow/cleanTmp.js +83 -78
  37. package/src/scripts/workflow/cleanTmp.js.map +1 -1
  38. package/src/scripts/workflow/git-exec.d.ts +32 -28
  39. package/src/scripts/workflow/git-exec.js +92 -85
  40. package/src/scripts/workflow/git-exec.js.map +1 -1
  41. package/src/scripts/workflow/git-findForkPoint.d.ts +12 -3
  42. package/src/scripts/workflow/git-findForkPoint.js +116 -107
  43. package/src/scripts/workflow/git-findForkPoint.js.map +1 -1
  44. package/src/scripts/workflow/git-readAiBranchName.d.ts +7 -2
  45. package/src/scripts/workflow/git-readAiBranchName.js +24 -15
  46. package/src/scripts/workflow/git-readAiBranchName.js.map +1 -1
  47. package/src/scripts/workflow/merge-end.d.ts +21 -6
  48. package/src/scripts/workflow/merge-end.js +147 -133
  49. package/src/scripts/workflow/merge-end.js.map +1 -1
  50. package/src/scripts/workflow/merge-start.d.ts +22 -1
  51. package/src/scripts/workflow/merge-start.js +180 -186
  52. package/src/scripts/workflow/merge-start.js.map +1 -1
  53. package/src/scripts/workflow/merge-state.d.ts +26 -23
  54. package/src/scripts/workflow/merge-state.js +131 -137
  55. package/src/scripts/workflow/merge-state.js.map +1 -1
  56. package/src/scripts/workflow/open-pr-check.d.ts +7 -1
  57. package/src/scripts/workflow/open-pr-check.js +34 -23
  58. package/src/scripts/workflow/open-pr-check.js.map +1 -1
  59. package/src/scripts/workflow/run-update.d.ts +13 -1
  60. package/src/scripts/workflow/run-update.js +59 -28
  61. package/src/scripts/workflow/run-update.js.map +1 -1
  62. package/src/scripts/wp-finish-update.d.ts +1 -1
  63. package/src/scripts/wp-finish-update.js +11 -30
  64. package/src/scripts/wp-finish-update.js.map +1 -1
  65. package/src/scripts/wp-start-update.d.ts +1 -2
  66. package/src/scripts/wp-start-update.js +11 -51
  67. package/src/scripts/wp-start-update.js.map +1 -1
  68. package/src/scripts/wp-start-upsert-pr.d.ts +1 -1
  69. package/src/scripts/wp-start-upsert-pr.js +11 -47
  70. package/src/scripts/wp-start-upsert-pr.js.map +1 -1
@@ -1,38 +1,69 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runUpdateFromMain = runUpdateFromMain;
3
+ exports.RunUpdate = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const rules_config_1 = require("@webpieces/rules-config");
6
+ const core_context_1 = require("@webpieces/core-context");
7
+ const inversify_1 = require("inversify");
5
8
  const git_readAiBranchName_1 = require("./git-readAiBranchName");
6
9
  const merge_state_1 = require("./merge-state");
7
10
  const merge_start_1 = require("./merge-start");
8
11
  const merge_end_1 = require("./merge-end");
9
- async function runUpdateFromMain(repoRoot, verb, finishCommand) {
10
- (0, rules_config_1.logBranchMutation)(repoRoot, new rules_config_1.BranchMutationEvent(verb, 'START'));
11
- const outcome = await runUpdate(repoRoot, verb, finishCommand);
12
- const end = new rules_config_1.BranchMutationEvent(verb, 'END');
13
- end.outcome = outcome;
14
- (0, rules_config_1.logBranchMutation)(repoRoot, end);
15
- return outcome;
16
- }
17
- async function runUpdate(repoRoot, verb, finishCommand) {
18
- const home = (0, merge_state_1.mergeDirFor)(repoRoot, (0, git_readAiBranchName_1.getFeatureName)());
19
- // Resume path: an in-progress merge is the `merge-<n>/` run dir that holds a marker.
20
- const activeDir = (0, merge_state_1.findActiveMergeRunDir)(home);
21
- if (activeDir) {
22
- const existing = (0, merge_state_1.readMergeMarker)(activeDir);
23
- if (existing === null || !existing.validated)
24
- return 'unvalidatedResume';
25
- // Already validated just finalize the branch swap (reads THIS run dir's marker).
26
- await (0, merge_end_1.mergeEnd)(repoRoot, verb, activeDir, new merge_start_1.MergeContext(existing.currentBranch, existing.squashBranch, existing.backupBranch, existing.prNumber), null);
27
- return 'finalized';
12
+ // The shared "sync this feature branch from main" engine — a thin composition of the two lifecycle
13
+ // primitives (merge-START brings main in, merge-END finalizes). INTERNAL, not a bin: `wp-start-update`
14
+ // (standalone) and `wp-start-upsert-pr` (PR flow) both call it. It NEVER creates a PR and NEVER
15
+ // process.exits; it RETURNS an outcome so each caller prints the handoff that fits its context.
16
+ let RunUpdate = class RunUpdate {
17
+ aiBranchName;
18
+ mergeState;
19
+ mergeStart;
20
+ mergeEnd;
21
+ constructor(aiBranchName, mergeState, mergeStart, mergeEnd) {
22
+ this.aiBranchName = aiBranchName;
23
+ this.mergeState = mergeState;
24
+ this.mergeStart = mergeStart;
25
+ this.mergeEnd = mergeEnd;
26
+ }
27
+ // `finishCommand` is the command the AI is told to run after resolving conflicts (standalone passes
28
+ // `wp-finish-update`, PR flow passes `wp-finish-upsert-pr`). `verb` is the invoking bin, threaded so
29
+ // every branch mutation is recorded in `.webpieces/hooks/branch-mutations.log`.
30
+ async runUpdateFromMain(repoRoot, verb, finishCommand) {
31
+ (0, rules_config_1.logBranchMutation)(repoRoot, new rules_config_1.BranchMutationEvent(verb, 'START'));
32
+ const outcome = await this.runUpdate(repoRoot, verb, finishCommand);
33
+ const end = new rules_config_1.BranchMutationEvent(verb, 'END');
34
+ end.outcome = outcome;
35
+ (0, rules_config_1.logBranchMutation)(repoRoot, end);
36
+ return outcome;
28
37
  }
29
- // Fresh update: mergeStart picks the slot number, creates its own `merge-<n>/` run dir, and
30
- // returns that path for merge-END to finalize against.
31
- const result = await (0, merge_start_1.mergeStart)(repoRoot, verb, home, finishCommand);
32
- if (result.status === 'conflict' || result.context === null) {
33
- return 'conflict';
38
+ async runUpdate(repoRoot, verb, finishCommand) {
39
+ const home = this.mergeState.mergeDirFor(repoRoot, this.aiBranchName.getFeatureName());
40
+ // Resume path: an in-progress merge is the `merge-<n>/` run dir that holds a marker.
41
+ const activeDir = this.mergeState.findActiveMergeRunDir(home);
42
+ if (activeDir) {
43
+ const existing = this.mergeState.readMergeMarker(activeDir);
44
+ if (existing === null || !existing.validated)
45
+ return 'unvalidatedResume';
46
+ // Already validated → just finalize the branch swap (reads THIS run dir's marker).
47
+ await this.mergeEnd.mergeEnd(repoRoot, verb, activeDir, new merge_start_1.MergeContext(existing.currentBranch, existing.squashBranch, existing.backupBranch, existing.prNumber), null);
48
+ return 'finalized';
49
+ }
50
+ // Fresh update: mergeStart picks the slot number, creates its own `merge-<n>/` run dir, and
51
+ // returns that path for merge-END to finalize against.
52
+ const result = await this.mergeStart.mergeStart(repoRoot, verb, home, finishCommand);
53
+ if (result.status === 'conflict' || result.context === null) {
54
+ return 'conflict';
55
+ }
56
+ await this.mergeEnd.mergeEnd(repoRoot, verb, result.runDir, result.context, null);
57
+ return 'finalized';
34
58
  }
35
- await (0, merge_end_1.mergeEnd)(repoRoot, verb, result.runDir, result.context, null);
36
- return 'finalized';
37
- }
59
+ };
60
+ exports.RunUpdate = RunUpdate;
61
+ exports.RunUpdate = RunUpdate = tslib_1.__decorate([
62
+ (0, core_context_1.provideSingleton)(),
63
+ (0, inversify_1.injectable)(),
64
+ tslib_1.__metadata("design:paramtypes", [git_readAiBranchName_1.AiBranchName,
65
+ merge_state_1.MergeState,
66
+ merge_start_1.MergeStart,
67
+ merge_end_1.MergeEnd])
68
+ ], RunUpdate);
38
69
  //# sourceMappingURL=run-update.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-update.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/run-update.ts"],"names":[],"mappings":";;AAqBA,8CAOC;AA5BD,0DAA+F;AAC/F,iEAAwD;AACxD,+CAAoF;AACpF,+CAAyD;AACzD,2CAAuC;AAiBhC,KAAK,UAAU,iBAAiB,CAAC,QAAgB,EAAE,IAAkB,EAAE,aAAqB;IAC/F,IAAA,gCAAiB,EAAC,QAAQ,EAAE,IAAI,kCAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACpE,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;IAC/D,MAAM,GAAG,GAAG,IAAI,kCAAmB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ACpE,OAAO,WAAW,CAAC;AACvB,CAAC","sourcesContent":["import { MutationVerb, BranchMutationEvent, logBranchMutation } from '@webpieces/rules-config';\nimport { getFeatureName } from './git-readAiBranchName';\nimport { mergeDirFor, readMergeMarker, findActiveMergeRunDir } from './merge-state';\nimport { mergeStart, MergeContext } from './merge-start';\nimport { mergeEnd } from './merge-end';\n\n// The shared \"sync this feature branch from main\" engine — a thin composition of the two lifecycle\n// primitives (merge-START brings main in, merge-END finalizes). It is an INTERNAL function, not a\n// bin: `wp-start-update` (standalone) and `wp-start-upsert-pr` (PR flow) both call it. It NEVER\n// creates a PR and unlike the old wp-git-update bin — it does NOT process.exit; it RETURNS an\n// outcome so each caller can print the handoff that fits its context.\n//\n// `finishCommand` is the command the AI is told to run after resolving conflicts the standalone\n// caller passes `wp-finish-update`, the PR flow passes `wp-finish-upsert-pr`.\n//\n// `verb` is the invoking bin, threaded through purely so every branch mutation (backup, checkout,\n// pull, squash, rename) is recorded in `.webpieces/hooks/branch-mutations.log` under the command the\n// user actually ran — the audit trail that used to exist only in `git reflog`.\n\nexport type UpdateOutcome = 'finalized' | 'conflict' | 'unvalidatedResume';\n\nexport async function runUpdateFromMain(repoRoot: string, verb: MutationVerb, finishCommand: string): Promise<UpdateOutcome> {\n logBranchMutation(repoRoot, new BranchMutationEvent(verb, 'START'));\n const outcome = await runUpdate(repoRoot, verb, finishCommand);\n const end = new BranchMutationEvent(verb, 'END');\n end.outcome = outcome;\n logBranchMutation(repoRoot, end);\n return outcome;\n}\n\nasync function runUpdate(repoRoot: string, verb: MutationVerb, finishCommand: string): Promise<UpdateOutcome> {\n const home = mergeDirFor(repoRoot, getFeatureName());\n\n // Resume path: an in-progress merge is the `merge-<n>/` run dir that holds a marker.\n const activeDir = findActiveMergeRunDir(home);\n if (activeDir) {\n const existing = readMergeMarker(activeDir);\n if (existing === null || !existing.validated) return 'unvalidatedResume';\n // Already validated → just finalize the branch swap (reads THIS run dir's marker).\n await mergeEnd(\n repoRoot, verb, activeDir,\n new MergeContext(existing.currentBranch, existing.squashBranch, existing.backupBranch, existing.prNumber),\n null,\n );\n return 'finalized';\n }\n\n // Fresh update: mergeStart picks the slot number, creates its own `merge-<n>/` run dir, and\n // returns that path for merge-END to finalize against.\n const result = await mergeStart(repoRoot, verb, home, finishCommand);\n if (result.status === 'conflict' || result.context === null) {\n return 'conflict';\n }\n await mergeEnd(repoRoot, verb, result.runDir, result.context, null);\n return 'finalized';\n}\n"]}
1
+ {"version":3,"file":"run-update.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/run-update.ts"],"names":[],"mappings":";;;;AAAA,0DAA+F;AAC/F,0DAA2D;AAC3D,yCAAuC;AACvC,iEAAsD;AACtD,+CAA2C;AAC3C,+CAAyD;AACzD,2CAAuC;AAIvC,mGAAmG;AACnG,uGAAuG;AACvG,gGAAgG;AAChG,gGAAgG;AAGzF,IAAM,SAAS,GAAf,MAAM,SAAS;IAEG;IACA;IACA;IACA;IAJrB,YACqB,YAA0B,EAC1B,UAAsB,EACtB,UAAsB,EACtB,QAAkB;QAHlB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,eAAU,GAAV,UAAU,CAAY;QACtB,eAAU,GAAV,UAAU,CAAY;QACtB,aAAQ,GAAR,QAAQ,CAAU;IACpC,CAAC;IAEJ,oGAAoG;IACpG,qGAAqG;IACrG,gFAAgF;IAChF,KAAK,CAAC,iBAAiB,CAAC,QAAgB,EAAE,IAAkB,EAAE,aAAqB;QAC/E,IAAA,gCAAiB,EAAC,QAAQ,EAAE,IAAI,kCAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;QACpE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;QACpE,MAAM,GAAG,GAAG,IAAI,kCAAmB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACjD,GAAG,CAAC,OAAO,GAAG,OAAO,CAA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,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAClF,OAAO,WAAW,CAAC;IACvB,CAAC;CACJ,CAAA;AA9CY,8BAAS;oBAAT,SAAS;IAFrB,IAAA,+BAAgB,GAAE;IAClB,IAAA,sBAAU,GAAE;6CAG0B,mCAAY;QACd,wBAAU;QACV,wBAAU;QACZ,oBAAQ;GAL9B,SAAS,CA8CrB","sourcesContent":["import { MutationVerb, BranchMutationEvent, logBranchMutation } from '@webpieces/rules-config';\nimport { provideSingleton } from '@webpieces/core-context';\nimport { injectable } from 'inversify';\nimport { AiBranchName } from './git-readAiBranchName';\nimport { MergeState } from './merge-state';\nimport { MergeStart, MergeContext } from './merge-start';\nimport { MergeEnd } from './merge-end';\n\nexport type UpdateOutcome = 'finalized' | 'conflict' | 'unvalidatedResume';\n\n// The shared \"sync this feature branch from main\" engine — a thin composition of the two lifecycle\n// primitives (merge-START brings main in, merge-END finalizes). INTERNAL, not a bin: `wp-start-update`\n// (standalone) and `wp-start-upsert-pr` (PR flow) both call it. It NEVER creates a PR and NEVER\n// process.exits; it RETURNS an outcome so each caller prints the handoff that fits its context.\n@provideSingleton()\n@injectable()\nexport class RunUpdate {\n constructor(\n private readonly aiBranchName: AiBranchName,\n private readonly mergeState: MergeState,\n private readonly mergeStart: MergeStart,\n private readonly mergeEnd: MergeEnd,\n ) {}\n\n // `finishCommand` is the command the AI is told to run after resolving conflicts (standalone passes\n // `wp-finish-update`, PR flow passes `wp-finish-upsert-pr`). `verb` is the invoking bin, threaded so\n // every branch mutation is recorded in `.webpieces/hooks/branch-mutations.log`.\n async runUpdateFromMain(repoRoot: string, verb: MutationVerb, finishCommand: string): Promise<UpdateOutcome> {\n logBranchMutation(repoRoot, new BranchMutationEvent(verb, 'START'));\n const outcome = await this.runUpdate(repoRoot, verb, finishCommand);\n const end = new BranchMutationEvent(verb, 'END');\n end.outcome = outcome;\n logBranchMutation(repoRoot, end);\n return outcome;\n }\n\n private async runUpdate(repoRoot: string, verb: MutationVerb, finishCommand: string): Promise<UpdateOutcome> {\n const home = this.mergeState.mergeDirFor(repoRoot, this.aiBranchName.getFeatureName());\n\n // Resume path: an in-progress merge is the `merge-<n>/` run dir that holds a marker.\n const activeDir = this.mergeState.findActiveMergeRunDir(home);\n if (activeDir) {\n const existing = this.mergeState.readMergeMarker(activeDir);\n if (existing === null || !existing.validated) return 'unvalidatedResume';\n // Already validated → just finalize the branch swap (reads THIS run dir's marker).\n await this.mergeEnd.mergeEnd(\n repoRoot, verb, activeDir,\n new MergeContext(existing.currentBranch, existing.squashBranch, existing.backupBranch, existing.prNumber),\n null,\n );\n return 'finalized';\n }\n\n // Fresh update: mergeStart picks the slot number, creates its own `merge-<n>/` run dir, and\n // returns that path for merge-END to finalize against.\n const result = await this.mergeStart.mergeStart(repoRoot, verb, home, finishCommand);\n if (result.status === 'conflict' || result.context === null) {\n return 'conflict';\n }\n await this.mergeEnd.mergeEnd(repoRoot, verb, result.runDir, result.context, null);\n return 'finalized';\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export declare function main(): Promise<void>;
2
+ import 'reflect-metadata';
@@ -1,35 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.main = main;
5
- const child_process_1 = require("child_process");
4
+ require("reflect-metadata");
5
+ const inversify_1 = require("inversify");
6
+ const binding_decorators_1 = require("@inversifyjs/binding-decorators");
6
7
  const rules_config_1 = require("@webpieces/rules-config");
7
- const git_readAiBranchName_1 = require("./workflow/git-readAiBranchName");
8
- const merge_state_1 = require("./workflow/merge-state");
9
- const merge_end_1 = require("./workflow/merge-end");
10
- const merge_start_1 = require("./workflow/merge-start");
11
- // wp-finish-update — finalize half of the 3-point squash-merge lifecycle. Run it AFTER `wp-start-update`
12
- // handed back conflicts and you resolved them. Given an in-progress merge marker it validates +
13
- // commits the AI's resolution (when the marker is not yet validated) and ALWAYS finalizes the branch
14
- // swap (squash→feature, push, stamp clean, clear marker). It does NOT run the build gate / dashboard
15
- // / PR — that is wp-finish-upsert-pr (the PR flow's finish). Refuses to run when there is no merge in
16
- // progress (a clean `wp-start-update` finalizes on its own — there is nothing left for this to do).
17
- async function main() {
18
- const repoRoot = (0, child_process_1.execSync)('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim();
19
- const home = (0, merge_state_1.mergeDirFor)(repoRoot, (0, git_readAiBranchName_1.getFeatureName)());
20
- // The in-progress merge is the `merge-<n>/` run dir holding a marker.
21
- const activeDir = (0, merge_state_1.findActiveMergeRunDir)(home);
22
- const marker = activeDir ? (0, merge_state_1.readMergeMarker)(activeDir) : null;
23
- if (!activeDir || !marker) {
24
- throw new rules_config_1.CliExitError(1, '❌ No merge in progress (no marker) — nothing to finalize.\n' +
25
- 'Start one with: pnpm wp-start-update (a clean update finalizes itself).');
26
- }
27
- // Not yet validated => a conflict resolution the AI owns, so validate + commit it first; already
28
- // validated => clean merge (or previously validated) => finalize only.
29
- const conflictedFiles = marker.validated ? null : marker.conflictedFiles;
30
- await (0, merge_end_1.mergeEnd)(repoRoot, 'wp-finish-update', activeDir, new merge_start_1.MergeContext(marker.currentBranch, marker.squashBranch, marker.backupBranch, marker.prNumber), conflictedFiles);
31
- process.stdout.write('\n✅ Merge finalized on ' + marker.currentBranch + '.\n');
32
- }
33
- if (require.main === module)
34
- (0, rules_config_1.runMain)(main);
8
+ const pr_gate_app_1 = require("./pr-gate-app");
9
+ // Composition root: build the container and resolve the app so inversify constructs the whole DAG.
10
+ (0, rules_config_1.runMain)(async () => {
11
+ const container = new inversify_1.Container();
12
+ container.bind(rules_config_1.RepoRootFinder).toConstantValue(new rules_config_1.RepoRootFinder());
13
+ await container.load((0, binding_decorators_1.buildProviderModule)());
14
+ await container.get(pr_gate_app_1.PrGateApp).finishUpdate();
15
+ });
35
16
  //# sourceMappingURL=wp-finish-update.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wp-finish-update.js","sourceRoot":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AM,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;AACnF,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;IAAE,IAAA,sBAAO,EAAC,IAAI,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { execSync } from 'child_process';\nimport { CliExitError, runMain } from '@webpieces/rules-config';\nimport { getFeatureName } from './workflow/git-readAiBranchName';\nimport { mergeDirFor, readMergeMarker, findActiveMergeRunDir } from './workflow/merge-state';\nimport { mergeEnd } from './workflow/merge-end';\nimport { MergeContext } from './workflow/merge-start';\n\n// wp-finish-update finalize half of the 3-point squash-merge lifecycle. Run it AFTER `wp-start-update`\n// handed back conflicts and you resolved them. Given an in-progress merge marker it validates +\n// commits the AI's resolution (when the marker is not yet validated) and ALWAYS finalizes the branch\n// swap (squash→feature, push, stamp clean, clear marker). It does NOT run the build gate / dashboard\n// / PR — that is wp-finish-upsert-pr (the PR flow's finish). Refuses to run when there is no merge in\n// progress (a clean `wp-start-update` finalizes on its own — there is nothing left for this to do).\n\nexport async function main(): Promise<void> {\n const repoRoot = execSync('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim();\n const home = mergeDirFor(repoRoot, getFeatureName());\n\n // The in-progress merge is the `merge-<n>/` run dir holding a marker.\n const activeDir = findActiveMergeRunDir(home);\n const marker = activeDir ? readMergeMarker(activeDir) : null;\n if (!activeDir || !marker) {\n throw new CliExitError(1,\n '❌ No merge in progress (no marker) — nothing to finalize.\\n' +\n 'Start one with: pnpm wp-start-update (a clean update finalizes itself).',\n );\n }\n\n // Not yet validated => a conflict resolution the AI owns, so validate + commit it first; already\n // validated => clean merge (or previously validated) => finalize only.\n const conflictedFiles = marker.validated ? null : marker.conflictedFiles;\n await mergeEnd(\n repoRoot, 'wp-finish-update', activeDir,\n new MergeContext(marker.currentBranch, marker.squashBranch, marker.backupBranch, marker.prNumber),\n conflictedFiles,\n );\n process.stdout.write('\\n✅ Merge finalized on ' + marker.currentBranch + '.\\n');\n}\n\nif (require.main === module) runMain(main);\n"]}
1
+ {"version":3,"file":"wp-finish-update.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/wp-finish-update.ts"],"names":[],"mappings":";;;AACA,4BAA0B;AAC1B,yCAAsC;AACtC,wEAAsE;AACtE,0DAAkE;AAClE,+CAA0C;AAE1C,mGAAmG;AACnG,IAAA,sBAAO,EAAC,KAAK,IAAmB,EAAE;IAC9B,MAAM,SAAS,GAAG,IAAI,qBAAS,EAAE,CAAC;IAClC,SAAS,CAAC,IAAI,CAAC,6BAAc,CAAC,CAAC,eAAe,CAAC,IAAI,6BAAc,EAAE,CAAC,CAAC;IACrE,MAAM,SAAS,CAAC,IAAI,CAAC,IAAA,wCAAmB,GAAE,CAAC,CAAC;IAC5C,MAAM,SAAS,CAAC,GAAG,CAAC,uBAAS,CAAC,CAAC,YAAY,EAAE,CAAC;AAClD,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport 'reflect-metadata';\nimport { Container } from 'inversify';\nimport { buildProviderModule } from '@inversifyjs/binding-decorators';\nimport { runMain, RepoRootFinder } from '@webpieces/rules-config';\nimport { PrGateApp } from './pr-gate-app';\n\n// Composition root: build the container and resolve the app so inversify constructs the whole DAG.\nrunMain(async (): Promise<void> => {\n const container = new Container();\n container.bind(RepoRootFinder).toConstantValue(new RepoRootFinder());\n await container.load(buildProviderModule());\n await container.get(PrGateApp).finishUpdate();\n});\n"]}
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export declare function assertNoOpenPr(repoRoot: string): void;
3
- export declare function main(): Promise<void>;
2
+ import 'reflect-metadata';
@@ -1,56 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.assertNoOpenPr = assertNoOpenPr;
5
- exports.main = main;
6
- const child_process_1 = require("child_process");
4
+ require("reflect-metadata");
5
+ const inversify_1 = require("inversify");
6
+ const binding_decorators_1 = require("@inversifyjs/binding-decorators");
7
7
  const rules_config_1 = require("@webpieces/rules-config");
8
- const open_pr_check_1 = require("./workflow/open-pr-check");
9
- const run_update_1 = require("./workflow/run-update");
10
- // wp-start-update: the "sync this feature branch from main" entry point (the redirect target of the
11
- // redirect-how-to-merge-main guard). It runs the FULL 3-point squash-update via the shared
12
- // runUpdateFromMain engine: on a CLEAN merge it finalizes everything (no need to call wp-finish-update);
13
- // on CONFLICT it writes the 3-point context + merge process doc and hands back — you resolve, then
14
- // run `wp-finish-update` to finalize. It NEVER creates a PR (that is the wp-*-upsert-pr flow).
15
- const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
16
- // If a PR is already OPEN for this branch, wp-start-update must refuse. The 3-point update re-squashes
17
- // your branch onto main and force-pushes it to origin/<feature> — the PR head — but it does NOT refresh
18
- // the PR body/review or run the authoritative build gate. So it would push new code onto an open PR
19
- // without an updated review. The PR flow (wp-start-upsert-pr → wp-finish-upsert-pr) is the ONLY correct
20
- // path once a PR exists: it re-merges main AND updates the PR. Fail fast and steer there. (openPrForBranch
21
- // itself fails fast if GitHub can't be reached — we never assume "no PR" when we simply couldn't ask.)
22
- function assertNoOpenPr(repoRoot) {
23
- const branch = (0, child_process_1.execSync)('git rev-parse --abbrev-ref HEAD', { cwd: repoRoot, encoding: 'utf8' }).trim();
24
- const openPr = (0, open_pr_check_1.openPrForBranch)(repoRoot, branch);
25
- if (openPr === '')
26
- return;
27
- throw new rules_config_1.CliExitError(2, '\n' + SEP + `⛔ An open PR (#${openPr}) already tracks this branch\n` + SEP + '\n' +
28
- 'wp-start-update re-squashes your branch onto main and force-pushes it, but it does NOT refresh\n' +
29
- `the PR body/review — so PR #${openPr} would get new code without an updated review. Use the PR\n` +
30
- 'flow instead — it re-merges main AND updates the PR:\n' +
31
- ' 1. pnpm wp-start-upsert-pr\n' +
32
- ' 2. /wp-merge (only if conflicts)\n' +
33
- ' 3. pnpm wp-finish-upsert-pr\n');
34
- }
35
- async function main() {
36
- const repoRoot = (0, child_process_1.execSync)('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim();
37
- // Refresh the AI-facing workflow doc so it's present + current for any failure message to cite.
38
- (0, rules_config_1.writeTemplate)(repoRoot, 'webpieces.git-workflow.md');
39
- // An open PR means the PR flow must be used — a 3-point update would strand the PR on the old
40
- // branch generation. Fails fast if GitHub can't be reached (never guesses "no PR").
41
- assertNoOpenPr(repoRoot);
42
- const outcome = await (0, run_update_1.runUpdateFromMain)(repoRoot, 'wp-start-update', 'wp-finish-update');
43
- if (outcome === 'conflict') {
44
- // Context + marker + merge process doc already written by merge-start; hand back to the AI.
45
- throw new rules_config_1.CliExitError(2, '');
46
- }
47
- if (outcome === 'unvalidatedResume') {
48
- throw new rules_config_1.CliExitError(1, '\n' + SEP + '⏸️ Merge in progress — not yet validated\n' + SEP + '\n' +
49
- 'Resolve the remaining conflicts in the working tree, then run:\n' +
50
- ' pnpm wp-finish-update\n');
51
- }
52
- process.stdout.write('\n✅ Updated from main — clean. No need to call wp-finish-update.\n');
53
- }
54
- if (require.main === module)
55
- (0, rules_config_1.runMain)(main);
8
+ const pr_gate_app_1 = require("./pr-gate-app");
9
+ // Composition root: build the container and resolve the app so inversify constructs the whole DAG.
10
+ (0, rules_config_1.runMain)(async () => {
11
+ const container = new inversify_1.Container();
12
+ container.bind(rules_config_1.RepoRootFinder).toConstantValue(new rules_config_1.RepoRootFinder());
13
+ await container.load((0, binding_decorators_1.buildProviderModule)());
14
+ await container.get(pr_gate_app_1.PrGateApp).startUpdate();
15
+ });
56
16
  //# sourceMappingURL=wp-start-update.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wp-start-update.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/wp-start-update.ts"],"names":[],"mappings":";;;AAoBA,wCAaC;AAED,oBAsBC;AAxDD,iDAAyC;AACzC,0DAA+E;AAC/E,4DAA2D;AAC3D,sDAA0D;AAE1D,oGAAo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AClC,CAAC;IACD,IAAI,OAAO,KAAK,mBAAmB,EAAE,CAAC;QAClC,MAAM,IAAI,2BAAY,CAAC,CAAC,EACpB,IAAI,GAAG,GAAG,GAAG,6CAA6C,GAAG,GAAG,GAAG,IAAI;YACvE,kEAAkE;YAClE,2BAA2B,CAC9B,CAAC;IACN,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oEAAoE,CAAC,CAAC;AAC/F,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;IAAE,IAAA,sBAAO,EAAC,IAAI,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { execSync } from 'child_process';\nimport { writeTemplate, CliExitError, runMain } from '@webpieces/rules-config';\nimport { openPrForBranch } from './workflow/open-pr-check';\nimport { runUpdateFromMain } from './workflow/run-update';\n\n// wp-start-update: the \"sync this feature branch from main\" entry point (the redirect target of the\n// redirect-how-to-merge-main guard). It runs the FULL 3-point squash-update via the shared\n// runUpdateFromMain engine: on a CLEAN merge it finalizes everything (no need to call wp-finish-update);\n// on CONFLICT it writes the 3-point context + merge process doc and hands back — you resolve, then\n// run `wp-finish-update` to finalize. It NEVER creates a PR (that is the wp-*-upsert-pr flow).\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n// If a PR is already OPEN for this branch, wp-start-update must refuse. The 3-point update re-squashes\n// your branch onto main and force-pushes it to origin/<feature> — the PR head — but it does NOT refresh\n// the PR body/review or run the authoritative build gate. So it would push new code onto an open PR\n// without an updated review. The PR flow (wp-start-upsert-pr → wp-finish-upsert-pr) is the ONLY correct\n// path once a PR exists: it re-merges main AND updates the PR. Fail fast and steer there. (openPrForBranch\n// itself fails fast if GitHub can't be reached — we never assume \"no PR\" when we simply couldn't ask.)\nexport function assertNoOpenPr(repoRoot: string): void {\n const branch = execSync('git rev-parse --abbrev-ref HEAD', { cwd: repoRoot, encoding: 'utf8' }).trim();\n const openPr = openPrForBranch(repoRoot, branch);\n if (openPr === '') return;\n throw new CliExitError(2,\n '\\n' + SEP + `⛔ An open PR (#${openPr}) already tracks this branch\\n` + SEP + '\\n' +\n 'wp-start-update re-squashes your branch onto main and force-pushes it, but it does NOT refresh\\n' +\n `the PR body/review — so PR #${openPr} would get new code without an updated review. Use the PR\\n` +\n 'flow instead — it re-merges main AND updates the PR:\\n' +\n ' 1. pnpm wp-start-upsert-pr\\n' +\n ' 2. /wp-merge (only if conflicts)\\n' +\n ' 3. pnpm wp-finish-upsert-pr\\n',\n );\n}\n\nexport async function main(): Promise<void> {\n const repoRoot = execSync('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim();\n // Refresh the AI-facing workflow doc so it's present + current for any failure message to cite.\n writeTemplate(repoRoot, 'webpieces.git-workflow.md');\n\n // An open PR means the PR flow must be used — a 3-point update would strand the PR on the old\n // branch generation. Fails fast if GitHub can't be reached (never guesses \"no PR\").\n assertNoOpenPr(repoRoot);\n\n const outcome = await runUpdateFromMain(repoRoot, 'wp-start-update', 'wp-finish-update');\n if (outcome === 'conflict') {\n // Context + marker + merge process doc already written by merge-start; hand back to the AI.\n throw new CliExitError(2, '');\n }\n if (outcome === 'unvalidatedResume') {\n throw new CliExitError(1,\n '\\n' + SEP + '⏸️ Merge in progress — not yet validated\\n' + SEP + '\\n' +\n 'Resolve the remaining conflicts in the working tree, then run:\\n' +\n ' pnpm wp-finish-update\\n',\n );\n }\n process.stdout.write('\\n✅ Updated from main — clean. No need to call wp-finish-update.\\n');\n}\n\nif (require.main === module) runMain(main);\n"]}
1
+ {"version":3,"file":"wp-start-update.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/wp-start-update.ts"],"names":[],"mappings":";;;AACA,4BAA0B;AAC1B,yCAAsC;AACtC,wEAAsE;AACtE,0DAAkE;AAClE,+CAA0C;AAE1C,mGAAmG;AACnG,IAAA,sBAAO,EAAC,KAAK,IAAmB,EAAE;IAC9B,MAAM,SAAS,GAAG,IAAI,qBAAS,EAAE,CAAC;IAClC,SAAS,CAAC,IAAI,CAAC,6BAAc,CAAC,CAAC,eAAe,CAAC,IAAI,6BAAc,EAAE,CAAC,CAAC;IACrE,MAAM,SAAS,CAAC,IAAI,CAAC,IAAA,wCAAmB,GAAE,CAAC,CAAC;IAC5C,MAAM,SAAS,CAAC,GAAG,CAAC,uBAAS,CAAC,CAAC,WAAW,EAAE,CAAC;AACjD,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport 'reflect-metadata';\nimport { Container } from 'inversify';\nimport { buildProviderModule } from '@inversifyjs/binding-decorators';\nimport { runMain, RepoRootFinder } from '@webpieces/rules-config';\nimport { PrGateApp } from './pr-gate-app';\n\n// Composition root: build the container and resolve the app so inversify constructs the whole DAG.\nrunMain(async (): Promise<void> => {\n const container = new Container();\n container.bind(RepoRootFinder).toConstantValue(new RepoRootFinder());\n await container.load(buildProviderModule());\n await container.get(PrGateApp).startUpdate();\n});\n"]}
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export declare function main(): Promise<void>;
2
+ import 'reflect-metadata';
@@ -1,52 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.main = main;
5
- const child_process_1 = require("child_process");
4
+ require("reflect-metadata");
5
+ const inversify_1 = require("inversify");
6
+ const binding_decorators_1 = require("@inversifyjs/binding-decorators");
6
7
  const rules_config_1 = require("@webpieces/rules-config");
7
- const git_readAiBranchName_1 = require("./workflow/git-readAiBranchName");
8
- const branch_naming_1 = require("./workflow/branch-naming");
9
- const build_affected_1 = require("./workflow/build-affected");
10
- const git_exec_1 = require("./workflow/git-exec");
11
- const run_update_1 = require("./workflow/run-update");
12
- // START of the AI-first PR flow (webpieces is AI-driven, so we invert trytami's human-first flow):
13
- // this command does the deterministic setup — update from main, push, run the build gate — then
14
- // hands the AI instructions to WRITE review.json and run `wp-finish-upsert-pr` (which reads it and
15
- // posts the PR). This command NEVER creates/updates a PR; all `gh` posting lives in finish.
16
- const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
17
- // Step A — bring the branch up to date with main via the shared 3-point engine (in-process). On
18
- // conflict the merge process doc it writes names `wp-finish-upsert-pr` as the finish command (this
19
- // PR flow's finish, which validates + finalizes + builds + posts the PR).
20
- async function updateBranchFromMain(repoRoot) {
21
- process.stdout.write('\n' + SEP + '① Updating branch from main\n' + SEP + '\n');
22
- const outcome = await (0, run_update_1.runUpdateFromMain)(repoRoot, 'wp-start-upsert-pr', 'wp-finish-upsert-pr');
23
- if (outcome === 'conflict' || outcome === 'unvalidatedResume') {
24
- throw new rules_config_1.CliExitError(2, '\n⏸️ Conflicts — resolve them, then run pnpm wp-finish-upsert-pr (it validates the merge AND finishes the PR).');
25
- }
26
- }
27
- async function main() {
28
- const repoRoot = (0, child_process_1.execSync)('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim();
29
- // Refresh the AI-facing workflow doc so it's present + current for any failure message to cite.
30
- (0, rules_config_1.writeTemplate)(repoRoot, 'webpieces.git-workflow.md');
31
- // Precondition: a fully-committed tree. This flow updates, pushes HEAD, and builds — the tooling
32
- // must not commit your work for you, and pushing HEAD while building the working tree would let an
33
- // uncommitted change build green yet push a stale commit. Fail early with instructions if dirty.
34
- (0, git_exec_1.assertCleanTree)(repoRoot);
35
- await updateBranchFromMain(repoRoot);
36
- // Local branch, remote branch, and PR share the one stable feature name (baseBranchName also
37
- // tolerates a leftover `…wpN` from the old scheme).
38
- (0, git_exec_1.ensurePushed)((0, branch_naming_1.baseBranchName)((0, child_process_1.execSync)('git branch --show-current', { encoding: 'utf8' }).trim()));
39
- // Advisory build gate — early feedback before the AI writes review.json. wp-finish-upsert-pr runs
40
- // the authoritative one. Both go through the same shared runBuildGate (only the framing differs).
41
- (0, build_affected_1.runBuildGate)(repoRoot, new build_affected_1.BuildGateOptions('② Build gate (nx affected)', 'pnpm wp-start-upsert-pr', 'Build failed — fix it before reviewing.'));
42
- // Hand the AI its next step: write review.json, then run finish (which posts the PR).
43
- const reviewPath = (0, rules_config_1.reviewJsonPath)(repoRoot, (0, git_readAiBranchName_1.getFeatureName)());
44
- process.stdout.write('\n' + SEP + '③ Review the PR, then finish\n' + SEP + '\n');
45
- process.stdout.write(`Branch is updated, pushed, and the build gate passed. Now review your own changes and\n` +
46
- `${(0, rules_config_1.reviewJsonSchemaHint)(reviewPath)}\n\n` +
47
- `Then run: pnpm wp-finish-upsert-pr\n` +
48
- `(It re-validates the build, renders the dashboard with your risk/violations, and creates/updates the PR.)\n\n`);
49
- }
50
- if (require.main === module)
51
- (0, rules_config_1.runMain)(main);
8
+ const pr_gate_app_1 = require("./pr-gate-app");
9
+ // Composition root: build the container and resolve the app so inversify constructs the whole DAG.
10
+ (0, rules_config_1.runMain)(async () => {
11
+ const container = new inversify_1.Container();
12
+ container.bind(rules_config_1.RepoRootFinder).toConstantValue(new rules_config_1.RepoRootFinder());
13
+ await container.load((0, binding_decorators_1.buildProviderModule)());
14
+ await container.get(pr_gate_app_1.PrGateApp).startUpsertPr();
15
+ });
52
16
  //# sourceMappingURL=wp-start-upsert-pr.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wp-start-upsert-pr.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/wp-start-upsert-pr.ts"],"names":[],"mappings":";;;AA6BA,oBA8BC;AA1DD,iDAAyC;AACzC,0DAAqH;AACrH,0EAAiE;AACjE,4DAA0D;AAC1D,8DAA2E;AAC3E,kDAAoE;AACpE,sDAA0D;AAE1D,mGAAmG;AACnG,gGAAgG;AAChG,mGAAmG;AACnG,4FAA4F;AAE5F,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE,gGAAgG;AAChG,mGAAmG;AACnG,0EAA0E;AAC1E,KAAK,UAAU,oBAAoB,CAAC,QAAgB;IAChD,OAAO,CAAC,MAAM,CAAC,KAAK,CAA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,CAAC,MAAM,CAAC,KAAK,CAChB,yFAAyF;QACzF,GAAG,IAAA,mCAAoB,EAAC,UAAU,CAAC,MAAM;QACzC,uCAAuC;QACvC,+GAA+G,CAClH,CAAC;AACN,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;IAAE,IAAA,sBAAO,EAAC,IAAI,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { execSync } from 'child_process';\nimport { reviewJsonPath, reviewJsonSchemaHint, writeTemplate, CliExitError, runMain } from '@webpieces/rules-config';\nimport { getFeatureName } from './workflow/git-readAiBranchName';\nimport { baseBranchName } from './workflow/branch-naming';\nimport { runBuildGate, BuildGateOptions } from './workflow/build-affected';\nimport { assertCleanTree, ensurePushed } from './workflow/git-exec';\nimport { runUpdateFromMain } from './workflow/run-update';\n\n// START of the AI-first PR flow (webpieces is AI-driven, so we invert trytami's human-first flow):\n// this command does the deterministic setup — update from main, push, run the build gate — then\n// hands the AI instructions to WRITE review.json and run `wp-finish-upsert-pr` (which reads it and\n// posts the PR). This command NEVER creates/updates a PR; all `gh` posting lives in finish.\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n// Step A — bring the branch up to date with main via the shared 3-point engine (in-process). On\n// conflict the merge process doc it writes names `wp-finish-upsert-pr` as the finish command (this\n// PR flow's finish, which validates + finalizes + builds + posts the PR).\nasync function updateBranchFromMain(repoRoot: string): Promise<void> {\n process.stdout.write('\\n' + SEP + '① Updating branch from main\\n' + SEP + '\\n');\n const outcome = await runUpdateFromMain(repoRoot, 'wp-start-upsert-pr', 'wp-finish-upsert-pr');\n if (outcome === 'conflict' || outcome === 'unvalidatedResume') {\n throw new CliExitError(2,\n '\\n⏸️ Conflicts — resolve them, then run pnpm wp-finish-upsert-pr (it validates the merge AND finishes the PR).',\n );\n }\n}\n\nexport async function main(): Promise<void> {\n const repoRoot = execSync('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim();\n // Refresh the AI-facing workflow doc so it's present + current for any failure message to cite.\n writeTemplate(repoRoot, 'webpieces.git-workflow.md');\n\n // Precondition: a fully-committed tree. This flow updates, pushes HEAD, and builds — the tooling\n // must not commit your work for you, and pushing HEAD while building the working tree would let an\n // uncommitted change build green yet push a stale commit. Fail early with instructions if dirty.\n assertCleanTree(repoRoot);\n\n await updateBranchFromMain(repoRoot);\n // Local branch, remote branch, and PR share the one stable feature name (baseBranchName also\n // tolerates a leftover `…wpN` from the old scheme).\n ensurePushed(baseBranchName(execSync('git branch --show-current', { encoding: 'utf8' }).trim()));\n\n // Advisory build gate — early feedback before the AI writes review.json. wp-finish-upsert-pr runs\n // the authoritative one. Both go through the same shared runBuildGate (only the framing differs).\n runBuildGate(repoRoot, new BuildGateOptions(\n '② Build gate (nx affected)', 'pnpm wp-start-upsert-pr', 'Build failed — fix it before reviewing.',\n ));\n\n // Hand the AI its next step: write review.json, then run finish (which posts the PR).\n const reviewPath = reviewJsonPath(repoRoot, getFeatureName());\n process.stdout.write('\\n' + SEP + '③ Review the PR, then finish\\n' + SEP + '\\n');\n process.stdout.write(\n `Branch is updated, pushed, and the build gate passed. Now review your own changes and\\n` +\n `${reviewJsonSchemaHint(reviewPath)}\\n\\n` +\n `Then run: pnpm wp-finish-upsert-pr\\n` +\n `(It re-validates the build, renders the dashboard with your risk/violations, and creates/updates the PR.)\\n\\n`,\n );\n}\n\nif (require.main === module) runMain(main);\n"]}
1
+ {"version":3,"file":"wp-start-upsert-pr.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/wp-start-upsert-pr.ts"],"names":[],"mappings":";;;AACA,4BAA0B;AAC1B,yCAAsC;AACtC,wEAAsE;AACtE,0DAAkE;AAClE,+CAA0C;AAE1C,mGAAmG;AACnG,IAAA,sBAAO,EAAC,KAAK,IAAmB,EAAE;IAC9B,MAAM,SAAS,GAAG,IAAI,qBAAS,EAAE,CAAC;IAClC,SAAS,CAAC,IAAI,CAAC,6BAAc,CAAC,CAAC,eAAe,CAAC,IAAI,6BAAc,EAAE,CAAC,CAAC;IACrE,MAAM,SAAS,CAAC,IAAI,CAAC,IAAA,wCAAmB,GAAE,CAAC,CAAC;IAC5C,MAAM,SAAS,CAAC,GAAG,CAAC,uBAAS,CAAC,CAAC,aAAa,EAAE,CAAC;AACnD,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport 'reflect-metadata';\nimport { Container } from 'inversify';\nimport { buildProviderModule } from '@inversifyjs/binding-decorators';\nimport { runMain, RepoRootFinder } from '@webpieces/rules-config';\nimport { PrGateApp } from './pr-gate-app';\n\n// Composition root: build the container and resolve the app so inversify constructs the whole DAG.\nrunMain(async (): Promise<void> => {\n const container = new Container();\n container.bind(RepoRootFinder).toConstantValue(new RepoRootFinder());\n await container.load(buildProviderModule());\n await container.get(PrGateApp).startUpsertPr();\n});\n"]}