Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 59 additions & 4 deletions .github/hooks/state-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* node .github/hooks/state-utils.js set-design <id> <json> → sets design artifact
* node .github/hooks/state-utils.js add-pbi <id> <json> → adds a PBI artifact
* node .github/hooks/state-utils.js add-agent-pr <id> <json> → adds an agent PR artifact
* node .github/hooks/state-utils.js add-timeline <id> <json> → adds a timeline event
*
* State file schema:
* {
Expand Down Expand Up @@ -41,6 +42,9 @@
* "agentSessions": [
* { "repo": "AzureAD/...", "prNumber": 2916, "prUrl": "https://...", "sessionUrl": "https://...", "status": "in_progress" }
* ],
* "timeline": [
* { "ts": 1740000000000, "agent": "design-writer", "action": "Created design spec", "phase": "designing" }
* ],
* "startedAt": 1740000000000,
* "updatedAt": 1740000000000
* }
Expand All @@ -55,8 +59,9 @@ const path = require('path');
const os = require('os');

// State file lives in user's home directory (not workspace root)
const STATE_DIR = path.join(os.homedir(), '.android-auth-orchestrator');
const STATE_DIR = path.join(os.homedir(), '.feature-orchestrator');
const STATE_FILE = path.join(STATE_DIR, 'state.json');
const LEGACY_STATE_FILE = path.join(os.homedir(), '.android-auth-orchestrator', 'state.json');

