@magnusekdahl/parallix 1.2.1 → 1.3.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 (79) hide show
  1. package/index.js +190 -185
  2. package/lib/commands/active.js +502 -579
  3. package/lib/commands/active.ts +665 -0
  4. package/lib/commands/checkpoint.js +98 -74
  5. package/lib/commands/checkpoint.ts +79 -0
  6. package/lib/commands/config.js +61 -31
  7. package/lib/commands/config.ts +47 -0
  8. package/lib/commands/coverage-gate.js +271 -246
  9. package/lib/commands/coverage-gate.ts +362 -0
  10. package/lib/commands/diff.js +140 -119
  11. package/lib/commands/diff.ts +125 -0
  12. package/lib/commands/draft.js +770 -923
  13. package/lib/commands/draft.ts +1021 -0
  14. package/lib/commands/handoff.js +588 -608
  15. package/lib/commands/handoff.ts +694 -0
  16. package/lib/commands/integrate.js +1331 -1468
  17. package/lib/commands/integrate.ts +1688 -0
  18. package/lib/commands/mission-start.js +279 -237
  19. package/lib/commands/mission-start.ts +263 -0
  20. package/lib/commands/rebase.js +606 -582
  21. package/lib/commands/rebase.ts +635 -0
  22. package/lib/commands/repair-handoff.js +181 -179
  23. package/lib/commands/repair-handoff.ts +228 -0
  24. package/lib/commands/resolve-conflict.js +121 -102
  25. package/lib/commands/resolve-conflict.ts +112 -0
  26. package/lib/commands/review.js +3 -4
  27. package/lib/commands/review.ts +14 -0
  28. package/lib/commands/setup-review.js +4 -5
  29. package/lib/commands/setup-review.ts +14 -0
  30. package/lib/commands/setup.js +3 -3
  31. package/lib/commands/setup.ts +2 -0
  32. package/lib/commands/stats-backfill.js +394 -359
  33. package/lib/commands/stats-backfill.ts +418 -0
  34. package/lib/commands/stats.js +1424 -1665
  35. package/lib/commands/stats.ts +2186 -0
  36. package/lib/commands/status.js +219 -200
  37. package/lib/commands/status.ts +219 -0
  38. package/lib/commands/verify.js +3 -1
  39. package/lib/commands/verify.ts +2 -0
  40. package/lib/core/nels.js +112 -127
  41. package/lib/core/nels.ts +189 -0
  42. package/lib/core/subagent-limit.js +15 -16
  43. package/lib/core/subagent-limit.ts +25 -0
  44. package/lib/index.js +142 -59
  45. package/lib/index.ts +134 -0
  46. package/lib/review/rebase.js +142 -145
  47. package/lib/review/rebase.ts +188 -0
  48. package/lib/review/review-adapter.js +99 -87
  49. package/lib/review/review-adapter.ts +198 -0
  50. package/lib/review/review-artifacts.js +486 -629
  51. package/lib/review/review-artifacts.ts +622 -0
  52. package/lib/review/review-commands.js +1220 -1373
  53. package/lib/review/review-commands.ts +1579 -0
  54. package/lib/review/review-events.js +544 -886
  55. package/lib/review/review-events.ts +954 -0
  56. package/lib/review/review-loop.js +945 -1020
  57. package/lib/review/review-loop.ts +1174 -0
  58. package/lib/review/review-polling.js +86 -115
  59. package/lib/review/review-polling.ts +194 -0
  60. package/lib/review/review-prompts.js +154 -189
  61. package/lib/review/review-prompts.ts +182 -0
  62. package/lib/review/review-state.js +246 -225
  63. package/lib/review/review-state.ts +353 -0
  64. package/lib/review/review.js +63 -84
  65. package/lib/review/review.ts +138 -0
  66. package/lib/tools/backlog.js +694 -680
  67. package/lib/tools/backlog.ts +835 -0
  68. package/lib/tools/forgejo.js +1270 -1405
  69. package/lib/tools/forgejo.ts +1793 -0
  70. package/lib/tools/gatekeeper.js +106 -96
  71. package/lib/tools/gatekeeper.ts +124 -0
  72. package/lib/tools/redgreen.js +200 -181
  73. package/lib/tools/redgreen.ts +221 -0
  74. package/lib/tools/sessions.js +58 -52
  75. package/lib/tools/sessions.ts +81 -0
  76. package/lib/tools/setup-review.js +902 -975
  77. package/lib/tools/setup-review.ts +1152 -0
  78. package/package.json +4 -4
  79. package/px.js +226 -208
