devworkspace 0.5.1 → 0.5.2
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/CHANGELOG.md +30 -2
- package/README.md +57 -509
- package/dist/agents/claude/adapter.js +0 -1
- package/dist/agents/claude/content.js +0 -1
- package/dist/agents/codex/adapter.js +0 -1
- package/dist/agents/copilot/adapter.js +0 -1
- package/dist/agents/cursor/adapter.js +0 -1
- package/dist/agents/index.js +0 -1
- package/dist/agents/shared.js +0 -1
- package/dist/agents/types.js +0 -1
- package/dist/cli/args.d.ts +16 -0
- package/dist/cli/args.js +5 -1
- package/dist/cli/help.js +59 -17
- package/dist/cli/main.js +0 -1
- package/dist/cli/prompt.d.ts +15 -0
- package/dist/cli/prompt.js +113 -0
- package/dist/cli/render.d.ts +10 -0
- package/dist/cli/render.js +174 -4
- package/dist/cli/run.d.ts +3 -0
- package/dist/cli/run.js +366 -17
- package/dist/config/feature-gate.d.ts +15 -0
- package/dist/config/feature-gate.js +77 -0
- package/dist/config/feature-registry.d.ts +49 -0
- package/dist/config/feature-registry.js +451 -0
- package/dist/config/schemas.js +0 -1
- package/dist/config/settings.d.ts +54 -0
- package/dist/config/settings.js +293 -0
- package/dist/config/validate.js +0 -1
- package/dist/core/artifacts.js +0 -1
- package/dist/core/contracts.js +0 -1
- package/dist/core/migrations.js +0 -1
- package/dist/core/version.js +0 -1
- package/dist/core/versioned.js +0 -1
- package/dist/core/workspace.d.ts +1 -0
- package/dist/core/workspace.js +1 -1
- package/dist/decisions/decision.js +0 -1
- package/dist/discovery/cache.js +0 -1
- package/dist/discovery/commands.js +0 -1
- package/dist/discovery/detect.js +0 -1
- package/dist/discovery/docs.js +0 -1
- package/dist/discovery/entrypoints.js +0 -1
- package/dist/discovery/ignore.js +0 -1
- package/dist/discovery/scan.js +0 -1
- package/dist/discovery/types.js +0 -1
- package/dist/dx/dashboard.js +2 -1
- package/dist/dx/guidance.js +0 -1
- package/dist/dx/guided-setup.d.ts +102 -0
- package/dist/dx/guided-setup.js +508 -0
- package/dist/dx/index.js +0 -1
- package/dist/dx/onboarding.js +0 -1
- package/dist/dx/types.js +0 -1
- package/dist/errors/index.js +0 -1
- package/dist/features/schema.js +0 -1
- package/dist/features/types.js +0 -1
- package/dist/features/validate.js +0 -1
- package/dist/git/git.js +0 -1
- package/dist/index.d.ts +15 -5
- package/dist/index.js +10 -2
- package/dist/integrations/adapters/agent-skills.js +0 -1
- package/dist/integrations/adapters/claudePlugin.js +0 -1
- package/dist/integrations/adapters/graphify.js +0 -1
- package/dist/integrations/adapters/omniroute.js +0 -1
- package/dist/integrations/adapters/pluginSkill.js +0 -1
- package/dist/integrations/adapters/ponytail.js +0 -1
- package/dist/integrations/exec.js +0 -1
- package/dist/integrations/index.js +0 -1
- package/dist/integrations/manager.d.ts +2 -1
- package/dist/integrations/manager.js +22 -3
- package/dist/integrations/notices.js +0 -1
- package/dist/integrations/persistentPath.js +0 -1
- package/dist/integrations/protect.js +0 -1
- package/dist/integrations/state.js +0 -1
- package/dist/integrations/types.d.ts +1 -1
- package/dist/integrations/types.js +1 -1
- package/dist/intelligence/agents/profiles.js +0 -1
- package/dist/intelligence/agents/registry.js +0 -1
- package/dist/intelligence/agents/types.js +0 -1
- package/dist/intelligence/observability/tracer.js +0 -1
- package/dist/intelligence/observability/types.js +0 -1
- package/dist/intelligence/orchestration/engine.d.ts +13 -4
- package/dist/intelligence/orchestration/engine.js +332 -54
- package/dist/intelligence/orchestration/lock-manager.js +0 -1
- package/dist/intelligence/orchestration/store.js +0 -1
- package/dist/intelligence/orchestration/types.d.ts +28 -1
- package/dist/intelligence/orchestration/types.js +0 -1
- package/dist/intelligence/routing/matcher.js +0 -1
- package/dist/intelligence/routing/router.js +0 -1
- package/dist/intelligence/routing/types.js +0 -1
- package/dist/intelligence/runtime/adk/adapter.js +1 -2
- package/dist/intelligence/runtime/adk/detector.js +0 -1
- package/dist/intelligence/runtime/auth-provider.d.ts +63 -0
- package/dist/intelligence/runtime/auth-provider.js +201 -0
- package/dist/intelligence/runtime/boundary.d.ts +118 -6
- package/dist/intelligence/runtime/boundary.js +720 -38
- package/dist/intelligence/runtime/changes.d.ts +59 -0
- package/dist/intelligence/runtime/changes.js +362 -0
- package/dist/intelligence/runtime/external.d.ts +1 -0
- package/dist/intelligence/runtime/external.js +9 -6
- package/dist/intelligence/runtime/native.js +0 -1
- package/dist/intelligence/runtime/types.d.ts +64 -2
- package/dist/intelligence/runtime/types.js +0 -1
- package/dist/intelligence/security/audit.js +8 -2
- package/dist/intelligence/security/policy.js +0 -1
- package/dist/intelligence/security/types.d.ts +8 -0
- package/dist/intelligence/security/types.js +0 -1
- package/dist/intelligence/skills/builtins.js +0 -1
- package/dist/intelligence/skills/loader.js +0 -1
- package/dist/intelligence/skills/registry.js +0 -1
- package/dist/intelligence/skills/types.js +0 -1
- package/dist/intelligence/verification/engine.d.ts +10 -2
- package/dist/intelligence/verification/engine.js +53 -9
- package/dist/intelligence/verification/reviewer.d.ts +18 -2
- package/dist/intelligence/verification/reviewer.js +356 -4
- package/dist/intelligence/verification/types.d.ts +60 -0
- package/dist/intelligence/verification/types.js +0 -1
- package/dist/knowledge/facts.js +0 -1
- package/dist/mcp/protocol.js +0 -1
- package/dist/mcp/server.js +38 -2
- package/dist/mcp/setup.js +5 -2
- package/dist/mcp/tools.js +0 -1
- package/dist/mcp/types.js +0 -1
- package/dist/mcp/verify.js +0 -1
- package/dist/portability/bundle.js +0 -1
- package/dist/prompts/onboarding.js +0 -1
- package/dist/prompts/refresh.js +0 -1
- package/dist/prompts/requirements.js +0 -1
- package/dist/security/files.js +0 -1
- package/dist/security/redact.js +0 -1
- package/dist/services/agent.js +2 -1
- package/dist/services/analysis.js +0 -1
- package/dist/services/common.js +0 -1
- package/dist/services/doctor.js +13 -2
- package/dist/services/drift.js +0 -1
- package/dist/services/features.js +5 -1
- package/dist/services/graph.js +4 -1
- package/dist/services/init.js +0 -1
- package/dist/services/integrations.d.ts +2 -1
- package/dist/services/integrations.js +29 -6
- package/dist/services/intelligence.d.ts +2 -2
- package/dist/services/intelligence.js +38 -36
- package/dist/services/knowledge.js +0 -1
- package/dist/services/migrate.js +0 -1
- package/dist/services/modules.d.ts +85 -0
- package/dist/services/modules.js +313 -0
- package/dist/services/portability.js +0 -1
- package/dist/services/records.js +5 -1
- package/dist/services/refresh.js +0 -1
- package/dist/services/reset.js +0 -1
- package/dist/services/settings.d.ts +36 -0
- package/dist/services/settings.js +102 -0
- package/dist/services/setup.d.ts +4 -5
- package/dist/services/setup.js +40 -28
- package/dist/services/standards.js +10 -1
- package/dist/services/status.js +0 -1
- package/dist/services/taskContext.js +0 -1
- package/dist/services/tasks.js +9 -1
- package/dist/services/verify.js +7 -2
- package/dist/sessions/session.js +0 -1
- package/dist/standards/acquisition/ingest.js +0 -1
- package/dist/standards/applicability/engine.js +0 -1
- package/dist/standards/builtin/code-quality.js +0 -1
- package/dist/standards/builtin/database-safety.js +0 -1
- package/dist/standards/builtin/index.js +0 -1
- package/dist/standards/builtin/security-baseline.js +0 -1
- package/dist/standards/builtin/testing-contracts.js +0 -1
- package/dist/standards/builtin/undo-kit.js +0 -1
- package/dist/standards/config/config.js +0 -1
- package/dist/standards/distribution/cache.js +0 -1
- package/dist/standards/distribution/index.js +0 -1
- package/dist/standards/distribution/keys.js +0 -1
- package/dist/standards/distribution/package.js +0 -1
- package/dist/standards/distribution/server.js +0 -1
- package/dist/standards/distribution/sync.js +0 -1
- package/dist/standards/distribution/types.js +0 -1
- package/dist/standards/engine/compliance.js +0 -1
- package/dist/standards/engine/engine.js +0 -1
- package/dist/standards/engine/reporter.js +0 -1
- package/dist/standards/index.js +0 -1
- package/dist/standards/registry/registry.js +0 -1
- package/dist/standards/schema/types.js +0 -1
- package/dist/standards/schema/validate.js +0 -1
- package/dist/standards/templates/index.js +0 -1
- package/dist/standards/validators/database.js +0 -1
- package/dist/standards/validators/quality.js +0 -1
- package/dist/standards/validators/registry.js +0 -1
- package/dist/standards/validators/security.js +0 -1
- package/dist/standards/validators/testing.js +0 -1
- package/dist/standards/validators/types.js +0 -1
- package/dist/standards/validators/undo-kit.js +0 -1
- package/dist/tasks/routing.js +0 -1
- package/dist/tasks/task.js +0 -1
- package/dist/utils/cleanup.js +0 -1
- package/dist/utils/fs.js +0 -1
- package/dist/utils/lock.js +92 -49
- package/dist/utils/logger.js +0 -1
- package/dist/utils/paths.js +0 -1
- package/dist/utils/proc.d.ts +8 -0
- package/dist/utils/proc.js +54 -46
- package/dist/verification/safety.js +0 -1
- package/dist/verification/scope.js +0 -1
- package/docs/architecture/global-standards-architecture.md +287 -0
- package/docs/archive/global-standards/GLOBAL_STANDARDS_AUDIT.md +99 -0
- package/docs/archive/global-standards/GLOBAL_STANDARDS_FINAL_STATUS.md +138 -0
- package/docs/archive/global-standards/GLOBAL_STANDARDS_IMPLEMENTATION_PLAN.md +100 -0
- package/docs/archive/global-standards/GLOBAL_STANDARDS_INDEPENDENT_AUDIT.md +219 -0
- package/docs/archive/global-standards/GLOBAL_STANDARDS_SECURITY_REPORT.md +184 -0
- package/docs/configuration.md +67 -0
- package/docs/contributing.md +15 -4
- package/docs/development/EXECUTION_STATE.md +50 -0
- package/docs/features.md +80 -0
- package/docs/getting-started.md +69 -111
- package/docs/guides/global-standards-migration.md +100 -0
- package/docs/integrations.md +7 -0
- package/docs/security/THIRD_PARTY_LICENSES.md +41 -0
- package/docs/testing/FINAL_CORRECTION_AND_CLEANUP_REPORT.md +92 -0
- package/docs/testing/global-standards-real-project-tests.md +218 -0
- package/docs/testing/global-standards-test-report.md +89 -0
- package/docs/testing/global-standards-verification-matrix.md +174 -0
- package/docs/troubleshooting.md +3 -0
- package/package.json +1 -1
- package/dist/agents/claude/adapter.js.map +0 -1
- package/dist/agents/claude/content.js.map +0 -1
- package/dist/agents/codex/adapter.js.map +0 -1
- package/dist/agents/copilot/adapter.js.map +0 -1
- package/dist/agents/cursor/adapter.js.map +0 -1
- package/dist/agents/index.js.map +0 -1
- package/dist/agents/shared.js.map +0 -1
- package/dist/agents/types.js.map +0 -1
- package/dist/cli/args.js.map +0 -1
- package/dist/cli/help.js.map +0 -1
- package/dist/cli/main.js.map +0 -1
- package/dist/cli/render.js.map +0 -1
- package/dist/cli/run.js.map +0 -1
- package/dist/config/schemas.js.map +0 -1
- package/dist/config/validate.js.map +0 -1
- package/dist/core/artifacts.js.map +0 -1
- package/dist/core/contracts.js.map +0 -1
- package/dist/core/migrations.js.map +0 -1
- package/dist/core/version.js.map +0 -1
- package/dist/core/versioned.js.map +0 -1
- package/dist/core/workspace.js.map +0 -1
- package/dist/decisions/decision.js.map +0 -1
- package/dist/discovery/cache.js.map +0 -1
- package/dist/discovery/commands.js.map +0 -1
- package/dist/discovery/detect.js.map +0 -1
- package/dist/discovery/docs.js.map +0 -1
- package/dist/discovery/entrypoints.js.map +0 -1
- package/dist/discovery/ignore.js.map +0 -1
- package/dist/discovery/scan.js.map +0 -1
- package/dist/discovery/types.js.map +0 -1
- package/dist/dx/dashboard.js.map +0 -1
- package/dist/dx/guidance.js.map +0 -1
- package/dist/dx/index.js.map +0 -1
- package/dist/dx/onboarding.js.map +0 -1
- package/dist/dx/types.js.map +0 -1
- package/dist/errors/index.js.map +0 -1
- package/dist/features/schema.js.map +0 -1
- package/dist/features/types.js.map +0 -1
- package/dist/features/validate.js.map +0 -1
- package/dist/git/git.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/integrations/adapters/agent-skills.js.map +0 -1
- package/dist/integrations/adapters/claudePlugin.js.map +0 -1
- package/dist/integrations/adapters/graphify.js.map +0 -1
- package/dist/integrations/adapters/omniroute.js.map +0 -1
- package/dist/integrations/adapters/pluginSkill.js.map +0 -1
- package/dist/integrations/adapters/ponytail.js.map +0 -1
- package/dist/integrations/exec.js.map +0 -1
- package/dist/integrations/index.js.map +0 -1
- package/dist/integrations/manager.js.map +0 -1
- package/dist/integrations/notices.js.map +0 -1
- package/dist/integrations/persistentPath.js.map +0 -1
- package/dist/integrations/protect.js.map +0 -1
- package/dist/integrations/state.js.map +0 -1
- package/dist/integrations/types.js.map +0 -1
- package/dist/intelligence/agents/profiles.js.map +0 -1
- package/dist/intelligence/agents/registry.js.map +0 -1
- package/dist/intelligence/agents/types.js.map +0 -1
- package/dist/intelligence/observability/tracer.js.map +0 -1
- package/dist/intelligence/observability/types.js.map +0 -1
- package/dist/intelligence/orchestration/engine.js.map +0 -1
- package/dist/intelligence/orchestration/lock-manager.js.map +0 -1
- package/dist/intelligence/orchestration/store.js.map +0 -1
- package/dist/intelligence/orchestration/types.js.map +0 -1
- package/dist/intelligence/routing/matcher.js.map +0 -1
- package/dist/intelligence/routing/router.js.map +0 -1
- package/dist/intelligence/routing/types.js.map +0 -1
- package/dist/intelligence/runtime/adk/adapter.js.map +0 -1
- package/dist/intelligence/runtime/adk/detector.js.map +0 -1
- package/dist/intelligence/runtime/boundary.js.map +0 -1
- package/dist/intelligence/runtime/external.js.map +0 -1
- package/dist/intelligence/runtime/native.js.map +0 -1
- package/dist/intelligence/runtime/types.js.map +0 -1
- package/dist/intelligence/security/audit.js.map +0 -1
- package/dist/intelligence/security/policy.js.map +0 -1
- package/dist/intelligence/security/types.js.map +0 -1
- package/dist/intelligence/skills/builtins.js.map +0 -1
- package/dist/intelligence/skills/loader.js.map +0 -1
- package/dist/intelligence/skills/registry.js.map +0 -1
- package/dist/intelligence/skills/types.js.map +0 -1
- package/dist/intelligence/verification/engine.js.map +0 -1
- package/dist/intelligence/verification/reviewer.js.map +0 -1
- package/dist/intelligence/verification/types.js.map +0 -1
- package/dist/knowledge/facts.js.map +0 -1
- package/dist/mcp/protocol.js.map +0 -1
- package/dist/mcp/server.js.map +0 -1
- package/dist/mcp/setup.js.map +0 -1
- package/dist/mcp/tools.js.map +0 -1
- package/dist/mcp/types.js.map +0 -1
- package/dist/mcp/verify.js.map +0 -1
- package/dist/portability/bundle.js.map +0 -1
- package/dist/prompts/onboarding.js.map +0 -1
- package/dist/prompts/refresh.js.map +0 -1
- package/dist/prompts/requirements.js.map +0 -1
- package/dist/security/files.js.map +0 -1
- package/dist/security/redact.js.map +0 -1
- package/dist/services/agent.js.map +0 -1
- package/dist/services/analysis.js.map +0 -1
- package/dist/services/common.js.map +0 -1
- package/dist/services/doctor.js.map +0 -1
- package/dist/services/drift.js.map +0 -1
- package/dist/services/features.js.map +0 -1
- package/dist/services/graph.js.map +0 -1
- package/dist/services/init.js.map +0 -1
- package/dist/services/integrations.js.map +0 -1
- package/dist/services/intelligence.js.map +0 -1
- package/dist/services/knowledge.js.map +0 -1
- package/dist/services/migrate.js.map +0 -1
- package/dist/services/portability.js.map +0 -1
- package/dist/services/records.js.map +0 -1
- package/dist/services/refresh.js.map +0 -1
- package/dist/services/reset.js.map +0 -1
- package/dist/services/setup.js.map +0 -1
- package/dist/services/standards.js.map +0 -1
- package/dist/services/status.js.map +0 -1
- package/dist/services/taskContext.js.map +0 -1
- package/dist/services/tasks.js.map +0 -1
- package/dist/services/verify.js.map +0 -1
- package/dist/sessions/session.js.map +0 -1
- package/dist/standards/acquisition/ingest.js.map +0 -1
- package/dist/standards/applicability/engine.js.map +0 -1
- package/dist/standards/builtin/code-quality.js.map +0 -1
- package/dist/standards/builtin/database-safety.js.map +0 -1
- package/dist/standards/builtin/index.js.map +0 -1
- package/dist/standards/builtin/security-baseline.js.map +0 -1
- package/dist/standards/builtin/testing-contracts.js.map +0 -1
- package/dist/standards/builtin/undo-kit.js.map +0 -1
- package/dist/standards/config/config.js.map +0 -1
- package/dist/standards/distribution/cache.js.map +0 -1
- package/dist/standards/distribution/index.js.map +0 -1
- package/dist/standards/distribution/keys.js.map +0 -1
- package/dist/standards/distribution/package.js.map +0 -1
- package/dist/standards/distribution/server.js.map +0 -1
- package/dist/standards/distribution/sync.js.map +0 -1
- package/dist/standards/distribution/types.js.map +0 -1
- package/dist/standards/engine/compliance.js.map +0 -1
- package/dist/standards/engine/engine.js.map +0 -1
- package/dist/standards/engine/reporter.js.map +0 -1
- package/dist/standards/index.js.map +0 -1
- package/dist/standards/registry/registry.js.map +0 -1
- package/dist/standards/schema/types.js.map +0 -1
- package/dist/standards/schema/validate.js.map +0 -1
- package/dist/standards/templates/index.js.map +0 -1
- package/dist/standards/validators/database.js.map +0 -1
- package/dist/standards/validators/quality.js.map +0 -1
- package/dist/standards/validators/registry.js.map +0 -1
- package/dist/standards/validators/security.js.map +0 -1
- package/dist/standards/validators/testing.js.map +0 -1
- package/dist/standards/validators/types.js.map +0 -1
- package/dist/standards/validators/undo-kit.js.map +0 -1
- package/dist/tasks/routing.js.map +0 -1
- package/dist/tasks/task.js.map +0 -1
- package/dist/utils/cleanup.js.map +0 -1
- package/dist/utils/fs.js.map +0 -1
- package/dist/utils/lock.js.map +0 -1
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/paths.js.map +0 -1
- package/dist/utils/proc.js.map +0 -1
- package/dist/verification/safety.js.map +0 -1
- package/dist/verification/scope.js.map +0 -1
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { findWorkspaceRoot, wsPaths } from '../core/workspace.js';
|
|
5
|
+
import { PRESET_DEFAULT_FEATURES, defaultSettingsForPreset, saveWorkspaceSettings, } from '../config/settings.js';
|
|
6
|
+
import { resolveFeatureSelectionGraph } from '../config/feature-registry.js';
|
|
7
|
+
import { DevWorkspaceError } from '../errors/index.js';
|
|
8
|
+
import { runSetup } from '../integrations/index.js';
|
|
9
|
+
import { getAgentAdapter } from '../agents/index.js';
|
|
10
|
+
import { detectAntigravityUserConfigPath, detectMcpAgents, planMcpAgentChanges, setupMcpAgent, } from '../mcp/setup.js';
|
|
11
|
+
import { atomicWriteJson, ensureDir, pathExists } from '../utils/fs.js';
|
|
12
|
+
import { analyzeWorkspace } from '../services/analysis.js';
|
|
13
|
+
import { installAgent } from '../services/agent.js';
|
|
14
|
+
import { managerEnv } from '../services/common.js';
|
|
15
|
+
import { runDoctor } from '../services/doctor.js';
|
|
16
|
+
import { initWorkspace } from '../services/init.js';
|
|
17
|
+
/** Detect coding agents configured or present in the workspace cleanly without network calls. */
|
|
18
|
+
export async function detectSetupAgents(cwd, homeDir) {
|
|
19
|
+
const root = (await findWorkspaceRoot(cwd)) ?? path.resolve(cwd);
|
|
20
|
+
const mcpDetected = new Set(await detectMcpAgents(root));
|
|
21
|
+
const cursorAdapter = getAgentAdapter('cursor');
|
|
22
|
+
const copilotAdapter = getAgentAdapter('copilot');
|
|
23
|
+
const cursorFiles = cursorAdapter ? await cursorAdapter.detectExisting(root) : [];
|
|
24
|
+
const copilotFiles = copilotAdapter ? await copilotAdapter.detectExisting(root) : [];
|
|
25
|
+
const home = homeDir ?? process.env.DEVWORKSPACE_HOME ?? os.homedir();
|
|
26
|
+
const agPath = await detectAntigravityUserConfigPath(home);
|
|
27
|
+
const agExists = (await pathExists(agPath)) || (await pathExists(path.dirname(agPath)));
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
id: 'claude-code',
|
|
31
|
+
label: 'Claude Code (MCP + CLAUDE.md)',
|
|
32
|
+
connectionMethod: 'mcp',
|
|
33
|
+
scope: 'project',
|
|
34
|
+
detected: mcpDetected.has('claude-code') || (await pathExists(path.join(root, '.claude'))),
|
|
35
|
+
reason: mcpDetected.has('claude-code') ? 'Found CLAUDE.md or .mcp.json/.claude' : 'No Claude project files detected yet',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 'codex',
|
|
39
|
+
label: 'OpenAI Codex (MCP + AGENTS.md)',
|
|
40
|
+
connectionMethod: 'mcp',
|
|
41
|
+
scope: 'project',
|
|
42
|
+
detected: mcpDetected.has('codex') || (await pathExists(path.join(root, '.codex'))),
|
|
43
|
+
reason: mcpDetected.has('codex') ? 'Found .codex or AGENTS.md' : 'No Codex project files detected yet',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 'cursor',
|
|
47
|
+
label: 'Cursor (.cursor/rules markdown)',
|
|
48
|
+
connectionMethod: 'instructions',
|
|
49
|
+
scope: 'project',
|
|
50
|
+
detected: cursorFiles.length > 0 || (await pathExists(path.join(root, '.cursor'))),
|
|
51
|
+
reason: cursorFiles.length > 0 ? `Found ${cursorFiles.join(', ')}` : 'No Cursor rules detected yet',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: 'copilot',
|
|
55
|
+
label: 'GitHub Copilot (.github/copilot-instructions.md)',
|
|
56
|
+
connectionMethod: 'instructions',
|
|
57
|
+
scope: 'project',
|
|
58
|
+
detected: copilotFiles.length > 0,
|
|
59
|
+
reason: copilotFiles.length > 0 ? `Found ${copilotFiles.join(', ')}` : 'No Copilot instructions detected yet',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: 'antigravity',
|
|
63
|
+
label: 'Google Antigravity (user-level MCP config)',
|
|
64
|
+
connectionMethod: 'mcp',
|
|
65
|
+
scope: 'user',
|
|
66
|
+
detected: agExists,
|
|
67
|
+
reason: agExists ? 'Detected user-level Antigravity config folder' : 'Requires explicit user-scope consent',
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
export async function readSetupRecoveryState(cwd) {
|
|
72
|
+
const root = (await findWorkspaceRoot(cwd)) ?? path.resolve(cwd);
|
|
73
|
+
const file = path.join(root, '.devworkspace', 'local', 'setup-recovery.json');
|
|
74
|
+
if (!(await pathExists(file)))
|
|
75
|
+
return null;
|
|
76
|
+
try {
|
|
77
|
+
return JSON.parse(await fs.readFile(file, 'utf8'));
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function normalizeAgentSelection(rawAgent) {
|
|
84
|
+
if (!rawAgent || rawAgent === 'none' || rawAgent === 'skip') {
|
|
85
|
+
return { agent: null, method: 'none' };
|
|
86
|
+
}
|
|
87
|
+
const lower = rawAgent.toLowerCase();
|
|
88
|
+
if (lower === 'claude')
|
|
89
|
+
return { agent: 'claude-code', method: 'mcp' };
|
|
90
|
+
if (lower === 'claude-code' || lower === 'codex' || lower === 'antigravity' || lower === 'all') {
|
|
91
|
+
return { agent: lower, method: 'mcp' };
|
|
92
|
+
}
|
|
93
|
+
if (lower === 'cursor' || lower === 'copilot') {
|
|
94
|
+
return { agent: lower, method: 'instructions' };
|
|
95
|
+
}
|
|
96
|
+
throw new DevWorkspaceError('USAGE', `Unknown setup agent "${rawAgent}".`, {
|
|
97
|
+
hint: 'Choose one of: auto, claude-code, codex, cursor, copilot, antigravity, all, none.',
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function resolveFeatureSelection(preset, customFeatures) {
|
|
101
|
+
if (preset === 'custom') {
|
|
102
|
+
if (!customFeatures || customFeatures.length === 0) {
|
|
103
|
+
throw new DevWorkspaceError('USAGE', 'Custom preset requires at least one feature (--features <list>).');
|
|
104
|
+
}
|
|
105
|
+
const resolved = resolveFeatureSelectionGraph({ requestedEnable: customFeatures });
|
|
106
|
+
return { enabledFeatures: resolved.enabled, disabledFeatures: resolved.disabled };
|
|
107
|
+
}
|
|
108
|
+
const resolved = resolveFeatureSelectionGraph({ requestedEnable: PRESET_DEFAULT_FEATURES[preset] });
|
|
109
|
+
return { enabledFeatures: resolved.enabled, disabledFeatures: resolved.disabled };
|
|
110
|
+
}
|
|
111
|
+
/** Pure read-only preview of all workspace, discovery, settings, agent, external tool, and user-level actions. */
|
|
112
|
+
export async function planGuidedSetup(o) {
|
|
113
|
+
const startDir = o.cwd ? path.resolve(o.cwd) : process.cwd();
|
|
114
|
+
const root = (await findWorkspaceRoot(startDir)) ?? startDir;
|
|
115
|
+
const ws = wsPaths(root);
|
|
116
|
+
const preset = o.preset ?? 'minimal';
|
|
117
|
+
const scope = o.scope ?? (o.user ? 'user' : 'project');
|
|
118
|
+
const resolvedAgent = o.agent === 'auto'
|
|
119
|
+
? await (async () => {
|
|
120
|
+
const candidates = (await detectSetupAgents(root, o.homeDir)).filter((c) => c.detected && c.scope === 'project');
|
|
121
|
+
if (candidates.length === 1)
|
|
122
|
+
return normalizeAgentSelection(candidates[0].id);
|
|
123
|
+
return { agent: null, method: 'none' };
|
|
124
|
+
})()
|
|
125
|
+
: normalizeAgentSelection(o.agent);
|
|
126
|
+
const rawFeatures = resolveFeatureSelection(preset, o.features);
|
|
127
|
+
const autoEnabledForChoices = [];
|
|
128
|
+
if (resolvedAgent.agent && resolvedAgent.method === 'mcp') {
|
|
129
|
+
autoEnabledForChoices.push('agent.mcp');
|
|
130
|
+
}
|
|
131
|
+
else if (resolvedAgent.agent && resolvedAgent.method === 'instructions') {
|
|
132
|
+
autoEnabledForChoices.push('agent.instructions');
|
|
133
|
+
}
|
|
134
|
+
if (o.onlyIntegrations && o.onlyIntegrations.length > 0 && o.consentExternalInstalls) {
|
|
135
|
+
for (const id of o.onlyIntegrations) {
|
|
136
|
+
autoEnabledForChoices.push(id.startsWith('integration.') ? id : `integration.${id}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const features = autoEnabledForChoices.length > 0
|
|
140
|
+
? (() => {
|
|
141
|
+
const merged = resolveFeatureSelectionGraph({
|
|
142
|
+
requestedEnable: autoEnabledForChoices,
|
|
143
|
+
currentEnabled: rawFeatures.enabledFeatures,
|
|
144
|
+
});
|
|
145
|
+
return { enabledFeatures: merged.enabled, disabledFeatures: merged.disabled };
|
|
146
|
+
})()
|
|
147
|
+
: rawFeatures;
|
|
148
|
+
const settings = defaultSettingsForPreset(preset, {
|
|
149
|
+
agentSelected: resolvedAgent.agent,
|
|
150
|
+
agentMethod: resolvedAgent.method,
|
|
151
|
+
scope,
|
|
152
|
+
customFeatures: features.enabledFeatures,
|
|
153
|
+
integrationsConsented: o.consentExternalInstalls
|
|
154
|
+
? (o.onlyIntegrations ?? []).map((id) => (id.startsWith('integration.') ? id : `integration.${id}`))
|
|
155
|
+
: [],
|
|
156
|
+
source: o.source ?? 'cli',
|
|
157
|
+
});
|
|
158
|
+
const plannedFiles = [];
|
|
159
|
+
const warnings = [];
|
|
160
|
+
const userLevelChanges = [];
|
|
161
|
+
const toRel = (abs) => path.relative(root, abs).replace(/\\/g, '/');
|
|
162
|
+
const priorRecovery = await readSetupRecoveryState(root);
|
|
163
|
+
if (priorRecovery) {
|
|
164
|
+
warnings.push(`Found partial setup recovery state from ${priorRecovery.failedAt} (failed step: ${priorRecovery.failedStep}). Re-running setup will resume safely without deleting existing data.`);
|
|
165
|
+
}
|
|
166
|
+
const initPreview = await initWorkspace({ ...o, cwd: root, root, dryRun: true });
|
|
167
|
+
for (const rel of initPreview.created) {
|
|
168
|
+
if (!rel.endsWith('/'))
|
|
169
|
+
plannedFiles.push({ path: rel, kind: 'create', note: 'workspace metadata' });
|
|
170
|
+
}
|
|
171
|
+
const gitkeepDirs = [ws.decisionsDir, ws.tasksActive, ws.tasksCompleted, ws.sessionsDir];
|
|
172
|
+
for (const dir of gitkeepDirs) {
|
|
173
|
+
const keepFile = path.join(dir, '.gitkeep');
|
|
174
|
+
if (!(await pathExists(keepFile))) {
|
|
175
|
+
plannedFiles.push({ path: toRel(keepFile), kind: 'create', note: 'keep tracked workspace folder in Git' });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Analysis & deterministic discovery files written by analyzeWorkspace()
|
|
179
|
+
const analysisTargets = [
|
|
180
|
+
{ abs: ws.discovery, note: 'deterministic repository discovery snapshot' },
|
|
181
|
+
{ abs: ws.commands, note: 'detected verification commands contract' },
|
|
182
|
+
{ abs: ws.facts, note: 'observed project facts' },
|
|
183
|
+
{ abs: ws.onboardingPrompt, note: 'generated onboarding prompt (git-ignored)' },
|
|
184
|
+
{ abs: ws.analysisState, note: 'analysis checksum & baseline state' },
|
|
185
|
+
];
|
|
186
|
+
for (const item of analysisTargets) {
|
|
187
|
+
plannedFiles.push({
|
|
188
|
+
path: toRel(item.abs),
|
|
189
|
+
kind: (await pathExists(item.abs)) ? 'update' : 'create',
|
|
190
|
+
note: item.note,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
// Preserved user-authored knowledge & artifacts (never overwritten by setup)
|
|
194
|
+
const preserveTargets = [
|
|
195
|
+
{ abs: ws.features, note: 'existing feature maps preserved' },
|
|
196
|
+
{ abs: ws.tasksActive, note: 'existing active tasks preserved' },
|
|
197
|
+
{ abs: ws.decisionsDir, note: 'existing architecture decisions preserved' },
|
|
198
|
+
];
|
|
199
|
+
for (const item of preserveTargets) {
|
|
200
|
+
if (await pathExists(item.abs)) {
|
|
201
|
+
plannedFiles.push({ path: toRel(item.abs), kind: 'preserve', note: item.note });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
plannedFiles.push({
|
|
205
|
+
path: '.devworkspace/settings.json',
|
|
206
|
+
kind: (await pathExists(ws.settings)) ? 'update' : 'create',
|
|
207
|
+
note: `persist ${preset} setup profile (no secrets)`,
|
|
208
|
+
});
|
|
209
|
+
if (resolvedAgent.agent && resolvedAgent.method === 'mcp') {
|
|
210
|
+
if (resolvedAgent.agent === 'antigravity' && scope !== 'user' && !o.user) {
|
|
211
|
+
warnings.push('Antigravity uses user-level MCP configuration; manual steps will be shown unless --user / user scope is approved.');
|
|
212
|
+
}
|
|
213
|
+
const mcpPlan = await planMcpAgentChanges(root, path.basename(root), resolvedAgent.agent, {
|
|
214
|
+
launcher: o.launcher,
|
|
215
|
+
packageVersion: o.packageVersion,
|
|
216
|
+
projectRoot: root,
|
|
217
|
+
user: scope === 'user' || o.user === true,
|
|
218
|
+
homeDir: o.homeDir,
|
|
219
|
+
});
|
|
220
|
+
for (const c of mcpPlan) {
|
|
221
|
+
plannedFiles.push({ path: c.path, kind: c.kind, note: c.note });
|
|
222
|
+
if (path.isAbsolute(c.path))
|
|
223
|
+
userLevelChanges.push(c.path);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
else if (resolvedAgent.agent && resolvedAgent.method === 'instructions') {
|
|
227
|
+
const adapter = getAgentAdapter(resolvedAgent.agent);
|
|
228
|
+
if (adapter) {
|
|
229
|
+
const changes = await adapter.plan({ root, projectName: path.basename(root) });
|
|
230
|
+
for (const c of changes) {
|
|
231
|
+
plannedFiles.push({ path: c.path, kind: c.kind, note: c.note });
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const externalInstalls = [];
|
|
236
|
+
if (o.onlyIntegrations && o.onlyIntegrations.length > 0) {
|
|
237
|
+
const intPlan = await runSetup(ws, managerEnv(o, root), {
|
|
238
|
+
dryRun: true,
|
|
239
|
+
yes: false,
|
|
240
|
+
repair: false,
|
|
241
|
+
scope,
|
|
242
|
+
only: o.onlyIntegrations,
|
|
243
|
+
});
|
|
244
|
+
for (const out of intPlan.outcomes) {
|
|
245
|
+
if (out.action === 'not-selected')
|
|
246
|
+
continue;
|
|
247
|
+
const desc = out.plan.map((s) => s.description).join('; ') || `Inspect/install ${out.name}`;
|
|
248
|
+
externalInstalls.push({
|
|
249
|
+
id: out.id,
|
|
250
|
+
name: out.name,
|
|
251
|
+
scope,
|
|
252
|
+
description: desc,
|
|
253
|
+
});
|
|
254
|
+
plannedFiles.push({
|
|
255
|
+
path: `external:${out.id}`,
|
|
256
|
+
kind: 'external',
|
|
257
|
+
note: `${out.name} (${scope} scope): ${desc}`,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
if (!o.consentExternalInstalls && externalInstalls.length > 0) {
|
|
261
|
+
warnings.push('External integrations selected cleanly in preview; explicit consent (--yes) is required before applying.');
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (plannedFiles.some((f) => f.kind === 'conflict')) {
|
|
265
|
+
warnings.push('One or more existing agent config files have merge conflicts and will NOT be overwritten.');
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
root,
|
|
269
|
+
alreadyInitialized: await pathExists(ws.projectJson),
|
|
270
|
+
preset,
|
|
271
|
+
agent: settings.agent.selected,
|
|
272
|
+
agentMethod: settings.agent.method,
|
|
273
|
+
scope,
|
|
274
|
+
enabledFeatures: settings.enabledFeatures,
|
|
275
|
+
disabledFeatures: settings.disabledFeatures,
|
|
276
|
+
plannedFiles,
|
|
277
|
+
externalInstalls,
|
|
278
|
+
userLevelChanges,
|
|
279
|
+
warnings,
|
|
280
|
+
untouchedNotice: 'Your application source code, git history, secrets, and existing tasks/decisions are never modified.',
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
async function snapshotManagedFiles(absPaths) {
|
|
284
|
+
const snap = new Map();
|
|
285
|
+
for (const abs of absPaths) {
|
|
286
|
+
if (snap.has(abs))
|
|
287
|
+
continue;
|
|
288
|
+
try {
|
|
289
|
+
snap.set(abs, await fs.readFile(abs, 'utf8'));
|
|
290
|
+
}
|
|
291
|
+
catch {
|
|
292
|
+
snap.set(abs, null);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return snap;
|
|
296
|
+
}
|
|
297
|
+
async function restoreManagedSnapshot(root, snap) {
|
|
298
|
+
const restored = [];
|
|
299
|
+
for (const [abs, prev] of snap.entries()) {
|
|
300
|
+
const label = path.isAbsolute(abs) && abs.startsWith(root)
|
|
301
|
+
? path.relative(root, abs).replace(/\\/g, '/')
|
|
302
|
+
: abs;
|
|
303
|
+
try {
|
|
304
|
+
if (prev === null) {
|
|
305
|
+
if (await pathExists(abs)) {
|
|
306
|
+
await fs.unlink(abs);
|
|
307
|
+
restored.push(`removed created ${label}`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
await ensureDir(path.dirname(abs));
|
|
312
|
+
await fs.writeFile(abs, prev, 'utf8');
|
|
313
|
+
restored.push(`restored previous ${label}`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
catch {
|
|
317
|
+
// Best-effort rollback for individual file; continue restoring remaining entries
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return restored;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Execute guided setup with staged execution, pre-run file snapshots, reversible
|
|
324
|
+
* rollback for local managed files, and explicit partial-setup recovery tracking.
|
|
325
|
+
* Honors `dryRun` cleanly and never auto-uninstalls third-party external tools.
|
|
326
|
+
*/
|
|
327
|
+
export async function applyGuidedSetup(o) {
|
|
328
|
+
const preview = await planGuidedSetup(o);
|
|
329
|
+
const ws = wsPaths(preview.root);
|
|
330
|
+
const settings = defaultSettingsForPreset(preview.preset, {
|
|
331
|
+
agentSelected: preview.agent,
|
|
332
|
+
agentMethod: preview.agentMethod,
|
|
333
|
+
scope: preview.scope,
|
|
334
|
+
customFeatures: preview.enabledFeatures,
|
|
335
|
+
integrationsConsented: o.consentExternalInstalls
|
|
336
|
+
? (o.onlyIntegrations ?? []).map((id) => (id.startsWith('integration.') ? id : `integration.${id}`))
|
|
337
|
+
: [],
|
|
338
|
+
source: o.source ?? 'cli',
|
|
339
|
+
});
|
|
340
|
+
if (o.dryRun) {
|
|
341
|
+
return {
|
|
342
|
+
root: preview.root,
|
|
343
|
+
initialized: preview.alreadyInitialized,
|
|
344
|
+
dryRun: true,
|
|
345
|
+
cancelled: false,
|
|
346
|
+
applied: false,
|
|
347
|
+
preset: preview.preset,
|
|
348
|
+
agent: preview.agent,
|
|
349
|
+
agentMethod: preview.agentMethod,
|
|
350
|
+
scope: preview.scope,
|
|
351
|
+
settings,
|
|
352
|
+
preview,
|
|
353
|
+
steps: [],
|
|
354
|
+
restartRequired: false,
|
|
355
|
+
nextStep: 'Preview only. Run "devworkspace setup" without --dry-run to apply.',
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
if (preview.externalInstalls.length > 0 && !o.consentExternalInstalls) {
|
|
359
|
+
throw new DevWorkspaceError('USAGE', `External integrations requested (${preview.externalInstalls.map((e) => e.id).join(', ')}) require explicit consent (--yes).`, { hint: 'Re-run with --yes after reviewing the preview, or omit --only to run core/agent setup without external installs.' });
|
|
360
|
+
}
|
|
361
|
+
const candidateSnapshotPaths = [
|
|
362
|
+
ws.settings,
|
|
363
|
+
...(preview.alreadyInitialized ? [ws.projectJson, ws.gitignore] : []),
|
|
364
|
+
ws.discovery,
|
|
365
|
+
ws.onboardingPrompt,
|
|
366
|
+
ws.commands,
|
|
367
|
+
ws.facts,
|
|
368
|
+
ws.analysisState,
|
|
369
|
+
];
|
|
370
|
+
for (const planned of preview.plannedFiles) {
|
|
371
|
+
if (planned.kind === 'create' || planned.kind === 'update') {
|
|
372
|
+
const abs = path.isAbsolute(planned.path) ? planned.path : path.join(preview.root, planned.path);
|
|
373
|
+
candidateSnapshotPaths.push(abs);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
const snap = await snapshotManagedFiles(candidateSnapshotPaths);
|
|
377
|
+
const steps = [];
|
|
378
|
+
const recoveryPath = path.join(ws.localDir, 'setup-recovery.json');
|
|
379
|
+
let currentStage = 'init';
|
|
380
|
+
let externalStarted = false;
|
|
381
|
+
let mcpResult;
|
|
382
|
+
let agentInstallResult;
|
|
383
|
+
let integrationsResult;
|
|
384
|
+
let doctor;
|
|
385
|
+
try {
|
|
386
|
+
currentStage = 'init';
|
|
387
|
+
await o.onStage?.('init');
|
|
388
|
+
await initWorkspace({ ...o, cwd: preview.root, root: preview.root, dryRun: false });
|
|
389
|
+
steps.push({ step: 'init', status: 'succeeded' });
|
|
390
|
+
currentStage = 'analysis';
|
|
391
|
+
await o.onStage?.('analysis');
|
|
392
|
+
await analyzeWorkspace(ws, { ...o, cwd: preview.root, dryRun: false });
|
|
393
|
+
steps.push({ step: 'analysis', status: 'succeeded' });
|
|
394
|
+
currentStage = 'settings';
|
|
395
|
+
await o.onStage?.('settings');
|
|
396
|
+
await saveWorkspaceSettings(ws, settings);
|
|
397
|
+
steps.push({ step: 'settings', status: 'succeeded' });
|
|
398
|
+
currentStage = 'agent';
|
|
399
|
+
await o.onStage?.('agent');
|
|
400
|
+
if (preview.agent && preview.agentMethod === 'mcp') {
|
|
401
|
+
mcpResult = await setupMcpAgent({
|
|
402
|
+
cwd: preview.root,
|
|
403
|
+
agent: preview.agent,
|
|
404
|
+
launcher: o.launcher,
|
|
405
|
+
packageVersion: o.packageVersion,
|
|
406
|
+
user: preview.scope === 'user' || o.user === true,
|
|
407
|
+
homeDir: o.homeDir,
|
|
408
|
+
verify: !o.noVerify,
|
|
409
|
+
});
|
|
410
|
+
steps.push({ step: 'agent', status: 'succeeded', detail: `MCP configured for ${preview.agent}` });
|
|
411
|
+
}
|
|
412
|
+
else if (preview.agent && preview.agentMethod === 'instructions') {
|
|
413
|
+
agentInstallResult = await installAgent({ ...o, cwd: preview.root, dryRun: false }, preview.agent);
|
|
414
|
+
steps.push({ step: 'agent', status: 'succeeded', detail: `Instructions installed for ${preview.agent}` });
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
steps.push({ step: 'agent', status: 'skipped', detail: 'No agent selected' });
|
|
418
|
+
}
|
|
419
|
+
currentStage = 'integrations';
|
|
420
|
+
await o.onStage?.('integrations');
|
|
421
|
+
if (o.onlyIntegrations && o.onlyIntegrations.length > 0 && o.consentExternalInstalls) {
|
|
422
|
+
externalStarted = true;
|
|
423
|
+
integrationsResult = await runSetup(ws, managerEnv(o, preview.root), {
|
|
424
|
+
dryRun: false,
|
|
425
|
+
yes: true,
|
|
426
|
+
repair: false,
|
|
427
|
+
scope: preview.scope,
|
|
428
|
+
only: o.onlyIntegrations,
|
|
429
|
+
});
|
|
430
|
+
steps.push({ step: 'integrations', status: 'succeeded', detail: `${o.onlyIntegrations.join(', ')}` });
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
steps.push({ step: 'integrations', status: 'skipped' });
|
|
434
|
+
}
|
|
435
|
+
currentStage = 'doctor';
|
|
436
|
+
await o.onStage?.('doctor');
|
|
437
|
+
doctor = await runDoctor({ ...o, cwd: preview.root });
|
|
438
|
+
steps.push({ step: 'doctor', status: 'succeeded' });
|
|
439
|
+
if (await pathExists(recoveryPath)) {
|
|
440
|
+
await fs.unlink(recoveryPath).catch(() => undefined);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
catch (err) {
|
|
444
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
445
|
+
steps.push({ step: currentStage, status: 'failed', detail: errMsg });
|
|
446
|
+
const rolledBackFiles = await restoreManagedSnapshot(preview.root, snap);
|
|
447
|
+
const irreversibleExternalNotes = externalStarted
|
|
448
|
+
? ['External integration commands had already started before failure and were not automatically uninstalled.']
|
|
449
|
+
: [];
|
|
450
|
+
if (await pathExists(ws.dir)) {
|
|
451
|
+
const recovery = {
|
|
452
|
+
status: 'PARTIAL',
|
|
453
|
+
preset: preview.preset,
|
|
454
|
+
agent: preview.agent,
|
|
455
|
+
scope: preview.scope,
|
|
456
|
+
failedStep: currentStage,
|
|
457
|
+
error: errMsg,
|
|
458
|
+
steps,
|
|
459
|
+
rolledBackFiles,
|
|
460
|
+
irreversibleExternalNotes,
|
|
461
|
+
failedAt: new Date().toISOString(),
|
|
462
|
+
};
|
|
463
|
+
await ensureDir(ws.localDir);
|
|
464
|
+
await atomicWriteJson(recoveryPath, recovery);
|
|
465
|
+
}
|
|
466
|
+
const succeededList = steps.filter((s) => s.status === 'succeeded').map((s) => s.step).join(', ') || 'none';
|
|
467
|
+
const rollbackNote = rolledBackFiles.length > 0
|
|
468
|
+
? ` Rolled back ${rolledBackFiles.length} local change(s): ${rolledBackFiles.join('; ')}.`
|
|
469
|
+
: '';
|
|
470
|
+
const extNote = irreversibleExternalNotes.length > 0 ? ` ${irreversibleExternalNotes[0]}` : '';
|
|
471
|
+
const code = err instanceof DevWorkspaceError ? err.code : 'INTERNAL';
|
|
472
|
+
throw new DevWorkspaceError(code, `Setup failed during step "${currentStage}" (succeeded earlier: ${succeededList}): ${errMsg}.${rollbackNote}${extNote}`, {
|
|
473
|
+
stateChanged: rolledBackFiles.length === 0 || externalStarted,
|
|
474
|
+
hint: `Existing project data and user files were preserved. Re-run setup safely after fixing the cause: devworkspace setup --preset ${preview.preset}${preview.agent ? ` --agent ${preview.agent}` : ''}`,
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
const restartRequired = Boolean(integrationsResult?.outcomes.some((x) => x.report.status === 'RESTART_REQUIRED'));
|
|
478
|
+
let nextStep = 'Run "devworkspace status" or start working with your coding agent.';
|
|
479
|
+
if (restartRequired) {
|
|
480
|
+
nextStep = 'Reload your coding agent and run: devworkspace integrations status --restarted';
|
|
481
|
+
}
|
|
482
|
+
else if (mcpResult && mcpResult.userActions.length > 0) {
|
|
483
|
+
nextStep = mcpResult.userActions[0];
|
|
484
|
+
}
|
|
485
|
+
else if (agentInstallResult) {
|
|
486
|
+
nextStep = `Open your repository in ${preview.agent}; instructions are ready.`;
|
|
487
|
+
}
|
|
488
|
+
return {
|
|
489
|
+
root: preview.root,
|
|
490
|
+
initialized: true,
|
|
491
|
+
dryRun: false,
|
|
492
|
+
cancelled: false,
|
|
493
|
+
applied: true,
|
|
494
|
+
preset: preview.preset,
|
|
495
|
+
agent: preview.agent,
|
|
496
|
+
agentMethod: preview.agentMethod,
|
|
497
|
+
scope: preview.scope,
|
|
498
|
+
settings,
|
|
499
|
+
preview,
|
|
500
|
+
steps,
|
|
501
|
+
...(mcpResult ? { mcpResult } : {}),
|
|
502
|
+
...(agentInstallResult ? { agentInstallResult } : {}),
|
|
503
|
+
...(integrationsResult ? { integrationsResult } : {}),
|
|
504
|
+
doctor,
|
|
505
|
+
restartRequired,
|
|
506
|
+
nextStep,
|
|
507
|
+
};
|
|
508
|
+
}
|
package/dist/dx/index.js
CHANGED
package/dist/dx/onboarding.js
CHANGED
package/dist/dx/types.js
CHANGED
package/dist/errors/index.js
CHANGED
package/dist/features/schema.js
CHANGED
package/dist/features/types.js
CHANGED
package/dist/git/git.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,13 @@ export { DevWorkspaceError, EXIT } from './errors/index.js';
|
|
|
3
3
|
export { createSuccessResult, createWarningResult, createFailureResult, serializeError, isServiceResult, } from './core/contracts.js';
|
|
4
4
|
export type { ServiceResult, ResultStatus, ResultProvenance, SerializedError, } from './core/contracts.js';
|
|
5
5
|
export { initWorkspace } from './services/init.js';
|
|
6
|
-
export { setupProject, detectCliProvenance } from './services/setup.js';
|
|
6
|
+
export { setupProject, detectCliProvenance, } from './services/setup.js';
|
|
7
|
+
export { detectSetupAgents, planGuidedSetup, applyGuidedSetup, readSetupRecoveryState, } from './dx/guided-setup.js';
|
|
8
|
+
export { getSettingsSummary, type SettingsSummaryResult, type SettingsCapabilitySummary } from './services/settings.js';
|
|
9
|
+
export { listModulesService, showModuleService, enableModuleService, disableModuleService, configureModuleService, type ModuleListEntry, type ModulesListResult, type ModuleDetailResult, type ModuleToggleResult, type ModuleConfigureResult, } from './services/modules.js';
|
|
10
|
+
export { FEATURE_REGISTRY, getFeatureDefinition, validateFeatureRegistry, topologicalSortFeatures, resolveFeatureSelectionGraph, presetFeaturesFromRegistry, type FeatureCategory, type FeatureAvailability, type FeatureInstallKind, type FeatureDataPolicy, type FeatureDefinition, type FeatureResolutionResult, } from './config/feature-registry.js';
|
|
11
|
+
export { checkModuleEnabled, assertModuleEnabled, type CapabilityGateCheck, } from './config/feature-gate.js';
|
|
12
|
+
export { SETTINGS_SCHEMA_VERSION, SETUP_PRESETS, CORE_FEATURE_IDS, PRESET_DESCRIPTIONS, PRESET_DEFAULT_FEATURES, defaultSettingsForPreset, loadWorkspaceSettingsSafe, loadWorkspaceSettingsStrict, saveWorkspaceSettings, validateWorkspaceSettings, type SetupPreset, type WorkspaceSettings, } from './config/settings.js';
|
|
7
13
|
export { analyzeWorkspace } from './services/analysis.js';
|
|
8
14
|
export { getStatus } from './services/status.js';
|
|
9
15
|
export { runDoctor } from './services/doctor.js';
|
|
@@ -31,7 +37,8 @@ export type { DoctorResult, DoctorCheck } from './services/doctor.js';
|
|
|
31
37
|
export type { Task, TaskStatus, TaskType } from './tasks/task.js';
|
|
32
38
|
export type { Fact, ProjectConfig, CommandEntry } from './config/schemas.js';
|
|
33
39
|
export type { FeatureItem, FeatureComponent, FeaturesFile, FeatureValidationReport } from './features/types.js';
|
|
34
|
-
export type { ProjectSetupResult, CliProvenance, CliExecutionMode } from './services/setup.js';
|
|
40
|
+
export type { ProjectSetupResult, CliProvenance, CliExecutionMode, } from './services/setup.js';
|
|
41
|
+
export type { SetupAgentCandidate, GuidedSetupOptions, GuidedSetupPreview, GuidedSetupResult, GuidedSetupStage, GuidedSetupStepStatus, SetupRecoveryState, } from './dx/guided-setup.js';
|
|
35
42
|
export type { IntegrationReport, StatusCode as IntegrationStatusCode } from './integrations/types.js';
|
|
36
43
|
export type { AgentAdapter, AgentCapabilities, PlannedChange } from './agents/types.js';
|
|
37
44
|
export type { AgentInfo, AgentInstallResult } from './services/agent.js';
|
|
@@ -63,14 +70,17 @@ export { NativeRuntimeAdapter, PlaceholderRuntimeAdapter } from './intelligence/
|
|
|
63
70
|
export { ExternalAgentAdapter } from './intelligence/runtime/external.js';
|
|
64
71
|
export { GoogleAdkAdapter } from './intelligence/runtime/adk/adapter.js';
|
|
65
72
|
export { detectGoogleAdk } from './intelligence/runtime/adk/detector.js';
|
|
73
|
+
export { createApprovalGrant, evaluateApprovalGrants, evaluateStageScope, hasMatchingApprovalGrant, revokeApprovalGrant, readRevokedGrantIds, readRevokedGrantState, serializeGrantPayload, verifyGrantSecurity, withRevocationAuthLock, type EvaluateApprovalGrantsOptions, type GrantValidationResult, type RevocationReadResult, } from './intelligence/runtime/boundary.js';
|
|
74
|
+
export { HmacApprovalAuthProvider, Ed25519ApprovalAuthProvider, createEnvApprovalAuthProvider, getEnvApproverCredentials, type BaseAuthProviderOptions, type CredentialVerifier, } from './intelligence/runtime/auth-provider.js';
|
|
75
|
+
export { DEFAULT_MAX_SNAPSHOT_FILES, MAX_SNAPSHOT_FILE_BYTES, captureWorkspaceSnapshot, captureWorkspaceSnapshotDetailed, diffWorkspaceSnapshots, hashWorkspaceSnapshot, type CaptureWorkspaceSnapshotOptions, type WorkspaceChangeManifest, type WorkspaceRename, type WorkspaceSymlinkEntry, type WorkspaceSnapshotResult, } from './intelligence/runtime/changes.js';
|
|
66
76
|
export type { AgentProfile, AgentRoleType, RiskClassification as AgentRiskTier, AgentHealthCheckResult, } from './intelligence/agents/types.js';
|
|
67
77
|
export type { SkillManifest, SkillPermissionRequirements, SkillValidationResult, SkillCategory, SkillProgressiveContent, } from './intelligence/skills/types.js';
|
|
68
78
|
export type { ComplexityTier, ExecutionStrategy, RoutingDecision, } from './intelligence/routing/types.js';
|
|
69
|
-
export type { OrchestrationRun, OrchestrationState, PlanOptions, RunOptions, ExecutionStage, StageStatus, ExecutionReceipt, } from './intelligence/orchestration/types.js';
|
|
79
|
+
export type { OrchestrationRun, OrchestrationState, PlanOptions, ApproveRunOptions, RunOptions, ExternalExecutionConfig, ExecutionStage, StageStatus, ExecutionReceipt, } from './intelligence/orchestration/types.js';
|
|
70
80
|
export type { PerformanceMetrics, TraceSpan, ExecutionTrace, } from './intelligence/observability/types.js';
|
|
71
81
|
export type { SecurityPolicy, PermissionScope, SecurityAuditEntry, } from './intelligence/security/types.js';
|
|
72
|
-
export type { GateResult, ReviewFinding, VerificationEvaluationReport, GateCheckType, IndependentReviewReport, } from './intelligence/verification/types.js';
|
|
73
|
-
export type { AgentRuntimeAdapter, AgentExecutionRequest, AgentExecutionResponse, } from './intelligence/runtime/types.js';
|
|
82
|
+
export type { GateResult, StructuredTestCaseEvidence, ReviewFinding, VerificationEvaluationReport, GateCheckType, IndependentReviewReport, AcceptanceCriterionSpec, CriterionEvidenceMapping, CriterionEvaluation, } from './intelligence/verification/types.js';
|
|
83
|
+
export type { AgentRuntimeAdapter, AgentExecutionRequest, AgentExecutionResponse, ApprovalAuthProvider, ApprovalGrant, ApprovalGrantProof, ApproverAuthMethod, ApproverCredentials, ApproverIdentity, AuthenticatedApproverSession, } from './intelligence/runtime/types.js';
|
|
74
84
|
export * from './standards/index.js';
|
|
75
85
|
export { listStandardsService, getStandardService, auditStandardsService, applyStandardService, addStandardService, updateStandardsService, validateStandardsRegistryService, generateStandardsReportService, } from './services/standards.js';
|
|
76
86
|
export * from './dx/index.js';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,13 @@ export { packageVersion } from './core/version.js';
|
|
|
3
3
|
export { DevWorkspaceError, EXIT } from './errors/index.js';
|
|
4
4
|
export { createSuccessResult, createWarningResult, createFailureResult, serializeError, isServiceResult, } from './core/contracts.js';
|
|
5
5
|
export { initWorkspace } from './services/init.js';
|
|
6
|
-
export { setupProject, detectCliProvenance } from './services/setup.js';
|
|
6
|
+
export { setupProject, detectCliProvenance, } from './services/setup.js';
|
|
7
|
+
export { detectSetupAgents, planGuidedSetup, applyGuidedSetup, readSetupRecoveryState, } from './dx/guided-setup.js';
|
|
8
|
+
export { getSettingsSummary } from './services/settings.js';
|
|
9
|
+
export { listModulesService, showModuleService, enableModuleService, disableModuleService, configureModuleService, } from './services/modules.js';
|
|
10
|
+
export { FEATURE_REGISTRY, getFeatureDefinition, validateFeatureRegistry, topologicalSortFeatures, resolveFeatureSelectionGraph, presetFeaturesFromRegistry, } from './config/feature-registry.js';
|
|
11
|
+
export { checkModuleEnabled, assertModuleEnabled, } from './config/feature-gate.js';
|
|
12
|
+
export { SETTINGS_SCHEMA_VERSION, SETUP_PRESETS, CORE_FEATURE_IDS, PRESET_DESCRIPTIONS, PRESET_DEFAULT_FEATURES, defaultSettingsForPreset, loadWorkspaceSettingsSafe, loadWorkspaceSettingsStrict, saveWorkspaceSettings, validateWorkspaceSettings, } from './config/settings.js';
|
|
7
13
|
export { analyzeWorkspace } from './services/analysis.js';
|
|
8
14
|
export { getStatus } from './services/status.js';
|
|
9
15
|
export { runDoctor } from './services/doctor.js';
|
|
@@ -50,9 +56,11 @@ export { NativeRuntimeAdapter, PlaceholderRuntimeAdapter } from './intelligence/
|
|
|
50
56
|
export { ExternalAgentAdapter } from './intelligence/runtime/external.js';
|
|
51
57
|
export { GoogleAdkAdapter } from './intelligence/runtime/adk/adapter.js';
|
|
52
58
|
export { detectGoogleAdk } from './intelligence/runtime/adk/detector.js';
|
|
59
|
+
export { createApprovalGrant, evaluateApprovalGrants, evaluateStageScope, hasMatchingApprovalGrant, revokeApprovalGrant, readRevokedGrantIds, readRevokedGrantState, serializeGrantPayload, verifyGrantSecurity, withRevocationAuthLock, } from './intelligence/runtime/boundary.js';
|
|
60
|
+
export { HmacApprovalAuthProvider, Ed25519ApprovalAuthProvider, createEnvApprovalAuthProvider, getEnvApproverCredentials, } from './intelligence/runtime/auth-provider.js';
|
|
61
|
+
export { DEFAULT_MAX_SNAPSHOT_FILES, MAX_SNAPSHOT_FILE_BYTES, captureWorkspaceSnapshot, captureWorkspaceSnapshotDetailed, diffWorkspaceSnapshots, hashWorkspaceSnapshot, } from './intelligence/runtime/changes.js';
|
|
53
62
|
// Standards & Engineering Governance System
|
|
54
63
|
export * from './standards/index.js';
|
|
55
64
|
export { listStandardsService, getStandardService, auditStandardsService, applyStandardService, addStandardService, updateStandardsService, validateStandardsRegistryService, generateStandardsReportService, } from './services/standards.js';
|
|
56
65
|
// Developer Experience, Progressive Guidance & Optional Local Dashboard
|
|
57
66
|
export * from './dx/index.js';
|
|
58
|
-
//# sourceMappingURL=index.js.map
|