@rasensio/aidlc 1.57.0 → 1.59.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 (46) hide show
  1. package/dist/autopilot/driver.d.ts.map +1 -1
  2. package/dist/autopilot/driver.js +30 -2
  3. package/dist/autopilot/driver.js.map +1 -1
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/cli.js +2 -0
  6. package/dist/cli.js.map +1 -1
  7. package/dist/commands/revert.d.ts +35 -0
  8. package/dist/commands/revert.d.ts.map +1 -0
  9. package/dist/commands/revert.js +184 -0
  10. package/dist/commands/revert.js.map +1 -0
  11. package/dist/commands/roadmap.d.ts +2 -1
  12. package/dist/commands/roadmap.d.ts.map +1 -1
  13. package/dist/commands/roadmap.js +23 -7
  14. package/dist/commands/roadmap.js.map +1 -1
  15. package/dist/menu/roster.d.ts.map +1 -1
  16. package/dist/menu/roster.js +2 -0
  17. package/dist/menu/roster.js.map +1 -1
  18. package/dist/revert/apply.d.ts +40 -0
  19. package/dist/revert/apply.d.ts.map +1 -0
  20. package/dist/revert/apply.js +144 -0
  21. package/dist/revert/apply.js.map +1 -0
  22. package/dist/revert/commits.d.ts +44 -0
  23. package/dist/revert/commits.d.ts.map +1 -0
  24. package/dist/revert/commits.js +92 -0
  25. package/dist/revert/commits.js.map +1 -0
  26. package/dist/revert/plan.d.ts +55 -0
  27. package/dist/revert/plan.d.ts.map +1 -0
  28. package/dist/revert/plan.js +60 -0
  29. package/dist/revert/plan.js.map +1 -0
  30. package/dist/revert/trailers.d.ts +26 -0
  31. package/dist/revert/trailers.d.ts.map +1 -0
  32. package/dist/revert/trailers.js +29 -0
  33. package/dist/revert/trailers.js.map +1 -0
  34. package/dist/roadmap/next.d.ts +13 -2
  35. package/dist/roadmap/next.d.ts.map +1 -1
  36. package/dist/roadmap/next.js +18 -1
  37. package/dist/roadmap/next.js.map +1 -1
  38. package/dist/roadmap/promote.d.ts +9 -0
  39. package/dist/roadmap/promote.d.ts.map +1 -1
  40. package/dist/roadmap/promote.js +21 -11
  41. package/dist/roadmap/promote.js.map +1 -1
  42. package/dist/tasks/reset.d.ts +18 -0
  43. package/dist/tasks/reset.d.ts.map +1 -0
  44. package/dist/tasks/reset.js +28 -0
  45. package/dist/tasks/reset.js.map +1 -0
  46. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"roster.d.ts","sourceRoot":"","sources":["../../src/menu/roster.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,wEAAwE;AACxE,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;AAE/E,MAAM,WAAW,SAAS;IACxB,gFAAgF;IAChF,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC;CAC/B;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,SAAS,SAAS,EAqBtC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAsCvD,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAM7C,CAAC"}