package/index.js CHANGED
@@ -1,209 +1,226 @@
1
1
  #!/usr/bin/env node
2
-
2
+ "use strict";
3
3
  /**
4
4
  * VisualBoard Parallix Coordination CLI
5
5
  * ADR 0037 — Wave 1
6
6
  */
7
-
8
- const fs = require('fs');
9
- const path = require('path');
10
- const fmt = require('./lib/core/fmt');
11
- const { ensureStandaloneGitRepo } = require('./lib/core/product-config');
12
- const { loadStateMap } = require('./lib/core/state-map');
13
-
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.KNOWN_COMMANDS = void 0;
45
+ exports.deriveAliases = deriveAliases;
46
+ exports.resolveAlias = resolveAlias;
47
+ exports.printAliases = printAliases;
48
+ exports.buildSuggestionSuffix = buildSuggestionSuffix;
49
+ exports.suggestCommand = suggestCommand;
50
+ exports.levenshteinDistance = levenshteinDistance;
51
+ exports.printUsage = printUsage;
52
+ exports.main = main;
53
+ const node_fs_1 = __importDefault(require("node:fs"));
54
+ const node_path_1 = __importDefault(require("node:path"));
55
+ const fmt = __importStar(require("./lib/core/fmt.js"));
56
+ const product_config_js_1 = require("./lib/core/product-config.js");
57
+ const state_map_js_1 = require("./lib/core/state-map.js");
14
58
  // Fixed virtual-state → canonical-command invariants for alias derivation.
15
59
  const STATE_COMMAND_MAP = {
16
- ready: 'draft',
17
- approved: 'integrate',
18
- done: 'integrate',
60
+ ready: 'draft',
61
+ approved: 'integrate',
62
+ done: 'integrate',
19
63
  };
