@lumenflow/cli 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/guard-main-branch.test.js +79 -0
- package/dist/agent-issues-query.d.ts +16 -0
- package/dist/agent-log-issue.d.ts +10 -0
- package/dist/agent-session-end.d.ts +10 -0
- package/dist/agent-session.d.ts +10 -0
- package/dist/backlog-prune.d.ts +84 -0
- package/dist/cli-entry-point.d.ts +8 -0
- package/dist/deps-add.d.ts +91 -0
- package/dist/deps-remove.d.ts +17 -0
- package/dist/docs-sync.d.ts +50 -0
- package/dist/file-delete.d.ts +84 -0
- package/dist/file-edit.d.ts +82 -0
- package/dist/file-read.d.ts +92 -0
- package/dist/file-write.d.ts +90 -0
- package/dist/flow-bottlenecks.d.ts +16 -0
- package/dist/flow-report.d.ts +16 -0
- package/dist/gates.d.ts +94 -0
- package/dist/git-branch.d.ts +65 -0
- package/dist/git-diff.d.ts +58 -0
- package/dist/git-log.d.ts +69 -0
- package/dist/git-status.d.ts +58 -0
- package/dist/guard-locked.d.ts +62 -0
- package/dist/guard-main-branch.d.ts +50 -0
- package/dist/guard-main-branch.js +11 -0
- package/dist/guard-worktree-commit.d.ts +59 -0
- package/dist/index.d.ts +10 -0
- package/dist/init-plan.d.ts +80 -0
- package/dist/init.d.ts +46 -0
- package/dist/initiative-add-wu.d.ts +22 -0
- package/dist/initiative-bulk-assign-wus.d.ts +16 -0
- package/dist/initiative-create.d.ts +28 -0
- package/dist/initiative-edit.d.ts +34 -0
- package/dist/initiative-list.d.ts +12 -0
- package/dist/initiative-status.d.ts +11 -0
- package/dist/lumenflow-upgrade.d.ts +103 -0
- package/dist/mem-checkpoint.d.ts +16 -0
- package/dist/mem-cleanup.d.ts +29 -0
- package/dist/mem-create.d.ts +17 -0
- package/dist/mem-export.d.ts +10 -0
- package/dist/mem-export.js +138 -0
- package/dist/mem-inbox.d.ts +35 -0
- package/dist/mem-init.d.ts +15 -0
- package/dist/mem-ready.d.ts +16 -0
- package/dist/mem-signal.d.ts +16 -0
- package/dist/mem-start.d.ts +16 -0
- package/dist/mem-summarize.d.ts +22 -0
- package/dist/mem-triage.d.ts +22 -0
- package/dist/metrics-cli.d.ts +90 -0
- package/dist/metrics-snapshot.d.ts +18 -0
- package/dist/orchestrate-init-status.d.ts +11 -0
- package/dist/orchestrate-initiative.d.ts +12 -0
- package/dist/orchestrate-monitor.d.ts +11 -0
- package/dist/release.d.ts +117 -0
- package/dist/rotate-progress.d.ts +48 -0
- package/dist/session-coordinator.d.ts +74 -0
- package/dist/spawn-list.d.ts +16 -0
- package/dist/state-bootstrap.d.ts +92 -0
- package/dist/sync-templates.d.ts +52 -0
- package/dist/trace-gen.d.ts +84 -0
- package/dist/validate-agent-skills.d.ts +50 -0
- package/dist/validate-agent-sync.d.ts +36 -0
- package/dist/validate-backlog-sync.d.ts +37 -0
- package/dist/validate-skills-spec.d.ts +40 -0
- package/dist/validate.d.ts +60 -0
- package/dist/wu-block.d.ts +16 -0
- package/dist/wu-claim.d.ts +74 -0
- package/dist/wu-cleanup.d.ts +35 -0
- package/dist/wu-cleanup.js +11 -2
- package/dist/wu-create.d.ts +69 -0
- package/dist/wu-delete.d.ts +21 -0
- package/dist/wu-deps.d.ts +13 -0
- package/dist/wu-done.d.ts +225 -0
- package/dist/wu-done.js +9 -3
- package/dist/wu-edit.d.ts +63 -0
- package/dist/wu-edit.js +76 -9
- package/dist/wu-infer-lane.d.ts +17 -0
- package/dist/wu-preflight.d.ts +47 -0
- package/dist/wu-prune.d.ts +16 -0
- package/dist/wu-recover.d.ts +37 -0
- package/dist/wu-release.d.ts +19 -0
- package/dist/wu-repair.d.ts +60 -0
- package/dist/wu-spawn-completion.d.ts +10 -0
- package/dist/wu-spawn.d.ts +192 -0
- package/dist/wu-spawn.js +176 -12
- package/dist/wu-status.d.ts +25 -0
- package/dist/wu-unblock.d.ts +16 -0
- package/dist/wu-unlock-lane.d.ts +19 -0
- package/dist/wu-validate.d.ts +16 -0
- package/package.json +7 -6
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file guard-main-branch.test.ts
|
|
3
|
+
* @description Tests for guard-main-branch worktree context detection (WU-1130)
|
|
4
|
+
*/
|
|
5
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
6
|
+
import { guardMainBranch } from '../guard-main-branch.js';
|
|
7
|
+
// Mock the core module
|
|
8
|
+
vi.mock('@lumenflow/core', () => ({
|
|
9
|
+
createGitForPath: vi.fn(),
|
|
10
|
+
getGitForCwd: vi.fn(),
|
|
11
|
+
isAgentBranch: vi.fn().mockResolvedValue(false),
|
|
12
|
+
getConfig: vi.fn().mockReturnValue({
|
|
13
|
+
git: {
|
|
14
|
+
mainBranch: 'main',
|
|
15
|
+
laneBranchPrefix: 'lane/',
|
|
16
|
+
},
|
|
17
|
+
}),
|
|
18
|
+
}));
|
|
19
|
+
// Mock the worktree-guard module
|
|
20
|
+
vi.mock('@lumenflow/core/dist/core/worktree-guard.js', () => ({
|
|
21
|
+
isInWorktree: vi.fn(),
|
|
22
|
+
}));
|
|
23
|
+
import { getGitForCwd, createGitForPath } from '@lumenflow/core';
|
|
24
|
+
import { isInWorktree } from '@lumenflow/core/dist/core/worktree-guard.js';
|
|
25
|
+
describe('guard-main-branch (WU-1130)', () => {
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
vi.clearAllMocks();
|
|
28
|
+
});
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
vi.restoreAllMocks();
|
|
31
|
+
});
|
|
32
|
+
describe('lane branch worktree detection', () => {
|
|
33
|
+
it('should allow operations when on lane branch AND in worktree', async () => {
|
|
34
|
+
// Setup: On lane branch, in worktree
|
|
35
|
+
const mockGit = {
|
|
36
|
+
getCurrentBranch: vi.fn().mockResolvedValue('lane/framework-cli/wu-1130'),
|
|
37
|
+
};
|
|
38
|
+
vi.mocked(getGitForCwd).mockReturnValue(mockGit);
|
|
39
|
+
vi.mocked(isInWorktree).mockReturnValue(true);
|
|
40
|
+
const result = await guardMainBranch({});
|
|
41
|
+
expect(result.success).toBe(true);
|
|
42
|
+
expect(result.isProtected).toBe(false);
|
|
43
|
+
expect(result.currentBranch).toBe('lane/framework-cli/wu-1130');
|
|
44
|
+
});
|
|
45
|
+
it('should block operations when on lane branch but NOT in worktree', async () => {
|
|
46
|
+
// Setup: On lane branch, but not in worktree (e.g., checked out directly)
|
|
47
|
+
const mockGit = {
|
|
48
|
+
getCurrentBranch: vi.fn().mockResolvedValue('lane/framework-cli/wu-1130'),
|
|
49
|
+
};
|
|
50
|
+
vi.mocked(getGitForCwd).mockReturnValue(mockGit);
|
|
51
|
+
vi.mocked(isInWorktree).mockReturnValue(false);
|
|
52
|
+
const result = await guardMainBranch({});
|
|
53
|
+
expect(result.success).toBe(true);
|
|
54
|
+
expect(result.isProtected).toBe(true);
|
|
55
|
+
expect(result.reason).toContain('requires worktree');
|
|
56
|
+
});
|
|
57
|
+
it('should use baseDir for worktree detection when provided', async () => {
|
|
58
|
+
const mockGit = {
|
|
59
|
+
getCurrentBranch: vi.fn().mockResolvedValue('lane/ops-tooling/wu-2725'),
|
|
60
|
+
};
|
|
61
|
+
vi.mocked(createGitForPath).mockReturnValue(mockGit);
|
|
62
|
+
vi.mocked(isInWorktree).mockReturnValue(true);
|
|
63
|
+
const result = await guardMainBranch({ baseDir: '/path/to/worktrees/ops-tooling-wu-2725' });
|
|
64
|
+
expect(isInWorktree).toHaveBeenCalledWith({ cwd: '/path/to/worktrees/ops-tooling-wu-2725' });
|
|
65
|
+
expect(result.isProtected).toBe(false);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe('main branch protection', () => {
|
|
69
|
+
it('should block operations on main branch', async () => {
|
|
70
|
+
const mockGit = {
|
|
71
|
+
getCurrentBranch: vi.fn().mockResolvedValue('main'),
|
|
72
|
+
};
|
|
73
|
+
vi.mocked(getGitForCwd).mockReturnValue(mockGit);
|
|
74
|
+
const result = await guardMainBranch({});
|
|
75
|
+
expect(result.isProtected).toBe(true);
|
|
76
|
+
expect(result.reason).toContain("'main' is protected");
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Agent Issues Query CLI (WU-1018)
|
|
4
|
+
*
|
|
5
|
+
* Query and display logged agent incidents/issues.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* pnpm agent:issues-query summary # Summary of last 7 days
|
|
9
|
+
* pnpm agent:issues-query summary --since 30 # Summary of last 30 days
|
|
10
|
+
* pnpm agent:issues-query summary --category tooling
|
|
11
|
+
* pnpm agent:issues-query summary --severity blocker
|
|
12
|
+
*
|
|
13
|
+
* @module agent-issues-query
|
|
14
|
+
* @see {@link @lumenflow/agent}
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Backlog Prune Command
|
|
4
|
+
*
|
|
5
|
+
* Maintains backlog hygiene by:
|
|
6
|
+
* - Auto-tagging stale WUs (in_progress/ready too long without activity)
|
|
7
|
+
* - Archiving old completed WUs (done for > N days)
|
|
8
|
+
*
|
|
9
|
+
* WU-1106: INIT-003 Phase 3b - Migrate from PatientPath tools/backlog-prune.mjs
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* pnpm backlog:prune # Dry-run mode (shows what would be done)
|
|
13
|
+
* pnpm backlog:prune --execute # Apply changes
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Default configuration for backlog pruning
|
|
17
|
+
*/
|
|
18
|
+
export declare const BACKLOG_PRUNE_DEFAULTS: {
|
|
19
|
+
/** Days without activity before in_progress WU is considered stale */
|
|
20
|
+
staleDaysInProgress: number;
|
|
21
|
+
/** Days without activity before ready WU is considered stale */
|
|
22
|
+
staleDaysReady: number;
|
|
23
|
+
/** Days after completion before done WU can be archived */
|
|
24
|
+
archiveDaysDone: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Arguments for backlog-prune command
|
|
28
|
+
*/
|
|
29
|
+
export interface BacklogPruneArgs {
|
|
30
|
+
dryRun: boolean;
|
|
31
|
+
staleDaysInProgress: number;
|
|
32
|
+
staleDaysReady: number;
|
|
33
|
+
archiveDaysDone: number;
|
|
34
|
+
help?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Minimal WU information needed for prune analysis
|
|
38
|
+
*/
|
|
39
|
+
export interface WuPruneInfo {
|
|
40
|
+
id: string;
|
|
41
|
+
status: string;
|
|
42
|
+
title?: string;
|
|
43
|
+
created?: string;
|
|
44
|
+
updated?: string;
|
|
45
|
+
completed?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Result of WU categorization
|
|
49
|
+
*/
|
|
50
|
+
export interface PruneCategorization {
|
|
51
|
+
stale: WuPruneInfo[];
|
|
52
|
+
archivable: WuPruneInfo[];
|
|
53
|
+
healthy: WuPruneInfo[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Parse command line arguments for backlog-prune
|
|
57
|
+
*/
|
|
58
|
+
export declare function parseBacklogPruneArgs(argv: string[]): BacklogPruneArgs;
|
|
59
|
+
/**
|
|
60
|
+
* Calculate days since a date string
|
|
61
|
+
* @returns Number of days since date, or null if invalid
|
|
62
|
+
*/
|
|
63
|
+
export declare function calculateStaleDays(dateStr: string | undefined | null): number | null;
|
|
64
|
+
/**
|
|
65
|
+
* Check if a WU is stale based on its status and last activity date
|
|
66
|
+
*/
|
|
67
|
+
export declare function isWuStale(wu: WuPruneInfo, options: {
|
|
68
|
+
staleDaysInProgress?: number;
|
|
69
|
+
staleDaysReady?: number;
|
|
70
|
+
}): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Check if a WU is archivable (done for more than N days)
|
|
73
|
+
*/
|
|
74
|
+
export declare function isWuArchivable(wu: WuPruneInfo, options: {
|
|
75
|
+
archiveDaysDone?: number;
|
|
76
|
+
}): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Categorize WUs into stale, archivable, and healthy
|
|
79
|
+
*/
|
|
80
|
+
export declare function categorizeWus(wus: WuPruneInfo[], options: {
|
|
81
|
+
staleDaysInProgress: number;
|
|
82
|
+
staleDaysReady: number;
|
|
83
|
+
archiveDaysDone: number;
|
|
84
|
+
}): PruneCategorization;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps an async main function with proper error handling.
|
|
3
|
+
* WU-1085: Also initializes color support based on NO_COLOR/FORCE_COLOR/--no-color
|
|
4
|
+
*
|
|
5
|
+
* @param main - The async main function to execute
|
|
6
|
+
* @returns Promise that resolves when main completes (or after error handling)
|
|
7
|
+
*/
|
|
8
|
+
export declare function runCLI(main: () => Promise<void>): Promise<void>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Deps Add CLI Command
|
|
4
|
+
*
|
|
5
|
+
* Safe wrapper for `pnpm add` that enforces worktree discipline.
|
|
6
|
+
* Dependencies can only be added from within a worktree, not from main checkout.
|
|
7
|
+
*
|
|
8
|
+
* WU-1112: INIT-003 Phase 6 - Migrate remaining Tier 1 tools
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* pnpm deps:add react
|
|
12
|
+
* pnpm deps:add --dev vitest
|
|
13
|
+
* pnpm deps:add --filter @lumenflow/cli chalk
|
|
14
|
+
*
|
|
15
|
+
* @see dependency-guard.ts for blocking logic
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Arguments for deps-add command
|
|
19
|
+
*/
|
|
20
|
+
export interface DepsAddArgs {
|
|
21
|
+
/** Package names to add */
|
|
22
|
+
packages?: string[];
|
|
23
|
+
/** Add as dev dependency */
|
|
24
|
+
dev?: boolean;
|
|
25
|
+
/** Filter to specific workspace package */
|
|
26
|
+
filter?: string;
|
|
27
|
+
/** Use exact version */
|
|
28
|
+
exact?: boolean;
|
|
29
|
+
/** Show help */
|
|
30
|
+
help?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Arguments for deps-remove command (also exported from here for convenience)
|
|
34
|
+
*/
|
|
35
|
+
export interface DepsRemoveArgs {
|
|
36
|
+
/** Package names to remove */
|
|
37
|
+
packages?: string[];
|
|
38
|
+
/** Filter to specific workspace package */
|
|
39
|
+
filter?: string;
|
|
40
|
+
/** Show help */
|
|
41
|
+
help?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Result of worktree context validation
|
|
45
|
+
*/
|
|
46
|
+
export interface WorktreeValidationResult {
|
|
47
|
+
/** Whether the context is valid (inside worktree) */
|
|
48
|
+
valid: boolean;
|
|
49
|
+
/** Error message if invalid */
|
|
50
|
+
error?: string;
|
|
51
|
+
/** Fix command suggestion */
|
|
52
|
+
fixCommand?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Parse command line arguments for deps-add
|
|
56
|
+
*
|
|
57
|
+
* @param argv - Process argv array
|
|
58
|
+
* @returns Parsed arguments
|
|
59
|
+
*/
|
|
60
|
+
export declare function parseDepsAddArgs(argv: string[]): DepsAddArgs;
|
|
61
|
+
/**
|
|
62
|
+
* Parse command line arguments for deps-remove
|
|
63
|
+
*
|
|
64
|
+
* @param argv - Process argv array
|
|
65
|
+
* @returns Parsed arguments
|
|
66
|
+
*/
|
|
67
|
+
export declare function parseDepsRemoveArgs(argv: string[]): DepsRemoveArgs;
|
|
68
|
+
/**
|
|
69
|
+
* Validate that the current directory is within a worktree
|
|
70
|
+
*
|
|
71
|
+
* Dependencies should only be modified in worktrees to maintain
|
|
72
|
+
* isolation and prevent lockfile conflicts on main checkout.
|
|
73
|
+
*
|
|
74
|
+
* @param cwd - Current working directory to validate
|
|
75
|
+
* @returns Validation result with error and fix command if invalid
|
|
76
|
+
*/
|
|
77
|
+
export declare function validateWorktreeContext(cwd: string): WorktreeValidationResult;
|
|
78
|
+
/**
|
|
79
|
+
* Build pnpm add command string from arguments
|
|
80
|
+
*
|
|
81
|
+
* @param args - Parsed deps-add arguments
|
|
82
|
+
* @returns Command string ready for execution
|
|
83
|
+
*/
|
|
84
|
+
export declare function buildPnpmAddCommand(args: DepsAddArgs): string;
|
|
85
|
+
/**
|
|
86
|
+
* Build pnpm remove command string from arguments
|
|
87
|
+
*
|
|
88
|
+
* @param args - Parsed deps-remove arguments
|
|
89
|
+
* @returns Command string ready for execution
|
|
90
|
+
*/
|
|
91
|
+
export declare function buildPnpmRemoveCommand(args: DepsRemoveArgs): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Deps Remove CLI Command
|
|
4
|
+
*
|
|
5
|
+
* Safe wrapper for `pnpm remove` that enforces worktree discipline.
|
|
6
|
+
* Dependencies can only be removed from within a worktree, not from main checkout.
|
|
7
|
+
*
|
|
8
|
+
* WU-1112: INIT-003 Phase 6 - Migrate remaining Tier 1 tools
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* pnpm deps:remove lodash
|
|
12
|
+
* pnpm deps:remove --filter @lumenflow/cli chalk
|
|
13
|
+
*
|
|
14
|
+
* @see dependency-guard.ts for blocking logic
|
|
15
|
+
*/
|
|
16
|
+
import { type DepsRemoveArgs } from './deps-add.js';
|
|
17
|
+
export type { DepsRemoveArgs };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file docs-sync.ts
|
|
3
|
+
* LumenFlow docs:sync command for syncing agent docs to existing projects (WU-1083)
|
|
4
|
+
* WU-1085: Added createWUParser for proper --help support
|
|
5
|
+
* WU-1124: Refactored to read templates from bundled files (INIT-004 Phase 2)
|
|
6
|
+
*/
|
|
7
|
+
export type VendorType = 'claude' | 'cursor' | 'aider' | 'all' | 'none';
|
|
8
|
+
/**
|
|
9
|
+
* WU-1085: Parse docs-sync command options using createWUParser
|
|
10
|
+
* Provides proper --help, --version, and option parsing
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseDocsSyncOptions(): {
|
|
13
|
+
force: boolean;
|
|
14
|
+
vendor: VendorType;
|
|
15
|
+
};
|
|
16
|
+
export interface SyncOptions {
|
|
17
|
+
force: boolean;
|
|
18
|
+
vendor?: VendorType;
|
|
19
|
+
}
|
|
20
|
+
export interface SyncResult {
|
|
21
|
+
created: string[];
|
|
22
|
+
skipped: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* WU-1124: Get the templates directory path
|
|
26
|
+
* Templates are bundled with the CLI package at dist/templates/
|
|
27
|
+
* Falls back to src/templates/ for development
|
|
28
|
+
*/
|
|
29
|
+
export declare function getTemplatesDir(): string;
|
|
30
|
+
/**
|
|
31
|
+
* WU-1124: Load a template file from the bundled templates directory
|
|
32
|
+
* @param templatePath - Relative path from templates directory (e.g., 'core/ai/onboarding/quick-ref-commands.md.template')
|
|
33
|
+
* @returns Template content as string
|
|
34
|
+
*/
|
|
35
|
+
export declare function loadTemplate(templatePath: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Sync agent onboarding docs to an existing project
|
|
38
|
+
* WU-1124: Now reads templates from bundled files instead of hardcoded strings
|
|
39
|
+
*/
|
|
40
|
+
export declare function syncAgentDocs(targetDir: string, options: SyncOptions): Promise<SyncResult>;
|
|
41
|
+
/**
|
|
42
|
+
* Sync Claude skills to an existing project
|
|
43
|
+
* WU-1124: Now reads templates from bundled files instead of hardcoded strings
|
|
44
|
+
*/
|
|
45
|
+
export declare function syncSkills(targetDir: string, options: SyncOptions): Promise<SyncResult>;
|
|
46
|
+
/**
|
|
47
|
+
* CLI entry point for docs:sync command
|
|
48
|
+
* WU-1085: Updated to use parseDocsSyncOptions for proper --help support
|
|
49
|
+
*/
|
|
50
|
+
export declare function main(): Promise<void>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* File Delete CLI Tool
|
|
4
|
+
*
|
|
5
|
+
* Provides audited file delete operations with:
|
|
6
|
+
* - Scope checking against WU code_paths
|
|
7
|
+
* - Recursive directory deletion
|
|
8
|
+
* - Force option for missing files
|
|
9
|
+
* - Audit logging
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* node file-delete.js <path> [--recursive] [--force]
|
|
13
|
+
*
|
|
14
|
+
* WU-1108: INIT-003 Phase 4a - Migrate file operations
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Default configuration for file delete operations
|
|
18
|
+
*/
|
|
19
|
+
export declare const FILE_DELETE_DEFAULTS: {
|
|
20
|
+
/** Delete directories recursively */
|
|
21
|
+
recursive: boolean;
|
|
22
|
+
/** Don't error on missing files */
|
|
23
|
+
force: boolean;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Arguments for file delete operation
|
|
27
|
+
*/
|
|
28
|
+
export interface FileDeleteArgs {
|
|
29
|
+
/** Path to file or directory to delete */
|
|
30
|
+
path?: string;
|
|
31
|
+
/** Delete directories recursively */
|
|
32
|
+
recursive?: boolean;
|
|
33
|
+
/** Don't error on missing files */
|
|
34
|
+
force?: boolean;
|
|
35
|
+
/** Show help */
|
|
36
|
+
help?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Metadata returned with file delete
|
|
40
|
+
*/
|
|
41
|
+
export interface FileDeleteMetadata {
|
|
42
|
+
/** Number of items deleted (files + directories) */
|
|
43
|
+
deletedCount: number;
|
|
44
|
+
/** Whether target was a directory */
|
|
45
|
+
wasDirectory: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Audit log entry for file operations
|
|
49
|
+
*/
|
|
50
|
+
export interface AuditLogEntry {
|
|
51
|
+
/** Operation type */
|
|
52
|
+
operation: 'read' | 'write' | 'edit' | 'delete';
|
|
53
|
+
/** File path */
|
|
54
|
+
path: string;
|
|
55
|
+
/** Timestamp */
|
|
56
|
+
timestamp: string;
|
|
57
|
+
/** Duration in ms */
|
|
58
|
+
durationMs?: number;
|
|
59
|
+
/** Success status */
|
|
60
|
+
success: boolean;
|
|
61
|
+
/** Error message if failed */
|
|
62
|
+
error?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Result of file delete operation
|
|
66
|
+
*/
|
|
67
|
+
export interface FileDeleteResult {
|
|
68
|
+
/** Whether operation succeeded */
|
|
69
|
+
success: boolean;
|
|
70
|
+
/** Error message (if failed) */
|
|
71
|
+
error?: string;
|
|
72
|
+
/** Delete metadata */
|
|
73
|
+
metadata?: FileDeleteMetadata;
|
|
74
|
+
/** Audit log entry */
|
|
75
|
+
auditLog?: AuditLogEntry;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Parse command line arguments for file-delete
|
|
79
|
+
*/
|
|
80
|
+
export declare function parseFileDeleteArgs(argv: string[]): FileDeleteArgs;
|
|
81
|
+
/**
|
|
82
|
+
* Delete a file or directory with audit logging and safety checks
|
|
83
|
+
*/
|
|
84
|
+
export declare function deleteFileWithAudit(args: FileDeleteArgs): Promise<FileDeleteResult>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* File Edit CLI Tool
|
|
4
|
+
*
|
|
5
|
+
* Provides audited file edit operations with:
|
|
6
|
+
* - Scope checking against WU code_paths
|
|
7
|
+
* - Exact string replacement
|
|
8
|
+
* - Uniqueness validation
|
|
9
|
+
* - Replace-all support
|
|
10
|
+
* - Audit logging
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* node file-edit.js <path> --old-string <old> --new-string <new> [--replace-all]
|
|
14
|
+
*
|
|
15
|
+
* WU-1108: INIT-003 Phase 4a - Migrate file operations
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Default configuration for file edit operations
|
|
19
|
+
*/
|
|
20
|
+
export declare const FILE_EDIT_DEFAULTS: {
|
|
21
|
+
/** Default encoding */
|
|
22
|
+
encoding: BufferEncoding;
|
|
23
|
+
/** Replace all occurrences (default: false - requires unique match) */
|
|
24
|
+
replaceAll: boolean;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Arguments for file edit operation
|
|
28
|
+
*/
|
|
29
|
+
export interface FileEditArgs {
|
|
30
|
+
/** Path to file to edit */
|
|
31
|
+
path?: string;
|
|
32
|
+
/** String to find */
|
|
33
|
+
oldString?: string;
|
|
34
|
+
/** String to replace with */
|
|
35
|
+
newString?: string;
|
|
36
|
+
/** File encoding */
|
|
37
|
+
encoding?: BufferEncoding;
|
|
38
|
+
/** Replace all occurrences */
|
|
39
|
+
replaceAll?: boolean;
|
|
40
|
+
/** Show help */
|
|
41
|
+
help?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Audit log entry for file operations
|
|
45
|
+
*/
|
|
46
|
+
export interface AuditLogEntry {
|
|
47
|
+
/** Operation type */
|
|
48
|
+
operation: 'read' | 'write' | 'edit' | 'delete';
|
|
49
|
+
/** File path */
|
|
50
|
+
path: string;
|
|
51
|
+
/** Timestamp */
|
|
52
|
+
timestamp: string;
|
|
53
|
+
/** Duration in ms */
|
|
54
|
+
durationMs?: number;
|
|
55
|
+
/** Success status */
|
|
56
|
+
success: boolean;
|
|
57
|
+
/** Error message if failed */
|
|
58
|
+
error?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Result of file edit operation
|
|
62
|
+
*/
|
|
63
|
+
export interface FileEditResult {
|
|
64
|
+
/** Whether operation succeeded */
|
|
65
|
+
success: boolean;
|
|
66
|
+
/** Error message (if failed) */
|
|
67
|
+
error?: string;
|
|
68
|
+
/** Number of replacements made */
|
|
69
|
+
replacements?: number;
|
|
70
|
+
/** Diff preview */
|
|
71
|
+
diff?: string;
|
|
72
|
+
/** Audit log entry */
|
|
73
|
+
auditLog?: AuditLogEntry;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Parse command line arguments for file-edit
|
|
77
|
+
*/
|
|
78
|
+
export declare function parseFileEditArgs(argv: string[]): FileEditArgs;
|
|
79
|
+
/**
|
|
80
|
+
* Edit a file with audit logging and safety checks
|
|
81
|
+
*/
|
|
82
|
+
export declare function editFileWithAudit(args: FileEditArgs): Promise<FileEditResult>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* File Read CLI Tool
|
|
4
|
+
*
|
|
5
|
+
* Provides audited file read operations with:
|
|
6
|
+
* - Scope checking against WU code_paths
|
|
7
|
+
* - File size limits
|
|
8
|
+
* - Line range support
|
|
9
|
+
* - Audit logging
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* node file-read.js <path> [--encoding utf-8] [--start-line N] [--end-line M]
|
|
13
|
+
*
|
|
14
|
+
* WU-1108: INIT-003 Phase 4a - Migrate file operations
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Default configuration for file read operations
|
|
18
|
+
*/
|
|
19
|
+
export declare const FILE_READ_DEFAULTS: {
|
|
20
|
+
/** Maximum file size in bytes (10MB) */
|
|
21
|
+
maxFileSizeBytes: number;
|
|
22
|
+
/** Default encoding */
|
|
23
|
+
encoding: BufferEncoding;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Arguments for file read operation
|
|
27
|
+
*/
|
|
28
|
+
export interface FileReadArgs {
|
|
29
|
+
/** Path to file to read */
|
|
30
|
+
path?: string;
|
|
31
|
+
/** File encoding */
|
|
32
|
+
encoding?: BufferEncoding;
|
|
33
|
+
/** Start line (1-based, inclusive) */
|
|
34
|
+
startLine?: number;
|
|
35
|
+
/** End line (1-based, inclusive) */
|
|
36
|
+
endLine?: number;
|
|
37
|
+
/** Maximum file size in bytes */
|
|
38
|
+
maxFileSizeBytes?: number;
|
|
39
|
+
/** Show help */
|
|
40
|
+
help?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Metadata returned with file read
|
|
44
|
+
*/
|
|
45
|
+
export interface FileReadMetadata {
|
|
46
|
+
/** File size in bytes */
|
|
47
|
+
sizeBytes: number;
|
|
48
|
+
/** Total line count */
|
|
49
|
+
lineCount: number;
|
|
50
|
+
/** Lines returned (if subset) */
|
|
51
|
+
linesReturned?: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Audit log entry for file operations
|
|
55
|
+
*/
|
|
56
|
+
export interface AuditLogEntry {
|
|
57
|
+
/** Operation type */
|
|
58
|
+
operation: 'read' | 'write' | 'edit' | 'delete';
|
|
59
|
+
/** File path */
|
|
60
|
+
path: string;
|
|
61
|
+
/** Timestamp */
|
|
62
|
+
timestamp: string;
|
|
63
|
+
/** Duration in ms */
|
|
64
|
+
durationMs?: number;
|
|
65
|
+
/** Success status */
|
|
66
|
+
success: boolean;
|
|
67
|
+
/** Error message if failed */
|
|
68
|
+
error?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Result of file read operation
|
|
72
|
+
*/
|
|
73
|
+
export interface FileReadResult {
|
|
74
|
+
/** Whether operation succeeded */
|
|
75
|
+
success: boolean;
|
|
76
|
+
/** File content (if successful) */
|
|
77
|
+
content?: string;
|
|
78
|
+
/** Error message (if failed) */
|
|
79
|
+
error?: string;
|
|
80
|
+
/** File metadata */
|
|
81
|
+
metadata?: FileReadMetadata;
|
|
82
|
+
/** Audit log entry */
|
|
83
|
+
auditLog?: AuditLogEntry;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Parse command line arguments for file-read
|
|
87
|
+
*/
|
|
88
|
+
export declare function parseFileReadArgs(argv: string[]): FileReadArgs;
|
|
89
|
+
/**
|
|
90
|
+
* Read a file with audit logging and safety checks
|
|
91
|
+
*/
|
|
92
|
+
export declare function readFileWithAudit(args: FileReadArgs): Promise<FileReadResult>;
|