@hasna/projects
Version:
High-level project management CLI, MCP server, SDK, and AI SDK agent loop for coding agents
106 lines • 4.29 kB
TypeScript
import { type ConversationsChannelRunner } from "./project-channel.js";
import { type WorkspaceRuntimeAction } from "./workspace-runtime.js";
import type { GuardedProjectMutationReceipt, JsonObject, UpdateWorkspaceInput, Workspace } from "../types/workspace.js";
import type { CompleteProjectPopulation, ProjectStore } from "../store/project-store.js";
export declare const PROJECT_PREFIXES: readonly ["internal-iproj-", "iproj-"];
export declare const PROJECT_PREFIX_MIGRATION_EVENT = "project_prefix_migration_step";
export interface ConversationsChannelIdentity {
name: string;
project_id: string | null;
archived_at: string | null;
member_count: number;
message_count: number;
}
export interface CompleteChannelPopulation {
readonly channels: ConversationsChannelIdentity[];
readonly total: number;
readonly pages: number;
readonly complete: true;
}
export interface ConversationsPrefixPort {
listChannels(): Promise<CompleteChannelPopulation>;
renameChannel(input: {
current_name: string;
target_name: string;
/** Called immediately after the package reports the rename write succeeded, before readback. */
on_written: (channel: ConversationsChannelIdentity) => Promise<void> | void;
}): Promise<ConversationsChannelIdentity>;
}
export interface PrefixMigrationReceipt {
receipt_id: string;
operation_id: string;
step_id: string;
direction: "forward" | "inverse";
outcome: "accepted" | "duplicate_of_accepted" | "terminal_nonacceptance";
target_kind: "project" | "channel";
target_id: string;
before: JsonObject;
after: JsonObject | null;
reason: string | null;
created_at: string;
guarded_receipt_id?: string;
}
export interface PrefixMigrationStep {
step_id: string;
target_kind: "project" | "channel";
target_id: string;
project_id: string | null;
current_name: string;
target_name: string;
status: "planned" | "accepted" | "rolled_back" | "terminal_nonacceptance";
receipt: PrefixMigrationReceipt | GuardedProjectMutationReceipt | null;
marker: WorkspaceRuntimeAction | null;
}
export interface PrefixMigrationInventory {
projects: CompleteProjectPopulation;
channels: CompleteChannelPopulation;
project_candidates: number;
channel_candidates: number;
complete: true;
}
export interface PrefixMigrationResult {
ok: boolean;
dry_run: boolean;
operation_id: string;
inventory: PrefixMigrationInventory;
steps: PrefixMigrationStep[];
rollback: {
attempted: boolean;
complete: boolean;
receipts: Array<PrefixMigrationReceipt | GuardedProjectMutationReceipt>;
};
refusal: string | null;
}
export interface RunProjectPrefixMigrationOptions {
store: ProjectStore;
dry_run?: boolean;
operation_id?: string;
response_byte_limit?: number;
time_budget_ms?: number;
agent_id?: string;
command?: string;
conversations?: ConversationsPrefixPort;
write_marker?: (project: Workspace) => WorkspaceRuntimeAction;
/** Test-only failure injection; never exposed as a production CLI option. */
fail_step_id?: string;
}
export declare class PrefixMigrationError extends Error {
constructor(message: string);
}
export declare function stripProjectPrefix(name: string): {
name: string;
prefix: string | null;
};
/**
* The channel a project step would pin although that name is not a channel
* after the migration, or `null` when the pin is backed.
*
* Exported for its unit test: the apply path can only reach a non-null result
* if `validateAmbiguousLinks` — which refuses a pin naming no existing channel
* before any step is built — is ever relaxed, so the predicate is asserted
* directly rather than through a run that cannot produce the condition.
*/
export declare function unbackedProjectChannelPin(patch: UpdateWorkspaceInput, channelNamesAfterMigration: ReadonlySet<string>): string | null;
export declare function createConversationsPrefixPort(runner?: ConversationsChannelRunner): ConversationsPrefixPort;
export declare function runProjectPrefixMigration(options: RunProjectPrefixMigrationOptions): Promise<PrefixMigrationResult>;
//# sourceMappingURL=project-prefix-migration.d.ts.map