fixo-cli 1.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/LICENSE +201 -0
- package/README.md +530 -0
- package/dist/agent/agent-client.d.ts +108 -0
- package/dist/agent/agent-client.d.ts.map +1 -0
- package/dist/agent/agent-client.js +1247 -0
- package/dist/agent/agent-client.js.map +1 -0
- package/dist/agent/agent-pool.d.ts +20 -0
- package/dist/agent/agent-pool.d.ts.map +1 -0
- package/dist/agent/agent-pool.js +217 -0
- package/dist/agent/agent-pool.js.map +1 -0
- package/dist/agent/background-awareness.d.ts +55 -0
- package/dist/agent/background-awareness.d.ts.map +1 -0
- package/dist/agent/background-awareness.js +104 -0
- package/dist/agent/background-awareness.js.map +1 -0
- package/dist/agent/command-parser.d.ts +33 -0
- package/dist/agent/command-parser.d.ts.map +1 -0
- package/dist/agent/command-parser.js +120 -0
- package/dist/agent/command-parser.js.map +1 -0
- package/dist/agent/context-budget.d.ts +91 -0
- package/dist/agent/context-budget.d.ts.map +1 -0
- package/dist/agent/context-budget.js +219 -0
- package/dist/agent/context-budget.js.map +1 -0
- package/dist/agent/conversation.d.ts +190 -0
- package/dist/agent/conversation.d.ts.map +1 -0
- package/dist/agent/conversation.js +547 -0
- package/dist/agent/conversation.js.map +1 -0
- package/dist/agent/hooks.d.ts +72 -0
- package/dist/agent/hooks.d.ts.map +1 -0
- package/dist/agent/hooks.js +214 -0
- package/dist/agent/hooks.js.map +1 -0
- package/dist/agent/mcp-bridge.d.ts +13 -0
- package/dist/agent/mcp-bridge.d.ts.map +1 -0
- package/dist/agent/mcp-bridge.js +86 -0
- package/dist/agent/mcp-bridge.js.map +1 -0
- package/dist/agent/mcp-client.d.ts +24 -0
- package/dist/agent/mcp-client.d.ts.map +1 -0
- package/dist/agent/mcp-client.js +146 -0
- package/dist/agent/mcp-client.js.map +1 -0
- package/dist/agent/mcp-manager.d.ts +13 -0
- package/dist/agent/mcp-manager.d.ts.map +1 -0
- package/dist/agent/mcp-manager.js +84 -0
- package/dist/agent/mcp-manager.js.map +1 -0
- package/dist/agent/mcp-registry.d.ts +45 -0
- package/dist/agent/mcp-registry.d.ts.map +1 -0
- package/dist/agent/mcp-registry.js +98 -0
- package/dist/agent/mcp-registry.js.map +1 -0
- package/dist/agent/orchestrator.d.ts +14 -0
- package/dist/agent/orchestrator.d.ts.map +1 -0
- package/dist/agent/orchestrator.js +118 -0
- package/dist/agent/orchestrator.js.map +1 -0
- package/dist/agent/parser-adapter.d.ts +120 -0
- package/dist/agent/parser-adapter.d.ts.map +1 -0
- package/dist/agent/parser-adapter.js +265 -0
- package/dist/agent/parser-adapter.js.map +1 -0
- package/dist/agent/parsers/imports.d.ts +11 -0
- package/dist/agent/parsers/imports.d.ts.map +1 -0
- package/dist/agent/parsers/imports.js +94 -0
- package/dist/agent/parsers/imports.js.map +1 -0
- package/dist/agent/parsers/shell.d.ts +23 -0
- package/dist/agent/parsers/shell.d.ts.map +1 -0
- package/dist/agent/parsers/shell.js +200 -0
- package/dist/agent/parsers/shell.js.map +1 -0
- package/dist/agent/parsers/symbols.d.ts +17 -0
- package/dist/agent/parsers/symbols.d.ts.map +1 -0
- package/dist/agent/parsers/symbols.js +103 -0
- package/dist/agent/parsers/symbols.js.map +1 -0
- package/dist/agent/permissions.d.ts +65 -0
- package/dist/agent/permissions.d.ts.map +1 -0
- package/dist/agent/permissions.js +219 -0
- package/dist/agent/permissions.js.map +1 -0
- package/dist/agent/predictive-gate.d.ts +69 -0
- package/dist/agent/predictive-gate.d.ts.map +1 -0
- package/dist/agent/predictive-gate.js +128 -0
- package/dist/agent/predictive-gate.js.map +1 -0
- package/dist/agent/provider-cooldown.d.ts +144 -0
- package/dist/agent/provider-cooldown.d.ts.map +1 -0
- package/dist/agent/provider-cooldown.js +300 -0
- package/dist/agent/provider-cooldown.js.map +1 -0
- package/dist/agent/providers-manager.d.ts +109 -0
- package/dist/agent/providers-manager.d.ts.map +1 -0
- package/dist/agent/providers-manager.js +464 -0
- package/dist/agent/providers-manager.js.map +1 -0
- package/dist/agent/repo-map.d.ts +6 -0
- package/dist/agent/repo-map.d.ts.map +1 -0
- package/dist/agent/repo-map.js +221 -0
- package/dist/agent/repo-map.js.map +1 -0
- package/dist/agent/retry.d.ts +103 -0
- package/dist/agent/retry.d.ts.map +1 -0
- package/dist/agent/retry.js +276 -0
- package/dist/agent/retry.js.map +1 -0
- package/dist/agent/search/index.d.ts +61 -0
- package/dist/agent/search/index.d.ts.map +1 -0
- package/dist/agent/search/index.js +314 -0
- package/dist/agent/search/index.js.map +1 -0
- package/dist/agent/single-agent.d.ts +76 -0
- package/dist/agent/single-agent.d.ts.map +1 -0
- package/dist/agent/single-agent.js +697 -0
- package/dist/agent/single-agent.js.map +1 -0
- package/dist/agent/skills.d.ts +22 -0
- package/dist/agent/skills.d.ts.map +1 -0
- package/dist/agent/skills.js +139 -0
- package/dist/agent/skills.js.map +1 -0
- package/dist/agent/stream-glue.d.ts +85 -0
- package/dist/agent/stream-glue.d.ts.map +1 -0
- package/dist/agent/stream-glue.js +120 -0
- package/dist/agent/stream-glue.js.map +1 -0
- package/dist/agent/subagent.d.ts +72 -0
- package/dist/agent/subagent.d.ts.map +1 -0
- package/dist/agent/subagent.js +193 -0
- package/dist/agent/subagent.js.map +1 -0
- package/dist/agent/telemetry.d.ts +192 -0
- package/dist/agent/telemetry.d.ts.map +1 -0
- package/dist/agent/telemetry.js +400 -0
- package/dist/agent/telemetry.js.map +1 -0
- package/dist/agent/tokenizer.d.ts +42 -0
- package/dist/agent/tokenizer.d.ts.map +1 -0
- package/dist/agent/tokenizer.js +107 -0
- package/dist/agent/tokenizer.js.map +1 -0
- package/dist/agent/tool-executor.d.ts +289 -0
- package/dist/agent/tool-executor.d.ts.map +1 -0
- package/dist/agent/tool-executor.js +2519 -0
- package/dist/agent/tool-executor.js.map +1 -0
- package/dist/agent/web-impl.d.ts +2 -0
- package/dist/agent/web-impl.d.ts.map +1 -0
- package/dist/agent/web-impl.js +34 -0
- package/dist/agent/web-impl.js.map +1 -0
- package/dist/agent/web.d.ts +8 -0
- package/dist/agent/web.d.ts.map +1 -0
- package/dist/agent/web.js +8 -0
- package/dist/agent/web.js.map +1 -0
- package/dist/agent/worker-agent.d.ts +27 -0
- package/dist/agent/worker-agent.d.ts.map +1 -0
- package/dist/agent/worker-agent.js +503 -0
- package/dist/agent/worker-agent.js.map +1 -0
- package/dist/config.d.ts +162 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +138 -0
- package/dist/config.js.map +1 -0
- package/dist/context/fixo-md-watcher.d.ts +42 -0
- package/dist/context/fixo-md-watcher.d.ts.map +1 -0
- package/dist/context/fixo-md-watcher.js +126 -0
- package/dist/context/fixo-md-watcher.js.map +1 -0
- package/dist/context/fixo-md.d.ts +50 -0
- package/dist/context/fixo-md.d.ts.map +1 -0
- package/dist/context/fixo-md.js +118 -0
- package/dist/context/fixo-md.js.map +1 -0
- package/dist/context/todo.d.ts +65 -0
- package/dist/context/todo.d.ts.map +1 -0
- package/dist/context/todo.js +194 -0
- package/dist/context/todo.js.map +1 -0
- package/dist/git/git-manager.d.ts +33 -0
- package/dist/git/git-manager.d.ts.map +1 -0
- package/dist/git/git-manager.js +293 -0
- package/dist/git/git-manager.js.map +1 -0
- package/dist/git/git-ops.d.ts +10 -0
- package/dist/git/git-ops.d.ts.map +1 -0
- package/dist/git/git-ops.js +131 -0
- package/dist/git/git-ops.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +352 -0
- package/dist/index.js.map +1 -0
- package/dist/indexer.d.ts +30 -0
- package/dist/indexer.d.ts.map +1 -0
- package/dist/indexer.js +273 -0
- package/dist/indexer.js.map +1 -0
- package/dist/lsp/lsp-client.d.ts +24 -0
- package/dist/lsp/lsp-client.d.ts.map +1 -0
- package/dist/lsp/lsp-client.js +205 -0
- package/dist/lsp/lsp-client.js.map +1 -0
- package/dist/lsp/lsp-manager.d.ts +17 -0
- package/dist/lsp/lsp-manager.d.ts.map +1 -0
- package/dist/lsp/lsp-manager.js +154 -0
- package/dist/lsp/lsp-manager.js.map +1 -0
- package/dist/lsp/lsp-pre-save.d.ts +137 -0
- package/dist/lsp/lsp-pre-save.d.ts.map +1 -0
- package/dist/lsp/lsp-pre-save.js +245 -0
- package/dist/lsp/lsp-pre-save.js.map +1 -0
- package/dist/lsp/syntax-fallback.d.ts +83 -0
- package/dist/lsp/syntax-fallback.d.ts.map +1 -0
- package/dist/lsp/syntax-fallback.js +275 -0
- package/dist/lsp/syntax-fallback.js.map +1 -0
- package/dist/model-outcomes.d.ts +12 -0
- package/dist/model-outcomes.d.ts.map +1 -0
- package/dist/model-outcomes.js +46 -0
- package/dist/model-outcomes.js.map +1 -0
- package/dist/planner.d.ts +32 -0
- package/dist/planner.d.ts.map +1 -0
- package/dist/planner.js +163 -0
- package/dist/planner.js.map +1 -0
- package/dist/project-memory.d.ts +29 -0
- package/dist/project-memory.d.ts.map +1 -0
- package/dist/project-memory.js +349 -0
- package/dist/project-memory.js.map +1 -0
- package/dist/review.d.ts +2 -0
- package/dist/review.d.ts.map +1 -0
- package/dist/review.js +61 -0
- package/dist/review.js.map +1 -0
- package/dist/runtime/background-jobs.d.ts +97 -0
- package/dist/runtime/background-jobs.d.ts.map +1 -0
- package/dist/runtime/background-jobs.js +331 -0
- package/dist/runtime/background-jobs.js.map +1 -0
- package/dist/runtime/credential-vault.d.ts +124 -0
- package/dist/runtime/credential-vault.d.ts.map +1 -0
- package/dist/runtime/credential-vault.js +184 -0
- package/dist/runtime/credential-vault.js.map +1 -0
- package/dist/runtime/loop-trap.d.ts +197 -0
- package/dist/runtime/loop-trap.d.ts.map +1 -0
- package/dist/runtime/loop-trap.js +420 -0
- package/dist/runtime/loop-trap.js.map +1 -0
- package/dist/runtime/policy.d.ts +15 -0
- package/dist/runtime/policy.d.ts.map +1 -0
- package/dist/runtime/policy.js +60 -0
- package/dist/runtime/policy.js.map +1 -0
- package/dist/runtime/redaction.d.ts +66 -0
- package/dist/runtime/redaction.d.ts.map +1 -0
- package/dist/runtime/redaction.js +155 -0
- package/dist/runtime/redaction.js.map +1 -0
- package/dist/runtime/session-snapshots.d.ts +76 -0
- package/dist/runtime/session-snapshots.d.ts.map +1 -0
- package/dist/runtime/session-snapshots.js +166 -0
- package/dist/runtime/session-snapshots.js.map +1 -0
- package/dist/runtime/staging.d.ts +205 -0
- package/dist/runtime/staging.d.ts.map +1 -0
- package/dist/runtime/staging.js +526 -0
- package/dist/runtime/staging.js.map +1 -0
- package/dist/runtime/task-session.d.ts +95 -0
- package/dist/runtime/task-session.d.ts.map +1 -0
- package/dist/runtime/task-session.js +263 -0
- package/dist/runtime/task-session.js.map +1 -0
- package/dist/runtime/worktree.d.ts +55 -0
- package/dist/runtime/worktree.d.ts.map +1 -0
- package/dist/runtime/worktree.js +175 -0
- package/dist/runtime/worktree.js.map +1 -0
- package/dist/setup-wizard.d.ts +8 -0
- package/dist/setup-wizard.d.ts.map +1 -0
- package/dist/setup-wizard.js +73 -0
- package/dist/setup-wizard.js.map +1 -0
- package/dist/shared/content.d.ts +43 -0
- package/dist/shared/content.d.ts.map +1 -0
- package/dist/shared/content.js +61 -0
- package/dist/shared/content.js.map +1 -0
- package/dist/shared/types.d.ts +217 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +3 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/test-runner.d.ts +5 -0
- package/dist/test-runner.d.ts.map +1 -0
- package/dist/test-runner.js +42 -0
- package/dist/test-runner.js.map +1 -0
- package/dist/types.d.ts +85 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/ascii.d.ts +23 -0
- package/dist/ui/ascii.d.ts.map +1 -0
- package/dist/ui/ascii.js +45 -0
- package/dist/ui/ascii.js.map +1 -0
- package/dist/ui/colors.d.ts +111 -0
- package/dist/ui/colors.d.ts.map +1 -0
- package/dist/ui/colors.js +166 -0
- package/dist/ui/colors.js.map +1 -0
- package/dist/ui/image-attach.d.ts +27 -0
- package/dist/ui/image-attach.d.ts.map +1 -0
- package/dist/ui/image-attach.js +100 -0
- package/dist/ui/image-attach.js.map +1 -0
- package/dist/ui/index.d.ts +18 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +18 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/markdown-stream.d.ts +91 -0
- package/dist/ui/markdown-stream.d.ts.map +1 -0
- package/dist/ui/markdown-stream.js +524 -0
- package/dist/ui/markdown-stream.js.map +1 -0
- package/dist/ui/plan-renderer.d.ts +36 -0
- package/dist/ui/plan-renderer.d.ts.map +1 -0
- package/dist/ui/plan-renderer.js +79 -0
- package/dist/ui/plan-renderer.js.map +1 -0
- package/dist/ui/prompt.d.ts +11 -0
- package/dist/ui/prompt.d.ts.map +1 -0
- package/dist/ui/prompt.js +1960 -0
- package/dist/ui/prompt.js.map +1 -0
- package/dist/ui/render-primitives.d.ts +117 -0
- package/dist/ui/render-primitives.d.ts.map +1 -0
- package/dist/ui/render-primitives.js +322 -0
- package/dist/ui/render-primitives.js.map +1 -0
- package/dist/ui/render.d.ts +133 -0
- package/dist/ui/render.d.ts.map +1 -0
- package/dist/ui/render.js +547 -0
- package/dist/ui/render.js.map +1 -0
- package/dist/ui/session-header.d.ts +30 -0
- package/dist/ui/session-header.d.ts.map +1 -0
- package/dist/ui/session-header.js +74 -0
- package/dist/ui/session-header.js.map +1 -0
- package/dist/workspace-guard.d.ts +68 -0
- package/dist/workspace-guard.d.ts.map +1 -0
- package/dist/workspace-guard.js +168 -0
- package/dist/workspace-guard.js.map +1 -0
- package/dist/workspace-lock.d.ts +27 -0
- package/dist/workspace-lock.d.ts.map +1 -0
- package/dist/workspace-lock.js +95 -0
- package/dist/workspace-lock.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atomic Workspace Shadow Staging — Pillar 2 of the Phase 2 safety
|
|
3
|
+
* refactor. The problem: a direct `fs.writeFileSync` to a user's
|
|
4
|
+
* source file is a non-atomic, non-rollbackable operation. If the
|
|
5
|
+
* process is killed mid-write, the user is left with a partially
|
|
6
|
+
* truncated file. If a downstream validation step fails, the
|
|
7
|
+
* user is left with a corrupted file. Both outcomes are
|
|
8
|
+
* unacceptable for a tool that markets itself as "enterprise
|
|
9
|
+
* safe".
|
|
10
|
+
*
|
|
11
|
+
* The fix: route every file write through a `.fixo/staging/`
|
|
12
|
+
* shadow directory, validate it (Pillar 3 LSP gate will plug in
|
|
13
|
+
* here), and only then perform an atomic `fs.renameSync` swap.
|
|
14
|
+
* If anything goes wrong, restore the original from a sibling
|
|
15
|
+
* `.pending.bak` file and the user is none the wiser.
|
|
16
|
+
*
|
|
17
|
+
* Layout under `cwd`:
|
|
18
|
+
*
|
|
19
|
+
* .fixo/staging/<run-id>/
|
|
20
|
+
* <sha256(targetPath)>.pending # staged content
|
|
21
|
+
* <sha256(targetPath)>.meta.json # { targetPath, mode, createdAt }
|
|
22
|
+
*
|
|
23
|
+
* <targetPath>.pending.bak # temporary backup, only
|
|
24
|
+
* # present during commit()
|
|
25
|
+
*
|
|
26
|
+
* The staging directory is created with mode `0o700`. Pending
|
|
27
|
+
* files and their metadata are written with mode `0o600`.
|
|
28
|
+
*
|
|
29
|
+
* The manager is synchronous (writes are small, no streaming),
|
|
30
|
+
* safe to construct at the start of a run, and thread-agnostic —
|
|
31
|
+
* the run-id is the only thing that disambiguates concurrent
|
|
32
|
+
* runs against the same workspace.
|
|
33
|
+
*/
|
|
34
|
+
/** Options for {@link AtomicStagingManager}. */
|
|
35
|
+
export interface AtomicStagingOptions {
|
|
36
|
+
/** Maximum age of a staged write before it is eligible for GC (ms). */
|
|
37
|
+
ttlMs?: number;
|
|
38
|
+
/**
|
|
39
|
+
* If supplied, the callback runs immediately before the rename
|
|
40
|
+
* swap inside `commit()`. If it throws, the staged write is
|
|
41
|
+
* rolled back and the original target is preserved. Pillar 3
|
|
42
|
+
* (LSP pre-save gate) wires in here.
|
|
43
|
+
*/
|
|
44
|
+
preCommitHook?: (entry: StagedWrite) => Promise<void> | void;
|
|
45
|
+
/**
|
|
46
|
+
* Pillar 5 / Protection 3 — structural syntax health check.
|
|
47
|
+
*
|
|
48
|
+
* If supplied, the callback runs *after* `preCommitHook` and
|
|
49
|
+
* *before* the rename swap. It receives the staged content and
|
|
50
|
+
* the target path, and should throw a {@link StructuralSyntaxError}
|
|
51
|
+
* (or any `Error`) if the content is unparseable. Pillar 5 wires
|
|
52
|
+
* in a JavaScript / TypeScript parser here so that catastrophic
|
|
53
|
+
* syntax damage (e.g. the LLM pasting code into the wrong
|
|
54
|
+
* function) is caught before it lands on disk.
|
|
55
|
+
*/
|
|
56
|
+
syntaxHealthCheck?: (entry: StagedWrite, content: string) => Promise<void> | void;
|
|
57
|
+
/**
|
|
58
|
+
* If false, the manager operates in "dry-run" mode: stage()
|
|
59
|
+
* writes to the shadow dir but commit() refuses to swap. Useful
|
|
60
|
+
* for tests and for users who want the staging guarantees
|
|
61
|
+
* without the actual file replacement. Defaults to true.
|
|
62
|
+
*/
|
|
63
|
+
enabled?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/** A staged write, returned by {@link AtomicStagingManager.stage}. */
|
|
66
|
+
export interface StagedWrite {
|
|
67
|
+
/** Opaque identifier — sha256 of the target path. */
|
|
68
|
+
readonly id: string;
|
|
69
|
+
/** Absolute path of the file that will be replaced at commit. */
|
|
70
|
+
readonly targetPath: string;
|
|
71
|
+
/** Absolute path of the pending staged file. */
|
|
72
|
+
readonly pendingPath: string;
|
|
73
|
+
/** Absolute path of the sidecar metadata file. */
|
|
74
|
+
readonly metaPath: string;
|
|
75
|
+
/** When the stage was created (ms since epoch). */
|
|
76
|
+
readonly createdAt: number;
|
|
77
|
+
/** Mode the file will have on disk after commit. */
|
|
78
|
+
readonly mode: number;
|
|
79
|
+
}
|
|
80
|
+
/** Result of {@link AtomicStagingManager.commit}. */
|
|
81
|
+
export interface CommitResult {
|
|
82
|
+
/** True if the swap succeeded and the file is on disk. */
|
|
83
|
+
readonly committed: boolean;
|
|
84
|
+
/** Path that was committed. */
|
|
85
|
+
readonly targetPath: string;
|
|
86
|
+
/** Whether a backup of the original was created and cleared. */
|
|
87
|
+
readonly backupCreated: boolean;
|
|
88
|
+
/** Number of bytes written to the target. */
|
|
89
|
+
readonly bytesWritten: number;
|
|
90
|
+
/** ISO timestamp of the commit. */
|
|
91
|
+
readonly committedAt: string;
|
|
92
|
+
}
|
|
93
|
+
/** Thrown when a requested staged write does not exist. */
|
|
94
|
+
export declare class StagedWriteNotFoundError extends Error {
|
|
95
|
+
readonly id: string;
|
|
96
|
+
constructor(id: string);
|
|
97
|
+
}
|
|
98
|
+
/** Thrown when commit() rolls back due to a pre-commit hook failure. */
|
|
99
|
+
export declare class PreCommitHookRejectedError extends Error {
|
|
100
|
+
readonly id: string;
|
|
101
|
+
readonly cause: unknown;
|
|
102
|
+
constructor(id: string, cause: unknown);
|
|
103
|
+
}
|
|
104
|
+
/** Thrown when a target path escapes the workspace root. */
|
|
105
|
+
export declare class StagingPathEscapeError extends Error {
|
|
106
|
+
readonly attempted: string;
|
|
107
|
+
constructor(attempted: string);
|
|
108
|
+
}
|
|
109
|
+
export declare class AtomicStagingManager {
|
|
110
|
+
readonly cwd: string;
|
|
111
|
+
readonly runId: string;
|
|
112
|
+
readonly options: Required<Pick<AtomicStagingOptions, 'ttlMs' | 'enabled'>> & Pick<AtomicStagingOptions, 'preCommitHook' | 'syntaxHealthCheck'>;
|
|
113
|
+
/** Absolute path of the staging directory for this run. */
|
|
114
|
+
readonly stagingDir: string;
|
|
115
|
+
constructor(cwd: string, runId: string, options?: AtomicStagingOptions);
|
|
116
|
+
/** Ensure the staging directory exists with mode 0o700. */
|
|
117
|
+
private ensureStagingDir;
|
|
118
|
+
/** Reject paths that escape the workspace root. */
|
|
119
|
+
private resolveTarget;
|
|
120
|
+
/**
|
|
121
|
+
* Stage a file for atomic write. Writes the content to
|
|
122
|
+
* `<staging>/<sha256(target)>.pending` and a sidecar
|
|
123
|
+
* `<staging>/<sha256(target)>.meta.json` containing the target
|
|
124
|
+
* path, mode, and timestamp. Returns the staged write metadata.
|
|
125
|
+
*/
|
|
126
|
+
stage(target: string, content: string, mode?: number): StagedWrite;
|
|
127
|
+
/** Read a staged write's content (lazy — only read on demand). */
|
|
128
|
+
read(id: string): string;
|
|
129
|
+
/** Look up a staged write by id without touching the file system further. */
|
|
130
|
+
readEntry(id: string): StagedWrite;
|
|
131
|
+
/** List all staged writes for this run. */
|
|
132
|
+
list(): StagedWrite[];
|
|
133
|
+
/**
|
|
134
|
+
* Remove a staged write without touching the target. Used by the
|
|
135
|
+
* LSP pre-save gate when it rejects a write.
|
|
136
|
+
*/
|
|
137
|
+
discard(id: string): void;
|
|
138
|
+
/**
|
|
139
|
+
* Commit a staged write to its target path. The flow is:
|
|
140
|
+
*
|
|
141
|
+
* 1. Run the optional pre-commit hook (Pillar 3 plugs in here).
|
|
142
|
+
* 2. Ensure the parent directory of the target exists.
|
|
143
|
+
* 3. If the target exists, rename it to `<target>.pending.bak`.
|
|
144
|
+
* 4. Rename the pending file to the target.
|
|
145
|
+
* 5. Delete the backup.
|
|
146
|
+
*
|
|
147
|
+
* If any step fails, the backup (if any) is restored to the
|
|
148
|
+
* target and the backup itself is removed. The pending and
|
|
149
|
+
* metadata files are always cleaned up on success.
|
|
150
|
+
*/
|
|
151
|
+
commit(id: string): Promise<CommitResult>;
|
|
152
|
+
/**
|
|
153
|
+
* Apply a surgical in-place edit to an existing file. The new
|
|
154
|
+
* content is staged under the same `.fixo/staging/<runId>/<id>.pending`
|
|
155
|
+
* layout and the commit step mirrors `commit()`: backup the
|
|
156
|
+
* target, atomic rename, clear the backup, clear the meta.
|
|
157
|
+
*
|
|
158
|
+
* This is functionally `stage() + commit()` collapsed into a
|
|
159
|
+
* single call, but the on-disk layout, backup semantics, and
|
|
160
|
+
* rollback path are identical. Provided so `str_replace` (and
|
|
161
|
+
* future surgical-edit tools) can route their edits through the
|
|
162
|
+
* same atomic staging pipeline as `write_file` without touching
|
|
163
|
+
* the existing `stage()` / `commit()` flow.
|
|
164
|
+
*
|
|
165
|
+
* The optional `meta` argument is recorded into `.meta.json` so
|
|
166
|
+
* the audit trail records the originator of the edit (e.g. a
|
|
167
|
+
* `str_replace` tool call vs. a `subagent`). The method never
|
|
168
|
+
* weakens the Pillar 2 atomicity guarantee: if the rename
|
|
169
|
+
* swap fails, the backup is restored and the original file is
|
|
170
|
+
* preserved byte-for-byte.
|
|
171
|
+
*/
|
|
172
|
+
applySurgicalReplace(target: string, newContent: string, meta: {
|
|
173
|
+
runId: string;
|
|
174
|
+
reason: 'str_replace' | 'todo_write' | 'subagent';
|
|
175
|
+
actorId: string;
|
|
176
|
+
}): Promise<{
|
|
177
|
+
ok: true;
|
|
178
|
+
path: string;
|
|
179
|
+
bytes: number;
|
|
180
|
+
}>;
|
|
181
|
+
/**
|
|
182
|
+
* Remove any staged write older than `ttlMs`. Returns the number
|
|
183
|
+
* of entries removed. Designed to be cheap at run start
|
|
184
|
+
* (typically <2ms for a few hundred entries).
|
|
185
|
+
*/
|
|
186
|
+
gc(now?: number): number;
|
|
187
|
+
/**
|
|
188
|
+
* Sweep every run-id directory under `<cwd>/.fixo/staging/`.
|
|
189
|
+
* Returns the total number of expired entries removed. Called
|
|
190
|
+
* automatically at the start of every streaming run and is also
|
|
191
|
+
* exposed via the `/fixo gc` slash command.
|
|
192
|
+
*/
|
|
193
|
+
static garbageCollectAll(cwd: string, ttlMs?: number): number;
|
|
194
|
+
/**
|
|
195
|
+
* Discard every staged write for the given (cwd, runId) pair. Used
|
|
196
|
+
* when an agent is force-killed (e.g. loop-trap hard-abort) so the
|
|
197
|
+
* workspace is left in its pre-run state. Returns the number of
|
|
198
|
+
* entries removed.
|
|
199
|
+
*
|
|
200
|
+
* Best-effort: a failure to remove a single entry is logged and
|
|
201
|
+
* swallowed so the caller never sees an exception from cleanup.
|
|
202
|
+
*/
|
|
203
|
+
static rollbackAll(cwd: string, runId: string): number;
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=staging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staging.d.ts","sourceRoot":"","sources":["../../src/runtime/staging.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAWH,gDAAgD;AAChD,MAAM,WAAW,oBAAoB;IACnC,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC7D;;;;;;;;;;OAUG;IACH,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAClF;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,sEAAsE;AACtE,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,kDAAkD;IAClD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,qDAAqD;AACrD,MAAM,WAAW,YAAY;IAC3B,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,+BAA+B;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CA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