20
-
21
- const KNOWN_COMMANDS = [
22
- 'mission-start',
23
- 'verify-env',
24
- 'verify',
25
- 'setup',
26
- 'setup-review',
27
- 'draft',
28
- 'active',
29
- 'status',
30
- 'checkpoint',
31
- 'review',
32
- 'handoff',
33
- 'integrate',
34
- 'resolve-conflict',
35
- 'rebase',
36
- 'stats',
37
- 'aliases',
38
- 'config',
39
- 'diff',
64
+ exports.KNOWN_COMMANDS = [
65
+ 'mission-start',
66
+ 'verify-env',
67
+ 'verify',
68
+ 'setup',
69
+ 'setup-review',
70
+ 'draft',
71
+ 'active',
72
+ 'status',
73
+ 'checkpoint',
74
+ 'review',
75
+ 'handoff',
76
+ 'integrate',
77
+ 'resolve-conflict',
78
+ 'rebase',
79
+ 'stats',
80
+ 'aliases',
81
+ 'config',
82
+ 'diff',
40
83
  ];
41
-
42
84
  const READ_ONLY_COMMANDS = new Set(['config']);
43
-
44
85
  function loadStateMapForAliases(options = {}) {
45
- return loadStateMap(options);
86
+ return (0, state_map_js_1.loadStateMap)(options);
46
87
  }
47
-
48
88
  // Derives the command-alias table from state-map.json and fixed parallix invariants.
49
89
  // Users only maintain state-map.json; aliases update automatically.
50
90
  function deriveAliases(options = {}) {
51
- const stateMap = loadStateMapForAliases(options);
52
- const aliases = { ...STATE_COMMAND_MAP };
53
- for (const [virtual, actual] of Object.entries(stateMap)) {
54
- if (actual && actual !== virtual && STATE_COMMAND_MAP[virtual]) {
55
- aliases[actual] = STATE_COMMAND_MAP[virtual];
91
+ const stateMap = loadStateMapForAliases(options);
92
+ const aliases = { ...STATE_COMMAND_MAP };
93
+ for (const [virtual, actual] of Object.entries(stateMap)) {
94
+ if (typeof actual === 'string' && actual !== virtual && STATE_COMMAND_MAP[virtual]) {
95
+ aliases[actual] = STATE_COMMAND_MAP[virtual];
96
+ }
56
97
  }
57
- }
58
- return aliases;
98
+ return aliases;
59
99
  }
60
-
61
100
  function resolveAlias(command, aliases = deriveAliases()) {
62
- return Object.prototype.hasOwnProperty.call(aliases, command) ? aliases[command] : null;
101
+ return Object.prototype.hasOwnProperty.call(aliases, command) ? aliases[command] : null;
63
102
  }
64
-
65
103
  function printAliases(aliases, logFn = fmt.log.plain) {
66
- const entries = Object.entries(aliases).sort(([a], [b]) => a.localeCompare(b));
67
- if (entries.length === 0) {
68
- logFn('No aliases configured.');
69
- return;
70
- }
71
- logFn(fmt.bold('alias canonical'));
72
- logFn(fmt.bold('--- ---'));
73
- for (const [alias, canonical] of entries) {
74
- logFn(`${alias.padEnd(30)}${canonical}`);
75
- }
104
+ const entries = Object.entries(aliases).sort(([a], [b]) => a.localeCompare(b));
105
+ if (entries.length === 0) {
106
+ logFn('No aliases configured.');
107
+ return;
108
+ }
109
+ logFn(fmt.bold('alias canonical'));
110
+ logFn(fmt.bold('--- ---'));
111
+ for (const [alias, canonical] of entries) {
112
+ logFn(`${alias.padEnd(30)}${canonical}`);
113
+ }
76
114
  }
77
-
78
- async function main(args = process.argv.slice(2), {
79
- existsSyncFn = fs.existsSync,
80
- cwdFn = () => process.cwd(),
81
- ensureStandaloneGitRepoFn = ensureStandaloneGitRepo,
82
- requireFn = require,
83
- printUsageFn = printUsage,
84
- exitFn = process.exit,
85
- errorFn = fmt.log.plainError,
86
- logFn = fmt.log.plain,
87
- loadAliasesFn = deriveAliases,
88
- } = {}) {
89
- const command = args[0];
90
-
91
- if (command === '--version' || command === '-v') {
92
- const pkg = requireFn(path.join(__dirname, 'package.json'));
93
- logFn(pkg.name + '@' + pkg.version);
94
- exitFn(0);
95
- return;
96
- }
97
-
98
- if (!command || command === 'help' || command === '--help' || command === '-h') {
99
- printUsageFn();
100
- exitFn(0);
101
- return;
102
- }
103
-
104
- if (command === 'aliases') {
105
- printAliases(loadAliasesFn({ rootDir: cwdFn() }), logFn);
106
- return;
107
- }
108
-
109
- const libPath = path.join(__dirname, 'lib', 'commands', `${command}.js`);
110
-
111
- // Special case: verify-env is an alias for mission-start diagnostic.
112
- // active is now its own command (real agent-start path).
113
- let targetLib = libPath;
114
- if (command === 'verify-env') {
115
- targetLib = path.join(__dirname, 'lib', 'commands', 'mission-start.js');
116
- }
117
-
118
- if (existsSyncFn(targetLib)) {
119
- if (!READ_ONLY_COMMANDS.has(command)) {
120
- const initResult = ensureStandaloneGitRepoFn(cwdFn());
121
- if (initResult && initResult.failed) {
122
- errorFn(fmt.status('FAIL', `Git init: ${initResult.message}`));
123
- exitFn(1);
115
+ async function main(args = process.argv.slice(2), options = {}) {
116
+ const { existsSyncFn = node_fs_1.default.existsSync, cwdFn = () => process.cwd(), ensureStandaloneGitRepoFn = product_config_js_1.ensureStandaloneGitRepo, requireFn = require, printUsageFn = printUsage, exitFn = process.exit, errorFn = fmt.log.plainError, logFn = fmt.log.plain, loadAliasesFn = deriveAliases, } = options;
117
+ const command = args[0];
118
+ if (command === '--version' || command === '-v') {
119
+ const pkg = requireFn(node_path_1.default.join(__dirname, 'package.json'));
120
+ logFn(pkg.name + '@' + pkg.version);
121
+ exitFn(0);
124
122
  return;
125
- }
126
- if (initResult && initResult.initialized) {
127
- logFn(fmt.status('INFO', `Initialized git repository for standalone parallix in ${cwdFn()} (branch ${initResult.branch || 'main'}).`));
128
- }
129
123
  }
130
-
131
- const cmdModule = requireFn(targetLib);
132
- if (typeof cmdModule === 'function') {
133
- await cmdModule(args.slice(1), { command });
134
- } else {
135
- errorFn(fmt.status('FAIL', `Command module '${command}' does not export a function.`));
136
- exitFn(1);
124
+ if (!command || command === 'help' || command === '--help' || command === '-h') {
125
+ printUsageFn();
126
+ exitFn(0);
127
+ return;
137
128
  }
138
- } else {
139
- const aliases = loadAliasesFn({ rootDir: cwdFn() });
140
- const canonical = resolveAlias(command, aliases);
141
- if (canonical) {
142
- logFn(fmt.status('INFO', `Resolving alias ${command} → ${canonical}`));
143
- await main([canonical, ...args.slice(1)], { existsSyncFn, cwdFn, ensureStandaloneGitRepoFn, requireFn, printUsageFn, exitFn, errorFn, logFn, loadAliasesFn });
144
- return;
129
+ if (command === 'aliases') {
130
+ printAliases(loadAliasesFn({ rootDir: cwdFn() }), logFn);
131
+ return;
145
132
  }
146
-
147
- errorFn(fmt.status('FAIL', `Unknown command: ${command}`));
148
- const suggestion = suggestCommand(command);
149
- if (suggestion) {
150
- errorFn(fmt.status('INFO', `Did you mean: px ${suggestion}${buildSuggestionSuffix(suggestion)}`));
133
+ const libPath = node_path_1.default.join(__dirname, 'lib', 'commands', `${command}.js`);
134
+ // Special case: verify-env is an alias for mission-start diagnostic.
135
+ // active is now its own command (real agent-start path).
136
+ let targetLib = libPath;
137
+ if (command === 'verify-env') {
138
+ targetLib = node_path_1.default.join(__dirname, 'lib', 'commands', 'mission-start.js');
139
+ }
140
+ if (existsSyncFn(targetLib)) {
141
+ if (!READ_ONLY_COMMANDS.has(command)) {
142
+ const initResult = ensureStandaloneGitRepoFn(cwdFn());
143
+ if (initResult && initResult.failed) {
144
+ errorFn(fmt.status('FAIL', `Git init: ${initResult.message}`));
145
+ exitFn(1);
146
+ return;
147
+ }
148
+ if (initResult && initResult.initialized) {
149
+ logFn(fmt.status('INFO', `Initialized git repository for standalone parallix in ${cwdFn()} (branch ${initResult.branch || 'main'}).`));
150
+ }
151
+ }
152
+ const cmdModule = requireFn(targetLib);
153
+ if (typeof cmdModule === 'function') {
154
+ await cmdModule(args.slice(1), { command });
155
+ }
156
+ else {
157
+ errorFn(fmt.status('FAIL', `Command module '${command}' does not export a function.`));
158
+ exitFn(1);
159
+ }
160
+ }
161
+ else {
162
+ const aliases = loadAliasesFn({ rootDir: cwdFn() });
163
+ const canonical = resolveAlias(command, aliases);
164
+ if (canonical) {
165
+ logFn(fmt.status('INFO', `Resolving alias ${command} → ${canonical}`));
166
+ await main([canonical, ...args.slice(1)], { existsSyncFn, cwdFn, ensureStandaloneGitRepoFn, requireFn, printUsageFn, exitFn, errorFn, logFn, loadAliasesFn });
167
+ return;
168
+ }
169
+ errorFn(fmt.status('FAIL', `Unknown command: ${command}`));
170
+ const suggestion = suggestCommand(command);
171
+ if (suggestion) {
172
+ errorFn(fmt.status('INFO', `Did you mean: px ${suggestion}${buildSuggestionSuffix(suggestion)}`));
173
+ }
174
+ printUsageFn();
175
+ exitFn(1);
151
176
  }
152
- printUsageFn();
153
- exitFn(1);
154
- }
155
177
  }
156
-
157
178
  function buildSuggestionSuffix(command) {
158
- if (command === 'diff' || command === 'resolve-conflict') {
159
- return ' <slug>';
160
- }
161
- if (command === 'checkpoint') {
162
- return ' <slug> <cp-name> "<next-action>"';
163
- }
164
- return '';
179
+ if (command === 'diff' || command === 'resolve-conflict') {
180
+ return ' <slug>';
181
+ }
182
+ if (command === 'checkpoint') {
183
+ return ' <slug> <cp-name> "<next-action>"';
184
+ }
185
+ return '';
165
186
  }
166
-
167
187
  function suggestCommand(input) {
168
- if (!input) return null;
169
- const normalizedInput = input.toLowerCase();
170
- let best = null;
171
-
172
- for (const candidate of KNOWN_COMMANDS) {
173
- const distance = levenshteinDistance(normalizedInput, candidate);
174
- if (distance > 2) continue;
175
- if (!best || distance < best.distance) {
176
- best = { candidate, distance };
188
+ if (!input) {
189
+ return null;
177
190
  }
178
- }
179
-
180
- return best ? best.candidate : null;
191
+ const normalizedInput = input.toLowerCase();
192
+ let best = null;
193
+ for (const candidate of exports.KNOWN_COMMANDS) {
194
+ const distance = levenshteinDistance(normalizedInput, candidate);
195
+ if (distance > 2) {
196
+ continue;
197
+ }
198
+ if (!best || distance < best.distance) {
199
+ best = { candidate, distance };
200
+ }
201
+ }
202
+ return best ? best.candidate : null;
181
203
  }
182
-
183
204
  function levenshteinDistance(a, b) {
184
- const rows = a.length + 1;
185
- const cols = b.length + 1;
186
- const dp = Array.from({ length: rows }, () => Array(cols).fill(0));
187
-
188
- for (let i = 0; i < rows; i += 1) dp[i][0] = i;
189
- for (let j = 0; j < cols; j += 1) dp[0][j] = j;
190
-
191
- for (let i = 1; i < rows; i += 1) {
192
- for (let j = 1; j < cols; j += 1) {
193
- const cost = a[i - 1] === b[j - 1] ? 0 : 1;
194
- dp[i][j] = Math.min(
195
- dp[i - 1][j] + 1,
196
- dp[i][j - 1] + 1,
197
- dp[i - 1][j - 1] + cost
198
- );
205
+ const rows = a.length + 1;
206
+ const cols = b.length + 1;
207
+ const dp = Array.from({ length: rows }, () => Array(cols).fill(0));
208
+ for (let i = 0; i < rows; i += 1) {
209
+ dp[i][0] = i;
199
210
  }
200
- }
201
-
202
- return dp[a.length][b.length];
211
+ for (let j = 0; j < cols; j += 1) {
212
+ dp[0][j] = j;
213
+ }
214
+ for (let i = 1; i < rows; i += 1) {
215
+ for (let j = 1; j < cols; j += 1) {
216
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
217
+ dp[i][j] = Math.min(dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + cost);
218
+ }
219
+ }
220
+ return dp[a.length][b.length];
203
221
  }
204
-
205
222
  function printUsage() {
206
- fmt.log.plain(`
223
+ fmt.log.plain(`
207
224
  Usage: px <command> [args]
208
225
 
209
226
  ${fmt.bold('Core Commands:')}
@@ -239,19 +256,7 @@ ${fmt.bold('Notes:')}
239
256
  - No npm dependencies — requires Node.js built-ins only.
240
257
  `);
241
258
  }
242
-
243
- if (require.main === module) {
244
- main();
259
+ // Run main when executed directly (compiled to CJS, require.main === module applies)
260
+ if (typeof require !== 'undefined' && require.main === module) {
261
+ main();
245
262
  }
246
-
247
- module.exports = {
248
- KNOWN_COMMANDS,
249
- main,
250
- printUsage,
251
- printAliases,
252
- suggestCommand,
253
- buildSuggestionSuffix,
254
- levenshteinDistance,
255
- deriveAliases,
256
- resolveAlias,
257
- };