@fnclaude/cli 1.1.0 → 2.0.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/bin/fnc.js +34 -79
- package/package.json +6 -9
- package/share/fnclaude/templates/handoff.template.md +11 -0
- package/src/argv/classify.ts +48 -0
- package/src/argv/expand.ts +51 -0
- package/src/argv/intake.ts +52 -0
- package/src/argv/magic.ts +103 -0
- package/src/argv/parse.ts +213 -0
- package/src/argv/preserve-args.ts +333 -0
- package/src/argv/sentinel.ts +41 -0
- package/src/argv/short-flags.ts +152 -0
- package/src/config/load.ts +116 -0
- package/src/handoff/awaiter.ts +140 -0
- package/src/handoff/clean-env.ts +45 -0
- package/src/handoff/kill-and-exec.ts +110 -0
- package/src/handoff/spawn-launcher.ts +185 -0
- package/src/handoff/summary-file.ts +86 -0
- package/src/handoff/trigger.ts +90 -0
- package/src/help-version.ts +151 -0
- package/src/launch/compose-env.ts +34 -0
- package/src/launch/cross-cwd-parse.ts +69 -0
- package/src/launch/cross-cwd-relaunch.ts +95 -0
- package/src/launch/find-claude.ts +52 -0
- package/src/launch/live-permission-reader.ts +133 -0
- package/src/launch/ring-buffer.ts +92 -0
- package/src/main.ts +580 -437
- package/src/mcp/dispatch.ts +240 -0
- package/src/mcp/handlers/clipboard-backends.ts +176 -0
- package/src/mcp/handlers/clipboard.ts +62 -0
- package/src/mcp/handlers/restart.ts +156 -0
- package/src/mcp/handlers/spawn.ts +219 -0
- package/src/mcp/handlers/switch.ts +272 -0
- package/src/mcp/inject-config.ts +59 -0
- package/src/mcp/jsonrpc-server.ts +154 -0
- package/src/mcp/listener.ts +141 -0
- package/src/mcp/parent-dispatch.ts +154 -0
- package/src/mcp/socket-path.ts +48 -0
- package/src/mcp/wire.ts +181 -0
- package/src/name/auto-name.ts +162 -0
- package/src/name/llm-prompt.ts +14 -0
- package/src/name/sanitize.ts +57 -0
- package/src/name/sdk-llm.ts +42 -0
- package/src/noop/seed.ts +63 -0
- package/src/noop/template-source.ts +62 -0
- package/src/path/ensure-cwd.ts +95 -0
- package/src/path/resolve.ts +58 -0
- package/src/prompts/dir.ts +61 -0
- package/src/prompts/load.ts +100 -0
- package/src/prompts/select.ts +43 -0
- package/src/repo/clone-exec.ts +37 -0
- package/src/repo/clone.ts +45 -0
- package/src/repo/gh-runner.ts +68 -0
- package/src/repo/host-aliases.ts +58 -0
- package/src/repo/owner-lookup.ts +71 -0
- package/src/repo/ref.ts +146 -0
- package/src/repo/repo-settings.ts +99 -0
- package/src/repo/resolve-input.ts +179 -0
- package/src/repo/template.ts +92 -0
- package/src/warnings/buffer.ts +39 -0
- package/src/worktree/auto-tmux.ts +45 -0
- package/src/worktree/git-list.ts +73 -0
- package/src/worktree/intercept.ts +150 -0
- package/bin/preflight.js +0 -66
- package/prompts/agent-pitfall.md +0 -1
- package/prompts/noop-router.md +0 -186
- package/prompts/project-switch.md +0 -64
- package/prompts/restart.md +0 -50
- package/prompts/spawn.md +0 -62
- package/src/argParser.ts +0 -367
- package/src/args/preserve.ts +0 -338
- package/src/args.ts +0 -239
- package/src/argv.ts +0 -203
- package/src/autoname.ts +0 -273
- package/src/clipboard.ts +0 -149
- package/src/config.ts +0 -369
- package/src/errors.ts +0 -13
- package/src/handoff.ts +0 -108
- package/src/help.ts +0 -139
- package/src/hostAliases.ts +0 -139
- package/src/index.ts +0 -120
- package/src/mcp/client.ts +0 -645
- package/src/mcp/protocol.ts +0 -445
- package/src/mcp/socketListener.ts +0 -540
- package/src/noop.ts +0 -106
- package/src/passthrough.ts +0 -36
- package/src/paths.ts +0 -55
- package/src/prompts.ts +0 -279
- package/src/pty/unix.ts +0 -429
- package/src/pty/windows.ts +0 -125
- package/src/pty.ts +0 -380
- package/src/repoRef.ts +0 -158
- package/src/repoSettings.ts +0 -144
- package/src/resolver.ts +0 -519
- package/src/sanitize.ts +0 -120
- package/src/sessionState.ts +0 -220
- package/src/silentRelaunch.ts +0 -178
- package/src/spawn.ts +0 -163
- package/src/template.ts +0 -44
- package/src/warnings.ts +0 -34
- package/src/worktree.ts +0 -201
package/src/hostAliases.ts
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
// Load the {host-short} alias map.
|
|
2
|
-
//
|
|
3
|
-
// Builtin defaults (BUILTIN_HOST_ALIASES) ship with the package — npm install
|
|
4
|
-
// has no hook to drop a JSON file under /usr/share, so the canonical 4 host
|
|
5
|
-
// mappings live in source. Users override per-key via
|
|
6
|
-
// ~/.local/share/fnrhombus/host-aliases.json.
|
|
7
|
-
//
|
|
8
|
-
// Missing user file is silently treated as empty. If a user template uses
|
|
9
|
-
// {host-short} and the merged map has no entry for the current host, the
|
|
10
|
-
// substitution step calls missingHostShortError() to produce a message
|
|
11
|
-
// naming the user file path and a copy-pasteable JSON example.
|
|
12
|
-
|
|
13
|
-
import { readFileSync } from 'node:fs';
|
|
14
|
-
import { homedir } from 'node:os';
|
|
15
|
-
import { join } from 'node:path';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Bundled host-alias defaults. These ship with the package and are
|
|
19
|
-
* always present; the user file (if any) overrides per key.
|
|
20
|
-
*
|
|
21
|
-
* Kept in sync with the Go reference's AUR PKGBUILD install fixture.
|
|
22
|
-
*/
|
|
23
|
-
export const BUILTIN_HOST_ALIASES: Readonly<Record<string, string>> = Object.freeze({
|
|
24
|
-
'github.com': 'gh',
|
|
25
|
-
'gitlab.com': 'gl',
|
|
26
|
-
'bitbucket.org': 'bb',
|
|
27
|
-
'codeberg.org': 'cb',
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Per-user override path. Wins per-key against the builtin defaults.
|
|
32
|
-
*/
|
|
33
|
-
export function hostAliasesUserPath(home: string): string {
|
|
34
|
-
return join(home, '.local', 'share', 'fnrhombus', 'host-aliases.json');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Result of a host-aliases load: the merged alias map plus any non-fatal
|
|
39
|
-
* warnings (e.g. malformed files that were skipped). Mirrors
|
|
40
|
-
* `LoadConfigResult` so the caller can thread warnings into the deferred
|
|
41
|
-
* flush.
|
|
42
|
-
*/
|
|
43
|
-
export interface LoadHostAliasesResult {
|
|
44
|
-
aliases: Record<string, string>;
|
|
45
|
-
warnings: readonly string[];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Return the merged alias map: builtin defaults overlaid with the user
|
|
50
|
-
* file (if present). User entries win per key. Missing user file is the
|
|
51
|
-
* common path and stays silent.
|
|
52
|
-
*/
|
|
53
|
-
export function loadHostAliases(home: string): LoadHostAliasesResult {
|
|
54
|
-
const userResult = mergeHostAliases([hostAliasesUserPath(home)]);
|
|
55
|
-
const merged: Record<string, string> = { ...BUILTIN_HOST_ALIASES };
|
|
56
|
-
for (const k of Object.keys(userResult.aliases)) {
|
|
57
|
-
merged[k] = userResult.aliases[k] as string;
|
|
58
|
-
}
|
|
59
|
-
return { aliases: merged, warnings: userResult.warnings };
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Read each path (if it exists) and merge per-key with later entries
|
|
64
|
-
* winning over earlier ones.
|
|
65
|
-
*/
|
|
66
|
-
export function mergeHostAliases(paths: string[]): LoadHostAliasesResult {
|
|
67
|
-
const merged: Record<string, string> = {};
|
|
68
|
-
const warnings: string[] = [];
|
|
69
|
-
for (const p of paths) {
|
|
70
|
-
const { aliases, warning } = readHostAliasesFile(p);
|
|
71
|
-
if (warning !== null) warnings.push(warning);
|
|
72
|
-
for (const k of Object.keys(aliases)) {
|
|
73
|
-
merged[k] = aliases[k] as string;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return { aliases: merged, warnings };
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface ReadHostAliasesFileResult {
|
|
80
|
-
aliases: Record<string, string>;
|
|
81
|
-
warning: string | null;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Parse one alias file. Missing file is the common path and stays
|
|
86
|
-
* silent. Malformed JSON or non-object roots produce a warning so the
|
|
87
|
-
* user can fix the file rather than wondering why their aliases don't
|
|
88
|
-
* apply. Non-string values are silently dropped (mirrors the JS plugin).
|
|
89
|
-
*/
|
|
90
|
-
export function readHostAliasesFile(path: string): ReadHostAliasesFileResult {
|
|
91
|
-
let data: string;
|
|
92
|
-
try {
|
|
93
|
-
data = readFileSync(path, 'utf8');
|
|
94
|
-
} catch {
|
|
95
|
-
return { aliases: {}, warning: null };
|
|
96
|
-
}
|
|
97
|
-
let raw: unknown;
|
|
98
|
-
try {
|
|
99
|
-
raw = JSON.parse(data);
|
|
100
|
-
} catch (err) {
|
|
101
|
-
return {
|
|
102
|
-
aliases: {},
|
|
103
|
-
warning: `fnclaude: host-aliases file ${path} is malformed, skipping: ${(err as Error).message}`,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
|
|
107
|
-
return {
|
|
108
|
-
aliases: {},
|
|
109
|
-
warning: `fnclaude: host-aliases file ${path} has a non-object root, skipping`,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
const out: Record<string, string> = {};
|
|
113
|
-
for (const [k, v] of Object.entries(raw as Record<string, unknown>)) {
|
|
114
|
-
if (typeof v === 'string') out[k] = v;
|
|
115
|
-
}
|
|
116
|
-
return { aliases: out, warning: null };
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Build the error emitted when a template uses {host-short} but no alias
|
|
121
|
-
* is configured for the current host. Points only at the user file path
|
|
122
|
-
* since builtins already cover the common forges and any further
|
|
123
|
-
* overrides go in the user file.
|
|
124
|
-
*
|
|
125
|
-
* `home` is injected so callers in tests can pin the user-path output
|
|
126
|
-
* without touching $HOME; production callers should pass `process.env.HOME
|
|
127
|
-
* ?? os.homedir()`.
|
|
128
|
-
*/
|
|
129
|
-
export function missingHostShortError(host: string, home?: string): Error {
|
|
130
|
-
const h = home ?? process.env.HOME ?? homedir();
|
|
131
|
-
const userPath = hostAliasesUserPath(h);
|
|
132
|
-
return new Error(
|
|
133
|
-
`cannot resolve {host-short} for host ${JSON.stringify(host)}: no alias configured.\n` +
|
|
134
|
-
`Add an entry to:\n` +
|
|
135
|
-
` ${userPath}\n` +
|
|
136
|
-
`Example:\n` +
|
|
137
|
-
` { "github.com": "gh", "gitlab.com": "gl" }`,
|
|
138
|
-
);
|
|
139
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
export const name = '@fnclaude/cli';
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
sanitizeName,
|
|
5
|
-
sanitizeNamesInPassthrough,
|
|
6
|
-
type SanitizeNamesResult,
|
|
7
|
-
} from './sanitize.js';
|
|
8
|
-
export {
|
|
9
|
-
parseRepoRef,
|
|
10
|
-
type RepoRef,
|
|
11
|
-
} from './repoRef.js';
|
|
12
|
-
export { expandTildePath, resolveSelfPath } from './paths.js';
|
|
13
|
-
export {
|
|
14
|
-
findPromptsDir,
|
|
15
|
-
isInteractiveSession,
|
|
16
|
-
loadPrompts,
|
|
17
|
-
readPromptFile,
|
|
18
|
-
readPromptFileSync,
|
|
19
|
-
selectFragments,
|
|
20
|
-
type FindPromptsDirResult,
|
|
21
|
-
type LoadPromptsResult,
|
|
22
|
-
type PromptSet,
|
|
23
|
-
type ReadPromptFileResult,
|
|
24
|
-
} from './prompts.js';
|
|
25
|
-
export {
|
|
26
|
-
applyWorktreeIntercept,
|
|
27
|
-
defaultGitRunner,
|
|
28
|
-
findWorktree,
|
|
29
|
-
listWorktrees,
|
|
30
|
-
type GitRunner,
|
|
31
|
-
type WorktreeInfo,
|
|
32
|
-
} from './worktree.js';
|
|
33
|
-
export {
|
|
34
|
-
buildArgv,
|
|
35
|
-
buildFnclaudeMCPConfigJSON,
|
|
36
|
-
nameInPassthrough,
|
|
37
|
-
settingSourcesInPassthrough,
|
|
38
|
-
tokenInPassthrough,
|
|
39
|
-
withAppendedSystemPrompts,
|
|
40
|
-
} from './argv.js';
|
|
41
|
-
|
|
42
|
-
// MCP wire protocol + parent-side listener + subprocess client.
|
|
43
|
-
export {
|
|
44
|
-
ActionDone,
|
|
45
|
-
ActionError,
|
|
46
|
-
ActionPasteFlow,
|
|
47
|
-
decodeRequest,
|
|
48
|
-
decodeResponse,
|
|
49
|
-
encodeRequest,
|
|
50
|
-
encodeResponse,
|
|
51
|
-
OpCopy,
|
|
52
|
-
OpRestart,
|
|
53
|
-
OpSpawn,
|
|
54
|
-
OpSwitch,
|
|
55
|
-
readRequest,
|
|
56
|
-
readResponse,
|
|
57
|
-
type Action,
|
|
58
|
-
type CopyRequest,
|
|
59
|
-
type Op,
|
|
60
|
-
type Request,
|
|
61
|
-
type RequestOverrides,
|
|
62
|
-
type Response,
|
|
63
|
-
type RestartRequest,
|
|
64
|
-
type SpawnRequest,
|
|
65
|
-
type SwitchRequest,
|
|
66
|
-
} from './mcp/protocol.js';
|
|
67
|
-
export {
|
|
68
|
-
SocketListener,
|
|
69
|
-
type ClipboardResult,
|
|
70
|
-
type SocketListenerDeps,
|
|
71
|
-
type SpawnResult,
|
|
72
|
-
type StartOptions as SocketListenerStartOptions,
|
|
73
|
-
} from './mcp/socketListener.js';
|
|
74
|
-
export {
|
|
75
|
-
runMCPServer,
|
|
76
|
-
type DialFn,
|
|
77
|
-
type MCPServerOptions,
|
|
78
|
-
} from './mcp/client.js';
|
|
79
|
-
export {
|
|
80
|
-
applyOverrides,
|
|
81
|
-
preserveArgs,
|
|
82
|
-
splitLeadingMagic,
|
|
83
|
-
transferDenyBareOK,
|
|
84
|
-
transferDenyFlags,
|
|
85
|
-
} from './args/preserve.js';
|
|
86
|
-
|
|
87
|
-
// Help / version surfaces consumed by main.ts and friendly to import in
|
|
88
|
-
// embedding hosts that want to render their own help.
|
|
89
|
-
export { helpText, setVersion, version, wantsHelp, wantsVersion } from './help.js';
|
|
90
|
-
|
|
91
|
-
// Warning flush. Loaders (loadConfig / loadRepoSettings / loadHostAliases
|
|
92
|
-
// / loadPrompts) return their warnings; flushWarnings drains a provided
|
|
93
|
-
// list to stderr.
|
|
94
|
-
export { flushWarnings } from './warnings.js';
|
|
95
|
-
|
|
96
|
-
// noop dir seeding (noop fallback when fnclaude is invoked with no path).
|
|
97
|
-
export { NOOP_HANDOFF_TEMPLATE, defaultNoopDir, seedNoop } from './noop.js';
|
|
98
|
-
|
|
99
|
-
// Silent-relaunch primitives — execve on POSIX, spawn-and-exit on Windows.
|
|
100
|
-
export { silentRelaunch, silentRelaunchHandoff, spawnAndExit } from './silentRelaunch.js';
|
|
101
|
-
|
|
102
|
-
// Top-level run loop + entry point.
|
|
103
|
-
export { main, run, type RunConfig, type RunDeps, type RunIO } from './main.js';
|
|
104
|
-
|
|
105
|
-
// PTY runner + shared helpers (ring buffer, cross-cwd detection,
|
|
106
|
-
// reconstructArgv, ensureCWD).
|
|
107
|
-
export {
|
|
108
|
-
clearScreen,
|
|
109
|
-
crossCwdRe,
|
|
110
|
-
detectCrossCwd,
|
|
111
|
-
ensureCWD,
|
|
112
|
-
RING_BUFFER_SIZE,
|
|
113
|
-
reconstructArgv,
|
|
114
|
-
RingBuffer,
|
|
115
|
-
runWithPTY,
|
|
116
|
-
type CrossCwdMatch,
|
|
117
|
-
type EnsureCWDHandle,
|
|
118
|
-
type RunOptions,
|
|
119
|
-
type RunResult,
|
|
120
|
-
} from './pty.js';
|