@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 @@
1
+ {"version":3,"file":"plugin-hooks.js","sourceRoot":"","sources":["../../src/events/plugin-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAS7B,8EAA8E;AAC9E,6BAA6B;AAC7B,8EAA8E;AAE9E,+CAA+C;AAC/C,MAAM,YAAY,GAAgB,IAAI,GAAG,CAAC;IACxC,mBAAmB;IACnB,gBAAgB;IAChB,eAAe;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AAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;gBACnE,sCAAsC;YACxC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Context budget packer for orchestrator mode.
3
+ *
4
+ * Greedy priority-first algorithm that packs context items into a token budget.
5
+ * When a full item doesn't fit, the packer tries its summary (Artifact_Summary)
6
+ * before excluding it entirely.
7
+ *
8
+ * Requirements: 19.4, 19.5, 25.7, 25.8
9
+ */
10
+ /** A context item to be considered for inclusion in a prompt. */
11
+ export interface ContextItem {
12
+ /** Unique identifier for this item. */
13
+ id: string;
14
+ /** Full content of this item. */
15
+ content: string;
16
+ /** Priority 1-100, higher = more important. */
17
+ priority: number;
18
+ /** Estimated token count for the full content. */
19
+ tokenEstimate: number;
20
+ /** Optional shorter summary version (used when full content doesn't fit). */
21
+ summary?: string;
22
+ }
23
+ /** Result of packing context items into a budget. */
24
+ export interface PackResult {
25
+ /** Items that fit in the budget (may use summary version). */
26
+ included: ContextItem[];
27
+ /** Items that didn't fit even as summaries. */
28
+ excluded: ContextItem[];
29
+ /** Total tokens used by included items. */
30
+ totalTokens: number;
31
+ /** IDs of items where the summary was used instead of full content. */
32
+ usedSummary: string[];
33
+ }
34
+ /**
35
+ * Estimate the token count of a text string.
36
+ *
37
+ * Uses the simple heuristic of ~4 characters per token.
38
+ * This is a rough approximation suitable for budget planning.
39
+ */
40
+ export declare function estimateTokens(text: string): number;
41
+ /**
42
+ * Pack context items into a token budget using a greedy priority-first algorithm.
43
+ *
44
+ * Algorithm:
45
+ * 1. Sort items by priority descending (stable sort preserves insertion order for ties)
46
+ * 2. For each item (highest priority first):
47
+ * a. If full content fits in remaining budget → include it
48
+ * b. Else if summary exists and fits → include summary version
49
+ * c. Else → exclude
50
+ * 3. Return PackResult
51
+ *
52
+ * @param items - Context items to pack.
53
+ * @param budgetTokens - Maximum token count for the packed result.
54
+ * @returns PackResult describing which items were included/excluded.
55
+ */
56
+ export declare function packContext(items: ContextItem[], budgetTokens: number): PackResult;
57
+ //# sourceMappingURL=budget-packer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"budget-packer.d.ts","sourceRoot":"","sources":["../../src/orchestrator/budget-packer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,iEAAiE;AACjE,MAAM,WAAW,WAAW;IAC1B,uCAAuC;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qDAAqD;AACrD,MAAM,WAAW,UAAU;IACzB,8DAA8D;IAC9D,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,+CAA+C;IAC/C,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAMD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,UAAU,CAmClF"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Context budget packer for orchestrator mode.
3
+ *
4
+ * Greedy priority-first algorithm that packs context items into a token budget.
5
+ * When a full item doesn't fit, the packer tries its summary (Artifact_Summary)
6
+ * before excluding it entirely.
7
+ *
8
+ * Requirements: 19.4, 19.5, 25.7, 25.8
9
+ */
10
+ // ---------------------------------------------------------------------------
11
+ // Token Estimation
12
+ // ---------------------------------------------------------------------------
13
+ /**
14
+ * Estimate the token count of a text string.
15
+ *
16
+ * Uses the simple heuristic of ~4 characters per token.
17
+ * This is a rough approximation suitable for budget planning.
18
+ */
19
+ export function estimateTokens(text) {
20
+ return Math.ceil(text.length / 4);
21
+ }
22
+ // ---------------------------------------------------------------------------
23
+ // Budget Packer
24
+ // ---------------------------------------------------------------------------
25
+ /**
26
+ * Pack context items into a token budget using a greedy priority-first algorithm.
27
+ *
28
+ * Algorithm:
29
+ * 1. Sort items by priority descending (stable sort preserves insertion order for ties)
30
+ * 2. For each item (highest priority first):
31
+ * a. If full content fits in remaining budget → include it
32
+ * b. Else if summary exists and fits → include summary version
33
+ * c. Else → exclude
34
+ * 3. Return PackResult
35
+ *
36
+ * @param items - Context items to pack.
37
+ * @param budgetTokens - Maximum token count for the packed result.
38
+ * @returns PackResult describing which items were included/excluded.
39
+ */
40
+ export function packContext(items, budgetTokens) {
41
+ // Sort by priority descending; stable sort preserves order for equal priorities
42
+ const sorted = [...items].sort((a, b) => b.priority - a.priority);
43
+ const included = [];
44
+ const excluded = [];
45
+ const usedSummary = [];
46
+ let totalTokens = 0;
47
+ for (const item of sorted) {
48
+ const remaining = budgetTokens - totalTokens;
49
+ // Try full content first
50
+ if (item.tokenEstimate <= remaining) {
51
+ included.push(item);
52
+ totalTokens += item.tokenEstimate;
53
+ continue;
54
+ }
55
+ // Try summary if available
56
+ if (item.summary !== undefined) {
57
+ const summaryTokens = estimateTokens(item.summary);
58
+ if (summaryTokens <= remaining) {
59
+ included.push(item);
60
+ totalTokens += summaryTokens;
61
+ usedSummary.push(item.id);
62
+ continue;
63
+ }
64
+ }
65
+ // Doesn't fit at all
66
+ excluded.push(item);
67
+ }
68
+ return { included, excluded, totalTokens, usedSummary };
69
+ }
70
+ //# sourceMappingURL=budget-packer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"budget-packer.js","sourceRoot":"","sources":["../../src/orchestrator/budget-packer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgCH,8EAA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;gBAC1B,SAAS;YACX,CAAC;QACH,CAAC;QAED,qBAAqB;QACrB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Orchestrator configuration loader and client factory.
3
+ *
4
+ * - `loadOrchestratorConfig()` reads orchestrator config from `.aidlc/config.yaml`.
5
+ * - `createClient()` creates an EndpointClient from an OrchestratorConfig.
6
+ * - `createClientFromFlags()` creates an EndpointClient from CLI flag values.
7
+ *
8
+ * Key constraint (Req 19.12): The orchestrator is strictly optional. All other
9
+ * AIDLC operations must work without any orchestrator config present.
10
+ *
11
+ * Requirements: 19.1, 19.3, 19.12
12
+ */
13
+ import type { ApiFormat, EndpointClient, OrchestratorConfig } from '../core/types.js';
14
+ /**
15
+ * Load the orchestrator section from a project config file.
16
+ *
17
+ * Returns `null` if:
18
+ * - The config file does not exist
19
+ * - The file is unreadable or invalid YAML
20
+ * - The `orchestrator` section is absent
21
+ *
22
+ * This ensures orchestrator remains optional (Req 19.12).
23
+ *
24
+ * @param configPath - Absolute path to the `.aidlc/config.yaml` file.
25
+ */
26
+ export declare function loadOrchestratorConfig(configPath: string): OrchestratorConfig | null;
27
+ /**
28
+ * Create an EndpointClient from an OrchestratorConfig.
29
+ *
30
+ * Selects the appropriate client implementation based on `config.api_format`.
31
+ */
32
+ export declare function createClient(config: OrchestratorConfig): EndpointClient;
33
+ /**
34
+ * Create an EndpointClient from CLI flags (--endpoint, --model, --api-format).
35
+ *
36
+ * CLI flags override config values per Req 19.3.
37
+ */
38
+ export declare function createClientFromFlags(opts: {
39
+ endpoint: string;
40
+ model: string;
41
+ apiFormat: ApiFormat;
42
+ }): EndpointClient;
43
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/orchestrator/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAOtF;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAsDpF;AAMD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,cAAc,CAOvE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,SAAS,CAAC;CACtB,GAAG,cAAc,CAOjB"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Orchestrator configuration loader and client factory.
3
+ *
4
+ * - `loadOrchestratorConfig()` reads orchestrator config from `.aidlc/config.yaml`.
5
+ * - `createClient()` creates an EndpointClient from an OrchestratorConfig.
6
+ * - `createClientFromFlags()` creates an EndpointClient from CLI flag values.
7
+ *
8
+ * Key constraint (Req 19.12): The orchestrator is strictly optional. All other
9
+ * AIDLC operations must work without any orchestrator config present.
10
+ *
11
+ * Requirements: 19.1, 19.3, 19.12
12
+ */
13
+ import { readFileSync, existsSync } from 'node:fs';
14
+ import { parse as parseYaml } from 'yaml';
15
+ import { createOllamaClient, createOpenAIClient } from './endpoint-clients.js';
16
+ // ---------------------------------------------------------------------------
17
+ // Config Loader
18
+ // ---------------------------------------------------------------------------
19
+ /**
20
+ * Load the orchestrator section from a project config file.
21
+ *
22
+ * Returns `null` if:
23
+ * - The config file does not exist
24
+ * - The file is unreadable or invalid YAML
25
+ * - The `orchestrator` section is absent
26
+ *
27
+ * This ensures orchestrator remains optional (Req 19.12).
28
+ *
29
+ * @param configPath - Absolute path to the `.aidlc/config.yaml` file.
30
+ */
31
+ export function loadOrchestratorConfig(configPath) {
32
+ if (!existsSync(configPath)) {
33
+ return null;
34
+ }
35
+ let raw;
36
+ try {
37
+ raw = readFileSync(configPath, 'utf-8');
38
+ }
39
+ catch {
40
+ return null;
41
+ }
42
+ let parsed;
43
+ try {
44
+ parsed = parseYaml(raw);
45
+ }
46
+ catch {
47
+ return null;
48
+ }
49
+ if (parsed === null || typeof parsed !== 'object') {
50
+ return null;
51
+ }
52
+ const doc = parsed;
53
+ const orch = doc.orchestrator;
54
+ if (!orch || typeof orch !== 'object') {
55
+ return null;
56
+ }
57
+ const orchObj = orch;
58
+ // Validate required fields
59
+ if (typeof orchObj.endpoint !== 'string' || orchObj.endpoint.length === 0) {
60
+ return null;
61
+ }
62
+ if (typeof orchObj.model !== 'string' || orchObj.model.length === 0) {
63
+ return null;
64
+ }
65
+ const apiFormat = orchObj.api_format;
66
+ if (apiFormat !== 'ollama' && apiFormat !== 'openai') {
67
+ return null;
68
+ }
69
+ return {
70
+ endpoint: orchObj.endpoint,
71
+ model: orchObj.model,
72
+ api_format: apiFormat,
73
+ review_model: typeof orchObj.review_model === 'string' ? orchObj.review_model : null,
74
+ auto_advance: orchObj.auto_advance === true,
75
+ context_budget_tokens: typeof orchObj.context_budget_tokens === 'number'
76
+ ? orchObj.context_budget_tokens
77
+ : 8192,
78
+ };
79
+ }
80
+ // ---------------------------------------------------------------------------
81
+ // Client Factory
82
+ // ---------------------------------------------------------------------------
83
+ /**
84
+ * Create an EndpointClient from an OrchestratorConfig.
85
+ *
86
+ * Selects the appropriate client implementation based on `config.api_format`.
87
+ */
88
+ export function createClient(config) {
89
+ switch (config.api_format) {
90
+ case 'ollama':
91
+ return createOllamaClient(config.endpoint);
92
+ case 'openai':
93
+ return createOpenAIClient(config.endpoint);
94
+ }
95
+ }
96
+ /**
97
+ * Create an EndpointClient from CLI flags (--endpoint, --model, --api-format).
98
+ *
99
+ * CLI flags override config values per Req 19.3.
100
+ */
101
+ export function createClientFromFlags(opts) {
102
+ switch (opts.apiFormat) {
103
+ case 'ollama':
104
+ return createOllamaClient(opts.endpoint);
105
+ case 'openai':
106
+ return createOpenAIClient(opts.endpoint);
107
+ }
108
+ }
109
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/orchestrator/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE/E,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAAkB;IACvD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,GAAW,CAAC;IAChB,IAAI,CAAC;QACH,GAAG,GAAG,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,GAAG,GAAG,MAAiC,CAAC;IAC9C,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC;IAC9B,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM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;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAIrC;IACC,QAAQ,IAAI,CAAC,SAAS,EAAE,CAAC;QACvB,KAAK,QAAQ;YACX,OAAO,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3C,KAAK,QAAQ;YACX,OAAO,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Endpoint clients for orchestrator mode.
3
+ *
4
+ * Implements the EndpointClient interface for:
5
+ * - Ollama native API (POST <endpoint>/api/chat)
6
+ * - OpenAI-compatible API (POST <endpoint>/v1/chat/completions)
7
+ *
8
+ * Requirements: 19.1, 19.2
9
+ */
10
+ import type { EndpointClient } from '../core/types.js';
11
+ /**
12
+ * Create an EndpointClient that communicates with the Ollama native API.
13
+ *
14
+ * @param endpoint - Base URL of the Ollama server (e.g., "http://localhost:11434")
15
+ */
16
+ export declare function createOllamaClient(endpoint: string): EndpointClient;
17
+ /**
18
+ * Create an EndpointClient that communicates with an OpenAI-compatible API.
19
+ *
20
+ * @param endpoint - Base URL of the API server (e.g., "http://localhost:11434")
21
+ */
22
+ export declare function createOpenAIClient(endpoint: string): EndpointClient;
23
+ //# sourceMappingURL=endpoint-clients.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-clients.d.ts","sourceRoot":"","sources":["../../src/orchestrator/endpoint-clients.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAuC,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAoC5F;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CAyBnE;AA2CD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CAyBnE"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Endpoint clients for orchestrator mode.
3
+ *
4
+ * Implements the EndpointClient interface for:
5
+ * - Ollama native API (POST <endpoint>/api/chat)
6
+ * - OpenAI-compatible API (POST <endpoint>/v1/chat/completions)
7
+ *
8
+ * Requirements: 19.1, 19.2
9
+ */
10
+ // ---------------------------------------------------------------------------
11
+ // Ollama Native Client
12
+ // ---------------------------------------------------------------------------
13
+ /**
14
+ * Build the request body for Ollama's native /api/chat endpoint.
15
+ */
16
+ function buildOllamaBody(messages, opts) {
17
+ const body = {
18
+ model: opts.model,
19
+ messages,
20
+ stream: false,
21
+ };
22
+ if (opts.temperature !== undefined) {
23
+ body.options = { temperature: opts.temperature };
24
+ }
25
+ return JSON.stringify(body);
26
+ }
27
+ /**
28
+ * Parse Ollama's native /api/chat response to extract the assistant message content.
29
+ */
30
+ function parseOllamaResponse(data) {
31
+ const obj = data;
32
+ const message = obj.message;
33
+ if (!message || typeof message.content !== 'string') {
34
+ throw new Error('Invalid Ollama response: missing message.content');
35
+ }
36
+ return {
37
+ content: message.content,
38
+ finish_reason: typeof obj.done_reason === 'string' ? obj.done_reason : undefined,
39
+ };
40
+ }
41
+ /**
42
+ * Create an EndpointClient that communicates with the Ollama native API.
43
+ *
44
+ * @param endpoint - Base URL of the Ollama server (e.g., "http://localhost:11434")
45
+ */
46
+ export function createOllamaClient(endpoint) {
47
+ const baseUrl = endpoint.replace(/\/+$/, '');
48
+ return {
49
+ async chat(messages, opts) {
50
+ const url = `${baseUrl}/api/chat`;
51
+ const body = buildOllamaBody(messages, opts);
52
+ const response = await fetch(url, {
53
+ method: 'POST',
54
+ headers: { 'Content-Type': 'application/json' },
55
+ body,
56
+ });
57
+ if (!response.ok) {
58
+ const text = await response.text().catch(() => '');
59
+ throw new Error(`Ollama endpoint error: ${response.status} ${response.statusText}${text ? ` — ${text}` : ''}`);
60
+ }
61
+ const data = await response.json();
62
+ return parseOllamaResponse(data);
63
+ },
64
+ };
65
+ }
66
+ // ---------------------------------------------------------------------------
67
+ // OpenAI-Compatible Client
68
+ // ---------------------------------------------------------------------------
69
+ /**
70
+ * Build the request body for OpenAI-compatible /v1/chat/completions endpoint.
71
+ */
72
+ function buildOpenAIBody(messages, opts) {
73
+ const body = {
74
+ model: opts.model,
75
+ messages,
76
+ };
77
+ if (opts.temperature !== undefined) {
78
+ body.temperature = opts.temperature;
79
+ }
80
+ if (opts.max_tokens !== undefined) {
81
+ body.max_tokens = opts.max_tokens;
82
+ }
83
+ return JSON.stringify(body);
84
+ }
85
+ /**
86
+ * Parse OpenAI-compatible /v1/chat/completions response.
87
+ */
88
+ function parseOpenAIResponse(data) {
89
+ const obj = data;
90
+ const choices = obj.choices;
91
+ if (!choices || choices.length === 0) {
92
+ throw new Error('Invalid OpenAI response: missing choices array');
93
+ }
94
+ const first = choices[0];
95
+ const message = first.message;
96
+ if (!message || typeof message.content !== 'string') {
97
+ throw new Error('Invalid OpenAI response: missing choices[0].message.content');
98
+ }
99
+ return {
100
+ content: message.content,
101
+ finish_reason: typeof first.finish_reason === 'string' ? first.finish_reason : undefined,
102
+ };
103
+ }
104
+ /**
105
+ * Create an EndpointClient that communicates with an OpenAI-compatible API.
106
+ *
107
+ * @param endpoint - Base URL of the API server (e.g., "http://localhost:11434")
108
+ */
109
+ export function createOpenAIClient(endpoint) {
110
+ const baseUrl = endpoint.replace(/\/+$/, '');
111
+ return {
112
+ async chat(messages, opts) {
113
+ const url = `${baseUrl}/v1/chat/completions`;
114
+ const body = buildOpenAIBody(messages, opts);
115
+ const response = await fetch(url, {
116
+ method: 'POST',
117
+ headers: { 'Content-Type': 'application/json' },
118
+ body,
119
+ });
120
+ if (!response.ok) {
121
+ const text = await response.text().catch(() => '');
122
+ throw new Error(`OpenAI endpoint error: ${response.status} ${response.statusText}${text ? ` — ${text}` : ''}`);
123
+ }
124
+ const data = await response.json();
125
+ return parseOpenAIResponse(data);
126
+ },
127
+ };
128
+ }
129
+ //# sourceMappingURL=endpoint-clients.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-clients.js","sourceRoot":"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AG,EAAE,CAAC,EAAE,CAAC,CAAC;gBACnD,MAAM,IAAI,KAAK,CACb,0BAA0B,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC9F,CAAC;YACJ,CAAC;YAED,MAAM,IAAI,GAAY,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC5C,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Orchestrator loop — drives a lifecycle instance through phases via a bare LLM endpoint.
3
+ *
4
+ * This module is optional (Req 19.12). It imports endpoint-clients and budget-packer
5
+ * but does NOT import into the CLI unless the `aidlc run` command is invoked.
6
+ *
7
+ * Loop:
8
+ * 1. Load instance state, resolve template, compute nextStep
9
+ * 2. Pack context items into the budget using packContext
10
+ * 3. Build the prompt (system message + context + task)
11
+ * 4. Call the LLM endpoint
12
+ * 5. Process the response (log; artifact processing is a future enhancement)
13
+ * 6. If autoAdvance, attempt transition
14
+ * 7. Repeat until complete or maxIterations reached
15
+ *
16
+ * Requirements: 19.1, 19.6, 19.12
17
+ */
18
+ import type { EndpointClient, InstanceState, PhaseState, WorkflowTemplate, NextStep } from '../core/types.js';
19
+ import type { ContextItem, PackResult } from './budget-packer.js';
20
+ /** Options for running the orchestrator loop. */
21
+ export interface OrchestratorOpts {
22
+ /** Lifecycle instance name. */
23
+ instance: string;
24
+ /** Endpoint client for LLM communication. */
25
+ client: EndpointClient;
26
+ /** Model name to pass to the endpoint. */
27
+ model: string;
28
+ /** Token budget for context packing per prompt. */
29
+ contextBudget: number;
30
+ /** If true, automatically attempt transition after response. */
31
+ autoAdvance: boolean;
32
+ /** Safety cap on iterations (default 50). */
33
+ maxIterations?: number;
34
+ }
35
+ /** Result returned when the orchestrator loop completes. */
36
+ export interface OrchestratorResult {
37
+ /** Number of iterations executed. */
38
+ iterations: number;
39
+ /** Phase the instance is in when the loop ended. */
40
+ finalPhase: string;
41
+ /** Whether the lifecycle instance reached completion. */
42
+ completed: boolean;
43
+ /** Error message if the loop ended due to an error. */
44
+ error?: string;
45
+ }
46
+ /**
47
+ * Context loader interface — abstracts state and file reading so the loop
48
+ * doesn't need direct filesystem access (enables testing without I/O).
49
+ */
50
+ export interface ContextLoader {
51
+ /** Load the instance state from the state store. */
52
+ loadInstanceState(instance: string): InstanceState;
53
+ /** Load all phase states for an instance. */
54
+ loadPhaseStates(instance: string): Map<string, PhaseState>;
55
+ /** Load and resolve the workflow template for an instance. */
56
+ loadTemplate(templateName: string): WorkflowTemplate;
57
+ /** Load the skill content for a given phase. Returns null if not found. */
58
+ loadPhaseSkill(phase: string): string | null;
59
+ /** Load context items (guidance, context docs, state summaries). */
60
+ loadContextItems(instance: string, phase: string): ContextItem[];
61
+ /** Record that the loop produced a response (placeholder for artifact processing). */
62
+ processResponse(instance: string, phase: string, response: string): void;
63
+ /**
64
+ * Attempt a phase transition after the loop determines it should advance.
65
+ * Returns the new phase name on success, or null if blocked.
66
+ */
67
+ attemptTransition(instance: string, currentPhase: string): string | null;
68
+ }
69
+ /**
70
+ * Build the system prompt from the current phase skill.
71
+ *
72
+ * The skill body forms the system message. If no skill is found, this is
73
+ * a hard error (Req 19.5) — callers must handle null skill before calling.
74
+ */
75
+ export declare function buildSystemPrompt(skillContent: string, phase: string): string;
76
+ /**
77
+ * Build the user message from packed context and the current task.
78
+ */
79
+ export declare function buildUserMessage(packResult: PackResult, step: NextStep, instanceName: string): string;
80
+ /**
81
+ * Run the orchestrator loop for a lifecycle instance.
82
+ *
83
+ * The loop repeats until:
84
+ * - The lifecycle instance reaches completion (nextStep returns 'complete')
85
+ * - maxIterations is reached (safety cap)
86
+ * - An error occurs (endpoint failure, missing skill, etc.)
87
+ *
88
+ * @param opts - Orchestrator configuration and endpoint client.
89
+ * @param loader - Context loader for state, templates, and files.
90
+ * @returns OrchestratorResult describing the outcome.
91
+ */
92
+ export declare function runOrchestratorLoop(opts: OrchestratorOpts, loader: ContextLoader): Promise<OrchestratorResult>;
93
+ //# sourceMappingURL=orchestrator-loop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator-loop.d.ts","sourceRoot":"","sources":["../../src/orchestrator/orchestrator-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAEV,cAAc,EACd,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMlE,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,MAAM,EAAE,cAAc,CAAC;IACvB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,aAAa,EAAE,MAAM,CAAC;IACtB,gEAAgE;IAChE,WAAW,EAAE,OAAO,CAAC;IACrB,6CAA6C;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,4DAA4D;AAC5D,MAAM,WAAW,kBAAkB;IACjC,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,SAAS,EAAE,OAAO,CAAC;IACnB,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,oDAAoD;IACpD,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAAC;IACnD,6CAA6C;IAC7C,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC3D,8DAA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