🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(claims): resolve user-level claims.json via os.homedir() on Windows
Marius Carlsson72c6228e1ced
diff --git a/v3/@claude-flow/cli/__tests__/claims-user-config-home-win32.test.ts b/v3/@claude-flow/cli/__tests__/claims-user-config-home-win32.test.tsnew file mode 100644index 0000000000..25ab5d5fcc--- /dev/null+++ b/v3/@claude-flow/cli/__tests__/claims-user-config-home-win32.test.ts@@ -0,0 +1,59 @@+/**+ * `claims check` must find the user-level policy at+ * <home>/.config/claude-flow/claims.json on every platform.+ *+ * The lookup used `resolve(process.env.HOME || '~', ...)`. On Windows HOME is+ * normally unset, so the path became `<cwd>/~/.config/claude-flow/claims.json`+ * — a literal "~" directory under whatever folder the command ran from — and+ * the user's real policy in %USERPROFILE% was silently ignored.+ */+import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { claimsCommand } from '../src/commands/claims.js';++const SAVED_ENV = { ...process.env };+const SAVED_CWD = process.cwd();++describe('claims user-level config lookup', () => {+ let home: string;+ let project: string;++ beforeEach(() => {+ home = mkdtempSync(join(tmpdir(), 'claims-home-'));+ project = mkdtempSync(join(tmpdir(), 'claims-project-'));+ mkdirSync(join(home, '.config', 'claude-flow'), { recursive: true });+ writeFileSync(+ join(home, '.config', 'claude-flow', 'claims.json'),+ JSON.stringify({ users: { alice: { claims: ['admin:delete'] } } }),+ );+ // Point the OS home directory at the fixture. On Windows os.homedir()+ // reads USERPROFILE and HOME is normally absent; elsewhere it reads HOME.+ if (process.platform === 'win32') {+ delete process.env.HOME;+ process.env.USERPROFILE = home;+ } else {+ process.env.HOME = home;+ }+ process.chdir(project);+ });++ afterEach(() => {+ process.chdir(SAVED_CWD);+ process.env = { ...SAVED_ENV };+ rmSync(home, { recursive: true, force: true });+ rmSync(project, { recursive: true, force: true });+ });++ it('grants a claim defined only in the home-directory policy', async () => {+ const check = claimsCommand.subcommands!.find((c) => c.name === 'check')!;+ const result = await check.action!({+ args: [],+ flags: { claim: 'admin:delete', user: 'alice' },+ cwd: project,+ interactive: false,+ } as never);+ expect(result).toMatchObject({ success: true });+ });+});diff --git a/v3/@claude-flow/cli/src/commands/claims.ts b/v3/@claude-flow/cli/src/commands/claims.tsindex 7d2289ebfa..c21b8c9c72 100644--- a/v3/@claude-flow/cli/src/commands/claims.ts+++ b/v3/@claude-flow/cli/src/commands/claims.ts@@ -6,7 +6,8 @@*/import { existsSync, readFileSync, writeFileSync, mkdirSync, renameSync } from 'node:fs';-import { resolve, dirname } from 'node:path';+import { resolve, dirname, join } from 'node:path';+import { homedir } from 'node:os';import type { Command, CommandContext, CommandResult } from '../types.js';import { output } from '../output.js';@@ -25,7 +26,9 @@ function getClaimsConfigPaths(): string[] {return [resolve(CLAIMS_CONFIG_PATHS[0]),resolve(CLAIMS_CONFIG_PATHS[1]),- resolve(process.env.HOME || '~', '.config/claude-flow/claims.json'),+ // os.homedir(), not $HOME: HOME is normally unset on Windows, and the old+ // `process.env.HOME || '~'` fallback resolved to a literal <cwd>/~ folder.+ join(homedir(), '.config', 'claude-flow', 'claims.json'),];}@@ -178,7 +181,6 @@ const checkCommand: Command = {spinner.start();const fs = await import('fs');- const path = await import('path');// Real claims evaluation from config filelet isGranted = false;@@ -187,11 +189,7 @@ const checkCommand: Command = {try {// Check for claims config file- const claimsConfigPaths = [- path.resolve('.claude-flow/claims.json'),- path.resolve('claude-flow.claims.json'),- path.resolve(process.env.HOME || '~', '.config/claude-flow/claims.json'),- ];+ const claimsConfigPaths = getClaimsConfigPaths();let claimsConfig: {roles?: Record<string, string[]>;