devworkspace 0.5.0 → 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 +44 -0
- 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 +21 -3
- package/dist/intelligence/orchestration/engine.js +486 -48
- package/dist/intelligence/orchestration/lock-manager.js +0 -1
- package/dist/intelligence/orchestration/store.js +0 -1
- package/dist/intelligence/orchestration/types.d.ts +40 -2
- package/dist/intelligence/orchestration/types.js +2 -3
- 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 +21 -33
- 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 +142 -0
- package/dist/intelligence/runtime/boundary.js +845 -0
- 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 +38 -61
- package/dist/intelligence/runtime/native.js +23 -56
- package/dist/intelligence/runtime/types.d.ts +91 -1
- package/dist/intelligence/runtime/types.js +11 -2
- 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 +30 -8
- package/dist/intelligence/verification/engine.js +126 -21
- package/dist/intelligence/verification/reviewer.d.ts +18 -2
- package/dist/intelligence/verification/reviewer.js +356 -4
- package/dist/intelligence/verification/types.d.ts +71 -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.d.ts +1 -0
- package/dist/standards/distribution/cache.js +199 -186
- package/dist/standards/distribution/index.js +0 -1
- package/dist/standards/distribution/keys.js +0 -1
- package/dist/standards/distribution/package.js +6 -1
- package/dist/standards/distribution/server.js +0 -1
- package/dist/standards/distribution/sync.d.ts +7 -2
- package/dist/standards/distribution/sync.js +41 -9
- 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 +12 -0
- package/dist/utils/proc.js +106 -44
- package/dist/verification/safety.js +0 -1
- package/dist/verification/scope.js +0 -1
- package/docs/agents.md +15 -0
- 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 -5
- 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/mcp.md +13 -0
- package/docs/security/THIRD_PARTY_LICENSES.md +41 -0
- package/docs/security.md +8 -2
- 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/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
package/dist/tasks/routing.js
CHANGED
package/dist/tasks/task.js
CHANGED
package/dist/utils/cleanup.js
CHANGED
package/dist/utils/fs.js
CHANGED
package/dist/utils/lock.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
1
2
|
import { promises as fs, unlinkSync } from 'node:fs';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { DevWorkspaceError } from '../errors/index.js';
|
|
4
5
|
import { ensureDir } from './fs.js';
|
|
5
6
|
import { onCleanup } from './cleanup.js';
|
|
7
|
+
const localLockQueues = new Map();
|
|
6
8
|
function pidAlive(pid) {
|
|
7
9
|
try {
|
|
8
10
|
process.kill(pid, 0);
|
|
@@ -18,68 +20,109 @@ export async function withLock(workspaceDir, fn, opts = {}) {
|
|
|
18
20
|
const staleMs = opts.staleMs ?? 60_000;
|
|
19
21
|
const dir = path.join(workspaceDir, 'local');
|
|
20
22
|
const lockPath = path.join(dir, opts.name ?? 'workspace.lock');
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
await new Promise((r) => setTimeout(r, 15 + Math.floor(Math.random() * 25)));
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
if (code !== 'EEXIST') {
|
|
40
|
-
throw new DevWorkspaceError('IO', 'Could not acquire the workspace lock.', { cause: e });
|
|
41
|
-
}
|
|
42
|
-
let stale;
|
|
23
|
+
const queueKey = process.platform === 'win32' ? path.resolve(lockPath).toLowerCase() : path.resolve(lockPath);
|
|
24
|
+
const myToken = randomBytes(8).toString('hex');
|
|
25
|
+
const previous = localLockQueues.get(queueKey) ?? Promise.resolve();
|
|
26
|
+
let releaseLocal;
|
|
27
|
+
const currentSlot = new Promise((resolve) => {
|
|
28
|
+
releaseLocal = resolve;
|
|
29
|
+
});
|
|
30
|
+
const chained = previous.then(() => currentSlot);
|
|
31
|
+
localLockQueues.set(queueKey, chained);
|
|
32
|
+
await previous;
|
|
33
|
+
try {
|
|
34
|
+
await ensureDir(dir);
|
|
35
|
+
const started = Date.now();
|
|
36
|
+
let winPermRetries = 0;
|
|
37
|
+
for (;;) {
|
|
43
38
|
try {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
const fh = await fs.open(lockPath, 'wx');
|
|
40
|
+
try {
|
|
41
|
+
await fh.writeFile(JSON.stringify({ pid: process.pid, at: Date.now(), token: myToken }));
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
await fh.close();
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
47
47
|
}
|
|
48
|
-
catch {
|
|
49
|
-
|
|
48
|
+
catch (e) {
|
|
49
|
+
const code = e.code;
|
|
50
|
+
// On Windows, opening a recently unlinked lock file while its handle is closing can briefly raise EPERM/EACCES.
|
|
51
|
+
if (process.platform === 'win32' && (code === 'EPERM' || code === 'EACCES') && winPermRetries < 25 && Date.now() - started <= timeoutMs) {
|
|
52
|
+
winPermRetries++;
|
|
53
|
+
await new Promise((r) => setTimeout(r, 15 + Math.floor(Math.random() * 25)));
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (code !== 'EEXIST') {
|
|
57
|
+
throw new DevWorkspaceError('IO', 'Could not acquire the workspace lock.', { cause: e });
|
|
58
|
+
}
|
|
59
|
+
let stale = false;
|
|
60
|
+
let disappeared = false;
|
|
50
61
|
try {
|
|
51
|
-
|
|
62
|
+
const info = JSON.parse(await fs.readFile(lockPath, 'utf8'));
|
|
63
|
+
const age = Date.now() - (info.at ?? 0);
|
|
64
|
+
stale = age > staleMs || (typeof info.pid === 'number' && !pidAlive(info.pid));
|
|
52
65
|
}
|
|
53
66
|
catch {
|
|
54
|
-
|
|
67
|
+
// Unreadable lock: another process may be mid-write, or the lock was just released.
|
|
68
|
+
try {
|
|
69
|
+
stale = Date.now() - (await fs.stat(lockPath)).mtimeMs > 2000;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
disappeared = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (disappeared) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (stale) {
|
|
79
|
+
const staleTrash = `${lockPath}.stale.${randomBytes(4).toString('hex')}`;
|
|
80
|
+
try {
|
|
81
|
+
await fs.rename(lockPath, staleTrash);
|
|
82
|
+
await fs.rm(staleTrash, { force: true }).catch(() => undefined);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// Another waiter already broke or removed the lock; retry cleanly.
|
|
86
|
+
}
|
|
87
|
+
continue;
|
|
55
88
|
}
|
|
89
|
+
if (Date.now() - started > timeoutMs) {
|
|
90
|
+
throw new DevWorkspaceError('LOCKED', 'Another DevWorkspace process is modifying this workspace.', {
|
|
91
|
+
hint: `Wait for it to finish, or delete ${path.join('.devworkspace', 'local', opts.name ?? 'workspace.lock')} if no process is running.`,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
await new Promise((r) => setTimeout(r, 25 + Math.floor(Math.random() * 50)));
|
|
56
95
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
96
|
+
}
|
|
97
|
+
const dispose = onCleanup(() => {
|
|
98
|
+
try {
|
|
99
|
+
unlinkSync(lockPath);
|
|
60
100
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
hint: `Wait for it to finish, or delete ${path.join('.devworkspace', 'local', opts.name ?? 'workspace.lock')} if no process is running.`,
|
|
64
|
-
});
|
|
101
|
+
catch {
|
|
102
|
+
/* already gone */
|
|
65
103
|
}
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const dispose = onCleanup(() => {
|
|
104
|
+
});
|
|
70
105
|
try {
|
|
71
|
-
|
|
106
|
+
return await fn();
|
|
72
107
|
}
|
|
73
|
-
|
|
74
|
-
|
|
108
|
+
finally {
|
|
109
|
+
dispose();
|
|
110
|
+
try {
|
|
111
|
+
const raw = await fs.readFile(lockPath, 'utf8');
|
|
112
|
+
const info = JSON.parse(raw);
|
|
113
|
+
if (info.token === myToken) {
|
|
114
|
+
await fs.rm(lockPath, { force: true }).catch(() => undefined);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// Lock was already removed (e.g. via cleanup hook or external stale break).
|
|
119
|
+
}
|
|
75
120
|
}
|
|
76
|
-
});
|
|
77
|
-
try {
|
|
78
|
-
return await fn();
|
|
79
121
|
}
|
|
80
122
|
finally {
|
|
81
|
-
|
|
82
|
-
|
|
123
|
+
releaseLocal();
|
|
124
|
+
if (localLockQueues.get(queueKey) === chained) {
|
|
125
|
+
localLockQueues.delete(queueKey);
|
|
126
|
+
}
|
|
83
127
|
}
|
|
84
128
|
}
|
|
85
|
-
//# sourceMappingURL=lock.js.map
|
package/dist/utils/logger.js
CHANGED
package/dist/utils/paths.js
CHANGED
package/dist/utils/proc.d.ts
CHANGED
|
@@ -13,11 +13,23 @@ export interface RunOptions {
|
|
|
13
13
|
maxBytes?: number;
|
|
14
14
|
/** Extra environment variables merged over process.env (undefined values unset the variable). */
|
|
15
15
|
env?: Record<string, string | undefined>;
|
|
16
|
+
/** When true, use `env` as the full environment instead of merging over process.env. */
|
|
17
|
+
replaceEnv?: boolean;
|
|
16
18
|
/** Abort (kill) the process when the signal fires. */
|
|
17
19
|
signal?: AbortSignal;
|
|
18
20
|
/** Windows only: pass the argument string through unmodified (used for cmd.exe /c with pre-validated arguments). */
|
|
19
21
|
windowsVerbatimArguments?: boolean;
|
|
20
22
|
}
|
|
23
|
+
/** Build a minimal process environment containing OS/runtime basics without leaking secrets. */
|
|
24
|
+
export declare function createMinimalExecutionEnv(baseEnv?: NodeJS.ProcessEnv, extraAllowKeys?: string[], overrides?: Record<string, string | undefined>): NodeJS.ProcessEnv;
|
|
25
|
+
/**
|
|
26
|
+
* Spawn an executable with an argument array without blocking on child exit until `done` is awaited.
|
|
27
|
+
* Never uses a shell, so project- or user-supplied values cannot be interpreted as shell syntax.
|
|
28
|
+
*/
|
|
29
|
+
export declare function startRun(command: string, args: string[], opts?: RunOptions): {
|
|
30
|
+
spawned: boolean;
|
|
31
|
+
done: Promise<RunResult>;
|
|
32
|
+
};
|
|
21
33
|
/**
|
|
22
34
|
* Run an executable with an argument array. Never uses a shell, so project- or
|
|
23
35
|
* user-supplied values cannot be interpreted as shell syntax.
|
package/dist/utils/proc.js
CHANGED
|
@@ -1,62 +1,117 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
1
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
2
2
|
import { promises as fs } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
const MINIMAL_ENV_ALLOW = new RegExp('^(?:' + [
|
|
5
|
+
'PATH', 'PATHEXT', 'HOME', 'USER', 'USERNAME', 'LOGNAME', 'SHELL', 'TERM', 'LANG', 'LANGUAGE', 'LC_[A-Z_]+', 'TZ',
|
|
6
|
+
'TMPDIR', 'TMP', 'TEMP', 'XDG_[A-Z_]+',
|
|
7
|
+
'SYSTEMROOT', 'SYSTEMDRIVE', 'WINDIR', 'COMSPEC', 'OS', 'USERDOMAIN', 'USERPROFILE', 'HOMEDRIVE', 'HOMEPATH',
|
|
8
|
+
'APPDATA', 'LOCALAPPDATA', 'PROGRAMDATA', 'PROGRAMFILES', 'PROGRAMFILES\\(X86\\)', 'PROGRAMW6432',
|
|
9
|
+
'COMMONPROGRAMFILES', 'ALLUSERSPROFILE', 'PUBLIC', 'PROCESSOR_ARCHITECTURE', 'NUMBER_OF_PROCESSORS',
|
|
10
|
+
'NODE_EXTRA_CA_CERTS', 'SSL_CERT_FILE', 'SSL_CERT_DIR',
|
|
11
|
+
].join('|') + ')$', 'i');
|
|
12
|
+
/** Build a minimal process environment containing OS/runtime basics without leaking secrets. */
|
|
13
|
+
export function createMinimalExecutionEnv(baseEnv = process.env, extraAllowKeys = [], overrides = {}) {
|
|
14
|
+
const allowExtra = new Set(extraAllowKeys.map((k) => k.trim().toLowerCase()).filter(Boolean));
|
|
15
|
+
const merged = {};
|
|
16
|
+
for (const [k, v] of Object.entries(baseEnv)) {
|
|
17
|
+
if (v !== undefined && (MINIMAL_ENV_ALLOW.test(k) || allowExtra.has(k.toLowerCase()))) {
|
|
18
|
+
merged[k] = v;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
for (const [k, v] of Object.entries(overrides)) {
|
|
22
|
+
if (v === undefined)
|
|
23
|
+
delete merged[k];
|
|
24
|
+
else
|
|
25
|
+
merged[k] = v;
|
|
26
|
+
}
|
|
27
|
+
return merged;
|
|
28
|
+
}
|
|
29
|
+
function killProcessTree(child) {
|
|
30
|
+
if (!child?.pid) {
|
|
31
|
+
child?.kill();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (process.platform === 'win32') {
|
|
35
|
+
try {
|
|
36
|
+
spawnSync('taskkill', ['/pid', String(child.pid), '/T', '/F'], { windowsHide: true });
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
child.kill();
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
process.kill(-child.pid, 'SIGKILL');
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
try {
|
|
48
|
+
child.kill('SIGKILL');
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
child.kill();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
4
55
|
/**
|
|
5
|
-
*
|
|
6
|
-
* user-supplied values cannot be interpreted as shell syntax.
|
|
56
|
+
* Spawn an executable with an argument array without blocking on child exit until `done` is awaited.
|
|
57
|
+
* Never uses a shell, so project- or user-supplied values cannot be interpreted as shell syntax.
|
|
7
58
|
*/
|
|
8
|
-
export function
|
|
59
|
+
export function startRun(command, args, opts = {}) {
|
|
9
60
|
const timeoutMs = opts.timeoutMs ?? 15_000;
|
|
10
61
|
const maxBytes = opts.maxBytes ?? 4 * 1024 * 1024;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
62
|
+
let stdout = '';
|
|
63
|
+
let stderr = '';
|
|
64
|
+
let timedOut = false;
|
|
65
|
+
let aborted = false;
|
|
66
|
+
let settled = false;
|
|
67
|
+
if (opts.signal?.aborted) {
|
|
68
|
+
return {
|
|
69
|
+
spawned: false,
|
|
70
|
+
done: Promise.resolve({ ok: false, code: null, stdout, stderr, timedOut: false, aborted: true, error: 'aborted' }),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
let child;
|
|
74
|
+
try {
|
|
75
|
+
const env = opts.replaceEnv
|
|
76
|
+
? { ...(opts.env ?? {}) }
|
|
77
|
+
: opts.env ? { ...process.env, ...opts.env } : process.env;
|
|
78
|
+
for (const [k, v] of Object.entries(env))
|
|
79
|
+
if (v === undefined)
|
|
80
|
+
delete env[k];
|
|
81
|
+
child = spawn(command, args, {
|
|
82
|
+
cwd: opts.cwd,
|
|
83
|
+
env,
|
|
84
|
+
shell: false,
|
|
85
|
+
windowsHide: true,
|
|
86
|
+
windowsVerbatimArguments: opts.windowsVerbatimArguments,
|
|
87
|
+
detached: process.platform !== 'win32',
|
|
88
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
return {
|
|
93
|
+
spawned: false,
|
|
94
|
+
done: Promise.resolve({ ok: false, code: null, stdout, stderr, timedOut: false, error: e.message }),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const c = child;
|
|
98
|
+
const done = new Promise((resolve) => {
|
|
19
99
|
const onAbort = () => {
|
|
20
100
|
aborted = true;
|
|
21
|
-
|
|
101
|
+
killProcessTree(c);
|
|
22
102
|
};
|
|
103
|
+
const timer = setTimeout(() => {
|
|
104
|
+
timedOut = true;
|
|
105
|
+
killProcessTree(c);
|
|
106
|
+
}, timeoutMs);
|
|
23
107
|
const finish = (r) => {
|
|
24
108
|
if (settled)
|
|
25
109
|
return;
|
|
26
110
|
settled = true;
|
|
27
|
-
|
|
28
|
-
clearTimeout(timer);
|
|
111
|
+
clearTimeout(timer);
|
|
29
112
|
opts.signal?.removeEventListener('abort', onAbort);
|
|
30
113
|
resolve(aborted ? { ...r, ok: false, aborted: true } : r);
|
|
31
114
|
};
|
|
32
|
-
let child;
|
|
33
|
-
if (opts.signal?.aborted) {
|
|
34
|
-
finish({ ok: false, code: null, stdout, stderr, timedOut: false, aborted: true, error: 'aborted' });
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
try {
|
|
38
|
-
const env = opts.env ? { ...process.env, ...opts.env } : process.env;
|
|
39
|
-
for (const [k, v] of Object.entries(env))
|
|
40
|
-
if (v === undefined)
|
|
41
|
-
delete env[k];
|
|
42
|
-
child = spawn(command, args, {
|
|
43
|
-
cwd: opts.cwd,
|
|
44
|
-
env,
|
|
45
|
-
shell: false,
|
|
46
|
-
windowsHide: true,
|
|
47
|
-
windowsVerbatimArguments: opts.windowsVerbatimArguments,
|
|
48
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
catch (e) {
|
|
52
|
-
finish({ ok: false, code: null, stdout, stderr, timedOut: false, error: e.message });
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const c = child;
|
|
56
|
-
timer = setTimeout(() => {
|
|
57
|
-
timedOut = true;
|
|
58
|
-
c.kill();
|
|
59
|
-
}, timeoutMs);
|
|
60
115
|
opts.signal?.addEventListener('abort', onAbort, { once: true });
|
|
61
116
|
c.stdout?.on('data', (d) => {
|
|
62
117
|
if (stdout.length < maxBytes)
|
|
@@ -69,6 +124,14 @@ export function run(command, args, opts = {}) {
|
|
|
69
124
|
c.on('error', (e) => finish({ ok: false, code: null, stdout, stderr, timedOut, error: e.message }));
|
|
70
125
|
c.on('close', (code) => finish({ ok: code === 0 && !timedOut && !aborted, code, stdout, stderr, timedOut }));
|
|
71
126
|
});
|
|
127
|
+
return { spawned: true, done };
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Run an executable with an argument array. Never uses a shell, so project- or
|
|
131
|
+
* user-supplied values cannot be interpreted as shell syntax.
|
|
132
|
+
*/
|
|
133
|
+
export function run(command, args, opts = {}) {
|
|
134
|
+
return startRun(command, args, opts).done;
|
|
72
135
|
}
|
|
73
136
|
/** Locate an executable on PATH (honouring PATHEXT on Windows) without executing anything. */
|
|
74
137
|
export async function which(name, env = process.env) {
|
|
@@ -112,4 +175,3 @@ export async function which(name, env = process.env) {
|
|
|
112
175
|
export function isShellShim(file) {
|
|
113
176
|
return /\.(cmd|bat)$/i.test(file);
|
|
114
177
|
}
|
|
115
|
-
//# sourceMappingURL=proc.js.map
|
package/docs/agents.md
CHANGED
|
@@ -96,6 +96,21 @@ devworkspace setup --agent claude-code --launcher direct
|
|
|
96
96
|
devworkspace setup --agent claude-code --launcher auto
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
+
## Execution vs. Verification Lifecycle
|
|
100
|
+
|
|
101
|
+
DevWorkspace's orchestration subsystem (`src/intelligence/`) enforces a strict separation between planning, preparation, execution, verification, and verified completion:
|
|
102
|
+
|
|
103
|
+
| Stage / State | Meaning | `ok` / `verified` |
|
|
104
|
+
| --- | --- | --- |
|
|
105
|
+
| **Generated Plan** (`orchestrate plan`) | Routing analysis selecting specialist roles, skills, file claims, and destructive approvals. | `state: READY` or `AWAITING_APPROVAL` |
|
|
106
|
+
| **Prepared Instructions** (`ExternalAgentAdapter` default) | CLI prompt/instructions assembled without invoking an external agent process. | `status: PREPARED`, `ok: false`, `verified: false` |
|
|
107
|
+
| **Unconfigured No-Op** (`NativeRuntimeAdapter` / `GoogleAdkAdapter`) | No executable command or local runner configured; generating a summary is never execution. | `status: NOT_EXECUTED` or `UNSUPPORTED`, `ok: false` |
|
|
108
|
+
| **Actual Execution** (`command` or `agent`) | Real child process ran (`shell: false`, minimal env, timeout & tree cleanup) and exited `0`. | `status: SUCCEEDED`, `ok: true`, `verificationStatus: NOT_TESTED` |
|
|
109
|
+
| **Independent Verification** (`IndependentVerificationEngine`) | Contract checks run + `IndependentReviewer` inspects bounded file contents against bound `executionId` and `workspaceFingerprint`. | `verificationStatus: PASS` (or `FAIL`/`ERROR`/`TIMED_OUT`/`SKIPPED`) |
|
|
110
|
+
| **Verified Completion** (`OrchestrationEngine`) | Stage becomes `COMPLETED` **only** when execution succeeded **and** verification returned `PASS` matching current workspace state. Workspace edits invalidate stale receipts via `invalidateStaleReceipts()`. | `stage.status: COMPLETED`, `receipt.verified: true` |
|
|
111
|
+
|
|
112
|
+
> **Isolation boundary:** DevWorkspace runtime adapters report `sandboxed: false` (`sandboxCapability: "unavailable-cwd-only"`). Setting `cwd` or `sandboxPath` sets the child working directory only and is **not** an OS-level container, chroot, or network sandbox.
|
|
113
|
+
|
|
99
114
|
## Adding a New Agent Adapter
|
|
100
115
|
|
|
101
116
|
To add support for a new coding agent:
|