1
+ {"version":3,"file":"roster.d.ts","sourceRoot":"","sources":["../../src/menu/roster.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,wEAAwE;AACxE,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;AAE/E,MAAM,WAAW,SAAS;IACxB,gFAAgF;IAChF,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC;CAC/B;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,SAAS,SAAS,EAqBtC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAyCvD,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAM7C,CAAC"}
@@ -82,6 +82,8 @@ export const EXCLUSIONS = {
82
82
  'cross-check': 'needs an instance at the start of its implementation phase, and the menu reads no project ' +
83
83
  'state so it cannot tell which one that is; the implementation skill offers it at that ' +
84
84
  'moment (cross-artifact-check/AC-17, AC-18).',
85
+ revert: 'needs an instance in its implementation phase and a task id, and the menu reads no project ' +
86
+ 'state so it cannot tell which; the implementation skill names it (revert-by-task/AC-1, AC-23).',
85
87
  };
86
88
  /** Bucket order for grouping; matches the order entries appear in `ROSTER`. */
87
89
  export const BUCKET_ORDER = [
@@ -1 +1 @@
1
- {"version":3,"file":"roster.js","sourceRoot":"","sources":["../../src/menu/roster.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAkBH;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAyB;IAC1C,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,8BAA8B,EAAE;IAC1E,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE;IACjE,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO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AK,EAAE,0BAA0B,EAAE;CAC1E,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAqC;IAC1D,IAAI,EAAE,yDAAyD;IAC/D,UAAU,EAAE,kDAAkD;IAC9D,KAAK,EAAE,mCAAmC;IAC1C,OAAO,EAAE,mCAAmC;IAC5C,GAAG,EAAE,oEAAoE;IACzE,SAAS,EACP,qFAAqF;IACvF,KAAK,EAAE,mCAAmC;IAC1C,IAAI,EAAE,QAAQ;IACd,UAAU,EACR,8EAA8E;QAC9E,gFAAgF;QAChF,yEAAyE;QACzE,qEAAqE;IACvE,YAAY,EACV,kGAAkG;IACpG,OAAO,EACL,mFAAmF;QACnF,uFAAuF;QACvF,uFAAuF;QACvF,8FAA8F;IAChG,KAAK,EACH,2FAA2F;QAC3F,4FAA4F;QAC5F,8EAA8E;QAC9E,4BAA4B;IAC9B,SAAS,EACP,oFAAoF;QACpF,0FAA0F;QAC1F,uCAAuC;IACzC,IAAI,EACF,2FAA2F;QAC3F,gGAAgG;IAClG,aAAa,EACX,4FAA4F;QAC5F,wFAAwF;QACxF,6CAA6C;IAC/C,MAAM,EACJ,6FAA6F;QAC7F,gGAAgG;CACnG,CAAC;AAEF,+EAA+E;AAC/E,MAAM,CAAC,MAAM,YAAY,GAA0B;IACjD,OAAO;IACP,OAAO;IACP,QAAQ;IACR,SAAS;IACT,UAAU;CACX,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Undo a plan's commits as one new commit (revert-by-task D2).
3
+ *
4
+ * The working tree was clean when this starts (`checkRepo`, AC-18), so every
5
+ * failure path can return to the recorded `HEAD` with `reset --hard` and lose
6
+ * nothing but what this run wrote (AC-17).
7
+ *
8
+ * Lifecycle state is never reverted by git: a task commit may carry its own
9
+ * `[x]`, phase YAML or cost records, and undoing those would rewind state by
10
+ * accident. `.aidlc/state/` is restored from `HEAD` after the revert, and the
11
+ * only state change is the checkbox reset this module writes (D3, AC-16).
12
+ *
13
+ * The new commit carries no `Task:` trailer — it would otherwise be selected
14
+ * by the next `--task` run and undone, re-applying the work.
15
+ *
16
+ * Requirements: revert-by-task/AC-15, AC-16, AC-17
17
+ */
18
+ import { type Plan } from './plan.js';
19
+ export type ApplyResult = {
20
+ ok: true;
21
+ sha: string;
22
+ short: string;
23
+ reset: number[];
24
+ } | {
25
+ ok: false;
26
+ reason: 'conflict';
27
+ short: string;
28
+ subject: string;
29
+ } | {
30
+ ok: false;
31
+ reason: 'empty';
32
+ } | {
33
+ ok: false;
34
+ reason: 'commit-failed';
35
+ detail: string;
36
+ };
37
+ /** The commit message: subject, one summary line, then git's own revert lines. */
38
+ export declare function revertMessage(instance: string, plan: Plan): string;
39
+ export declare function applyRevert(projectRoot: string, instance: string, plan: Plan): ApplyResult;
40
+ //# sourceMappingURL=apply.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/revert/apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAQH,OAAO,EAA8B,KAAK,IAAI,EAAE,MAAM,WAAW,CAAC;AAElE,MAAM,MAAM,WAAW,GACnB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,GACzD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACjE;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC9B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAI3D,kFAAkF;AAClF,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAelE;AAgDD,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,WAAW,CA0D1F"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Undo a plan's commits as one new commit (revert-by-task D2).
3
+ *
4
+ * The working tree was clean when this starts (`checkRepo`, AC-18), so every
5
+ * failure path can return to the recorded `HEAD` with `reset --hard` and lose
6
+ * nothing but what this run wrote (AC-17).
7
+ *
8
+ * Lifecycle state is never reverted by git: a task commit may carry its own
9
+ * `[x]`, phase YAML or cost records, and undoing those would rewind state by
10
+ * accident. `.aidlc/state/` is restored from `HEAD` after the revert, and the
11
+ * only state change is the checkbox reset this module writes (D3, AC-16).
12
+ *
13
+ * The new commit carries no `Task:` trailer — it would otherwise be selected
14
+ * by the next `--task` run and undone, re-applying the work.
15
+ *
16
+ * Requirements: revert-by-task/AC-15, AC-16, AC-17
17
+ */
18
+ import { readFileSync, writeFileSync } from 'node:fs';
19
+ import { join } from 'node:path';
20
+ import { instancePath } from '../state/snapshot-store.js';
21
+ import { resetDone } from '../tasks/reset.js';
22
+ import { git } from './commits.js';
23
+ import { describeSelector, taskList } from './plan.js';
24
+ const STATE_DIR = '.aidlc/state';
25
+ /** The commit message: subject, one summary line, then git's own revert lines. */
26
+ export function revertMessage(instance, plan) {
27
+ const n = plan.commits.length;
28
+ const tagged = plan.selector.kind === 'task'
29
+ ? `Task: ${instance}/T${plan.selector.task}`
30
+ : `a task of ${instance}`;
31
+ return [
32
+ `revert(${instance}): undo ${describeSelector(plan.selector)}`,
33
+ '',
34
+ `Undoes ${n} commit${n === 1 ? '' : 's'} tagged with ${tagged}. ` +
35
+ `Resets ${taskList(plan.resetTasks)} in tasks.md.`,
36
+ '',
37
+ ...plan.commits.map((c) => `This reverts commit ${c.sha}.`),
38
+ '',
39
+ ].join('\n');
40
+ }
41
+ function abandon(projectRoot, head) {
42
+ // `--quit` clears any sequencer state a failed revert left; it fails
43
+ // harmlessly when there is none.
44
+ try {
45
+ git(projectRoot, ['revert', '--quit']);
46
+ }
47
+ catch {
48
+ /* nothing in progress */
49
+ }
50
+ git(projectRoot, ['reset', '-q', '--hard', head]);
51
+ }
52
+ /**
53
+ * After git stopped a revert, resolve it when every conflict is under
54
+ * `.aidlc/state/`, and say whether it did. A task commit usually ticks its own
55
+ * box, so undoing it collides with the next task's tick on the adjacent line;
56
+ * state is restored from `HEAD` regardless (D3), so taking `HEAD`'s state now
57
+ * loses nothing. No unmerged path at all means git failed for another reason.
58
+ */
59
+ function resolvedInState(projectRoot) {
60
+ try {
61
+ const paths = git(projectRoot, ['diff', '--name-only', '-z', '--diff-filter=U']).split('\0').filter(Boolean);
62
+ if (paths.length === 0 || !paths.every((p) => p.startsWith(`${STATE_DIR}/`)))
63
+ return false;
64
+ git(projectRoot, ['restore', '--source=HEAD', '--staged', '--worktree', '--', STATE_DIR]);
65
+ // Clears the stopped revert so the next commit can be undone.
66
+ git(projectRoot, ['revert', '--quit']);
67
+ return true;
68
+ }
69
+ catch {
70
+ return false;
71
+ }
72
+ }
73
+ function isTracked(projectRoot, path) {
74
+ try {
75
+ git(projectRoot, ['ls-files', '--error-unmatch', '--', path]);
76
+ return true;
77
+ }
78
+ catch {
79
+ return false;
80
+ }
81
+ }
82
+ function firstLine(err) {
83
+ const e = err;
84
+ const text = (e.stderr || e.message || String(err)).trim();
85
+ return text.split('\n')[0] ?? '';
86
+ }
87
+ export function applyRevert(projectRoot, instance, plan) {
88
+ const head = git(projectRoot, ['rev-parse', 'HEAD']).trim();
89
+ // Validates the instance name as a single path segment before it reaches git.
90
+ const tasksAbs = join(instancePath(join(projectRoot, STATE_DIR), instance), 'tasks.md');
91
+ const tasksRel = `${STATE_DIR}/${instance}/tasks.md`;
92
+ // Newest first, so each inverse applies over the tree its successor left.
93
+ for (const c of plan.commits) {
94
+ try {
95
+ git(projectRoot, ['revert', '--no-commit', c.sha]);
96
+ }
97
+ catch {
98
+ if (!resolvedInState(projectRoot)) {
99
+ abandon(projectRoot, head);
100
+ return { ok: false, reason: 'conflict', short: c.short, subject: c.subject };
101
+ }
102
+ }
103
+ }
104
+ const stateTracked = git(projectRoot, ['ls-tree', '-d', '--name-only', 'HEAD', '--', STATE_DIR]).trim() !== '';
105
+ const stateStaged = git(projectRoot, ['diff', '--cached', '--name-only', '--', STATE_DIR]).trim() !== '';
106
+ if (stateTracked || stateStaged) {
107
+ git(projectRoot, ['restore', '--source=HEAD', '--staged', '--worktree', '--', STATE_DIR]);
108
+ }
109
+ let tasksContent = null;
110
+ try {
111
+ tasksContent = readFileSync(tasksAbs, 'utf8');
112
+ }
113
+ catch {
114
+ /* no tasks.md: nothing to reset */
115
+ }
116
+ const reset = tasksContent === null ? { content: '', reset: [] } : resetDone(tasksContent, plan.resetTasks);
117
+ const tasksTracked = reset.reset.length > 0 && isTracked(projectRoot, tasksRel);
118
+ if (tasksTracked) {
119
+ writeFileSync(tasksAbs, reset.content);
120
+ git(projectRoot, ['add', '--', tasksRel]);
121
+ }
122
+ try {
123
+ git(projectRoot, ['diff', '--cached', '--quiet']);
124
+ abandon(projectRoot, head);
125
+ return { ok: false, reason: 'empty' };
126
+ }
127
+ catch {
128
+ /* staged changes exist — the normal case */
129
+ }
130
+ try {
131
+ git(projectRoot, ['commit', '-q', '-F', '-'], revertMessage(instance, plan));
132
+ }
133
+ catch (err) {
134
+ abandon(projectRoot, head);
135
+ return { ok: false, reason: 'commit-failed', detail: firstLine(err) };
136
+ }
137
+ // An untracked (ignored) tasks.md cannot ride in the commit; write it only
138
+ // once the commit exists, so a failure above leaves it untouched.
139
+ if (reset.reset.length > 0 && !tasksTracked)
140
+ writeFileSync(tasksAbs, reset.content);
141
+ const sha = git(projectRoot, ['rev-parse', 'HEAD']).trim();
142
+ return { ok: true, sha, short: sha.slice(0, 7), reset: reset.reset };
143
+ }
144
+ //# sourceMappingURL=apply.js.map
@@ -0,0 +1 @@
1
+ {"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EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC;QAClD,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAC3B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,4CAA4C;IAC9C,CAAC;IAED,IAAI,CAAC;QACH,GAAG,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;IAC/E,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAC3B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;IACxE,CAAC;IAED,2EAA2E;IAC3E,kEAAkE;IAClE,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,YAAY;QAAE,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAEpF,MAAM,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3D,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;AACvE,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Git reads for `aidlc revert`: is this a branch we may revert on, and which
3
+ * commits has it made since it left `main`.
4
+ *
5
+ * `main` is the base branch the rest of the CLI hard-codes
6
+ * (`concurrency/worktree.ts`, `autopilot/driver.ts`); merged work on `main` is
7
+ * out of scope (revert-by-task/AC-22). Every call is `execFileSync` with an
8
+ * argument array — no shell string ever carries a name from argv.
9
+ *
10
+ * Requirements: revert-by-task/AC-2, AC-3, AC-6, AC-9, AC-18, AC-21, AC-22
11
+ */
12
+ import { type TaskRef } from './trailers.js';
13
+ /** One commit in `main..HEAD`. */
14
+ export interface BranchCommit {
15
+ sha: string;
16
+ short: string;
17
+ subject: string;
18
+ /** Parent count; more than one is a merge (AC-9). */
19
+ parents: number;
20
+ /** Tasks named by well-formed `Task:` trailers. */
21
+ tasks: TaskRef[];
22
+ /** Full shas this commit's message says it reverts (AC-6). */
23
+ reverts: string[];
24
+ }
25
+ export type RepoMiss = 'not-a-repo' | 'no-main' | 'on-main' | 'dirty';
26
+ export type RepoCheck = {
27
+ ok: true;
28
+ branch: string;
29
+ } | {
30
+ ok: false;
31
+ reason: RepoMiss;
32
+ };
33
+ /** Run git in the project root and return stdout; throws on a non-zero exit. */
34
+ export declare function git(projectRoot: string, args: string[], input?: string): string;
35
+ /**
36
+ * The preconditions every revert needs, in the order the command reports
37
+ * them: a work tree, a `main` branch, not standing on it, and no uncommitted
38
+ * change to a tracked file (untracked files cannot be lost by a revert and do
39
+ * not block it).
40
+ */
41
+ export declare function checkRepo(projectRoot: string): RepoCheck;
42
+ /** Commits reachable from HEAD and not from `main`, newest first. */
43
+ export declare function branchCommits(projectRoot: string): BranchCommit[];
44
+ //# sourceMappingURL=commits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commits.d.ts","sourceRoot":"","sources":["../../src/revert/commits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAkC,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7E,kCAAkC;AAClC,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAEtE,MAAM,MAAM,SAAS,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEvF,gFAAgF;AAChF,wBAAgB,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAO/E;AAWD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAiBxD;AAWD,qEAAqE;AACrE,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,EAAE,CAsBjE"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Git reads for `aidlc revert`: is this a branch we may revert on, and which
3
+ * commits has it made since it left `main`.
4
+ *
5
+ * `main` is the base branch the rest of the CLI hard-codes
6
+ * (`concurrency/worktree.ts`, `autopilot/driver.ts`); merged work on `main` is
7
+ * out of scope (revert-by-task/AC-22). Every call is `execFileSync` with an
8
+ * argument array — no shell string ever carries a name from argv.
9
+ *
10
+ * Requirements: revert-by-task/AC-2, AC-3, AC-6, AC-9, AC-18, AC-21, AC-22
11
+ */
12
+ import { execFileSync } from 'node:child_process';
13
+ import { parseTaskTrailer, revertedShas } from './trailers.js';
14
+ /** Run git in the project root and return stdout; throws on a non-zero exit. */
15
+ export function git(projectRoot, args, input) {
16
+ return execFileSync('git', args, {
17
+ cwd: projectRoot,
18
+ encoding: 'utf8',
19
+ input,
20
+ stdio: ['pipe', 'pipe', 'pipe'],
21
+ });
22
+ }
23
+ function succeeds(projectRoot, args) {
24
+ try {
25
+ git(projectRoot, args);
26
+ return true;
27
+ }
28
+ catch {
29
+ return false;
30
+ }
31
+ }
32
+ /**
33
+ * The preconditions every revert needs, in the order the command reports
34
+ * them: a work tree, a `main` branch, not standing on it, and no uncommitted
35
+ * change to a tracked file (untracked files cannot be lost by a revert and do
36
+ * not block it).
37
+ */
38
+ export function checkRepo(projectRoot) {
39
+ if (!succeeds(projectRoot, ['rev-parse', '--is-inside-work-tree'])) {
40
+ return { ok: false, reason: 'not-a-repo' };
41
+ }
42
+ if (!succeeds(projectRoot, ['rev-parse', '--verify', '--quiet', 'refs/heads/main'])) {
43
+ return { ok: false, reason: 'no-main' };
44
+ }
45
+ let branch = '';
46
+ try {
47
+ branch = git(projectRoot, ['symbolic-ref', '-q', 'HEAD']).trim();
48
+ }
49
+ catch {
50
+ // Detached HEAD: main..HEAD is still well defined, so it is allowed.
51
+ }
52
+ if (branch === 'refs/heads/main')
53
+ return { ok: false, reason: 'on-main' };
54
+ const dirty = git(projectRoot, ['status', '--porcelain', '--untracked-files=no']).trim();
55
+ if (dirty !== '')
56
+ return { ok: false, reason: 'dirty' };
57
+ return { ok: true, branch: branch.replace(/^refs\/heads\//, '') || 'HEAD' };
58
+ }
59
+ // NUL separates every field, and `-z` ends every record with one. It is the
60
+ // only byte no message can carry: `git commit` refuses a NUL, and git cuts a
61
+ // hand-built message's output at one. Other control characters survive in a
62
+ // message — a body carrying the old \x1e/\x1f separators forged a second
63
+ // record naming a commit on main (revert-by-task/AC-2). Trailer values are
64
+ // unfolded, so a newline cannot occur inside one and separates them.
65
+ const FIELDS = ['%H', '%h', '%P', '%s', '%(trailers:key=Task,valueonly,unfold,separator=%x0a)', '%b'];
66
+ const FORMAT = FIELDS.join('%x00');
67
+ /** Commits reachable from HEAD and not from `main`, newest first. */
68
+ export function branchCommits(projectRoot) {
69
+ const out = git(projectRoot, ['log', '-z', `--format=${FORMAT}`, 'main..HEAD']);
70
+ const fields = out.split('\0');
71
+ fields.pop(); // the empty string after the last record's terminator
72
+ const commits = [];
73
+ for (let i = 0; i + FIELDS.length <= fields.length; i += FIELDS.length) {
74
+ const [sha, short, parents, subject, trailers, body] = fields.slice(i, i + FIELDS.length);
75
+ const tasks = [];
76
+ for (const value of trailers.split('\n')) {
77
+ const ref = parseTaskTrailer(value);
78
+ if (ref)
79
+ tasks.push(ref);
80
+ }
81
+ commits.push({
82
+ sha,
83
+ short,
84
+ subject,
85
+ parents: parents.trim() === '' ? 0 : parents.trim().split(' ').length,
86
+ tasks,
87
+ reverts: revertedShas(body),
88
+ });
89
+ }
90
+ return commits;
91
+ }
92
+ //# sourceMappingURL=commits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commits.js","sourceRoot":"","sources":["../../src/revert/commits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAgB,MAAM,eAAe,CAAC;AAmB7E,gFAAgF;AAChF,MAAM,UAAU,GAAG,CAAC,WAAmB,EAAE,IAAc,EAAE,KAAc;IACrE,OAAO,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE;QAC/B,GAAG,EAAE,WAAW;QAChB,QAAQ,EAAE,MAAM;QAChB,KAAK;QACL,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;KAChC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,QAAQ,CAAC,WAAmB,EAAE,IAAc;IACnD,IAAI,CAAC;QACH,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,WAAmB;IAC3C,IAAI,CAAC,QAAQ,CAAC,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AO,EAAE,YAAY,CAAC,IAAI,CAAC;SAC5B,CAAC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Choose the commits a revert undoes and say so before anything changes.
3
+ *
4
+ * Pure: takes the branch's commits as `branchCommits()` returns them (newest
5
+ * first) and decides. The plan is the whole safety story the roadmap item
6
+ * asks for — "it must show the plan and ask first" — so every commit that also
7
+ * belongs to another task is marked `shared` in words, never by colour alone
8
+ * (revert-by-task/AC-11).
9
+ *
10
+ * Requirements: revert-by-task/AC-2, AC-3, AC-6, AC-8, AC-9, AC-10, AC-11
11
+ */
12
+ import type { BranchCommit } from './commits.js';
13
+ /** `--task T<n>` or `--phase implementation` (every task of the instance). */
14
+ export type Selector = {
15
+ kind: 'task';
16
+ task: number;
17
+ } | {
18
+ kind: 'phase';
19
+ };
20
+ export interface PlanCommit {
21
+ sha: string;
22
+ short: string;
23
+ subject: string;
24
+ /** This instance's tasks the commit names, ascending. */
25
+ tasks: number[];
26
+ /** Of those, the ones the selector did not ask for (AC-11). */
27
+ shared: number[];
28
+ }
29
+ export interface Plan {
30
+ selector: Selector;
31
+ /** Newest first — the order they are undone in. */
32
+ commits: PlanCommit[];
33
+ /** Every task of this instance a selected commit names, ascending. */
34
+ resetTasks: number[];
35
+ }
36
+ export type PlanResult = {
37
+ ok: true;
38
+ plan: Plan;
39
+ } | {
40
+ ok: false;
41
+ reason: 'no-commits';
42
+ } | {
43
+ ok: false;
44
+ reason: 'merge-commit';
45
+ short: string;
46
+ subject: string;
47
+ };
48
+ export declare function buildPlan(instance: string, selector: Selector, commits: BranchCommit[]): PlanResult;
49
+ /** `T3` or `T3, T4`. */
50
+ export declare function taskList(ids: number[]): string;
51
+ /** What the selector names, for the plan heading and the commit subject. */
52
+ export declare function describeSelector(selector: Selector): string;
53
+ /** The plan as printed before the question (AC-10, AC-11). */
54
+ export declare function formatPlan(instance: string, plan: Plan, branch: string): string[];
55
+ //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GAAG,MAAM,CAE9C;AAED,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAE3D;AAED,8DAA8D;AAC9D,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAajF"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Choose the commits a revert undoes and say so before anything changes.
3
+ *
4
+ * Pure: takes the branch's commits as `branchCommits()` returns them (newest
5
+ * first) and decides. The plan is the whole safety story the roadmap item
6
+ * asks for — "it must show the plan and ask first" — so every commit that also
7
+ * belongs to another task is marked `shared` in words, never by colour alone
8
+ * (revert-by-task/AC-11).
9
+ *
10
+ * Requirements: revert-by-task/AC-2, AC-3, AC-6, AC-8, AC-9, AC-10, AC-11
11
+ */
12
+ const ascending = (a, b) => a - b;
13
+ export function buildPlan(instance, selector, commits) {
14
+ // A commit can only revert an older one, so collecting across the whole
15
+ // range is the same as "a later commit reverts it" (AC-6).
16
+ const undone = new Set(commits.flatMap((c) => c.reverts));
17
+ const selected = [];
18
+ for (const c of commits) {
19
+ if (undone.has(c.sha))
20
+ continue;
21
+ const tasks = [...new Set(c.tasks.filter((t) => t.instance === instance).map((t) => t.task))]
22
+ .sort(ascending);
23
+ if (tasks.length === 0)
24
+ continue;
25
+ if (selector.kind === 'task' && !tasks.includes(selector.task))
26
+ continue;
27
+ if (c.parents > 1)
28
+ return { ok: false, reason: 'merge-commit', short: c.short, subject: c.subject };
29
+ const shared = selector.kind === 'task' ? tasks.filter((t) => t !== selector.task) : [];
30
+ selected.push({ sha: c.sha, short: c.short, subject: c.subject, tasks, shared });
31
+ }
32
+ if (selected.length === 0)
33
+ return { ok: false, reason: 'no-commits' };
34
+ const resetTasks = [...new Set(selected.flatMap((c) => c.tasks))].sort(ascending);
35
+ return { ok: true, plan: { selector, commits: selected, resetTasks } };
36
+ }
37
+ /** `T3` or `T3, T4`. */
38
+ export function taskList(ids) {
39
+ return ids.map((n) => `T${n}`).join(', ');
40
+ }
41
+ /** What the selector names, for the plan heading and the commit subject. */
42
+ export function describeSelector(selector) {
43
+ return selector.kind === 'task' ? `T${selector.task}` : 'the implementation phase';
44
+ }
45
+ /** The plan as printed before the question (AC-10, AC-11). */
46
+ export function formatPlan(instance, plan, branch) {
47
+ const n = plan.commits.length;
48
+ const lines = [
49
+ `Plan: undo ${describeSelector(plan.selector)} of ${instance} — ` +
50
+ `${n} commit${n === 1 ? '' : 's'} on ${branch} since main, newest first:`,
51
+ ];
52
+ for (const c of plan.commits) {
53
+ const shared = c.shared.length > 0 ? ` — shared: also ${taskList(c.shared)}` : '';
54
+ lines.push(` ${c.short} ${c.subject} [${taskList(c.tasks)}]${shared}`);
55
+ }
56
+ lines.push(`Tasks reset to open in tasks.md (if done): ${taskList(plan.resetTasks)}`);
57
+ lines.push('Nothing under .aidlc/state/ changes except those checkboxes.');
58
+ return lines;
59
+ }
60
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/revert/plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA8BH,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AAE1D,MAAM,UAAU,SAAS,CACvB,QAAgB,EAChB,QAAkB,EAClB,OAAuB;IAEvB,wEAAwE;IACxE,2DAA2D;IAC3D,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAE1D,MAAM,QAAQ,GAAiB,EAAE,CAAC;IAClC,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;YAAE,SAAS;QA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AAC,KAAK,KAAK,CAAC,CAAC,OAAO,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC;IAC5E,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,8CAA8C,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACtF,KAAK,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;IAC3E,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Pure readers for the two commit-message lines `aidlc revert` trusts: the
3
+ * `Task:` trailer that ties a commit to a task, and git's own
4
+ * `This reverts commit <sha>.` line that marks one as already undone.
5
+ *
6
+ * Nothing here reads subjects. A subject mentioning "T3" for another reason
7
+ * must never select a commit (revert-by-task D1).
8
+ *
9
+ * Requirements: revert-by-task/AC-2, AC-3, AC-6
10
+ */
11
+ /** One task a commit's trailer names. */
12
+ export interface TaskRef {
13
+ instance: string;
14
+ /** n in T<n>. */
15
+ task: number;
16
+ }
17
+ /**
18
+ * Parse one `Task:` trailer value (`<instance>/T<n>`).
19
+ *
20
+ * @returns null for anything else — an unqualified `T3` or free text names no
21
+ * task, so it selects nothing.
22
+ */
23
+ export declare function parseTaskTrailer(value: string): TaskRef | null;
24
+ /** Full shas named by `This reverts commit <sha>.` lines in a commit body. */
25
+ export declare function revertedShas(body: string): string[];
26
+ //# sourceMappingURL=trailers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trailers.d.ts","sourceRoot":"","sources":["../../src/revert/trailers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,yCAAyC;AACzC,MAAM,WAAW,OAAO;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAQD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAG9D;AAED,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAEnD"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Pure readers for the two commit-message lines `aidlc revert` trusts: the
3
+ * `Task:` trailer that ties a commit to a task, and git's own
4
+ * `This reverts commit <sha>.` line that marks one as already undone.
5
+ *
6
+ * Nothing here reads subjects. A subject mentioning "T3" for another reason
7
+ * must never select a commit (revert-by-task D1).
8
+ *
9
+ * Requirements: revert-by-task/AC-2, AC-3, AC-6
10
+ */
11
+ // Instance names are lowercase kebab-case single segments; task ids carry no
12
+ // leading zero, matching the tasks.md grammar (tasks/parser.ts).
13
+ const TASK_TRAILER_RE = /^([a-z0-9][a-z0-9-]*)\/T([1-9][0-9]*)$/;
14
+ const REVERTS_RE = /^This reverts commit ([0-9a-f]{40})\.?\s*$/gm;
15
+ /**
16
+ * Parse one `Task:` trailer value (`<instance>/T<n>`).
17
+ *
18
+ * @returns null for anything else — an unqualified `T3` or free text names no
19
+ * task, so it selects nothing.
20
+ */
21
+ export function parseTaskTrailer(value) {
22
+ const m = TASK_TRAILER_RE.exec(value.trim());
23
+ return m ? { instance: m[1], task: Number(m[2]) } : null;
24
+ }
25
+ /** Full shas named by `This reverts commit <sha>.` lines in a commit body. */
26
+ export function revertedShas(body) {
27
+ return [...body.matchAll(REVERTS_RE)].map((m) => m[1]);
28
+ }
29
+ //# sourceMappingURL=trailers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trailers.js","sourceRoot":"","sources":["../../src/revert/trailers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,6EAA6E;AAC7E,iEAAiE;AACjE,MAAM,eAAe,GAAG,wCAAwC,CAAC;AAEjE,MAAM,UAAU,GAAG,8CAA8C,CAAC;AAElE;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,MAAM,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7C,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3D,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzD,CAAC"}
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * "What next?" answered the same way every time (autopilot-priority/AC-1..AC-7).
3
3
  *
4
- * The ready set is `backlog/` items whose `depends_on` ids are all in `done/`; the
4
+ * The ready set is `backlog/` items whose `depends_on` ids are all in `done/` and
5
+ * that `start --roadmap-item` would take (`promotionRefusal`); the
5
6
  * order is `priority` (a rank: 1 is first) with unranked items last, then file
6
7
  * name. Read-only by construction — nothing here writes, so the one thing a
7
8
  * driver that works the backlog must never do, promote, is out of its reach.
@@ -11,6 +12,7 @@
11
12
  *
12
13
  * @module
13
14
  */
15
+ import { type RoadmapItem } from './paths.js';
14
16
  export interface NextCandidate {
15
17
  file: string;
16
18
  id: string | null;
@@ -19,9 +21,18 @@ export interface NextCandidate {
19
21
  }
20
22
  export interface Skipped {
21
23
  file: string;
22
- reason: 'bad-priority' | 'blocked';
24
+ reason: 'bad-priority' | 'blocked' | 'promoted';
23
25
  detail: string;
24
26
  }
27
+ /**
28
+ * Why `start --roadmap-item` refuses this item, or null when it would take it.
29
+ *
30
+ * Shared with `findPromotable` for the reason `parsePriority` is shared with `rank`:
31
+ * on 2026-10-04 `next` offered an item un-parked by hand with its link still set,
32
+ * `start` refused it, and autopilot asked again once a minute for five hours
33
+ * (autopilot-start-failure-blocks-queue/AC-12).
34
+ */
35
+ export declare function promotionRefusal(item: Pick<RoadmapItem, 'promotedTo'>): string | null;
25
36
  export interface NextResult {
26
37
  next: NextCandidate | null;
27
38
  ready: NextCandidate[];
@@ -1 +1 @@
1
- {"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../src/roadmap/next.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,yGAAyG;IACzG,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,EAAE,CAAC;CACpD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,CAIjE;AAED,wFAAwF;AACxF,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,MAAM,CAO5E;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CA0ChD"}
1
+ {"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../src/roadmap/next.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAA0C,KAAK,WAAW,EAAE,MAAM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