@ai-sdlc/orchestrator 0.6.0 → 0.9.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.
- package/dist/admission-composite.d.ts +67 -0
- package/dist/admission-composite.js +158 -0
- package/dist/admission-enrichment.d.ts +142 -0
- package/dist/admission-enrichment.js +331 -0
- package/dist/admission-hc.d.ts +62 -0
- package/dist/admission-hc.js +83 -0
- package/dist/admission-score.d.ts +95 -5
- package/dist/admission-score.js +84 -11
- package/dist/analysis/analyzer.js +3 -2
- package/dist/analysis/convention-detector.d.ts +85 -2
- package/dist/analysis/convention-detector.js +375 -70
- package/dist/analysis/diff-analyzer.d.ts +33 -0
- package/dist/analysis/diff-analyzer.js +122 -0
- package/dist/analysis/hotspot-analyzer.js +3 -1
- package/dist/analysis/index.d.ts +2 -1
- package/dist/analysis/index.js +2 -1
- package/dist/artifacts/index.d.ts +65 -0
- package/dist/artifacts/index.js +142 -0
- package/dist/backlog-adapter.d.ts +121 -0
- package/dist/backlog-adapter.js +438 -0
- package/dist/calibration.d.ts +43 -0
- package/dist/calibration.js +76 -0
- package/dist/cli/commands/agents.d.ts +24 -0
- package/dist/cli/commands/agents.js +66 -1
- package/dist/cli/commands/git-remote.d.ts +49 -0
- package/dist/cli/commands/git-remote.js +91 -0
- package/dist/cli/commands/health.d.ts +4 -0
- package/dist/cli/commands/health.js +13 -1
- package/dist/cli/commands/init.d.ts +26 -0
- package/dist/cli/commands/init.js +164 -22
- package/dist/cli/commands/mcp-setup.d.ts +31 -0
- package/dist/cli/commands/mcp-setup.js +78 -8
- package/dist/cli/formatters/table.js +15 -2
- package/dist/cli/index.d.ts +14 -1
- package/dist/cli/index.js +81 -20
- package/dist/cli/versions.d.ts +57 -0
- package/dist/cli/versions.js +128 -0
- package/dist/code-area-classifier.d.ts +21 -0
- package/dist/code-area-classifier.js +48 -0
- package/dist/config.d.ts +33 -1
- package/dist/config.js +78 -8
- package/dist/database/adapters/external.d.ts +24 -0
- package/dist/database/adapters/external.js +80 -0
- package/dist/database/adapters/neon.d.ts +41 -0
- package/dist/database/adapters/neon.js +98 -0
- package/dist/database/adapters/pg-snapshot-restore.d.ts +28 -0
- package/dist/database/adapters/pg-snapshot-restore.js +68 -0
- package/dist/database/adapters/sqlite-copy.d.ts +32 -0
- package/dist/database/adapters/sqlite-copy.js +145 -0
- package/dist/database/connection-injection.d.ts +35 -0
- package/dist/database/connection-injection.js +93 -0
- package/dist/database/index.d.ts +12 -0
- package/dist/database/index.js +23 -0
- package/dist/database/registry.d.ts +13 -0
- package/dist/database/registry.js +27 -0
- package/dist/database/topology.d.ts +52 -0
- package/dist/database/topology.js +44 -0
- package/dist/database/types.d.ts +89 -0
- package/dist/database/types.js +26 -0
- package/dist/design-authority.d.ts +40 -0
- package/dist/design-authority.js +71 -0
- package/dist/design-lookahead.d.ts +64 -0
- package/dist/design-lookahead.js +86 -0
- package/dist/design-quality-trend.d.ts +87 -0
- package/dist/design-quality-trend.js +190 -0
- package/dist/design-system-context.d.ts +46 -0
- package/dist/design-system-context.js +80 -0
- package/dist/design-system-correction-loop.d.ts +64 -0
- package/dist/design-system-correction-loop.js +128 -0
- package/dist/design-system-metrics.d.ts +61 -0
- package/dist/design-system-metrics.js +104 -0
- package/dist/design-system-stewardship.d.ts +22 -0
- package/dist/design-system-stewardship.js +85 -0
- package/dist/design-system-validation.d.ts +37 -0
- package/dist/design-system-validation.js +88 -0
- package/dist/dispatch/index.d.ts +4 -0
- package/dist/dispatch/index.js +4 -0
- package/dist/dispatch/merge-gate.d.ts +46 -0
- package/dist/dispatch/merge-gate.js +90 -0
- package/dist/dispatch/requeue.d.ts +57 -0
- package/dist/dispatch/requeue.js +131 -0
- package/dist/dispatch/worker-pool.d.ts +62 -0
- package/dist/dispatch/worker-pool.js +60 -0
- package/dist/execute.d.ts +40 -0
- package/dist/execute.js +185 -15
- package/dist/fix-ci.js +8 -1
- package/dist/fix-review.js +8 -1
- package/dist/harness/adapters/claude-code.d.ts +29 -0
- package/dist/harness/adapters/claude-code.js +191 -0
- package/dist/harness/adapters/codex.d.ts +25 -0
- package/dist/harness/adapters/codex.js +61 -0
- package/dist/harness/independence.d.ts +51 -0
- package/dist/harness/independence.js +67 -0
- package/dist/harness/index.d.ts +14 -0
- package/dist/harness/index.js +20 -0
- package/dist/harness/registry.d.ts +17 -0
- package/dist/harness/registry.js +31 -0
- package/dist/harness/types.d.ts +123 -0
- package/dist/harness/types.js +8 -0
- package/dist/harness/version-probe.d.ts +14 -0
- package/dist/harness/version-probe.js +123 -0
- package/dist/index.d.ts +30 -4
- package/dist/index.js +35 -2
- package/dist/models/classifier.d.ts +76 -0
- package/dist/models/classifier.js +221 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/models/index.js +3 -0
- package/dist/models/registry.d.ts +97 -0
- package/dist/models/registry.js +173 -0
- package/dist/pillar-breakdown.d.ts +63 -0
- package/dist/pillar-breakdown.js +153 -0
- package/dist/priority.d.ts +5 -0
- package/dist/priority.js +18 -5
- package/dist/review-meta.d.ts +65 -0
- package/dist/review-meta.js +149 -0
- package/dist/review.d.ts +4 -0
- package/dist/review.js +12 -2
- package/dist/runners/claude-code-sdk.d.ts +31 -0
- package/dist/runners/claude-code-sdk.js +238 -0
- package/dist/runners/claude-code.d.ts +3 -0
- package/dist/runners/claude-code.js +30 -66
- package/dist/runners/codex.js +4 -1
- package/dist/runners/copilot.js +4 -1
- package/dist/runners/cursor.js +4 -1
- package/dist/runners/git-utils.d.ts +81 -0
- package/dist/runners/git-utils.js +201 -0
- package/dist/runners/index.d.ts +3 -0
- package/dist/runners/index.js +3 -0
- package/dist/runners/review-agent.d.ts +20 -0
- package/dist/runners/review-agent.js +171 -41
- package/dist/runners/runner-registry.js +10 -0
- package/dist/runners/sdk-review-runner.d.ts +65 -0
- package/dist/runners/sdk-review-runner.js +185 -0
- package/dist/runners/security-triage.d.ts +20 -4
- package/dist/runners/security-triage.js +39 -15
- package/dist/runners/types.d.ts +6 -0
- package/dist/runtime/attestations.d.ts +274 -0
- package/dist/runtime/attestations.js +460 -0
- package/dist/runtime/git-env.d.ts +53 -0
- package/dist/runtime/git-env.js +60 -0
- package/dist/runtime/index.d.ts +7 -0
- package/dist/runtime/index.js +7 -0
- package/dist/runtime/parallelism-flag.d.ts +10 -0
- package/dist/runtime/parallelism-flag.js +18 -0
- package/dist/runtime/port-allocator.d.ts +21 -0
- package/dist/runtime/port-allocator.js +66 -0
- package/dist/runtime/worktree-pool.d.ts +86 -0
- package/dist/runtime/worktree-pool.js +204 -0
- package/dist/runtime/worktree.d.ts +25 -0
- package/dist/runtime/worktree.js +111 -0
- package/dist/sa-scoring/auto-calibrate.d.ts +69 -0
- package/dist/sa-scoring/auto-calibrate.js +107 -0
- package/dist/sa-scoring/c1-sa2-computable.d.ts +42 -0
- package/dist/sa-scoring/c1-sa2-computable.js +59 -0
- package/dist/sa-scoring/composite.d.ts +107 -0
- package/dist/sa-scoring/composite.js +139 -0
- package/dist/sa-scoring/depparse-client.d.ts +79 -0
- package/dist/sa-scoring/depparse-client.js +187 -0
- package/dist/sa-scoring/did-compiler.d.ts +122 -0
- package/dist/sa-scoring/did-compiler.js +286 -0
- package/dist/sa-scoring/drift-monitor.d.ts +84 -0
- package/dist/sa-scoring/drift-monitor.js +186 -0
- package/dist/sa-scoring/exemplar-bank.d.ts +78 -0
- package/dist/sa-scoring/exemplar-bank.js +154 -0
- package/dist/sa-scoring/feedback-store.d.ts +100 -0
- package/dist/sa-scoring/feedback-store.js +156 -0
- package/dist/sa-scoring/index.d.ts +71 -0
- package/dist/sa-scoring/index.js +158 -0
- package/dist/sa-scoring/layer1-deterministic.d.ts +115 -0
- package/dist/sa-scoring/layer1-deterministic.js +298 -0
- package/dist/sa-scoring/layer2-structural.d.ts +71 -0
- package/dist/sa-scoring/layer2-structural.js +151 -0
- package/dist/sa-scoring/layer3-llm.d.ts +86 -0
- package/dist/sa-scoring/layer3-llm.js +282 -0
- package/dist/sa-scoring/rescore-orchestrator.d.ts +52 -0
- package/dist/sa-scoring/rescore-orchestrator.js +47 -0
- package/dist/scheduling/burn-down.d.ts +27 -0
- package/dist/scheduling/burn-down.js +43 -0
- package/dist/scheduling/calibration.d.ts +42 -0
- package/dist/scheduling/calibration.js +150 -0
- package/dist/scheduling/index.d.ts +8 -0
- package/dist/scheduling/index.js +8 -0
- package/dist/scheduling/ledger.d.ts +59 -0
- package/dist/scheduling/ledger.js +216 -0
- package/dist/scheduling/off-peak.d.ts +27 -0
- package/dist/scheduling/off-peak.js +112 -0
- package/dist/scheduling/schedule-decision.d.ts +39 -0
- package/dist/scheduling/schedule-decision.js +89 -0
- package/dist/scheduling/tier-analysis.d.ts +47 -0
- package/dist/scheduling/tier-analysis.js +81 -0
- package/dist/scheduling/types.d.ts +140 -0
- package/dist/scheduling/types.js +11 -0
- package/dist/shared.d.ts +13 -0
- package/dist/shared.js +32 -0
- package/dist/state/schema.d.ts +5 -1
- package/dist/state/schema.js +223 -1
- package/dist/state/store.d.ts +55 -1
- package/dist/state/store.js +342 -7
- package/dist/state/types.d.ts +139 -0
- package/dist/types.d.ts +1 -1
- package/dist/validate-agent-output.js +4 -1
- package/dist/watch.js +6 -0
- package/package.json +2 -2
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { execFile } from 'node:child_process';
|
|
6
6
|
import { promisify } from 'node:util';
|
|
7
7
|
import { DEFAULT_GIT_HISTORY_DAYS, DEFAULT_HOTSPOT_THRESHOLD } from '../defaults.js';
|
|
8
|
+
import { cleanGitEnv } from '../runtime/git-env.js';
|
|
8
9
|
const execFileAsync = promisify(execFile);
|
|
9
10
|
/**
|
|
10
11
|
* Run `git log` to get file churn data.
|
|
@@ -12,7 +13,8 @@ const execFileAsync = promisify(execFile);
|
|
|
12
13
|
export async function getFileChurn(repoPath, historyDays = DEFAULT_GIT_HISTORY_DAYS) {
|
|
13
14
|
try {
|
|
14
15
|
const since = `${historyDays} days ago`;
|
|
15
|
-
|
|
16
|
+
// cleanGitEnv() prevents leaked GIT_DIR from binding to a parent repo (AISDLC-72).
|
|
17
|
+
const { stdout } = await execFileAsync('git', ['log', '--format=', '--name-only', `--since=${since}`], { cwd: repoPath, maxBuffer: 10 * 1024 * 1024, env: cleanGitEnv() });
|
|
16
18
|
const counts = new Map();
|
|
17
19
|
for (const line of stdout.split('\n')) {
|
|
18
20
|
const trimmed = line.trim();
|
package/dist/analysis/index.d.ts
CHANGED
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
export type { CodebaseProfile, CodebaseContext, Hotspot, ArchitecturalPattern, DetectedConvention, ModuleInfo, ModuleGraph, DependencyEdge, AnalyzerOptions, FileInfo, ImportStatement, } from './types.js';
|
|
5
5
|
export { walkFiles, detectModules } from './file-walker.js';
|
|
6
6
|
export { parseImports, buildModuleGraph } from './dependency-parser.js';
|
|
7
|
-
export { detectConventions } from './convention-detector.js';
|
|
7
|
+
export { detectConventions, detectReactProject, loadProjectAliases, parseTsConfigAliases, parseViteOrWebpackAliases, enumerateTestLocations, type DetectConventionsOptions, type PathAliasMap, type TestLocationSummary, } from './convention-detector.js';
|
|
8
8
|
export { detectPatterns } from './pattern-detector.js';
|
|
9
9
|
export { analyzeHotspots } from './hotspot-analyzer.js';
|
|
10
10
|
export { computeComplexityScore } from './complexity-scorer.js';
|
|
11
11
|
export { analyzeCodebase } from './analyzer.js';
|
|
12
12
|
export { buildCodebaseContext, formatContextForPrompt } from './context-builder.js';
|
|
13
|
+
export { analyzeDiff, extractChangedFiles, type DiffFinding, type DiffAnalysisResult, } from './diff-analyzer.js';
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/analysis/index.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { walkFiles, detectModules } from './file-walker.js';
|
|
5
5
|
export { parseImports, buildModuleGraph } from './dependency-parser.js';
|
|
6
|
-
export { detectConventions } from './convention-detector.js';
|
|
6
|
+
export { detectConventions, detectReactProject, loadProjectAliases, parseTsConfigAliases, parseViteOrWebpackAliases, enumerateTestLocations, } from './convention-detector.js';
|
|
7
7
|
export { detectPatterns } from './pattern-detector.js';
|
|
8
8
|
export { analyzeHotspots } from './hotspot-analyzer.js';
|
|
9
9
|
export { computeComplexityScore } from './complexity-scorer.js';
|
|
10
10
|
export { analyzeCodebase } from './analyzer.js';
|
|
11
11
|
export { buildCodebaseContext, formatContextForPrompt } from './context-builder.js';
|
|
12
|
+
export { analyzeDiff, extractChangedFiles, } from './diff-analyzer.js';
|
|
12
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact directory module per RFC-0010 §16. Provides:
|
|
3
|
+
* - Heartbeat writer (state.json updated every 60s; stale > 5 min surfaces in cli-status)
|
|
4
|
+
* - Event-stream emitter (_events.jsonl JSONL append-only)
|
|
5
|
+
* - Schema-conformant artifact validator (Q7)
|
|
6
|
+
* - Resumability helper (read state.json to determine next stage)
|
|
7
|
+
*/
|
|
8
|
+
export declare const HEARTBEAT_INTERVAL_MS = 60000;
|
|
9
|
+
export declare const HEARTBEAT_STALE_MS: number;
|
|
10
|
+
export type StageStatus = 'pending' | 'running' | 'success' | 'failure' | 'skipped';
|
|
11
|
+
export interface RuntimeState {
|
|
12
|
+
issueId: string;
|
|
13
|
+
currentStage: string;
|
|
14
|
+
startedAt: string;
|
|
15
|
+
lastHeartbeat: string;
|
|
16
|
+
status: StageStatus;
|
|
17
|
+
resolvedHarness?: string;
|
|
18
|
+
resolvedModel?: string;
|
|
19
|
+
port?: number;
|
|
20
|
+
worktreePath?: string;
|
|
21
|
+
databaseBranchKeys?: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
export interface ArtifactEvent {
|
|
24
|
+
type: string;
|
|
25
|
+
timestamp: string;
|
|
26
|
+
issueId?: string;
|
|
27
|
+
stage?: string;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
export declare class StateWriter {
|
|
31
|
+
readonly artifactsDir: string;
|
|
32
|
+
readonly issueId: string;
|
|
33
|
+
private readonly statePath;
|
|
34
|
+
private heartbeatTimer;
|
|
35
|
+
constructor(artifactsDir: string, issueId: string);
|
|
36
|
+
writeState(state: RuntimeState): Promise<void>;
|
|
37
|
+
readState(): Promise<RuntimeState | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Start emitting heartbeats. The caller's `produce` function returns the latest
|
|
40
|
+
* RuntimeState snapshot to persist; the writer schedules persistence every
|
|
41
|
+
* HEARTBEAT_INTERVAL_MS. Returns a stop function.
|
|
42
|
+
*/
|
|
43
|
+
startHeartbeat(produce: () => RuntimeState): () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Returns true when the persisted state's lastHeartbeat is older than HEARTBEAT_STALE_MS.
|
|
46
|
+
* Used by cli-status to flag hung agents.
|
|
47
|
+
*/
|
|
48
|
+
static isStale(state: RuntimeState, now?: Date): boolean;
|
|
49
|
+
}
|
|
50
|
+
/** Append a single event to $ARTIFACTS_DIR/_events.jsonl. Atomic per-line. */
|
|
51
|
+
export declare function appendEvent(artifactsDir: string, event: ArtifactEvent): Promise<void>;
|
|
52
|
+
export declare function readEvents(artifactsDir: string, options?: {
|
|
53
|
+
sinceTimestamp?: string;
|
|
54
|
+
}): Promise<ArtifactEvent[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Atomic write: write to <path>.tmp, fsync (implicit via Node), rename. Per RFC §16.4
|
|
57
|
+
* the JSON artifact MUST NOT be visible to downstream stages until fully written.
|
|
58
|
+
*/
|
|
59
|
+
export declare function atomicWriteJson(path: string, data: unknown): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Read all per-issue runtime states under the artifacts dir. Used by cli-status --all
|
|
62
|
+
* to enumerate active branches per RFC §17.
|
|
63
|
+
*/
|
|
64
|
+
export declare function listActiveStates(artifactsDir: string): Promise<RuntimeState[]>;
|
|
65
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact directory module per RFC-0010 §16. Provides:
|
|
3
|
+
* - Heartbeat writer (state.json updated every 60s; stale > 5 min surfaces in cli-status)
|
|
4
|
+
* - Event-stream emitter (_events.jsonl JSONL append-only)
|
|
5
|
+
* - Schema-conformant artifact validator (Q7)
|
|
6
|
+
* - Resumability helper (read state.json to determine next stage)
|
|
7
|
+
*/
|
|
8
|
+
import { appendFile, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
9
|
+
import { dirname, join } from 'node:path';
|
|
10
|
+
export const HEARTBEAT_INTERVAL_MS = 60_000;
|
|
11
|
+
export const HEARTBEAT_STALE_MS = 5 * 60_000;
|
|
12
|
+
export class StateWriter {
|
|
13
|
+
artifactsDir;
|
|
14
|
+
issueId;
|
|
15
|
+
statePath;
|
|
16
|
+
heartbeatTimer = null;
|
|
17
|
+
constructor(artifactsDir, issueId) {
|
|
18
|
+
this.artifactsDir = artifactsDir;
|
|
19
|
+
this.issueId = issueId;
|
|
20
|
+
this.statePath = join(artifactsDir, issueId, 'state.json');
|
|
21
|
+
}
|
|
22
|
+
async writeState(state) {
|
|
23
|
+
await mkdir(dirname(this.statePath), { recursive: true });
|
|
24
|
+
state.lastHeartbeat = new Date().toISOString();
|
|
25
|
+
await writeFile(this.statePath, JSON.stringify(state, null, 2), 'utf8');
|
|
26
|
+
}
|
|
27
|
+
async readState() {
|
|
28
|
+
try {
|
|
29
|
+
const raw = await readFile(this.statePath, 'utf8');
|
|
30
|
+
return JSON.parse(raw);
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
if (err.code === 'ENOENT')
|
|
34
|
+
return null;
|
|
35
|
+
throw err;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Start emitting heartbeats. The caller's `produce` function returns the latest
|
|
40
|
+
* RuntimeState snapshot to persist; the writer schedules persistence every
|
|
41
|
+
* HEARTBEAT_INTERVAL_MS. Returns a stop function.
|
|
42
|
+
*/
|
|
43
|
+
startHeartbeat(produce) {
|
|
44
|
+
if (this.heartbeatTimer)
|
|
45
|
+
throw new Error('Heartbeat already running');
|
|
46
|
+
const tick = async () => {
|
|
47
|
+
try {
|
|
48
|
+
const state = produce();
|
|
49
|
+
await this.writeState(state);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// Heartbeat failures are non-fatal; the stale-detection at read-time will surface them.
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
this.heartbeatTimer = setInterval(tick, HEARTBEAT_INTERVAL_MS);
|
|
56
|
+
return () => {
|
|
57
|
+
if (this.heartbeatTimer) {
|
|
58
|
+
clearInterval(this.heartbeatTimer);
|
|
59
|
+
this.heartbeatTimer = null;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns true when the persisted state's lastHeartbeat is older than HEARTBEAT_STALE_MS.
|
|
65
|
+
* Used by cli-status to flag hung agents.
|
|
66
|
+
*/
|
|
67
|
+
static isStale(state, now = new Date()) {
|
|
68
|
+
const last = new Date(state.lastHeartbeat).getTime();
|
|
69
|
+
return now.getTime() - last > HEARTBEAT_STALE_MS;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** Append a single event to $ARTIFACTS_DIR/_events.jsonl. Atomic per-line. */
|
|
73
|
+
export async function appendEvent(artifactsDir, event) {
|
|
74
|
+
const path = join(artifactsDir, '_events.jsonl');
|
|
75
|
+
await mkdir(dirname(path), { recursive: true });
|
|
76
|
+
await appendFile(path, JSON.stringify(event) + '\n', 'utf8');
|
|
77
|
+
}
|
|
78
|
+
export async function readEvents(artifactsDir, options = {}) {
|
|
79
|
+
const path = join(artifactsDir, '_events.jsonl');
|
|
80
|
+
let raw;
|
|
81
|
+
try {
|
|
82
|
+
raw = await readFile(path, 'utf8');
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
if (err.code === 'ENOENT')
|
|
86
|
+
return [];
|
|
87
|
+
throw err;
|
|
88
|
+
}
|
|
89
|
+
const events = [];
|
|
90
|
+
for (const line of raw.split('\n')) {
|
|
91
|
+
if (!line.trim())
|
|
92
|
+
continue;
|
|
93
|
+
try {
|
|
94
|
+
const e = JSON.parse(line);
|
|
95
|
+
if (options.sinceTimestamp && e.timestamp < options.sinceTimestamp)
|
|
96
|
+
continue;
|
|
97
|
+
events.push(e);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
// skip malformed
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return events;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Atomic write: write to <path>.tmp, fsync (implicit via Node), rename. Per RFC §16.4
|
|
107
|
+
* the JSON artifact MUST NOT be visible to downstream stages until fully written.
|
|
108
|
+
*/
|
|
109
|
+
export async function atomicWriteJson(path, data) {
|
|
110
|
+
await mkdir(dirname(path), { recursive: true });
|
|
111
|
+
const tmp = `${path}.tmp.${process.pid}.${Date.now()}`;
|
|
112
|
+
await writeFile(tmp, JSON.stringify(data, null, 2), 'utf8');
|
|
113
|
+
const { rename } = await import('node:fs/promises');
|
|
114
|
+
await rename(tmp, path);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Read all per-issue runtime states under the artifacts dir. Used by cli-status --all
|
|
118
|
+
* to enumerate active branches per RFC §17.
|
|
119
|
+
*/
|
|
120
|
+
export async function listActiveStates(artifactsDir) {
|
|
121
|
+
const { readdir } = await import('node:fs/promises');
|
|
122
|
+
let entries;
|
|
123
|
+
try {
|
|
124
|
+
entries = await readdir(artifactsDir);
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
if (err.code === 'ENOENT')
|
|
128
|
+
return [];
|
|
129
|
+
throw err;
|
|
130
|
+
}
|
|
131
|
+
const states = [];
|
|
132
|
+
for (const entry of entries) {
|
|
133
|
+
if (entry.startsWith('_'))
|
|
134
|
+
continue; // skip _ledger, _events.jsonl, _classifier
|
|
135
|
+
const writer = new StateWriter(artifactsDir, entry);
|
|
136
|
+
const state = await writer.readState();
|
|
137
|
+
if (state)
|
|
138
|
+
states.push(state);
|
|
139
|
+
}
|
|
140
|
+
return states;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backlog.md tracker adapter for the admission composite.
|
|
3
|
+
*
|
|
4
|
+
* Backlog.md tasks are markdown files in `backlog/tasks/` (open) or
|
|
5
|
+
* `backlog/completed/` (archived). They carry YAML frontmatter
|
|
6
|
+
* (`id`, `title`, `status`, `priority`, `labels`, `references`,
|
|
7
|
+
* `created_date`, `updated_date`, `assignee`) plus a body that
|
|
8
|
+
* includes a `## Acceptance Criteria` checklist.
|
|
9
|
+
*
|
|
10
|
+
* This module:
|
|
11
|
+
* 1. Parses a task file into `BacklogTaskSnapshot`
|
|
12
|
+
* 2. Maps the snapshot onto `AdmissionInput` using the conventions
|
|
13
|
+
* in the bug-fix doc (priority:p* / size:[SML] / track:* / etc.)
|
|
14
|
+
* 3. Emits `qualityFlags` for "Done with unchecked ACs" zombie closes
|
|
15
|
+
*
|
|
16
|
+
* The GitHub-shaped `mapIssueToPriorityInput` in `admission-score.ts`
|
|
17
|
+
* is left intact; the dispatch sits in `cli-admit`.
|
|
18
|
+
*/
|
|
19
|
+
import type { PriorityInput, QualityFlag } from '@ai-sdlc/reference';
|
|
20
|
+
import { type AdmissionInput } from './admission-score.js';
|
|
21
|
+
export interface BacklogAcceptanceCriterion {
|
|
22
|
+
index: number;
|
|
23
|
+
text: string;
|
|
24
|
+
checked: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface BacklogTaskSnapshot {
|
|
27
|
+
/** Canonical id from the YAML frontmatter, e.g. "AISDLC-42". */
|
|
28
|
+
id: string;
|
|
29
|
+
/** Numeric tail of the id, e.g. 42. */
|
|
30
|
+
numericId: number;
|
|
31
|
+
title: string;
|
|
32
|
+
description: string;
|
|
33
|
+
status: string;
|
|
34
|
+
priority: string | null;
|
|
35
|
+
labels: string[];
|
|
36
|
+
createdDate: string;
|
|
37
|
+
updatedDate: string;
|
|
38
|
+
createdBy?: string;
|
|
39
|
+
acceptanceCriteria: BacklogAcceptanceCriterion[];
|
|
40
|
+
references: string[];
|
|
41
|
+
/** Task IDs this task is blocked by (frontmatter `dependencies`). */
|
|
42
|
+
dependencies: string[];
|
|
43
|
+
/** Filesystem path the snapshot was read from. */
|
|
44
|
+
sourcePath?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Parse a Backlog.md task markdown file into `BacklogTaskSnapshot`.
|
|
48
|
+
* Throws when the frontmatter is missing or malformed.
|
|
49
|
+
*/
|
|
50
|
+
export declare function parseBacklogTask(content: string, sourcePath?: string): BacklogTaskSnapshot;
|
|
51
|
+
/**
|
|
52
|
+
* Resolve a Backlog task id ("AISDLC-42" or "task-42") to a snapshot
|
|
53
|
+
* by searching the `backlog/tasks/` and `backlog/completed/` directories
|
|
54
|
+
* under `backlogRoot` (typically the project root).
|
|
55
|
+
*/
|
|
56
|
+
export declare function loadBacklogTaskFromRoot(backlogRoot: string, id: string): BacklogTaskSnapshot | undefined;
|
|
57
|
+
export interface BacklogMappingOptions {
|
|
58
|
+
/**
|
|
59
|
+
* Soul-tracks dictionary loaded from `.ai-sdlc/soul-tracks.json`,
|
|
60
|
+
* mapping `track:*` labels to a soul-alignment floor in [0, 1].
|
|
61
|
+
* Absent/empty → only `source:rfc` / `source:spec` /
|
|
62
|
+
* `governance` / `compliance` lift soulAlignment.
|
|
63
|
+
*/
|
|
64
|
+
soulTracks?: Record<string, number>;
|
|
65
|
+
/**
|
|
66
|
+
* Maintainer logins for `OWNER` author-association mapping. When
|
|
67
|
+
* `createdBy` matches one of these, AdmissionInput.authorAssociation
|
|
68
|
+
* is set to OWNER (which feeds the trust-based signal floors in
|
|
69
|
+
* the existing GitHub mapper).
|
|
70
|
+
*/
|
|
71
|
+
maintainers?: string[];
|
|
72
|
+
}
|
|
73
|
+
export interface BacklogAdmissionMapping {
|
|
74
|
+
/** Admission input shaped like the GitHub mapper output. */
|
|
75
|
+
input: AdmissionInput;
|
|
76
|
+
/**
|
|
77
|
+
* PriorityInput overrides derived from Backlog conventions
|
|
78
|
+
* (priority:p* / size:[SML] / track:* / source:* / AC progress).
|
|
79
|
+
* Pass these to `computeAdmissionComposite` via
|
|
80
|
+
* `AdmissionCompositeOptions.priorityInputOverrides` so they
|
|
81
|
+
* win over the GitHub-shaped label heuristic.
|
|
82
|
+
*/
|
|
83
|
+
priorityInputOverrides: Partial<PriorityInput>;
|
|
84
|
+
/** Quality flags surfaced for renderers (zombie close, etc). */
|
|
85
|
+
qualityFlags: QualityFlag[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Map a Backlog snapshot onto an `AdmissionInput` plus the
|
|
89
|
+
* `PriorityInput` overrides cli-admit feeds into the composite.
|
|
90
|
+
* The label-mapping table is the load-bearing piece; tests in
|
|
91
|
+
* `backlog-adapter.test.ts` pin each row.
|
|
92
|
+
*/
|
|
93
|
+
export declare function mapBacklogTaskToAdmissionInput(snap: BacklogTaskSnapshot, options?: BacklogMappingOptions): BacklogAdmissionMapping;
|
|
94
|
+
/**
|
|
95
|
+
* Load `.ai-sdlc/soul-tracks.json` from the given config root.
|
|
96
|
+
* Format: `{ "track:enchantment": 0.85, "track:reflect": 0.85, ... }`.
|
|
97
|
+
* Missing file → empty object (caller falls back to DEFAULT_SOUL_TRACKS).
|
|
98
|
+
*/
|
|
99
|
+
export declare function loadSoulTracks(configRoot: string): Record<string, number>;
|
|
100
|
+
/**
|
|
101
|
+
* Load `.ai-sdlc/maintainers.yaml` from the given config root.
|
|
102
|
+
*
|
|
103
|
+
* Accepts either of two shapes:
|
|
104
|
+
*
|
|
105
|
+
* maintainers:
|
|
106
|
+
* - alice
|
|
107
|
+
* - bob
|
|
108
|
+
*
|
|
109
|
+
* or with metadata (only `login` is read, the rest is forward-looking):
|
|
110
|
+
*
|
|
111
|
+
* maintainers:
|
|
112
|
+
* - login: alice
|
|
113
|
+
* role: owner
|
|
114
|
+
* - login: bob
|
|
115
|
+
*
|
|
116
|
+
* A bare top-level list (`- alice\n- bob`) is also accepted. Returns
|
|
117
|
+
* an empty array on missing file or any parse error — callers can
|
|
118
|
+
* still pass `--maintainers` explicitly to override.
|
|
119
|
+
*/
|
|
120
|
+
export declare function loadMaintainers(configRoot: string): string[];
|
|
121
|
+
//# sourceMappingURL=backlog-adapter.d.ts.map
|