@rasensio/aidlc 0.1.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 (187) hide show
  1. package/README.md +251 -0
  2. package/capabilities/claude-code.yaml +9 -0
  3. package/capabilities/codex.yaml +8 -0
  4. package/capabilities/cursor.yaml +8 -0
  5. package/capabilities/kiro.yaml +9 -0
  6. package/capabilities/windsurf.yaml +8 -0
  7. package/ci/aidlc-gate.yml +100 -0
  8. package/dist/cli.d.ts +11 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +39 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/commands/add-action.d.ts +83 -0
  13. package/dist/commands/add-action.d.ts.map +1 -0
  14. package/dist/commands/add-action.js +437 -0
  15. package/dist/commands/add-action.js.map +1 -0
  16. package/dist/commands/continue.d.ts +23 -0
  17. package/dist/commands/continue.d.ts.map +1 -0
  18. package/dist/commands/continue.js +238 -0
  19. package/dist/commands/continue.js.map +1 -0
  20. package/dist/commands/discover.d.ts +19 -0
  21. package/dist/commands/discover.d.ts.map +1 -0
  22. package/dist/commands/discover.js +85 -0
  23. package/dist/commands/discover.js.map +1 -0
  24. package/dist/commands/docs.d.ts +25 -0
  25. package/dist/commands/docs.d.ts.map +1 -0
  26. package/dist/commands/docs.js +282 -0
  27. package/dist/commands/docs.js.map +1 -0
  28. package/dist/commands/gate.d.ts +25 -0
  29. package/dist/commands/gate.d.ts.map +1 -0
  30. package/dist/commands/gate.js +168 -0
  31. package/dist/commands/gate.js.map +1 -0
  32. package/dist/commands/init.d.ts +24 -0
  33. package/dist/commands/init.d.ts.map +1 -0
  34. package/dist/commands/init.js +187 -0
  35. package/dist/commands/init.js.map +1 -0
  36. package/dist/commands/review.d.ts +60 -0
  37. package/dist/commands/review.d.ts.map +1 -0
  38. package/dist/commands/review.js +264 -0
  39. package/dist/commands/review.js.map +1 -0
  40. package/dist/commands/setup.d.ts +24 -0
  41. package/dist/commands/setup.d.ts.map +1 -0
  42. package/dist/commands/setup.js +206 -0
  43. package/dist/commands/setup.js.map +1 -0
  44. package/dist/commands/start.d.ts +27 -0
  45. package/dist/commands/start.d.ts.map +1 -0
  46. package/dist/commands/start.js +243 -0
  47. package/dist/commands/start.js.map +1 -0
  48. package/dist/commands/status.d.ts +25 -0
  49. package/dist/commands/status.d.ts.map +1 -0
  50. package/dist/commands/status.js +263 -0
  51. package/dist/commands/status.js.map +1 -0
  52. package/dist/commands/transition.d.ts +30 -0
  53. package/dist/commands/transition.d.ts.map +1 -0
  54. package/dist/commands/transition.js +353 -0
  55. package/dist/commands/transition.js.map +1 -0
  56. package/dist/compile/adapters/claude-code.d.ts +24 -0
  57. package/dist/compile/adapters/claude-code.d.ts.map +1 -0
  58. package/dist/compile/adapters/claude-code.js +271 -0
  59. package/dist/compile/adapters/claude-code.js.map +1 -0
  60. package/dist/compile/adapters/codex.d.ts +19 -0
  61. package/dist/compile/adapters/codex.d.ts.map +1 -0
  62. package/dist/compile/adapters/codex.js +157 -0
  63. package/dist/compile/adapters/codex.js.map +1 -0
  64. package/dist/compile/adapters/cursor.d.ts +21 -0
  65. package/dist/compile/adapters/cursor.d.ts.map +1 -0
  66. package/dist/compile/adapters/cursor.js +181 -0
  67. package/dist/compile/adapters/cursor.js.map +1 -0
  68. package/dist/compile/adapters/index.d.ts +16 -0
  69. package/dist/compile/adapters/index.d.ts.map +1 -0
  70. package/dist/compile/adapters/index.js +26 -0
  71. package/dist/compile/adapters/index.js.map +1 -0
  72. package/dist/compile/adapters/kiro.d.ts +24 -0
  73. package/dist/compile/adapters/kiro.d.ts.map +1 -0
  74. package/dist/compile/adapters/kiro.js +222 -0
  75. package/dist/compile/adapters/kiro.js.map +1 -0
  76. package/dist/compile/adapters/windsurf.d.ts +25 -0
  77. package/dist/compile/adapters/windsurf.d.ts.map +1 -0
  78. package/dist/compile/adapters/windsurf.js +242 -0
  79. package/dist/compile/adapters/windsurf.js.map +1 -0
  80. package/dist/compile/install-plan.d.ts +49 -0
  81. package/dist/compile/install-plan.d.ts.map +1 -0
  82. package/dist/compile/install-plan.js +112 -0
  83. package/dist/compile/install-plan.js.map +1 -0
  84. package/dist/compile/loaders.d.ts +81 -0
  85. package/dist/compile/loaders.d.ts.map +1 -0
  86. package/dist/compile/loaders.js +293 -0
  87. package/dist/compile/loaders.js.map +1 -0
  88. package/dist/compile/merger.d.ts +32 -0
  89. package/dist/compile/merger.d.ts.map +1 -0
  90. package/dist/compile/merger.js +60 -0
  91. package/dist/compile/merger.js.map +1 -0
  92. package/dist/core/gate.d.ts +36 -0
  93. package/dist/core/gate.d.ts.map +1 -0
  94. package/dist/core/gate.js +97 -0
  95. package/dist/core/gate.js.map +1 -0
  96. package/dist/core/index.d.ts +7 -0
  97. package/dist/core/index.d.ts.map +1 -0
  98. package/dist/core/index.js +7 -0
  99. package/dist/core/index.js.map +1 -0
  100. package/dist/core/lifecycle.d.ts +89 -0
  101. package/dist/core/lifecycle.d.ts.map +1 -0
  102. package/dist/core/lifecycle.js +356 -0
  103. package/dist/core/lifecycle.js.map +1 -0
  104. package/dist/core/template-resolver.d.ts +56 -0
  105. package/dist/core/template-resolver.d.ts.map +1 -0
  106. package/dist/core/template-resolver.js +261 -0
  107. package/dist/core/template-resolver.js.map +1 -0
  108. package/dist/core/types.d.ts +527 -0
  109. package/dist/core/types.d.ts.map +1 -0
  110. package/dist/core/types.js +8 -0
  111. package/dist/core/types.js.map +1 -0
  112. package/dist/discover/scanner.d.ts +58 -0
  113. package/dist/discover/scanner.d.ts.map +1 -0
  114. package/dist/discover/scanner.js +772 -0
  115. package/dist/discover/scanner.js.map +1 -0
  116. package/dist/events/event-bus.d.ts +53 -0
  117. package/dist/events/event-bus.d.ts.map +1 -0
  118. package/dist/events/event-bus.js +263 -0
  119. package/dist/events/event-bus.js.map +1 -0
  120. package/dist/events/plugin-hooks.d.ts +44 -0
  121. package/dist/events/plugin-hooks.d.ts.map +1 -0
  122. package/dist/events/plugin-hooks.js +225 -0
  123. package/dist/events/plugin-hooks.js.map +1 -0
  124. package/dist/orchestrator/budget-packer.d.ts +57 -0
  125. package/dist/orchestrator/budget-packer.d.ts.map +1 -0
  126. package/dist/orchestrator/budget-packer.js +70 -0
  127. package/dist/orchestrator/budget-packer.js.map +1 -0
  128. package/dist/orchestrator/config.d.ts +43 -0
  129. package/dist/orchestrator/config.d.ts.map +1 -0
  130. package/dist/orchestrator/config.js +109 -0
  131. package/dist/orchestrator/config.js.map +1 -0
  132. package/dist/orchestrator/endpoint-clients.d.ts +23 -0
  133. package/dist/orchestrator/endpoint-clients.d.ts.map +1 -0
  134. package/dist/orchestrator/endpoint-clients.js +129 -0
  135. package/dist/orchestrator/endpoint-clients.js.map +1 -0
  136. package/dist/orchestrator/orchestrator-loop.d.ts +93 -0
  137. package/dist/orchestrator/orchestrator-loop.d.ts.map +1 -0
  138. package/dist/orchestrator/orchestrator-loop.js +185 -0
  139. package/dist/orchestrator/orchestrator-loop.js.map +1 -0
  140. package/dist/security/confirmation.d.ts +90 -0
  141. package/dist/security/confirmation.d.ts.map +1 -0
  142. package/dist/security/confirmation.js +140 -0
  143. package/dist/security/confirmation.js.map +1 -0
  144. package/dist/setup/setup-compute.d.ts +54 -0
  145. package/dist/setup/setup-compute.d.ts.map +1 -0
  146. package/dist/setup/setup-compute.js +66 -0
  147. package/dist/setup/setup-compute.js.map +1 -0
  148. package/dist/state/snapshot-store.d.ts +79 -0
  149. package/dist/state/snapshot-store.d.ts.map +1 -0
  150. package/dist/state/snapshot-store.js +164 -0
  151. package/dist/state/snapshot-store.js.map +1 -0
  152. package/dist/state/state-recovery.d.ts +87 -0
  153. package/dist/state/state-recovery.d.ts.map +1 -0
  154. package/dist/state/state-recovery.js +274 -0
  155. package/dist/state/state-recovery.js.map +1 -0
  156. package/dist/state/transition-log.d.ts +40 -0
  157. package/dist/state/transition-log.d.ts.map +1 -0
  158. package/dist/state/transition-log.js +83 -0
  159. package/dist/state/transition-log.js.map +1 -0
  160. package/dist/state/yaml-helpers.d.ts +53 -0
  161. package/dist/state/yaml-helpers.d.ts.map +1 -0
  162. package/dist/state/yaml-helpers.js +110 -0
  163. package/dist/state/yaml-helpers.js.map +1 -0
  164. package/examples/.gitkeep +0 -0
  165. package/guidance/accessibility.md +67 -0
  166. package/guidance/api-conventions.md +124 -0
  167. package/guidance/index.yaml +7 -0
  168. package/guidance/secure-defaults.md +71 -0
  169. package/package.json +52 -0
  170. package/phases/.gitkeep +0 -0
  171. package/skills/00-overview.md +74 -0
  172. package/skills/10-ideation.md +45 -0
  173. package/skills/20-requirements.md +54 -0
  174. package/skills/30-design.md +57 -0
  175. package/skills/40-implementation.md +64 -0
  176. package/skills/50-testing.md +60 -0
  177. package/skills/60-deployment.md +63 -0
  178. package/skills/70-maintenance.md +56 -0
  179. package/skills/80-review.md +85 -0
  180. package/skills/81-continue.md +57 -0
  181. package/skills/82-add-action.md +71 -0
  182. package/templates/.gitkeep +0 -0
  183. package/templates/bugfix.yaml +14 -0
  184. package/templates/full-feature.yaml +44 -0
  185. package/templates/micro-task.yaml +11 -0
  186. package/templates/quick-feature.yaml +20 -0
  187. package/templates/spike.yaml +15 -0
