cc-codeconductor 0.5.0 → 1.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 (268) hide show
  1. package/README.md +387 -150
  2. package/dist/cli/errors.d.ts +65 -0
  3. package/dist/core/compilation/compile-checker.d.ts +53 -0
  4. package/dist/core/config/codeconductor-config.d.ts +42 -0
  5. package/dist/core/config/config-loader.d.ts +11 -0
  6. package/dist/core/filesystem/credential-guard.d.ts +18 -0
  7. package/dist/core/goal/goal-planner.d.ts +8 -0
  8. package/dist/core/goal/goal-state.d.ts +15 -0
  9. package/dist/core/loop/git-stats.d.ts +13 -0
  10. package/dist/core/loop/loop-engine.d.ts +82 -0
  11. package/dist/core/memory/episodic-store.d.ts +6 -0
  12. package/dist/core/memory/operational-state.d.ts +6 -0
  13. package/dist/core/orchestrator/runtime-orchestrator.d.ts +25 -0
  14. package/dist/core/planner/product-planner.d.ts +18 -0
  15. package/dist/core/presets/package-paths.d.ts +4 -0
  16. package/dist/core/product-graph/graph-store.d.ts +11 -0
  17. package/dist/core/product-graph/paths.d.ts +18 -0
  18. package/dist/core/verification/verification-runner.d.ts +57 -0
  19. package/dist/domain/loop/loop-state.d.ts +74 -0
  20. package/dist/domain/product/entities.d.ts +11 -0
  21. package/dist/index.d.ts +15 -0
  22. package/dist/index.js +24165 -15800
  23. package/dist/library.js +2744 -0
  24. package/dist/utils/result.d.ts +36 -0
  25. package/dist/validation/schemas.d.ts +4006 -0
  26. package/package.json +18 -2
  27. package/policy.yml +12 -11
  28. package/presets/agy/AGENTS.md +14 -5
  29. package/presets/agy/gates/pre-commit/GATE.md +137 -0
  30. package/presets/agy/skills/backlog/SKILL.md +91 -0
  31. package/presets/agy/skills/cc-fix/SKILL.md +2 -2
  32. package/presets/agy/skills/cc-tdd-cycle/SKILL.md +11 -0
  33. package/presets/agy/skills/openspec/SKILL.md +5 -1
  34. package/presets/agy/skills/security-ai-llm/SKILL.md +43 -0
  35. package/presets/agy/skills/security-blue-team/SKILL.md +43 -0
  36. package/presets/agy/skills/security-cloud/SKILL.md +43 -0
  37. package/presets/agy/skills/security-crypto/SKILL.md +43 -0
  38. package/presets/agy/skills/security-exploit-dev/SKILL.md +45 -0
  39. package/presets/agy/skills/security-grc/SKILL.md +43 -0
  40. package/presets/agy/skills/security-incident-response/SKILL.md +45 -0
  41. package/presets/agy/skills/security-log-analysis/SKILL.md +43 -0
  42. package/presets/agy/skills/security-malware-analysis/SKILL.md +44 -0
  43. package/presets/agy/skills/security-mobile/SKILL.md +43 -0
  44. package/presets/agy/skills/security-network/SKILL.md +43 -0
  45. package/presets/agy/skills/security-ot-ics/SKILL.md +43 -0
  46. package/presets/agy/skills/security-recon/SKILL.md +45 -0
  47. package/presets/agy/skills/security-red-team/SKILL.md +44 -0
  48. package/presets/agy/skills/security-reverse-engineering/SKILL.md +44 -0
  49. package/presets/agy/skills/security-soc-automation/SKILL.md +43 -0
  50. package/presets/agy/skills/security-threat-hunting/SKILL.md +43 -0
  51. package/presets/agy/skills/security-vuln-assessment/SKILL.md +45 -0
  52. package/presets/agy/skills/security-web/SKILL.md +44 -0
  53. package/presets/agy/workflows/cc-api-contract.md +12 -0
  54. package/presets/agy/workflows/cc-ask.md +56 -0
  55. package/presets/agy/workflows/cc-backlog.md +69 -0
  56. package/presets/agy/workflows/cc-clarify.md +33 -0
  57. package/presets/agy/workflows/cc-council.md +31 -7
  58. package/presets/agy/workflows/cc-db-migration.md +22 -9
  59. package/presets/agy/workflows/cc-explore.md +37 -0
  60. package/presets/agy/workflows/cc-feature.md +41 -19
  61. package/presets/agy/workflows/cc-fix.md +50 -23
  62. package/presets/agy/workflows/cc-handoff.md +42 -0
  63. package/presets/agy/workflows/cc-iterative.md +128 -0
  64. package/presets/agy/workflows/cc-openspec.md +16 -1
  65. package/presets/agy/workflows/cc-pagespeed.md +12 -0
  66. package/presets/agy/workflows/cc-prototype.md +39 -0
  67. package/presets/agy/workflows/cc-refactor.md +12 -0
  68. package/presets/agy/workflows/cc-review.md +12 -0
  69. package/presets/agy/workflows/cc-scorecard.md +12 -0
  70. package/presets/agy/workflows/cc-security.md +180 -0
  71. package/presets/agy/workflows/cc-tdd-cycle.md +24 -0
  72. package/presets/agy/workflows/cc-test-plan.md +12 -0
  73. package/presets/agy/workflows/cc-triage.md +35 -0
  74. package/presets/claude/CLAUDE.md +68 -0
  75. package/presets/claude/commands/cc/api-contract.md +12 -0
  76. package/presets/claude/commands/cc/ask.md +56 -0
  77. package/presets/claude/commands/cc/backlog.md +104 -0
  78. package/presets/claude/commands/cc/clarify.md +32 -0
  79. package/presets/claude/commands/cc/council.md +87 -0
  80. package/presets/claude/commands/cc/db-migration.md +22 -9
  81. package/presets/claude/commands/cc/explore.md +36 -0
  82. package/presets/claude/commands/cc/feature.md +49 -22
  83. package/presets/claude/commands/cc/fix.md +74 -20
  84. package/presets/claude/commands/cc/handoff.md +44 -0
  85. package/presets/claude/commands/cc/iterative.md +132 -0
  86. package/presets/claude/commands/cc/openspec.md +41 -1
  87. package/presets/claude/commands/cc/pagespeed.md +12 -0
  88. package/presets/claude/commands/cc/prototype.md +38 -0
  89. package/presets/claude/commands/cc/refactor.md +152 -1
  90. package/presets/claude/commands/cc/review.md +78 -16
  91. package/presets/claude/commands/cc/scorecard.md +12 -0
  92. package/presets/claude/commands/cc/security.md +179 -0
  93. package/presets/claude/commands/cc/tdd-cycle.md +53 -3
  94. package/presets/claude/commands/cc/test-plan.md +12 -0
  95. package/presets/claude/commands/cc/triage.md +34 -0
  96. package/presets/claude/gates/pre-commit/GATE.md +137 -0
  97. package/presets/claude/settings.json +8 -46
  98. package/presets/claude/skills/backlog/SKILL.md +91 -0
  99. package/presets/claude/skills/openspec/SKILL.md +5 -1
  100. package/presets/claude/skills/security/SKILL.md +382 -0
  101. package/presets/claude/skills/security-ai-llm/SKILL.md +43 -0
  102. package/presets/claude/skills/security-blue-team/SKILL.md +43 -0
  103. package/presets/claude/skills/security-cloud/SKILL.md +43 -0
  104. package/presets/claude/skills/security-crypto/SKILL.md +43 -0
  105. package/presets/claude/skills/security-exploit-dev/SKILL.md +45 -0
  106. package/presets/claude/skills/security-grc/SKILL.md +43 -0
  107. package/presets/claude/skills/security-incident-response/SKILL.md +45 -0
  108. package/presets/claude/skills/security-log-analysis/SKILL.md +43 -0
  109. package/presets/claude/skills/security-malware-analysis/SKILL.md +44 -0
  110. package/presets/claude/skills/security-mobile/SKILL.md +43 -0
  111. package/presets/claude/skills/security-network/SKILL.md +43 -0
  112. package/presets/claude/skills/security-ot-ics/SKILL.md +43 -0
  113. package/presets/claude/skills/security-recon/SKILL.md +45 -0
  114. package/presets/claude/skills/security-red-team/SKILL.md +44 -0
  115. package/presets/claude/skills/security-reverse-engineering/SKILL.md +44 -0
  116. package/presets/claude/skills/security-soc-automation/SKILL.md +43 -0
  117. package/presets/claude/skills/security-threat-hunting/SKILL.md +43 -0
  118. package/presets/claude/skills/security-vuln-assessment/SKILL.md +45 -0
  119. package/presets/claude/skills/security-web/SKILL.md +44 -0
  120. package/presets/codex/AGENTS.md +6 -6
  121. package/presets/codex/commands/cc-ask.md +56 -0
  122. package/presets/codex/gates/pre-commit/GATE.md +137 -0
  123. package/presets/cursor/AGENTS.md +8 -8
  124. package/presets/cursor/agents/business-agent.md +44 -0
  125. package/presets/cursor/agents/continuous-architect.md +37 -0
  126. package/presets/cursor/agents/docs.md +1 -0
  127. package/presets/cursor/agents/goal-planner.md +1 -1
  128. package/presets/cursor/agents/impact-analyst.md +43 -0
  129. package/presets/cursor/agents/orchestrator.md +6 -6
  130. package/presets/cursor/commands/cc/api-contract.md +12 -0
  131. package/presets/cursor/commands/cc/ask.md +56 -0
  132. package/presets/cursor/commands/cc/backlog.md +105 -0
  133. package/presets/cursor/commands/cc/clarify.md +32 -0
  134. package/presets/cursor/commands/cc/council.md +87 -0
  135. package/presets/cursor/commands/cc/db-migration.md +22 -9
  136. package/presets/cursor/commands/cc/explore.md +36 -0
  137. package/presets/cursor/commands/cc/feature.md +41 -19
  138. package/presets/cursor/commands/cc/fix.md +47 -20
  139. package/presets/cursor/commands/cc/handoff.md +41 -0
  140. package/presets/cursor/commands/cc/iterative.md +133 -0
  141. package/presets/cursor/commands/cc/openspec.md +38 -8
  142. package/presets/cursor/commands/cc/pagespeed.md +12 -0
  143. package/presets/cursor/commands/cc/prototype.md +38 -0
  144. package/presets/cursor/commands/cc/refactor.md +12 -0
  145. package/presets/cursor/commands/cc/review.md +12 -0
  146. package/presets/cursor/commands/cc/scorecard.md +12 -0
  147. package/presets/cursor/commands/cc/security.md +179 -0
  148. package/presets/cursor/commands/cc/tdd-cycle.md +24 -0
  149. package/presets/cursor/commands/cc/test-plan.md +12 -0
  150. package/presets/cursor/commands/cc/triage.md +34 -0
  151. package/presets/cursor/gates/pre-commit/GATE.md +137 -0
  152. package/presets/cursor/rules/orchestration.mdc +1 -1
  153. package/presets/cursor/skills/backlog/SKILL.md +91 -0
  154. package/presets/cursor/skills/openspec/SKILL.md +5 -1
  155. package/presets/cursor/skills/security-ai-llm/SKILL.md +43 -0
  156. package/presets/cursor/skills/security-blue-team/SKILL.md +43 -0
  157. package/presets/cursor/skills/security-cloud/SKILL.md +43 -0
  158. package/presets/cursor/skills/security-crypto/SKILL.md +43 -0
  159. package/presets/cursor/skills/security-exploit-dev/SKILL.md +45 -0
  160. package/presets/cursor/skills/security-grc/SKILL.md +43 -0
  161. package/presets/cursor/skills/security-incident-response/SKILL.md +45 -0
  162. package/presets/cursor/skills/security-log-analysis/SKILL.md +43 -0
  163. package/presets/cursor/skills/security-malware-analysis/SKILL.md +44 -0
  164. package/presets/cursor/skills/security-mobile/SKILL.md +43 -0
  165. package/presets/cursor/skills/security-network/SKILL.md +43 -0
  166. package/presets/cursor/skills/security-ot-ics/SKILL.md +43 -0
  167. package/presets/cursor/skills/security-recon/SKILL.md +45 -0
  168. package/presets/cursor/skills/security-red-team/SKILL.md +44 -0
  169. package/presets/cursor/skills/security-reverse-engineering/SKILL.md +44 -0
  170. package/presets/cursor/skills/security-soc-automation/SKILL.md +43 -0
  171. package/presets/cursor/skills/security-threat-hunting/SKILL.md +43 -0
  172. package/presets/cursor/skills/security-vuln-assessment/SKILL.md +45 -0
  173. package/presets/cursor/skills/security-web/SKILL.md +44 -0
  174. package/presets/opencode/agents/architect.md +22 -1
  175. package/presets/opencode/agents/complexity-auditor.md +16 -1
  176. package/presets/opencode/agents/contract-builder.md +17 -1
  177. package/presets/opencode/agents/devil.md +158 -0
  178. package/presets/opencode/agents/docs.md +19 -1
  179. package/presets/opencode/agents/goal-planner.md +32 -2
  180. package/presets/opencode/agents/implementer.md +32 -2
  181. package/presets/opencode/agents/orchestrator.md +79 -12
  182. package/presets/opencode/agents/planner.md +61 -0
  183. package/presets/opencode/agents/repo-explorer.md +16 -0
  184. package/presets/opencode/agents/reviewer.md +33 -3
  185. package/presets/opencode/agents/security-reviewer.md +31 -1
  186. package/presets/opencode/agents/task-coach.md +69 -1
  187. package/presets/opencode/agents/tester.md +18 -1
  188. package/presets/opencode/commands/cc-api-contract.md +12 -0
  189. package/presets/opencode/commands/cc-ask.md +56 -0
  190. package/presets/opencode/commands/cc-backlog.md +68 -0
  191. package/presets/opencode/commands/cc-clarify.md +31 -0
  192. package/presets/opencode/commands/cc-council.md +87 -0
  193. package/presets/opencode/commands/cc-db-migration.md +22 -9
  194. package/presets/opencode/commands/cc-explore.md +35 -0
  195. package/presets/opencode/commands/cc-feature.md +41 -19
  196. package/presets/opencode/commands/cc-fix.md +50 -23
  197. package/presets/opencode/commands/cc-handoff.md +40 -0
  198. package/presets/opencode/commands/cc-iterative.md +127 -0
  199. package/presets/opencode/commands/cc-openspec.md +16 -1
  200. package/presets/opencode/commands/cc-pagespeed.md +12 -0
  201. package/presets/opencode/commands/cc-prototype.md +37 -0
  202. package/presets/opencode/commands/cc-refactor.md +12 -0
  203. package/presets/opencode/commands/cc-review.md +12 -0
  204. package/presets/opencode/commands/cc-scorecard.md +12 -0
  205. package/presets/opencode/commands/cc-security.md +179 -0
  206. package/presets/opencode/commands/cc-tdd-cycle.md +24 -0
  207. package/presets/opencode/commands/cc-test-plan.md +12 -0
  208. package/presets/opencode/commands/cc-triage.md +33 -0
  209. package/presets/opencode/gates/pre-commit/GATE.md +137 -0
  210. package/presets/opencode/prompts/v0.1.0/DEPRECATED.md +11 -0
  211. package/presets/opencode/prompts/v0.2.0/DEPRECATED.md +11 -0
  212. package/presets/opencode/prompts/v0.3.0/DEPRECATED.md +11 -0
  213. package/presets/opencode/prompts/v0.4.0/DEPRECATED.md +11 -0
  214. package/presets/opencode/prompts/v0.5.0/goal-planner.md +1 -1
  215. package/presets/opencode/prompts/v0.5.0/orchestrator.md +6 -6
  216. package/presets/opencode/prompts/v0.6.0/implementer.md +35 -0
  217. package/presets/opencode/prompts/v0.6.0/planner.md +36 -0
  218. package/presets/opencode/prompts/v0.6.0/reviewer.md +40 -0
  219. package/presets/opencode/prompts/v1.0.0/README.md +47 -0
  220. package/presets/opencode/prompts/v1.0.0/architect.md +259 -0
  221. package/presets/opencode/prompts/v1.0.0/complexity-auditor.md +116 -0
  222. package/presets/opencode/prompts/v1.0.0/contract-builder.md +120 -0
  223. package/presets/opencode/prompts/v1.0.0/devil.md +169 -0
  224. package/presets/opencode/prompts/v1.0.0/docs.md +229 -0
  225. package/presets/opencode/prompts/v1.0.0/goal-planner.md +123 -0
  226. package/presets/opencode/prompts/v1.0.0/implementer.md +228 -0
  227. package/presets/opencode/prompts/v1.0.0/orchestrator.md +474 -0
  228. package/presets/opencode/prompts/v1.0.0/planner.md +72 -0
  229. package/presets/opencode/prompts/v1.0.0/repo-explorer.md +147 -0
  230. package/presets/opencode/prompts/v1.0.0/reviewer.md +295 -0
  231. package/presets/opencode/prompts/v1.0.0/security-reviewer.md +170 -0
  232. package/presets/opencode/prompts/v1.0.0/task-coach.md +235 -0
  233. package/presets/opencode/prompts/v1.0.0/tester.md +298 -0
  234. package/presets/opencode/skills/backlog/SKILL.md +91 -0
  235. package/presets/opencode/skills/openspec/SKILL.md +5 -1
  236. package/presets/opencode/skills/security-ai-llm/SKILL.md +43 -0
  237. package/presets/opencode/skills/security-blue-team/SKILL.md +43 -0
  238. package/presets/opencode/skills/security-cloud/SKILL.md +43 -0
  239. package/presets/opencode/skills/security-crypto/SKILL.md +43 -0
  240. package/presets/opencode/skills/security-exploit-dev/SKILL.md +45 -0
  241. package/presets/opencode/skills/security-grc/SKILL.md +43 -0
  242. package/presets/opencode/skills/security-incident-response/SKILL.md +45 -0
  243. package/presets/opencode/skills/security-log-analysis/SKILL.md +43 -0
  244. package/presets/opencode/skills/security-malware-analysis/SKILL.md +44 -0
  245. package/presets/opencode/skills/security-mobile/SKILL.md +43 -0
  246. package/presets/opencode/skills/security-network/SKILL.md +43 -0
  247. package/presets/opencode/skills/security-ot-ics/SKILL.md +43 -0
  248. package/presets/opencode/skills/security-recon/SKILL.md +45 -0
  249. package/presets/opencode/skills/security-red-team/SKILL.md +44 -0
  250. package/presets/opencode/skills/security-reverse-engineering/SKILL.md +44 -0
  251. package/presets/opencode/skills/security-soc-automation/SKILL.md +43 -0
  252. package/presets/opencode/skills/security-threat-hunting/SKILL.md +43 -0
  253. package/presets/opencode/skills/security-vuln-assessment/SKILL.md +45 -0
  254. package/presets/opencode/skills/security-web/SKILL.md +44 -0
  255. package/presets/seo-hotel/settings.json +0 -17
  256. package/src/presets/council/council.yml +12 -0
  257. package/src/presets/manifests/agy.yml +2 -2
  258. package/src/presets/manifests/claude.yml +2 -2
  259. package/src/presets/manifests/codex.yml +2 -2
  260. package/src/presets/manifests/cursor.yml +2 -2
  261. package/src/presets/manifests/gemini.yml +2 -2
  262. package/src/presets/manifests/opencode.yml +2 -2
  263. package/src/presets/models/agy.yml +93 -66
  264. package/src/presets/models/claude.yml +79 -53
  265. package/src/presets/models/codex.yml +79 -54
  266. package/src/presets/models/cursor.yml +72 -58
  267. package/src/presets/models/gemini.yml +79 -53
  268. package/src/presets/models/opencode.yml +72 -46
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Exit codes as per CLI contract
3
+ */
4
+ export declare const ExitCode: {
5
+ readonly SUCCESS: 0;
6
+ readonly VALIDATION_ERROR: 1;
7
+ readonly UNSAFE_OPERATION: 2;
8
+ readonly UNSUPPORTED_PROJECT: 3;
9
+ readonly CONFIG_CONFLICT: 4;
10
+ readonly CREDENTIAL_LEAK: 5;
11
+ };
12
+ export type ExitCodeType = (typeof ExitCode)[keyof typeof ExitCode];
13
+ /**
14
+ * Base error class for CLI errors
15
+ */
16
+ export declare class CliError extends Error {
17
+ readonly code: ExitCodeType;
18
+ readonly details?: unknown | undefined;
19
+ constructor(message: string, code: ExitCodeType, details?: unknown | undefined);
20
+ }
21
+ /**
22
+ * Validation error - invalid arguments, malformed config, Zod validation failure
23
+ */
24
+ export declare class ValidationError extends CliError {
25
+ constructor(message: string, details?: unknown);
26
+ }
27
+ /**
28
+ * Unsafe operation - destructive operation without --force, protected path conflict
29
+ */
30
+ export declare class UnsafeOperationError extends CliError {
31
+ constructor(message: string, details?: unknown);
32
+ }
33
+ /**
34
+ * Unsupported project - project stack not detected or not supported
35
+ */
36
+ export declare class UnsupportedProjectError extends CliError {
37
+ constructor(message: string, details?: unknown);
38
+ }
39
+ /**
40
+ * Config conflict - existing config conflicts with requested operation
41
+ */
42
+ export declare class ConfigConflictError extends CliError {
43
+ constructor(message: string, details?: unknown);
44
+ }
45
+ /**
46
+ * Credential leak - content contains secrets or API keys
47
+ */
48
+ export declare class CredentialGuardError extends CliError {
49
+ readonly matches: ReadonlyArray<{
50
+ filePath: string;
51
+ line: number;
52
+ pattern: string;
53
+ matched: string;
54
+ }>;
55
+ constructor(message: string, matches: ReadonlyArray<{
56
+ filePath: string;
57
+ line: number;
58
+ pattern: string;
59
+ matched: string;
60
+ }>, details?: unknown);
61
+ }
62
+ /**
63
+ * Map error to exit code
64
+ */
65
+ export declare function getExitCode(error: unknown): ExitCodeType;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Compile Check — runs a build command via Bun.spawn, captures output,
3
+ * parses errors, and returns structured results for re-injection.
4
+ */
5
+ export interface CompileError {
6
+ file: string;
7
+ line?: number;
8
+ column?: number;
9
+ code: string;
10
+ message: string;
11
+ raw: string;
12
+ }
13
+ export interface CompileResult {
14
+ success: boolean;
15
+ exitCode: number;
16
+ stdout: string;
17
+ stderr: string;
18
+ errors: CompileError[];
19
+ durationMs: number;
20
+ timedOut: boolean;
21
+ skipped?: boolean;
22
+ skipReason?: string;
23
+ }
24
+ export interface CompileCheckOptions {
25
+ /**
26
+ * Shell command to run (string or pre-split args). Default: `tsc --noEmit`.
27
+ * Must be a project-trusted compile command from config, never unsanitized CLI input.
28
+ */
29
+ command?: string | string[];
30
+ /** Working directory. Default: process.cwd() */
31
+ cwd?: string;
32
+ /** Timeout in milliseconds. Default: 120 000 (2 min) */
33
+ timeoutMs?: number;
34
+ }
35
+ /**
36
+ * Tokenize a shell command string, respecting single and double quotes.
37
+ *
38
+ * Exported so other modules that must spawn configured commands (e.g. the
39
+ * regression checklist) can avoid invoking a shell entirely.
40
+ */
41
+ export declare function tokenizeCommand(cmd: string): string[];
42
+ export declare function isAllowlistedCompileCommand(command: string | string[]): boolean;
43
+ /** Allowlisted commands that actually run a test suite (`bun test`, `npm test`, …). */
44
+ export declare function isAllowlistedTestCommand(command: string | string[]): boolean;
45
+ /**
46
+ * Parse compile stderr output into structured CompileError[].
47
+ * Tries TypeScript format first, then ESLint, then generic.
48
+ */
49
+ export declare function parseCompileErrors(stderr: string): CompileError[];
50
+ /**
51
+ * Run a compile check via Bun.spawn with configurable timeout.
52
+ */
53
+ export declare function runCompileCheck(options?: CompileCheckOptions): Promise<CompileResult>;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * CodeConductor configuration interface
3
+ */
4
+ export interface CodeConductorConfig {
5
+ version: string;
6
+ project: {
7
+ name: string;
8
+ profile?: string;
9
+ };
10
+ defaults: {
11
+ target: 'opencode' | 'claude' | 'codex' | 'gemini' | 'cursor' | 'agy';
12
+ overwrite: boolean;
13
+ locale: 'en' | 'es';
14
+ };
15
+ presets: {
16
+ council: {
17
+ enabled: boolean;
18
+ version: string;
19
+ };
20
+ };
21
+ safety: {
22
+ destructiveCommands: string[];
23
+ secretPatterns: string[];
24
+ compileCheck?: {
25
+ enabled: boolean;
26
+ command?: string;
27
+ timeoutMs?: number;
28
+ };
29
+ };
30
+ loop?: {
31
+ enabled?: boolean;
32
+ maxIterations?: number;
33
+ maxTokenBudget?: number;
34
+ };
35
+ }
36
+ /**
37
+ * Default configuration.
38
+ * `safety.secretPatterns` references `DEFAULT_SECRET_PATTERNS` from
39
+ * credential-guard.ts so there is a single source of truth for default
40
+ * credential patterns.
41
+ */
42
+ export declare const DEFAULT_CONFIG: CodeConductorConfig;
@@ -0,0 +1,11 @@
1
+ import { ValidationError } from '../../cli/errors';
2
+ import { type Result } from '../../utils/result';
3
+ import type { CodeConductorConfig } from './codeconductor-config';
4
+ /**
5
+ * Load configuration from project root
6
+ */
7
+ export declare function loadConfig(projectRoot: string): Promise<Result<CodeConductorConfig, ValidationError>>;
8
+ /**
9
+ * Check if config exists
10
+ */
11
+ export declare function configExists(projectRoot: string): Promise<boolean>;
@@ -0,0 +1,18 @@
1
+ import type { CodeConductorConfig } from '../config/codeconductor-config';
2
+ /**
3
+ * Default keyword patterns. Empty by design: built-in detection is handled by
4
+ * the high-confidence signatures in `safety.ts`, which match provider-specific
5
+ * credential shapes instead of generic keyword assignments. Keyword matching
6
+ * remains available as an opt-in via project `secretPatterns`.
7
+ */
8
+ export declare const DEFAULT_SECRET_PATTERNS: string[];
9
+ /**
10
+ * Load opt-in keyword patterns by merging sources in priority order:
11
+ * 1. CodeConductorConfig.safety.secretPatterns (highest — user/project overrides)
12
+ * 2. policy.yml secretPatterns (declarative policy)
13
+ * 3. DEFAULT_SECRET_PATTERNS (empty — see above)
14
+ *
15
+ * These are additive to the always-on high-confidence signatures.
16
+ * Note: policy.yml loading is async, so this function is async.
17
+ */
18
+ export declare function loadCredentialPatterns(config?: CodeConductorConfig): Promise<ReadonlyArray<string>>;
@@ -0,0 +1,8 @@
1
+ import type { GoalGraphInput } from '../../validation/schemas';
2
+ /**
3
+ * Pure function: objective string → GoalGraph
4
+ *
5
+ * Matches the objective against built-in templates (auth, crud, search,
6
+ * notification, migration) or falls back to a generic 4-task chain.
7
+ */
8
+ export declare function planGoal(objective: string): GoalGraphInput;
@@ -0,0 +1,15 @@
1
+ import { type GoalGraphInput } from '../../validation/schemas';
2
+ import { type Result } from '../../utils/result';
3
+ /**
4
+ * Write a goal graph to .codeconductor/current-goal.yml
5
+ */
6
+ export declare function writeGoal(projectRoot: string, graph: GoalGraphInput): Promise<Result<void, Error>>;
7
+ /**
8
+ * Load and validate a goal graph from .codeconductor/current-goal.yml
9
+ */
10
+ export declare function loadGoal(projectRoot: string): Promise<Result<GoalGraphInput, Error>>;
11
+ /**
12
+ * Mark a task as blocked in the goal graph.
13
+ * Loads the graph, finds the task by ID, sets status to 'blocked', and writes back.
14
+ */
15
+ export declare function markTaskBlocked(projectRoot: string, taskId: string, reason: string): Promise<Result<void, Error>>;
@@ -0,0 +1,13 @@
1
+ /** Shared TTL so loop iterations do not spawn git on every tick. */
2
+ export declare const GIT_STATS_CACHE_TTL_MS = 3000;
3
+ export interface GitChangeStats {
4
+ readonly filesModified: number;
5
+ readonly linesChanged: number;
6
+ }
7
+ export type GitStatsReader = (cwd: string) => Promise<GitChangeStats>;
8
+ export declare function resetGitStatsCache(): void;
9
+ export declare function fetchGitChangeStats(cwd: string): Promise<GitChangeStats>;
10
+ export declare function readGitChangeStats(cwd: string, options?: {
11
+ readonly now?: number;
12
+ readonly fetch?: GitStatsReader;
13
+ }): Promise<GitChangeStats>;
@@ -0,0 +1,82 @@
1
+ import { type CompileError, type CompileResult } from '../compilation/compile-checker';
2
+ import { type LoopState, type TddState } from '../../domain/loop/loop-state';
3
+ import { type GitStatsReader } from './git-stats';
4
+ import { type Result } from '../../utils/result';
5
+ export interface LoopConfig {
6
+ maxIterations?: number;
7
+ maxTokenBudget?: number;
8
+ buildCommand?: string;
9
+ cwd?: string;
10
+ maxWallClockSeconds?: number;
11
+ maxFilesModified?: number;
12
+ maxLinesChanged?: number;
13
+ gitStats?: GitStatsReader;
14
+ }
15
+ export interface EscalationReport {
16
+ readonly taskTitle: string;
17
+ readonly iterationsAttempted: number;
18
+ readonly errorHistory: readonly (readonly CompileError[])[];
19
+ readonly attemptedFixes: readonly string[];
20
+ readonly originalContext: string;
21
+ readonly recommendedAction: string;
22
+ }
23
+ export interface LoopResult {
24
+ readonly success: boolean;
25
+ readonly iterations: number;
26
+ readonly totalErrors: number;
27
+ readonly finalPhase: LoopState['phase'];
28
+ readonly escalationReport?: EscalationReport;
29
+ readonly errorHistory: readonly (readonly CompileError[])[];
30
+ readonly compileCheck?: 'ran' | 'skipped';
31
+ readonly compileCheckSkipReason?: string;
32
+ }
33
+ export type GuardrailHit = {
34
+ readonly kind: 'timeout';
35
+ readonly elapsedSeconds: number;
36
+ readonly limit: number;
37
+ } | {
38
+ readonly kind: 'files';
39
+ readonly count: number;
40
+ readonly limit: number;
41
+ } | {
42
+ readonly kind: 'lines';
43
+ readonly count: number;
44
+ readonly limit: number;
45
+ };
46
+ /**
47
+ * Shared wall-clock / git-diff budget checks for compile-fix and the 8-phase pipeline.
48
+ */
49
+ export declare class LoopEngine {
50
+ private readonly limits;
51
+ readonly startedAt: number;
52
+ constructor(limits: {
53
+ readonly maxWallClockSeconds?: number;
54
+ readonly maxFilesModified?: number;
55
+ readonly maxLinesChanged?: number;
56
+ readonly cwd?: string;
57
+ }, gitStats?: GitStatsReader, startedAt?: number);
58
+ private readonly gitStats;
59
+ evaluate(scope?: 'time' | 'all'): Promise<GuardrailHit | null>;
60
+ }
61
+ export declare function formatFeedback(errors: readonly CompileError[]): string;
62
+ export type GenerateFn = (feedback?: string) => Promise<{
63
+ tokenUsage: number;
64
+ } | void>;
65
+ export type CompileCheckFn = () => Promise<CompileResult>;
66
+ export declare function runLoop(generateFn: GenerateFn, compileCheckFn: CompileCheckFn, config?: LoopConfig, taskTitle?: string, originalTask?: string): Promise<LoopResult>;
67
+ export declare function skippedCompileResult(reason: string): CompileResult;
68
+ /** implement / test agent phases that must run the compile-fix engine. */
69
+ export declare function shouldRunAgentLoop(type?: string, agentType?: string, phase?: string): boolean;
70
+ /**
71
+ * Apply runner-captured TDD suite evidence to the domain TDD machine.
72
+ * Hand-written evidence files fail closed via `loadTddSuiteEvidence`.
73
+ */
74
+ export declare function advanceTddPhase(projectRoot: string, taskId: string, state: TddState, evidenceId: string): Promise<Result<{
75
+ state: TddState;
76
+ result: 'CONTINUE' | 'TERMINATE';
77
+ }, Error>>;
78
+ export declare function runLoopForProject(projectRoot: string, options: {
79
+ readonly taskTitle: string;
80
+ readonly allowCompileCheck?: boolean;
81
+ readonly originalTask?: string;
82
+ }): Promise<LoopResult>;
@@ -0,0 +1,6 @@
1
+ import { type ProductEventInput } from '../../validation/schemas';
2
+ import { type Result } from '../../utils/result';
3
+ export declare function appendEvent(projectRoot: string, event: Omit<ProductEventInput, 'id'> & {
4
+ id?: string;
5
+ }): Promise<Result<ProductEventInput, Error>>;
6
+ export declare function listEvents(projectRoot: string, since?: string, type?: ProductEventInput['type']): Promise<Result<ProductEventInput[], Error>>;
@@ -0,0 +1,6 @@
1
+ import { type OperationalStateInput } from '../../validation/schemas';
2
+ import { type Result } from '../../utils/result';
3
+ export declare function loadOperationalState(projectRoot: string): Promise<Result<OperationalStateInput, Error>>;
4
+ export declare function saveOperationalState(projectRoot: string, state: OperationalStateInput): Promise<Result<void, Error>>;
5
+ export declare function setActiveTask(projectRoot: string, taskId: string, agent?: string): Promise<Result<void, Error>>;
6
+ export declare function clearActiveTask(projectRoot: string, taskId: string): Promise<Result<void, Error>>;
@@ -0,0 +1,25 @@
1
+ import type { CanonicalTaskCardInput, GoalGraphInput, GoalTaskInput, OperationalStateInput } from '../../validation/schemas';
2
+ import { type Result } from '../../utils/result';
3
+ import type { CommandEnvelopeInput } from '../../validation/schemas';
4
+ /**
5
+ * Undo a task status change and restore the operational state captured before
6
+ * it. Used when a later step fails, so a task is never left half-transitioned.
7
+ * The original failure is returned, annotated when the undo itself fails.
8
+ */
9
+ export declare function rollbackTaskStatus(projectRoot: string, graph: GoalGraphInput, task: GoalTaskInput, previousStatus: GoalTaskInput['status'], previousState: OperationalStateInput, cause: Error): Promise<Result<never, Error>>;
10
+ export declare function getReadyTasks(graph: GoalGraphInput): GoalTaskInput[];
11
+ export declare function goalTaskToCanonicalCard(task: GoalTaskInput & {
12
+ targetFiles?: string[];
13
+ agentType?: string;
14
+ evidenceRequired?: string[];
15
+ }, objective: string): CanonicalTaskCardInput;
16
+ export declare function buildTaskEnvelope(card: CanonicalTaskCardInput, projectRoot: string, projectName: string): CommandEnvelopeInput;
17
+ export interface OrchestratorNextResult {
18
+ task: CanonicalTaskCardInput;
19
+ envelope: CommandEnvelopeInput;
20
+ readyCount: number;
21
+ }
22
+ export declare function getNextTask(projectRoot: string, projectName: string): Promise<Result<OrchestratorNextResult, Error>>;
23
+ export declare function startTask(projectRoot: string, taskId: string, agent?: string): Promise<Result<void, Error>>;
24
+ export declare function completeTask(projectRoot: string, taskId: string, evidenceIds?: string[]): Promise<Result<void, Error>>;
25
+ export declare function formatGoalStatus(graph: GoalGraphInput): string;
@@ -0,0 +1,18 @@
1
+ import type { GoalGraphInput, GoalTaskInput, ProductGraphInput } from '../../validation/schemas';
2
+ export declare function inferEvidenceRequired(task: GoalTaskInput): string[];
3
+ export interface ProductGoalGraph extends GoalGraphInput {
4
+ productEnriched: boolean;
5
+ impactPreview?: {
6
+ components: string[];
7
+ requirements: string[];
8
+ };
9
+ }
10
+ export declare function planProductGoal(objective: string, graph?: ProductGraphInput): ProductGoalGraph;
11
+ export declare function enrichGoalWithProduct(graph: GoalGraphInput, productGraph?: ProductGraphInput): GoalGraphInput & {
12
+ enrichedTasks: Array<GoalTaskInput & {
13
+ targetFiles: string[];
14
+ agentType: string;
15
+ evidenceRequired: string[];
16
+ }>;
17
+ };
18
+ export declare function scoreTaskPriority(task: GoalTaskInput, graph?: ProductGraphInput): number;
@@ -0,0 +1,4 @@
1
+ export declare const PACKAGE_ROOT: string;
2
+ export declare const SRC_PRESETS_DIR: string;
3
+ export declare const ROOT_PRESETS_DIR: string;
4
+ export declare const POLICY_PATH: string;
@@ -0,0 +1,11 @@
1
+ import type { ProductNodeType } from '../../domain/product/entities';
2
+ import { type ProductGraphInput, type ProductGraphNodeInput, type ProductGraphEdgeInput } from '../../validation/schemas';
3
+ import { type Result } from '../../utils/result';
4
+ export declare function loadGraph(projectRoot: string): Promise<Result<ProductGraphInput, Error>>;
5
+ export declare function saveGraph(projectRoot: string, graph: ProductGraphInput): Promise<Result<void, Error>>;
6
+ export declare function upsertNode(graph: ProductGraphInput, node: ProductGraphNodeInput): ProductGraphInput;
7
+ export declare function linkNodes(graph: ProductGraphInput, edge: ProductGraphEdgeInput): ProductGraphInput;
8
+ export declare function queryNodes(graph: ProductGraphInput, type?: ProductNodeType, textFilter?: string): ProductGraphNodeInput[];
9
+ export declare function findPath(graph: ProductGraphInput, fromId: string, toId: string): string[] | null;
10
+ export declare function countByType(graph: ProductGraphInput): Record<string, number>;
11
+ export declare function getNeighbors(graph: ProductGraphInput, nodeId: string, relation?: ProductGraphEdgeInput['relation']): ProductGraphNodeInput[];
@@ -0,0 +1,18 @@
1
+ export declare const PRODUCT_DIR = ".codeconductor";
2
+ export declare const PRODUCT_GRAPH_FILE = "product-graph.json";
3
+ export declare const PRODUCT_META_FILE = "product-meta.json";
4
+ export declare const EVENTS_FILE = "events.jsonl";
5
+ export declare const OPERATIONAL_STATE_FILE = "operational-state.json";
6
+ export declare const STRATEGIC_FILE = "strategic.json";
7
+ export declare const PRODUCT_REPORT_FILE = "product-report.md";
8
+ export declare const FEEDBACK_SOURCES_FILE = "feedback-sources.yml";
9
+ export declare const DECISIONS_DIR = "decisions";
10
+ export declare const EVIDENCE_DIR = "evidence";
11
+ export declare function productGraphPath(projectRoot: string): string;
12
+ export declare function productMetaPath(projectRoot: string): string;
13
+ export declare function eventsPath(projectRoot: string): string;
14
+ export declare function operationalStatePath(projectRoot: string): string;
15
+ export declare function strategicPath(projectRoot: string): string;
16
+ export declare function productReportPath(projectRoot: string): string;
17
+ export declare function decisionsDir(projectRoot: string): string;
18
+ export declare function evidenceDir(projectRoot: string): string;
@@ -0,0 +1,57 @@
1
+ import type { GoalGraphInput } from '../../validation/schemas';
2
+ import type { TddSuiteEvidence } from '../../domain/loop/loop-state';
3
+ import { type Result } from '../../utils/result';
4
+ export interface VerificationCheck {
5
+ name: string;
6
+ passed: boolean;
7
+ message: string;
8
+ }
9
+ /**
10
+ * Check that ids handed to a completion really name evidence of this task.
11
+ *
12
+ * Every id must resolve to a stored record that parses as `EvidenceSchema`,
13
+ * carries that exact id, is related to this task and records a passing result —
14
+ * and at least one cited id must be a passing `verification` record, so
15
+ * supporting test/review evidence alone cannot stand in for verification.
16
+ */
17
+ export declare function validateEvidenceIds(projectRoot: string, taskId: string, evidenceIds: string[]): Promise<Result<void, Error>>;
18
+ export interface RunVerificationOptions {
19
+ /**
20
+ * Explicit trust to execute the compile command configured by the analyzed
21
+ * project itself (`.codeconductor/config.yml`). Without this opt-in the
22
+ * command is executed only if it matches the compile allowlist
23
+ * (`tsc`, `bun run`, `npm test`, …). Anything else fails closed.
24
+ */
25
+ readonly allowCompileCheck?: boolean;
26
+ }
27
+ export declare function runVerification(projectRoot: string, taskId: string, goal?: GoalGraphInput, options?: RunVerificationOptions): Promise<Result<{
28
+ passed: boolean;
29
+ checks: VerificationCheck[];
30
+ evidenceIds: string[];
31
+ }, Error>>;
32
+ /**
33
+ * Decide whether a task may be completed.
34
+ *
35
+ * A requirement is only satisfied by evidence of the matching type whose
36
+ * payload proves success. Unknown requirements, missing evidence and
37
+ * unreadable evidence all block completion.
38
+ */
39
+ export declare function gateTaskCompletion(projectRoot: string, taskId: string, evidenceRequired: string[], evidenceIds?: string[]): Promise<Result<boolean, Error>>;
40
+ export interface CaptureTddSuiteOptions extends RunVerificationOptions {
41
+ /** Allowlisted test command (`bun test`, `npm test`, …). */
42
+ readonly command: string;
43
+ }
44
+ /**
45
+ * Run a test suite and store TDD evidence. Only this function writes records
46
+ * that `tddCycleStateMachine` will accept as RED/GREEN gates.
47
+ */
48
+ export declare function captureTddSuiteEvidence(projectRoot: string, taskId: string, options: CaptureTddSuiteOptions): Promise<Result<{
49
+ evidenceId: string;
50
+ suiteFailed: boolean;
51
+ suitePassed: boolean;
52
+ }, Error>>;
53
+ /**
54
+ * Load TDD suite evidence written by `captureTddSuiteEvidence`. Hand-edited
55
+ * files (wrong source/type/`capturedBy`) are rejected.
56
+ */
57
+ export declare function loadTddSuiteEvidence(projectRoot: string, taskId: string, evidenceId: string): Promise<Result<TddSuiteEvidence, Error>>;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Loop State Machine — pure state transitions for compile-fix iteration cycles.
3
+ *
4
+ * Phases: IDLE → RUNNING → CHECKING → FEEDBACK → (back to RUNNING or DONE/FAILED/ESCALATED)
5
+ */
6
+ import type { CompileError } from '../../core/compilation/compile-checker';
7
+ export type LoopPhase = 'IDLE' | 'RUNNING' | 'CHECKING' | 'FEEDBACK' | 'DONE' | 'FAILED' | 'ESCALATED';
8
+ export interface LoopState {
9
+ readonly phase: LoopPhase;
10
+ readonly iteration: number;
11
+ readonly maxIterations: number;
12
+ readonly errors: readonly CompileError[];
13
+ readonly errorHistory: readonly (readonly CompileError[])[];
14
+ readonly tokenBudgetUsed: number;
15
+ readonly maxTokenBudget: number;
16
+ }
17
+ export type LoopAction = {
18
+ readonly type: 'START';
19
+ } | {
20
+ readonly type: 'CODE_GENERATED';
21
+ } | {
22
+ readonly type: 'COMPILE_CHECK_COMPLETED';
23
+ readonly errors: readonly CompileError[];
24
+ } | {
25
+ readonly type: 'FEEDBACK_FORMATTED';
26
+ } | {
27
+ readonly type: 'TOKEN_BUDGET_EXCEEDED';
28
+ readonly tokenUsage: number;
29
+ } | {
30
+ readonly type: 'ABORT';
31
+ };
32
+ export type LoopActionResult = 'CONTINUE' | 'TERMINATE';
33
+ /**
34
+ * Create an initial LoopState with sensible defaults.
35
+ */
36
+ export declare function createInitialState(overrides?: Partial<LoopState>): LoopState;
37
+ /**
38
+ * Pure state machine — given a state and an action, returns the new state.
39
+ * No side effects. Logs are the caller's responsibility.
40
+ */
41
+ export declare function loopStateMachine(state: LoopState, action: LoopAction): {
42
+ state: LoopState;
43
+ result: LoopActionResult;
44
+ };
45
+ /**
46
+ * Evidence payload that may advance TDD phases. Only records written by
47
+ * `captureTddSuiteEvidence` set `capturedBy: 'verification-runner'`.
48
+ */
49
+ export interface TddSuiteEvidence {
50
+ readonly capturedBy: string;
51
+ readonly suiteFailed: boolean;
52
+ readonly suitePassed: boolean;
53
+ }
54
+ export type TddPhase = 'RED' | 'GREEN' | 'REFACTOR' | 'FAILED';
55
+ export interface TddState {
56
+ readonly phase: TddPhase;
57
+ readonly evidenceIds: readonly string[];
58
+ }
59
+ export type TddAction = {
60
+ readonly type: 'SUITE_EVIDENCE';
61
+ readonly evidenceId: string;
62
+ readonly evidence: TddSuiteEvidence;
63
+ } | {
64
+ readonly type: 'ABORT';
65
+ };
66
+ export declare function createInitialTddState(): TddState;
67
+ /**
68
+ * Guarded TDD phase machine. RED→GREEN needs a failing suite captured by the
69
+ * verification runner; GREEN→REFACTOR needs a passing suite from the same source.
70
+ */
71
+ export declare function tddCycleStateMachine(state: TddState, action: TddAction): {
72
+ state: TddState;
73
+ result: LoopActionResult;
74
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Product OS entity taxonomy — pure types for the product AST.
3
+ * Persisted forms are validated via Zod schemas in validation/schemas.ts.
4
+ */
5
+ export type ConfidenceLevel = 'low' | 'medium' | 'high';
6
+ export type ProductNodeType = 'product' | 'domain' | 'capability' | 'requirement' | 'decision' | 'component' | 'flow' | 'contract' | 'metric' | 'risk' | 'task' | 'evidence';
7
+ export type GraphRelation = 'implements' | 'depends_on' | 'documents' | 'affects' | 'evidences' | 'blocks' | 'contains';
8
+ export type MemoryLayer = 'operational' | 'semantic' | 'episodic' | 'procedural' | 'strategic';
9
+ export type ProductEventType = 'task.started' | 'task.completed' | 'decision.recorded' | 'evidence.added' | 'ingest.completed' | 'goal.updated' | 'blocker.detected' | 'verification.completed' | 'feedback.processed';
10
+ export declare const PRODUCT_NODE_TYPES: readonly ProductNodeType[];
11
+ export declare const GRAPH_RELATIONS: readonly GraphRelation[];
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Public library surface for CodeConductor.
3
+ *
4
+ * CLI remains `dist/index.js` (`bin`). This module is the programmatic API.
5
+ * Do not re-export `infrastructure/` or `*-internal` modules.
6
+ */
7
+ export { getReadyTasks, goalTaskToCanonicalCard, buildTaskEnvelope, getNextTask, startTask, completeTask, rollbackTaskStatus, formatGoalStatus, } from './core/orchestrator/runtime-orchestrator';
8
+ export type { OrchestratorNextResult } from './core/orchestrator/runtime-orchestrator';
9
+ export { LoopEngine, runLoop, runLoopForProject, shouldRunAgentLoop, formatFeedback, advanceTddPhase, } from './core/loop/loop-engine';
10
+ export type { LoopConfig, LoopResult, EscalationReport, GuardrailHit, GenerateFn, CompileCheckFn, } from './core/loop/loop-engine';
11
+ export { runVerification, gateTaskCompletion, validateEvidenceIds, captureTddSuiteEvidence, loadTddSuiteEvidence, } from './core/verification/verification-runner';
12
+ export type { RunVerificationOptions, VerificationCheck, CaptureTddSuiteOptions, } from './core/verification/verification-runner';
13
+ export * from './validation/schemas';
14
+ export { createInitialState, loopStateMachine, createInitialTddState, tddCycleStateMachine, } from './domain/loop/loop-state';
15
+ export type { LoopPhase, LoopState, LoopAction, LoopActionResult, TddPhase, TddState, TddAction, TddSuiteEvidence, } from './domain/loop/loop-state';