ai-sdlc 0.1.0-alpha.1

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 (96) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +847 -0
  3. package/dist/agents/implementation.d.ts +11 -0
  4. package/dist/agents/implementation.d.ts.map +1 -0
  5. package/dist/agents/implementation.js +123 -0
  6. package/dist/agents/implementation.js.map +1 -0
  7. package/dist/agents/index.d.ts +7 -0
  8. package/dist/agents/index.d.ts.map +1 -0
  9. package/dist/agents/index.js +8 -0
  10. package/dist/agents/index.js.map +1 -0
  11. package/dist/agents/planning.d.ts +9 -0
  12. package/dist/agents/planning.d.ts.map +1 -0
  13. package/dist/agents/planning.js +84 -0
  14. package/dist/agents/planning.js.map +1 -0
  15. package/dist/agents/refinement.d.ts +10 -0
  16. package/dist/agents/refinement.d.ts.map +1 -0
  17. package/dist/agents/refinement.js +98 -0
  18. package/dist/agents/refinement.js.map +1 -0
  19. package/dist/agents/research.d.ts +16 -0
  20. package/dist/agents/research.d.ts.map +1 -0
  21. package/dist/agents/research.js +141 -0
  22. package/dist/agents/research.js.map +1 -0
  23. package/dist/agents/review.d.ts +24 -0
  24. package/dist/agents/review.d.ts.map +1 -0
  25. package/dist/agents/review.js +740 -0
  26. package/dist/agents/review.js.map +1 -0
  27. package/dist/agents/rework.d.ts +17 -0
  28. package/dist/agents/rework.d.ts.map +1 -0
  29. package/dist/agents/rework.js +139 -0
  30. package/dist/agents/rework.js.map +1 -0
  31. package/dist/agents/state-assessor.d.ts +21 -0
  32. package/dist/agents/state-assessor.d.ts.map +1 -0
  33. package/dist/agents/state-assessor.js +29 -0
  34. package/dist/agents/state-assessor.js.map +1 -0
  35. package/dist/cli/commands.d.ts +87 -0
  36. package/dist/cli/commands.d.ts.map +1 -0
  37. package/dist/cli/commands.js +1183 -0
  38. package/dist/cli/commands.js.map +1 -0
  39. package/dist/cli/formatting.d.ts +68 -0
  40. package/dist/cli/formatting.d.ts.map +1 -0
  41. package/dist/cli/formatting.js +194 -0
  42. package/dist/cli/formatting.js.map +1 -0
  43. package/dist/cli/runner.d.ts +57 -0
  44. package/dist/cli/runner.d.ts.map +1 -0
  45. package/dist/cli/runner.js +272 -0
  46. package/dist/cli/runner.js.map +1 -0
  47. package/dist/cli/story-utils.d.ts +19 -0
  48. package/dist/cli/story-utils.d.ts.map +1 -0
  49. package/dist/cli/story-utils.js +44 -0
  50. package/dist/cli/story-utils.js.map +1 -0
  51. package/dist/cli/table-renderer.d.ts +22 -0
  52. package/dist/cli/table-renderer.d.ts.map +1 -0
  53. package/dist/cli/table-renderer.js +159 -0
  54. package/dist/cli/table-renderer.js.map +1 -0
  55. package/dist/core/auth.d.ts +39 -0
  56. package/dist/core/auth.d.ts.map +1 -0
  57. package/dist/core/auth.js +128 -0
  58. package/dist/core/auth.js.map +1 -0
  59. package/dist/core/client.d.ts +73 -0
  60. package/dist/core/client.d.ts.map +1 -0
  61. package/dist/core/client.js +140 -0
  62. package/dist/core/client.js.map +1 -0
  63. package/dist/core/config.d.ts +48 -0
  64. package/dist/core/config.d.ts.map +1 -0
  65. package/dist/core/config.js +330 -0
  66. package/dist/core/config.js.map +1 -0
  67. package/dist/core/kanban.d.ts +34 -0
  68. package/dist/core/kanban.d.ts.map +1 -0
  69. package/dist/core/kanban.js +253 -0
  70. package/dist/core/kanban.js.map +1 -0
  71. package/dist/core/story.d.ts +91 -0
  72. package/dist/core/story.d.ts.map +1 -0
  73. package/dist/core/story.js +349 -0
  74. package/dist/core/story.js.map +1 -0
  75. package/dist/core/theme.d.ts +17 -0
  76. package/dist/core/theme.d.ts.map +1 -0
  77. package/dist/core/theme.js +136 -0
  78. package/dist/core/theme.js.map +1 -0
  79. package/dist/core/workflow-state.d.ts +56 -0
  80. package/dist/core/workflow-state.d.ts.map +1 -0
  81. package/dist/core/workflow-state.js +162 -0
  82. package/dist/core/workflow-state.js.map +1 -0
  83. package/dist/index.d.ts +3 -0
  84. package/dist/index.d.ts.map +1 -0
  85. package/dist/index.js +103 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/types/index.d.ts +228 -0
  88. package/dist/types/index.d.ts.map +1 -0
  89. package/dist/types/index.js +38 -0
  90. package/dist/types/index.js.map +1 -0
  91. package/dist/types/workflow-state.d.ts +54 -0
  92. package/dist/types/workflow-state.d.ts.map +1 -0
  93. package/dist/types/workflow-state.js +5 -0
  94. package/dist/types/workflow-state.js.map +1 -0
  95. package/package.json +71 -0
  96. package/templates/story.md +35 -0