@@ -0,0 +1,238 @@
1
+ /**
2
+ * `aidlc continue` command — resume an in-progress lifecycle instance.
3
+ *
4
+ * Behavior:
5
+ * - Load instance state, phase states, and resolve template.
6
+ * - Call `nextStep(state, phaseStates, template)` from the lifecycle engine.
7
+ * - Based on the result:
8
+ * - `artifact`: print what artifact to produce, with context about the phase.
9
+ * - `phase`: print what phase to enter next.
10
+ * - `complete`: print that the lifecycle is complete.
11
+ * - Output is a pre-built continuation prompt that can be pasted into any AI agent.
12
+ * - With `--json`: output `{ nextStep, prompt }` as JSON.
13
+ *
14
+ * Requirements: 26.1, 26.3
15
+ *
16
+ * @module
17
+ */
18
+ import { Command } from 'commander';
19
+ import { existsSync, readdirSync } from 'node:fs';
20
+ import { join, resolve } from 'node:path';
21
+ import { fileURLToPath } from 'node:url';
22
+ import { nextStep } from '../core/lifecycle.js';
23
+ import { loadTemplates, resolveTemplate, } from '../core/template-resolver.js';
24
+ import { loadSnapshot, listInstanceDirs } from '../state/snapshot-store.js';
25
+ // ---------------------------------------------------------------------------
26
+ // Helpers
27
+ // ---------------------------------------------------------------------------
28
+ /**
29
+ * Resolve the package root directory.
30
+ */
31
+ function getPackageRoot() {
32
+ const thisFile = fileURLToPath(import.meta.url);
33
+ return resolve(thisFile, '..', '..', '..');
34
+ }
35
+ /**
36
+ * Load all templates: built-in from the package + custom from the project.
37
+ */
38
+ function loadAllTemplates(packageRoot, projectRoot) {
39
+ const builtInDir = join(packageRoot, 'templates');
40
+ const customDir = join(projectRoot, '.aidlc', 'templates');
41
+ const templates = loadTemplates(builtInDir);
42
+ if (existsSync(customDir)) {
43
+ const custom = loadTemplates(customDir);
44
+ for (const [name, tpl] of custom) {
45
+ templates.set(name, tpl);
46
+ }
47
+ }
48
+ return templates;
49
+ }
50
+ /**
51
+ * Synchronously load all phase state files for a given instance.
52
+ */
53
+ function loadPhaseStates(stateDir, instanceName) {
54
+ const instanceDir = join(stateDir, instanceName);
55
+ const phaseStates = new Map();
56
+ if (!existsSync(instanceDir)) {
57
+ return phaseStates;
58
+ }
59
+ let entries;
60
+ try {
61
+ entries = readdirSync(instanceDir);
62
+ }
63
+ catch {
64
+ return phaseStates;
65
+ }
66
+ for (const entry of entries) {
67
+ if (entry.startsWith('phase-') && entry.endsWith('.yaml')) {
68
+ const phaseName = entry.slice('phase-'.length, -'.yaml'.length);
69
+ try {
70
+ const ps = loadSnapshot(stateDir, instanceName, entry);
71
+ phaseStates.set(phaseName, ps);
72
+ }
73
+ catch {
74
+ // Skip unreadable phase files
75
+ }
76
+ }
77
+ }
78
+ return phaseStates;
79
+ }
80
+ /**
81
+ * Build the continuation prompt text based on the next step result.
82
+ */
83
+ function buildPrompt(instanceName, step, currentPhase) {
84
+ switch (step.kind) {
85
+ case 'artifact': {
86
+ const skillFile = `aidlc-${step.phase}.md`;
87
+ return [
88
+ `You are continuing work on lifecycle instance "${instanceName}".`,
89
+ `Current phase: ${step.phase}.`,
90
+ `Next artifact to produce: ${step.artifact}`,
91
+ '',
92
+ `Read \`.aidlc/skills/${skillFile}\` for phase instructions.`,
93
+ `Read \`.aidlc/state/${instanceName}/instance.yaml\` for current state.`,
94
+ ].join('\n');
95
+ }
96
+ case 'phase': {
97
+ const skillFile = `aidlc-${step.phase}.md`;
98
+ return [
99
+ `You are continuing work on lifecycle instance "${instanceName}".`,
100
+ `Current phase "${currentPhase}" is complete.`,
101
+ `Next phase to enter: ${step.phase}.`,
102
+ '',
103
+ `Read \`.aidlc/skills/${skillFile}\` for phase instructions.`,
104
+ `Read \`.aidlc/state/${instanceName}/instance.yaml\` for current state.`,
105
+ ].join('\n');
106
+ }
107
+ case 'complete': {
108
+ return [
109
+ `Lifecycle instance "${instanceName}" is complete.`,
110
+ `All phases and artifacts have been finished.`,
111
+ ].join('\n');
112
+ }
113
+ }
114
+ }
115
+ /**
116
+ * Build the human-readable text output.
117
+ */
118
+ function buildTextOutput(instanceName, step, currentPhase) {
119
+ const prompt = buildPrompt(instanceName, step, currentPhase);
120
+ const lines = [];
121
+ switch (step.kind) {
122
+ case 'artifact':
123
+ lines.push(`Next step for "${instanceName}":`);
124
+ lines.push(` Phase: ${step.phase}`);
125
+ lines.push(` Produce: ${step.artifact}`);
126
+ break;
127
+ case 'phase':
128
+ lines.push(`Next step for "${instanceName}":`);
129
+ lines.push(` Enter phase: ${step.phase}`);
130
+ break;
131
+ case 'complete':
132
+ lines.push(`Lifecycle "${instanceName}" is complete.`);
133
+ break;
134
+ }
135
+ lines.push('');
136
+ lines.push('Prompt:');
137
+ lines.push('---');
138
+ lines.push(prompt);
139
+ lines.push('---');
140
+ lines.push('');
141
+ return lines.join('\n');
142
+ }
143
+ // ---------------------------------------------------------------------------
144
+ // Command registration
145
+ // ---------------------------------------------------------------------------
146
+ /**
147
+ * Register the `aidlc continue` command on the given commander program.
148
+ */
149
+ export function registerContinue(program) {
150
+ program
151
+ .command('continue')
152
+ .description('Resume the active lifecycle instance from the next incomplete step')
153
+ .argument('[instance]', 'Instance name to continue')
154
+ .option('--json', 'Output as JSON')
155
+ .action(async (instanceArg, opts) => {
156
+ await runContinue(instanceArg, opts);
157
+ });
158
+ }
159
+ // ---------------------------------------------------------------------------
160
+ // Core logic
161
+ // ---------------------------------------------------------------------------
162
+ async function runContinue(instanceArg, opts) {
163
+ const packageRoot = getPackageRoot();
164
+ const projectRoot = process.cwd();
165
+ const stateDir = join(projectRoot, '.aidlc', 'state');
166
+ // List all instances
167
+ const instanceNames = listInstanceDirs(stateDir);
168
+ if (instanceNames.length === 0) {
169
+ process.stderr.write('Error: no active lifecycle instance found. Run `aidlc start` to create one.\n');
170
+ process.exitCode = 1;
171
+ return;
172
+ }
173
+ // Determine which instance to continue
174
+ let targetInstance;
175
+ if (instanceArg) {
176
+ if (!instanceNames.includes(instanceArg)) {
177
+ process.stderr.write(`Error: instance '${instanceArg}' not found.\n` +
178
+ `Available instances: ${instanceNames.join(', ')}\n`);
179
+ process.exitCode = 1;
180
+ return;
181
+ }
182
+ targetInstance = instanceArg;
183
+ }
184
+ else if (instanceNames.length === 1) {
185
+ // Only one instance — use it directly
186
+ targetInstance = instanceNames[0];
187
+ }
188
+ else {
189
+ // Multiple instances and no argument provided
190
+ process.stderr.write('Error: multiple active instances found. Specify which to continue:\n' +
191
+ instanceNames.map((n) => ` - ${n}`).join('\n') +
192
+ '\n');
193
+ process.exitCode = 1;
194
+ return;
195
+ }
196
+ // Load instance state
197
+ let instanceState;
198
+ try {
199
+ instanceState = loadSnapshot(stateDir, targetInstance, 'instance.yaml');
200
+ }
201
+ catch (err) {
202
+ process.stderr.write(`Error: failed to load instance state: ${err.message}\n`);
203
+ process.exitCode = 1;
204
+ return;
205
+ }
206
+ // Load phase states
207
+ const phaseStates = loadPhaseStates(stateDir, targetInstance);
208
+ // Load and resolve template
209
+ const allTemplates = loadAllTemplates(packageRoot, projectRoot);
210
+ const rawTemplate = allTemplates.get(instanceState.template);
211
+ if (!rawTemplate) {
212
+ process.stderr.write(`Error: template '${instanceState.template}' not found.\n`);
213
+ process.exitCode = 1;
214
+ return;
215
+ }
216
+ let resolvedTemplate;
217
+ try {
218
+ resolvedTemplate = resolveTemplate(rawTemplate, allTemplates);
219
+ }
220
+ catch (err) {
221
+ process.stderr.write(`Error resolving template: ${err.message}\n`);
222
+ process.exitCode = 1;
223
+ return;
224
+ }
225
+ // Call nextStep
226
+ const step = nextStep(instanceState, phaseStates, resolvedTemplate);
227
+ // Output
228
+ if (opts.json) {
229
+ const prompt = buildPrompt(targetInstance, step, instanceState.current_phase);
230
+ const output = { nextStep: step, prompt };
231
+ process.stdout.write(JSON.stringify(output, null, 2) + '\n');
232
+ }
233
+ else {
234
+ const text = buildTextOutput(targetInstance, step, instanceState.current_phase);
235
+ process.stdout.write(text);
236
+ }
237
+ }
238
+ //# sourceMappingURL=continue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"continue.js","sourceRoot":"","sources":["../../src/commands/continue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAQzC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EACL,aAAa,EACb,eAAe,GAChB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE5E,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;GAEG;AACH,SAAS,cAAc;IACrB,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,C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AI,gBAAkC,CAAC;IACvC,IAAI,CAAC;QACH,gBAAgB,GAAG,eAAe,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAChE,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,6BAA8B,GAAa,CAAC,OAAO,IAAI,CACxD,CAAC;QACF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IAED,gBAAgB;IAChB,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAAC;IAEpE,SAAS;IACT,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,MAAM,MAAM,GAAG,WAAW,CAAC,cAAc,EAAE,IAAI,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;QAC9E,MAAM,MAAM,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC1C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC/D,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,GAAG,eAAe,CAAC,cAAc,EAAE,IAAI,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;QAChF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `aidlc discover` command — scan codebase and generate Context_Docs.
3
+ *
4
+ * Behavior:
5
+ * - Call `scanCodebase(process.cwd())` to analyze the project.
6
+ * - Call `writeContextDocs(cwd, result)` to produce Context_Docs in `.aidlc/context/`.
7
+ * - Print a human-readable summary to stdout: primary language, frameworks, conventions.
8
+ * - With `--json`: output the full ScanResult as JSON.
9
+ *
10
+ * Requirements: 15.1, 15.3, 15.10
11
+ *
12
+ * @module
13
+ */
14
+ import { Command } from 'commander';
15
+ /**
16
+ * Register the `aidlc discover` command on the given commander program.
17
+ */
18
+ export declare function registerDiscover(program: Command): void;
19
+ //# sourceMappingURL=discover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../src/commands/discover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuDpC;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsBvD"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * `aidlc discover` command — scan codebase and generate Context_Docs.
3
+ *
4
+ * Behavior:
5
+ * - Call `scanCodebase(process.cwd())` to analyze the project.
6
+ * - Call `writeContextDocs(cwd, result)` to produce Context_Docs in `.aidlc/context/`.
7
+ * - Print a human-readable summary to stdout: primary language, frameworks, conventions.
8
+ * - With `--json`: output the full ScanResult as JSON.
9
+ *
10
+ * Requirements: 15.1, 15.3, 15.10
11
+ *
12
+ * @module
13
+ */
14
+ import { Command } from 'commander';
15
+ import { scanCodebase, writeContextDocs } from '../discover/scanner.js';
16
+ // ---------------------------------------------------------------------------
17
+ // Summary renderer
18
+ // ---------------------------------------------------------------------------
19
+ /**
20
+ * Format a human-readable summary from the scan result.
21
+ */
22
+ function formatSummary(result, docPaths) {
23
+ const lines = [];
24
+ // Languages
25
+ if (result.languages.length > 0) {
26
+ const langParts = result.languages
27
+ .slice(0, 5)
28
+ .map((l) => `${l.name} (${l.percentage}%)`);
29
+ lines.push(`Discovered: ${langParts.join(', ')}`);
30
+ }
31
+ else {
32
+ lines.push('Discovered: no source files detected');
33
+ }
34
+ // Frameworks
35
+ if (result.frameworks.length > 0) {
36
+ lines.push(`Frameworks: ${result.frameworks.join(', ')}`);
37
+ }
38
+ else {
39
+ lines.push('Frameworks: none detected');
40
+ }
41
+ // Conventions
42
+ const conventions = [];
43
+ if (result.conventions.indentation !== 'unknown') {
44
+ conventions.push(`${result.conventions.indentation} indentation`);
45
+ }
46
+ if (result.conventions.naming !== 'unknown') {
47
+ conventions.push(`${result.conventions.naming} naming`);
48
+ }
49
+ if (conventions.length > 0) {
50
+ lines.push(`Conventions: ${conventions.join(', ')}`);
51
+ }
52
+ // Context docs written
53
+ if (docPaths.length > 0) {
54
+ lines.push(`Context docs written: ${docPaths.join(', ')}`);
55
+ }
56
+ return lines.join('\n') + '\n';
57
+ }
58
+ // ---------------------------------------------------------------------------
59
+ // Command registration
60
+ // ---------------------------------------------------------------------------
61
+ /**
62
+ * Register the `aidlc discover` command on the given commander program.
63
+ */
64
+ export function registerDiscover(program) {
65
+ program
66
+ .command('discover')
67
+ .description('Scan codebase and generate context documents')
68
+ .option('--json', 'Output full scan result as JSON')
69
+ .action((opts) => {
70
+ const cwd = process.cwd();
71
+ // Run the scanner
72
+ const result = scanCodebase(cwd);
73
+ // Write Context_Docs
74
+ const docPaths = writeContextDocs(cwd, result);
75
+ // Output
76
+ if (opts.json) {
77
+ process.stdout.write(JSON.stringify(result, null, 2) + '\n');
78
+ }
79
+ else {
80
+ const summary = formatSummary(result, docPaths);
81
+ process.stdout.write(summary);
82
+ }
83
+ });
84
+ }
85
+ //# sourceMappingURL=discover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discover.js","sourceRoot":"","sources":["../../src/commands/discover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAGxE,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;GAEG;AACH,SAAS,aAAa,CAAC,MAAkB,EAAE,QAAkB;IAC3D,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,YAAY;IACZ,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,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M,GAAG,CAAC,EAAE,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,yBAAyB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACjC,CAAC;AAED,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E;AAE9E;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,OAAO;SACJ,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,8CAA8C,CAAC;SAC3D,MAAM,CAAC,QAAQ,EAAE,iCAAiC,CAAC;SACnD,MAAM,CAAC,CAAC,IAAwB,EAAE,EAAE;QACnC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAE1B,kBAAkB;QAClB,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAEjC,qBAAqB;QACrB,MAAM,QAAQ,GAAG,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAE/C,SAAS;QACT,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QAC/D,CAAC;aAAM,CAAC;YACN,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YAChD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * `aidlc docs` command — generate onboarding documentation.
3
+ *
4
+ * Produces `.aidlc/ONBOARDING.md` explaining the AIDLC framework to new
5
+ * contributors. The content is assembled from the project's actual configuration:
6
+ * - Available workflow templates
7
+ * - Available phase guidance (skills)
8
+ * - Guidance layers from index.yaml
9
+ * - Quick-start commands
10
+ *
11
+ * Requirements: 12.1, 12.6
12
+ *
13
+ * @module
14
+ */
15
+ import { Command } from 'commander';
16
+ import type { WorkflowTemplate, GuidanceIndexEntry } from '../core/types.js';
17
+ /**
18
+ * Generate the ONBOARDING.md content from project configuration.
19
+ */
20
+ export declare function generateOnboardingContent(templates: Map<string, WorkflowTemplate>, skillNames: string[], guidanceLayers: GuidanceIndexEntry[]): string;
21
+ /**
22
+ * Register the `aidlc docs` command on the given commander program.
23
+ */
24
+ export declare function registerDocs(program: Command): void;
25
+ //# sourceMappingURL=docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/commands/docs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAmF7E;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,EACxC,UAAU,EAAE,MAAM,EAAE,EACpB,cAAc,EAAE,kBAAkB,EAAE,GACnC,MAAM,CA2JR;AAMD;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAOnD"}
@@ -0,0 +1,282 @@
1
+ /**
2
+ * `aidlc docs` command — generate onboarding documentation.
3
+ *
4
+ * Produces `.aidlc/ONBOARDING.md` explaining the AIDLC framework to new
5
+ * contributors. The content is assembled from the project's actual configuration:
6
+ * - Available workflow templates
7
+ * - Available phase guidance (skills)
8
+ * - Guidance layers from index.yaml
9
+ * - Quick-start commands
10
+ *
11
+ * Requirements: 12.1, 12.6
12
+ *
13
+ * @module
14
+ */
15
+ import { Command } from 'commander';
16
+ import { existsSync, mkdirSync, writeFileSync, readdirSync, readFileSync } from 'node:fs';
17
+ import { join, resolve } from 'node:path';
18
+ import { fileURLToPath } from 'node:url';
19
+ import { parse as parseYaml } from 'yaml';
20
+ import { loadTemplates, resolveTemplate } from '../core/template-resolver.js';
21
+ // ---------------------------------------------------------------------------
22
+ // Helpers
23
+ // ---------------------------------------------------------------------------
24
+ /**
25
+ * Resolve the package root directory.
26
+ */
27
+ function getPackageRoot() {
28
+ const thisFile = fileURLToPath(import.meta.url);
29
+ return resolve(thisFile, '..', '..', '..');
30
+ }
31
+ /**
32
+ * Load all templates: built-in from the package + custom from the project.
33
+ */
34
+ function loadAllTemplates(packageRoot, projectRoot) {
35
+ const builtInDir = join(packageRoot, 'templates');
36
+ const customDir = join(projectRoot, '.aidlc', 'templates');
37
+ const templates = loadTemplates(builtInDir);
38
+ if (existsSync(customDir)) {
39
+ const custom = loadTemplates(customDir);
40
+ for (const [name, tpl] of custom) {
41
+ templates.set(name, tpl);
42
+ }
43
+ }
44
+ return templates;
45
+ }
46
+ /**
47
+ * Load skill names from the skills/ directory.
48
+ */
49
+ function loadSkillNames(packageRoot) {
50
+ const skillsDir = join(packageRoot, 'skills');
51
+ if (!existsSync(skillsDir)) {
52
+ return [];
53
+ }
54
+ return readdirSync(skillsDir)
55
+ .filter((f) => f.endsWith('.md'))
56
+ .sort()
57
+ .map((f) => f.replace(/\.md$/, ''));
58
+ }
59
+ /**
60
+ * Load guidance layer entries from the project or package guidance index.
61
+ */
62
+ function loadGuidanceEntries(projectRoot, packageRoot) {
63
+ // First try project-level guidance
64
+ const projectIndex = join(projectRoot, '.aidlc', 'guidance', 'index.yaml');
65
+ // Fall back to package-level guidance
66
+ const packageIndex = join(packageRoot, 'guidance', 'index.yaml');
67
+ const indexPath = existsSync(projectIndex) ? projectIndex : packageIndex;
68
+ if (!existsSync(indexPath)) {
69
+ return [];
70
+ }
71
+ try {
72
+ const raw = readFileSync(indexPath, 'utf8');
73
+ const data = parseYaml(raw);
74
+ if (data && Array.isArray(data.layers)) {
75
+ return data.layers;
76
+ }
77
+ }
78
+ catch {
79
+ // Ignore parse errors — guidance is optional
80
+ }
81
+ return [];
82
+ }
83
+ // ---------------------------------------------------------------------------
84
+ // Content generation
85
+ // ---------------------------------------------------------------------------
86
+ /**
87
+ * Generate the ONBOARDING.md content from project configuration.
88
+ */
89
+ export function generateOnboardingContent(templates, skillNames, guidanceLayers) {
90
+ const lines = [];
91
+ // Header
92
+ lines.push('# AIDLC Framework — Onboarding Guide');
93
+ lines.push('');
94
+ lines.push('Welcome! This project uses the **AI Development Lifecycle (AIDLC)** framework');
95
+ lines.push('to provide structured, phase-driven guidance for AI-assisted development.');
96
+ lines.push('');
97
+ // What is AIDLC?
98
+ lines.push('## What is AIDLC?');
99
+ lines.push('');
100
+ lines.push('AIDLC is a lightweight framework that defines lifecycle phases (Ideation through');
101
+ lines.push('Maintenance), persists state in version-controlled files, and provides skills');
102
+ lines.push('that guide AI coding agents through each phase. It works across platforms');
103
+ lines.push('(Claude Code, Kiro, Cursor, Windsurf, Codex) and supports bare LLM endpoints.');
104
+ lines.push('');
105
+ // Available workflows
106
+ lines.push('## Available Workflow Templates');
107
+ lines.push('');
108
+ if (templates.size === 0) {
109
+ lines.push('_No templates found._');
110
+ }
111
+ else {
112
+ lines.push('| Template | Scope | Description |');
113
+ lines.push('|----------|-------|-------------|');
114
+ for (const [name, tpl] of templates) {
115
+ const desc = tpl.description || '—';
116
+ lines.push(`| ${name} | ${tpl.scope} | ${desc} |`);
117
+ }
118
+ }
119
+ lines.push('');
120
+ // Phases
121
+ lines.push('## Lifecycle Phases');
122
+ lines.push('');
123
+ lines.push('The standard AIDLC phases in order:');
124
+ lines.push('');
125
+ lines.push('1. **Ideation** — Explore the problem space, define goals and constraints');
126
+ lines.push('2. **Requirements** — Write acceptance criteria and user stories');
127
+ lines.push('3. **Design** — Architecture decisions, interfaces, data models');
128
+ lines.push('4. **Implementation** — Produce code following the design');
129
+ lines.push('5. **Testing** — Verify against requirements');
130
+ lines.push('6. **Deployment** — Release preparation and execution');
131
+ lines.push('7. **Maintenance** — Monitoring, iteration, documentation');
132
+ lines.push('');
133
+ lines.push('Not all phases apply to every task. The scope determines which phases are active:');
134
+ lines.push('');
135
+ lines.push('- **Full** — All 7 phases (starts at Ideation)');
136
+ lines.push('- **Standard** — Requirements through Deployment');
137
+ lines.push('- **Micro** — Implementation and Testing only');
138
+ lines.push('');
139
+ // Reading state
140
+ lines.push('## Reading Lifecycle State');
141
+ lines.push('');
142
+ lines.push('All state is stored under `.aidlc/state/<instance-name>/`:');
143
+ lines.push('');
144
+ lines.push('| File | Purpose |');
145
+ lines.push('|------|---------|');
146
+ lines.push('| `instance.yaml` | Instance metadata: template, scope, current phase, claim |');
147
+ lines.push('| `phase-<name>.yaml` | Per-phase status, artifacts, metrics |');
148
+ lines.push('| `transitions.log` | Append-only NDJSON log of all phase transitions |');
149
+ lines.push('');
150
+ lines.push('### instance.yaml');
151
+ lines.push('');
152
+ lines.push('```yaml');
153
+ lines.push('name: my-feature');
154
+ lines.push('template: full-feature');
155
+ lines.push('scope: full');
156
+ lines.push('current_phase: design');
157
+ lines.push('claim: null');
158
+ lines.push('```');
159
+ lines.push('');
160
+ lines.push('### phase-<name>.yaml');
161
+ lines.push('');
162
+ lines.push('```yaml');
163
+ lines.push('phase: requirements');
164
+ lines.push('status: complete # pending | in-progress | complete | skipped');
165
+ lines.push('artifacts:');
166
+ lines.push(' - { name: requirements.md, status: complete }');
167
+ lines.push('```');
168
+ lines.push('');
169
+ lines.push('### transitions.log');
170
+ lines.push('');
171
+ lines.push('Each line is a JSON object:');
172
+ lines.push('');
173
+ lines.push('```json');
174
+ lines.push('{"at":"2025-01-15T10:00:00Z","by":"developer","from":"requirements","to":"design","type":"normal"}');
175
+ lines.push('```');
176
+ lines.push('');
177
+ // Skills
178
+ lines.push('## Available Skills');
179
+ lines.push('');
180
+ if (skillNames.length === 0) {
181
+ lines.push('_No skills found._');
182
+ }
183
+ else {
184
+ lines.push('Skills provide phase-specific guidance to AI agents:');
185
+ lines.push('');
186
+ for (const name of skillNames) {
187
+ lines.push(`- \`${name}\``);
188
+ }
189
+ }
190
+ lines.push('');
191
+ // Guidance layers
192
+ lines.push('## Guidance Layers');
193
+ lines.push('');
194
+ if (guidanceLayers.length === 0) {
195
+ lines.push('_No guidance layers configured._');
196
+ }
197
+ else {
198
+ lines.push('Guidance layers provide domain-specific rules referenced during implementation:');
199
+ lines.push('');
200
+ for (const layer of guidanceLayers) {
201
+ lines.push(`- **${layer.name}** — \`${layer.file}\``);
202
+ }
203
+ }
204
+ lines.push('');
205
+ // Quick-start commands
206
+ lines.push('## Quick-Start Commands');
207
+ lines.push('');
208
+ lines.push('```bash');
209
+ lines.push('# Start a new lifecycle instance');
210
+ lines.push('aidlc start [template]');
211
+ lines.push('');
212
+ lines.push('# Check lifecycle status');
213
+ lines.push('aidlc status');
214
+ lines.push('');
215
+ lines.push('# CI/CD gate check (exit 0 if phase complete)');
216
+ lines.push('aidlc gate <phase>');
217
+ lines.push('');
218
+ lines.push('# Advance to the next phase');
219
+ lines.push('aidlc transition --to <phase>');
220
+ lines.push('');
221
+ lines.push('# Resume work on an instance');
222
+ lines.push('aidlc continue');
223
+ lines.push('');
224
+ lines.push('# Generate platform-specific skills');
225
+ lines.push('aidlc init --platform <name>');
226
+ lines.push('```');
227
+ lines.push('');
228
+ // Further reading
229
+ lines.push('## Further Reading');
230
+ lines.push('');
231
+ lines.push('- Run `aidlc help [phase]` for details on any phase');
232
+ lines.push('- Check `.aidlc/context/` for project-specific style and architecture docs');
233
+ lines.push('- See `.aidlc/guidance/` for active guidance layers');
234
+ lines.push('- Templates live in `.aidlc/templates/` (custom) and the package `templates/` dir');
235
+ lines.push('');
236
+ return lines.join('\n');
237
+ }
238
+ // ---------------------------------------------------------------------------
239
+ // Command registration
240
+ // ---------------------------------------------------------------------------
241
+ /**
242
+ * Register the `aidlc docs` command on the given commander program.
243
+ */
244
+ export function registerDocs(program) {
245
+ program
246
+ .command('docs')
247
+ .description('Generate onboarding documentation (.aidlc/ONBOARDING.md)')
248
+ .action(async () => {
249
+ await runDocs();
250
+ });
251
+ }
252
+ // ---------------------------------------------------------------------------
253
+ // Core logic
254
+ // ---------------------------------------------------------------------------
255
+ async function runDocs() {
256
+ const packageRoot = getPackageRoot();
257
+ const projectRoot = process.cwd();
258
+ // Load templates
259
+ const templates = loadAllTemplates(packageRoot, projectRoot);
260
+ if (templates.size === 0) {
261
+ process.stderr.write('Error: no workflow templates found. Cannot generate documentation.\n' +
262
+ 'Ensure the package templates/ directory exists or add custom templates to .aidlc/templates/.\n');
263
+ process.exitCode = 1;
264
+ return;
265
+ }
266
+ // Load skill names
267
+ const skillNames = loadSkillNames(packageRoot);
268
+ // Load guidance layers
269
+ const guidanceLayers = loadGuidanceEntries(projectRoot, packageRoot);
270
+ // Generate content
271
+ const content = generateOnboardingContent(templates, skillNames, guidanceLayers);
272
+ // Ensure .aidlc/ directory exists
273
+ const aidlcDir = join(projectRoot, '.aidlc');
274
+ if (!existsSync(aidlcDir)) {
275
+ mkdirSync(aidlcDir, { recursive: true });
276
+ }
277
+ // Write the file
278
+ const outputPath = join(aidlcDir, 'ONBOARDING.md');
279
+ writeFileSync(outputPath, content, 'utf8');
280
+ process.stdout.write(`Wrote ${outputPath}\n`);
281
+ }
282
+ //# sourceMappingURL=docs.js.map