function ensureStateDir() {
if (!fs.existsSync(STATE_DIR)) {
Expand All @@ -65,11 +70,15 @@ function ensureStateDir() {
}

function readState() {
if (!fs.existsSync(STATE_FILE)) {
// Try new path first, fall back to legacy
const filePath = fs.existsSync(STATE_FILE) ? STATE_FILE
: fs.existsSync(LEGACY_STATE_FILE) ? LEGACY_STATE_FILE
: STATE_FILE;
if (!fs.existsSync(filePath)) {
return { version: 1, features: [], lastUpdated: Date.now() };
}
try {
return JSON.parse(fs.readFileSync(STATE_FILE, 'utf-8'));
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
} catch {
return { version: 1, features: [], lastUpdated: Date.now() };
}
Expand Down Expand Up @@ -142,6 +151,32 @@ switch (command) {
// Record phase timestamp for duration tracking
if (!feature.phaseTimestamps) { feature.phaseTimestamps = {}; }
feature.phaseTimestamps[args[1]] = Date.now();
// Auto-record timeline event for phase transition
if (!feature.timeline) { feature.timeline = []; }
const agentMap = {
'designing': 'design-writer', 'design_review': 'design-writer',
'planning': 'feature-planner', 'plan_review': 'feature-planner',
'backlogging': 'pbi-creator', 'backlog_review': 'pbi-creator',
'dispatching': 'agent-dispatcher', 'monitoring': 'agent-dispatcher',
'done': 'orchestrator',
};
const actionMap = {
'designing': 'Started writing design spec',
'design_review': 'Design spec ready for review',
'planning': 'Started decomposing into PBIs',
'plan_review': 'Plan ready for review',
'backlogging': 'Creating work items in ADO',
'backlog_review': 'Work items created — ready for dispatch',
'dispatching': 'Dispatching PBIs to coding agent',
'monitoring': 'Agents working on PRs',
'done': 'Feature complete',
};
feature.timeline.push({
ts: Date.now(),
agent: agentMap[args[1]] || 'orchestrator',
action: actionMap[args[1]] || `Moved to ${args[1]}`,
phase: args[1],
});
writeState(state);
console.log(JSON.stringify({ ok: true, id: args[0], step: args[1] }));
} else {
Expand Down Expand Up @@ -267,7 +302,27 @@ switch (command) {
}
break;
}
case 'add-timeline': {
const state = readState();
const feature = findFeature(state, args[0]);
if (feature) {
const event = JSON.parse(args[1]);
if (!feature.timeline) { feature.timeline = []; }
feature.timeline.push({
ts: Date.now(),
agent: event.agent || 'orchestrator',
action: event.action || '',
phase: event.phase || feature.step || '',
});
feature.updatedAt = Date.now();
writeState(state);
console.log(JSON.stringify({ ok: true, timelineCount: feature.timeline.length }));
} else {
console.log(JSON.stringify({ ok: false, error: 'Feature not found' }));
}
break;
}
default:
console.error('Usage: state-utils.js <get|list-features|get-feature|set-step|add-feature|set-agent-info|set-design|add-pbi|add-agent-pr> [args]');
console.error('Usage: state-utils.js <get|list-features|get-feature|set-step|add-feature|set-agent-info|set-design|add-pbi|add-agent-pr|add-timeline> [args]');
process.exit(1);
}
4 changes: 2 additions & 2 deletions extensions/feature-orchestrator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
VS Code extension for the AI-driven feature development pipeline. Provides the dashboard UI,
feature detail panel, and design review system.

For the full developer guide, see [AI Driven Development Guide](../../AI%20Driven%20Development%20Guide.md).
For the full developer guide, see `AI Driven Development Guide.md` in the repository root.

## What This Extension Provides

Expand Down Expand Up @@ -42,7 +42,7 @@ code --install-extension feature-orchestrator-latest.vsix --force

## State

Feature state is stored at `~/.android-auth-orchestrator/state.json` (per-developer, not in repo).
Feature state is stored at `~/.feature-orchestrator/<project>/state.json` (per-developer, not in repo).
Managed by `.github/hooks/state-utils.js`.

## Works Without This Extension
Expand Down
14 changes: 9 additions & 5 deletions extensions/feature-orchestrator/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
"name": "feature-orchestrator",
"displayName": "Android Auth Feature Orchestrator",
"description": "AI-driven feature development orchestrator for the Android Auth multi-repo project. Dashboard + @orchestrator chat participant.",
"version": "0.3.0",
"displayName": "Feature Orchestrator",
"description": "AI-driven feature development orchestrator for multi-repo projects. Dashboard + @orchestrator chat participant.",
"version": "0.4.0",
"publisher": "AzureAD",
"repository": {
"type": "git",
"url": "https://github.com/AzureAD/android-complete.git",
"directory": "extensions/feature-orchestrator"
},
"engines": {
"vscode": "^1.100.0"
},
Expand Down Expand Up @@ -108,8 +113,7 @@
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"lint": "eslint src --ext ts"
"watch": "tsc -watch -p ./"
},
"devDependencies": {
"@types/node": "^20.0.0",
Expand Down
232 changes: 232 additions & 0 deletions extensions/feature-orchestrator/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
// Copyright (c) Microsoft Corporation.
// All rights reserved.
//
// This code is licensed under the MIT License.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files(the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions :
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import * as vscode from 'vscode';

interface RepositoryConfig {
slug?: string;
host?: string;
}

interface ModuleConfig {
repo?: string;
}

interface OrchestratorConfig {
project?: { name?: string };
repositories?: Record<string, RepositoryConfig>;
modules?: Record<string, ModuleConfig>;
ado?: { org?: string; project?: string };
design?: { docsPath?: string };
github?: { configFile?: string };
}

let cachedConfig: OrchestratorConfig | null = null;

export function getWorkspaceRoot(): string | undefined {
return vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
}

export function getOrchestratorConfig(): OrchestratorConfig {
if (cachedConfig) {
return cachedConfig;
}

const workspaceRoot = getWorkspaceRoot();
if (!workspaceRoot) {
cachedConfig = {};
return cachedConfig;
}

const configPath = path.join(workspaceRoot, '.github', 'orchestrator-config.json');
if (!fs.existsSync(configPath)) {
cachedConfig = {};
return cachedConfig;
}

try {
cachedConfig = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
} catch {
cachedConfig = {};
}

return cachedConfig || {};
}

export function getAdoConfig(): { org: string; project: string } {
const config = getOrchestratorConfig();
return {
org: config.ado?.org || '',
project: config.ado?.project || '',
};
}

export function getAdoOrgUrl(): string {
const ado = getAdoConfig();
return ado.org ? `https://dev.azure.com/${ado.org}` : '';
}

export function getAdoWorkItemUrl(id: string | number): string {
const ado = getAdoConfig();
if (!ado.org || !ado.project) {
return '';
}
return `https://dev.azure.com/${ado.org}/${ado.project}/_workitems/edit/${id}`;
}

export function getDesignDocsPath(): string {
const docsPath = getOrchestratorConfig().design?.docsPath;
return docsPath || 'design-docs/';
}

export function getStateFilePath(): string {
const genericPath = path.join(os.homedir(), '.feature-orchestrator', 'state.json');
const legacyPath = path.join(os.homedir(), '.android-auth-orchestrator', 'state.json');

// Prefer the new generic path if it exists
if (fs.existsSync(genericPath)) {
return genericPath;
}

// Fall back to legacy path for backward compat
if (fs.existsSync(legacyPath)) {
return legacyPath;
}

// Default to generic path for new installs
return genericPath;
}

export function ensureStateDirectoryExists(): void {
const stateDir = path.dirname(getStateFilePath());
if (!fs.existsSync(stateDir)) {
fs.mkdirSync(stateDir, { recursive: true });
}
}

export function getRepositoryMap(): Record<string, string> {
const repos = getOrchestratorConfig().repositories || {};
const result: Record<string, string> = {};

for (const [key, repo] of Object.entries(repos)) {
if (repo.slug) {
result[key] = repo.slug;
}
}

return result;
}

export function getGithubRepositories(): Array<{ key: string; slug: string }> {
const repos = getOrchestratorConfig().repositories || {};
const result: Array<{ key: string; slug: string }> = [];

for (const [key, repo] of Object.entries(repos)) {
if ((repo.host || '').toLowerCase() === 'github' && repo.slug) {
result.push({ key, slug: repo.slug });
}
}

return result;
}

export function getRepoSlugForModule(moduleOrRepo: string): string | undefined {
if (!moduleOrRepo) {
return undefined;
}

if (moduleOrRepo.includes('/')) {
return moduleOrRepo;
}

const config = getOrchestratorConfig();
const repos = config.repositories || {};

if (repos[moduleOrRepo]?.slug) {
return repos[moduleOrRepo].slug;
}

const moduleConfig = config.modules?.[moduleOrRepo];
if (moduleConfig?.repo && repos[moduleConfig.repo]?.slug) {
return repos[moduleConfig.repo].slug;
}

return undefined;
}

export function getModuleRepoChoices(): Array<{ label: string; description: string; value: string }> {
const config = getOrchestratorConfig();
const repos = config.repositories || {};
const modules = config.modules || {};

const seen = new Set<string>();
const choices: Array<{ label: string; description: string; value: string }> = [];

for (const [moduleName, moduleConfig] of Object.entries(modules)) {
const repoKey = moduleConfig.repo || moduleName;
const repoSlug = repos[repoKey]?.slug;
if (!repoSlug || seen.has(moduleName)) {
continue;
}

seen.add(moduleName);
choices.push({
label: moduleName,
description: repoSlug,
value: repoSlug,
});
}

if (choices.length > 0) {
return choices;
}

for (const [repoKey, repoConfig] of Object.entries(repos)) {
if (repoConfig.slug) {
choices.push({
label: repoKey,
description: repoConfig.slug,
value: repoConfig.slug,
});
}
}

return choices;
}

export function getDeveloperLocalConfigPath(): string | undefined {
const workspaceRoot = getWorkspaceRoot();
if (!workspaceRoot) {
return undefined;
}

const configured = getOrchestratorConfig().github?.configFile;
if (configured) {
return path.join(workspaceRoot, configured);
}

return path.join(workspaceRoot, '.github', 'developer-local.json');
}
Loading
Loading