@@ -0,0 +1,128 @@
1
+ import { execSync } from 'child_process';
2
+ import { platform } from 'os';
3
+ /**
4
+ * Get API key/token from various sources in order of preference:
5
+ * 1. ANTHROPIC_API_KEY environment variable (direct API key)
6
+ * 2. CLAUDE_CODE_OAUTH_TOKEN environment variable (OAuth token)
7
+ * 3. macOS Keychain (Claude Code credentials)
8
+ */
9
+ export function getApiKey() {
10
+ // First check environment variables
11
+ if (process.env.ANTHROPIC_API_KEY) {
12
+ return process.env.ANTHROPIC_API_KEY;
13
+ }
14
+ if (process.env.CLAUDE_CODE_OAUTH_TOKEN) {
15
+ return process.env.CLAUDE_CODE_OAUTH_TOKEN;
16
+ }
17
+ // Try macOS Keychain
18
+ if (platform() === 'darwin') {
19
+ const keychainKey = getApiKeyFromKeychain();
20
+ if (keychainKey) {
21
+ return keychainKey;
22
+ }
23
+ }
24
+ return null;
25
+ }
26
+ /**
27
+ * Check if the API key is an OAuth token
28
+ */
29
+ export function isOAuthToken(key) {
30
+ return key.startsWith('sk-ant-oat');
31
+ }
32
+ /**
33
+ * Check if the API key is a direct API key
34
+ */
35
+ export function isDirectApiKey(key) {
36
+ return key.startsWith('sk-ant-api');
37
+ }
38
+ /**
39
+ * Get the credential type for a given key
40
+ */
41
+ export function getCredentialType(key) {
42
+ if (!key)
43
+ return 'none';
44
+ if (isOAuthToken(key))
45
+ return 'oauth_token';
46
+ return 'api_key';
47
+ }
48
+ /**
49
+ * Configure environment variables for the Agent SDK based on credential type.
50
+ * The Agent SDK uses:
51
+ * - ANTHROPIC_API_KEY for direct API keys
52
+ * - CLAUDE_CODE_OAUTH_TOKEN for OAuth tokens
53
+ */
54
+ export function configureAgentSdkAuth() {
55
+ const key = getApiKey();
56
+ if (!key) {
57
+ return { configured: false, type: 'none' };
58
+ }
59
+ const credType = getCredentialType(key);
60
+ if (credType === 'oauth_token') {
61
+ // Set OAuth token for Agent SDK
62
+ process.env.CLAUDE_CODE_OAUTH_TOKEN = key;
63
+ // Clear API key to avoid confusion
64
+ delete process.env.ANTHROPIC_API_KEY;
65
+ }
66
+ else {
67
+ // Set API key
68
+ process.env.ANTHROPIC_API_KEY = key;
69
+ delete process.env.CLAUDE_CODE_OAUTH_TOKEN;
70
+ }
71
+ return { configured: true, type: credType };
72
+ }
73
+ /**
74
+ * Get API key from macOS Keychain
75
+ * Claude Code stores OAuth credentials in "Claude Code-credentials"
76
+ */
77
+ function getApiKeyFromKeychain() {
78
+ try {
79
+ // Try to get Claude Code OAuth credentials
80
+ const credentials = execSync('security find-generic-password -s "Claude Code-credentials" -w 2>/dev/null', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
81
+ if (credentials) {
82
+ // The credentials are stored as JSON
83
+ try {
84
+ const parsed = JSON.parse(credentials);
85
+ // Check for Claude AI OAuth format: {"claudeAiOauth":{"accessToken":"..."}}
86
+ if (parsed.claudeAiOauth?.accessToken) {
87
+ return parsed.claudeAiOauth.accessToken;
88
+ }
89
+ // Check for legacy format: {"accessToken":"..."}
90
+ if (parsed.accessToken) {
91
+ return parsed.accessToken;
92
+ }
93
+ }
94
+ catch {
95
+ // If not JSON, it might be the raw token
96
+ if (credentials.startsWith('sk-') || credentials.length > 20) {
97
+ return credentials;
98
+ }
99
+ }
100
+ }
101
+ }
102
+ catch {
103
+ // Keychain access failed - that's okay, we'll fall back
104
+ }
105
+ return null;
106
+ }
107
+ /**
108
+ * Check if API key is available from any source
109
+ */
110
+ export function hasApiKey() {
111
+ return getApiKey() !== null;
112
+ }
113
+ /**
114
+ * Get the source of the API key (for display purposes)
115
+ */
116
+ export function getApiKeySource() {
117
+ if (process.env.ANTHROPIC_API_KEY) {
118
+ return 'env';
119
+ }
120
+ if (platform() === 'darwin') {
121
+ const keychainKey = getApiKeyFromKeychain();
122
+ if (keychainKey) {
123
+ return 'keychain';
124
+ }
125
+ }
126
+ return 'none';
127
+ }
128
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/core/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAc9B;;;;;GAKG;AACH,MAAM,UAAU,SAAS;IACvB,oCAAoC;IACpC,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;QAClC,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IACvC,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;IAC7C,CAAC;IAED,qBAAqB;IACrB,IAAI,QAAQ,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,WAAW,GAAG,qBAAqB,EAAE,CAAC;QAC5C,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,WAAW,CAAC;QACrB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,OAAO,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB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C5E,IAAI,MAAM,CAAC,aAAa,EAAE,WAAW,EAAE,CAAC;oBACtC,OAAO,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC;gBAC1C,CAAC;gBAED,iDAAiD;gBACjD,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;oBACvB,OAAO,MAAM,CAAC,WAAW,CAAC;gBAC5B,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,yCAAyC;gBACzC,IAAI,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;oBAC7D,OAAO,WAAW,CAAC;gBACrB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,wDAAwD;IAC1D,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,SAAS,EAAE,KAAK,IAAI,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,QAAQ,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,WAAW,GAAG,qBAAqB,EAAE,CAAC;QAC5C,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,73 @@
1
+ import { CredentialType } from './auth.js';
2
+ /**
3
+ * Error thrown when an agent query times out
4
+ */
5
+ export declare class AgentTimeoutError extends Error {
6
+ constructor(timeoutMs: number);
7
+ }
8
+ /**
9
+ * Progress event types from the Agent SDK
10
+ */
11
+ export type AgentProgressEvent = {
12
+ type: 'session_start';
13
+ sessionId: string;
14
+ } | {
15
+ type: 'tool_start';
16
+ toolName: string;
17
+ input?: Record<string, unknown>;
18
+ } | {
19
+ type: 'tool_end';
20
+ toolName: string;
21
+ result?: unknown;
22
+ } | {
23
+ type: 'assistant_message';
24
+ content: string;
25
+ } | {
26
+ type: 'completion';
27
+ } | {
28
+ type: 'error';
29
+ message: string;
30
+ };
31
+ /**
32
+ * Callback for receiving real-time progress from agent execution
33
+ */
34
+ export type AgentProgressCallback = (event: AgentProgressEvent) => void;
35
+ export interface AgentQueryOptions {
36
+ prompt: string;
37
+ systemPrompt?: string;
38
+ workingDirectory?: string;
39
+ model?: string;
40
+ /** Timeout in milliseconds. Defaults to config value or 10 minutes. */
41
+ timeout?: number;
42
+ /** Callback for real-time progress updates */
43
+ onProgress?: AgentProgressCallback;
44
+ }
45
+ export interface AgentMessage {
46
+ type: string;
47
+ subtype?: string;
48
+ content?: string | Array<{
49
+ type: string;
50
+ text?: string;
51
+ name?: string;
52
+ }>;
53
+ tool_name?: string;
54
+ input?: Record<string, unknown>;
55
+ result?: unknown;
56
+ error?: {
57
+ message: string;
58
+ type?: string;
59
+ tool?: string;
60
+ };
61
+ session_id?: string;
62
+ }
63
+ /**
64
+ * Run an agent query using the Claude Agent SDK.
65
+ * Automatically configures authentication from environment or keychain.
66
+ * CLAUDE.md discovery is handled automatically by the SDK when settingSources includes 'project'.
67
+ */
68
+ export declare function runAgentQuery(options: AgentQueryOptions): Promise<string>;
69
+ /**
70
+ * Get the current credential type being used
71
+ */
72
+ export declare function getCurrentCredentialType(): CredentialType;
73
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAuD,cAAc,EAAE,MAAM,WAAW,CAAC;AAIhG;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,SAAS,EAAE,MAAM;CAK9B;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,SAAS,EA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ACjB,KAAK,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAgBD;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CA2G/E;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,cAAc,CAEzD"}
@@ -0,0 +1,140 @@
1
+ import { query } from '@anthropic-ai/claude-agent-sdk';
2
+ import { configureAgentSdkAuth, getApiKey, getCredentialType } from './auth.js';
3
+ import { loadConfig, DEFAULT_TIMEOUTS } from './config.js';
4
+ import path from 'path';
5
+ /**
6
+ * Error thrown when an agent query times out
7
+ */
8
+ export class AgentTimeoutError extends Error {
9
+ constructor(timeoutMs) {
10
+ const timeoutSec = Math.round(timeoutMs / 1000);
11
+ super(`Agent query timed out after ${timeoutSec} seconds. Consider increasing 'timeouts.agentTimeout' in .agentic-sdlc.json`);
12
+ this.name = 'AgentTimeoutError';
13
+ }
14
+ }
15
+ /**
16
+ * Validate that the working directory is within safe boundaries
17
+ */
18
+ function isValidWorkingDirectory(workingDir) {
19
+ try {
20
+ const normalized = path.resolve(workingDir);
21
+ const projectRoot = path.resolve(process.cwd());
22
+ // Allow working directory to be the project root or any subdirectory
23
+ return normalized.startsWith(projectRoot) || normalized === projectRoot;
24
+ }
25
+ catch {
26
+ return false;
27
+ }
28
+ }
29
+ /**
30
+ * Run an agent query using the Claude Agent SDK.
31
+ * Automatically configures authentication from environment or keychain.
32
+ * CLAUDE.md discovery is handled automatically by the SDK when settingSources includes 'project'.
33
+ */
34
+ export async function runAgentQuery(options) {
35
+ // Configure authentication
36
+ const authResult = configureAgentSdkAuth();
37
+ if (!authResult.configured) {
38
+ throw new Error('No API key or OAuth token found. Set ANTHROPIC_API_KEY or sign in to Claude Code.');
39
+ }
40
+ // Validate and normalize working directory
41
+ const workingDir = path.resolve(options.workingDirectory || process.cwd());
42
+ if (!isValidWorkingDirectory(workingDir)) {
43
+ throw new Error('Invalid working directory: path is outside project boundaries');
44
+ }
45
+ // Load configuration to get settingSources and timeout
46
+ const config = loadConfig(workingDir);
47
+ const settingSources = config.settingSources || [];
48
+ const timeout = options.timeout ?? config.timeouts?.agentTimeout ?? DEFAULT_TIMEOUTS.agentTimeout;
49
+ const results = [];
50
+ const response = query({
51
+ prompt: options.prompt,
52
+ options: {
53
+ model: options.model || 'claude-sonnet-4-5-20250929',
54
+ systemPrompt: options.systemPrompt,
55
+ cwd: workingDir,
56
+ permissionMode: 'acceptEdits',
57
+ settingSources: settingSources,
58
+ },
59
+ });
60
+ // Create a timeout promise
61
+ let timeoutId;
62
+ const timeoutPromise = new Promise((_, reject) => {
63
+ timeoutId = setTimeout(() => {
64
+ reject(new AgentTimeoutError(timeout));
65
+ }, timeout);
66
+ });
67
+ // Process the async generator with timeout
68
+ const processMessages = async () => {
69
+ try {
70
+ for await (const message of response) {
71
+ switch (message.type) {
72
+ case 'system':
73
+ if (message.subtype === 'init' && message.session_id) {
74
+ options.onProgress?.({ type: 'session_start', sessionId: message.session_id });
75
+ }
76
+ else if (message.subtype === 'completion') {
77
+ options.onProgress?.({ type: 'completion' });
78
+ }
79
+ break;
80
+ case 'assistant':
81
+ const content = message.content;
82
+ if (typeof content === 'string') {
83
+ results.push(content);
84
+ options.onProgress?.({ type: 'assistant_message', content });
85
+ }
86
+ else if (Array.isArray(content)) {
87
+ for (const block of content) {
88
+ if (block.type === 'text' && block.text) {
89
+ results.push(block.text);
90
+ options.onProgress?.({ type: 'assistant_message', content: block.text });
91
+ }
92
+ else if (block.type === 'tool_use' && block.name) {
93
+ // Tool use request from assistant
94
+ options.onProgress?.({ type: 'tool_start', toolName: block.name });
95
+ }
96
+ }
97
+ }
98
+ break;
99
+ case 'tool_call':
100
+ options.onProgress?.({
101
+ type: 'tool_start',
102
+ toolName: message.tool_name || 'unknown',
103
+ input: message.input
104
+ });
105
+ break;
106
+ case 'tool_result':
107
+ options.onProgress?.({
108
+ type: 'tool_end',
109
+ toolName: message.tool_name || 'unknown',
110
+ result: message.result
111
+ });
112
+ break;
113
+ case 'result':
114
+ if (message.subtype === 'success' && typeof message.result === 'string') {
115
+ results.push(message.result);
116
+ }
117
+ break;
118
+ case 'error':
119
+ options.onProgress?.({ type: 'error', message: message.error?.message || 'Agent error' });
120
+ throw new Error(message.error?.message || 'Agent error');
121
+ }
122
+ }
123
+ return results.join('\n');
124
+ }
125
+ finally {
126
+ if (timeoutId) {
127
+ clearTimeout(timeoutId);
128
+ }
129
+ }
130
+ };
131
+ // Race between the agent query and the timeout
132
+ return Promise.race([processMessages(), timeoutPromise]);
133
+ }
134
+ /**
135
+ * Get the current credential type being used
136
+ */
137
+ export function getCurrentCredentialType() {
138
+ return getCredentialType(getApiKey());
139
+ }
140
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,iBAAiB,EAAkB,MAAM,WAAW,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,SAAiB;QAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;QAChD,KAAK,CAAC,+BAA+B,UAAU,6EAA6E,CAAC,CAAC;QAC9H,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAwCD;;GAEG;AACH,SAAS,uBAAuB,CAAC,UAAkB;IAC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,CAAC,MAAM,CAAC,CAAC;wBAC/B,CAAC;wBACD,MAAM;oBAER,KAAK,OAAO;wBACV,OAAO,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,CAAC,CAAC;wBAC1F,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,IAAI,aAAa,CAAC,CAAC;gBAC7D,CAAC;YACH,CAAC;YACD,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;gBAAS,CAAC;YACT,IAAI,SAAS,EAAE,CAAC;gBACd,YAAY,CAAC,SAAS,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,+CAA+C;IAC/C,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,iBAAiB,CAAC,SAAS,EAAE,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { Config, StageGateConfig, RefinementConfig, ReviewConfig, TimeoutConfig } from '../types/index.js';
2
+ /**
3
+ * Default timeout configuration
4
+ */
5
+ export declare const DEFAULT_TIMEOUTS: TimeoutConfig;
6
+ export declare const DEFAULT_CONFIG: Config;
7
+ /**
8
+ * Get the SDLC root folder path
9
+ * Respects AGENTIC_SDLC_ROOT env var if set (useful for testing)
10
+ */
11
+ export declare function getSdlcRoot(workingDir?: string): string;
12
+ /**
13
+ * Load configuration from the working directory
14
+ */
15
+ export declare function loadConfig(workingDir?: string): Config;
16
+ /**
17
+ * Save configuration to the working directory
18
+ */
19
+ export declare function saveConfig(config: Config, workingDir?: string): void;
20
+ /**
21
+ * Update stage gate configuration
22
+ */
23
+ export declare function updateStageGates(gates: Partial<StageGateConfig>, workingDir?: string): Config;
24
+ /**
25
+ * Check if a specific stage gate is enabled
26
+ */
27
+ export declare function isStageGateEnabled(gate: keyof StageGateConfig, workingDir?: string): boolean;
28
+ /**
29
+ * Initialize configuration file with defaults
30
+ */
31
+ export declare function initConfig(workingDir?: string): Config;
32
+ /**
33
+ * Update refinement configuration
34
+ */
35
+ export declare function updateRefinementConfig(refinementConfig: Partial<RefinementConfig>, workingDir?: string): Config;
36
+ /**
37
+ * Get the maximum number of refinement iterations allowed
38
+ */
39
+ export declare function getMaxRefinementIterations(workingDir?: string): number;
40
+ /**
41
+ * Validate review configuration
42
+ */
43
+ export declare function validateReviewConfig(reviewConfig: ReviewConfig): ReviewConfig;
44
+ /**
45
+ * Update review configuration
46
+ */
47
+ export declare function updateReviewConfig(reviewConfig: Partial<ReviewConfig>, workingDir?: string): Config;
48
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAI3G;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,aAI9B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,MA2B5B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,WAAW,CAAC,UAAU,GAAE,MAAsB,GAAG,MAAM,CAOtE;AAyHD;;GAEG;AACH,wBAAgB,UAAU,CAAC,UAAU,GAAE,MAAsB,GAAG,MAAM,CAoFrE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,GAAE,MAAsB,GAAG,IAAI,CAGnF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,CAAC,eAAe,CAAC,EAC/B,UAAU,GAAE,MAAsB,GACjC,MAAM,CAQR;AAED;;GAEG;AACH,wBA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