@aefree/pi-plastic 0.7.6 → 0.8.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/CHANGELOG.md +37 -0
- package/README.md +48 -174
- package/docs/2026-10-06-development.md +101 -0
- package/docs/2026-10-06-diffs-and-patches.md +136 -0
- package/docs/2026-10-06-discovery.md +135 -0
- package/docs/2026-10-06-integrations.md +49 -0
- package/docs/2026-10-06-merging.md +153 -0
- package/docs/2026-10-06-safety-and-receipts.md +95 -0
- package/docs/2026-10-06-setup.md +101 -0
- package/docs/2026-10-06-shelvesets-and-reviews.md +113 -0
- package/docs/2026-10-06-status.md +116 -0
- package/docs/2026-10-06-tools-and-loading.md +64 -0
- package/docs/2026-10-06-workspace-operations.md +142 -0
- package/docs/README.md +65 -0
- package/extensions/bash-cm-diff-guard.ts +1 -1
- package/index.ts +4 -687
- package/package.json +10 -4
- package/skills/using-plastic/SKILL.md +11 -5
- package/skills/using-plastic/references/branch-management.md +5 -1
- package/skills/using-plastic/references/changeset-operations.md +9 -8
- package/skills/using-plastic/references/code-review-creation.md +25 -18
- package/skills/using-plastic/references/integration.md +9 -5
- package/skills/using-plastic/references/quick-reference.md +4 -4
- package/skills/using-plastic/references/reviewing-changes.md +10 -10
- package/skills/using-plastic/references/shelving.md +26 -11
- package/skills/using-plastic/references/troubleshooting.md +4 -4
- package/src/diff/local-snapshot.ts +74 -0
- package/src/diff/text.ts +187 -0
- package/src/domain/add-contract.ts +24 -0
- package/src/domain/branch-create-contract.ts +38 -0
- package/src/domain/branch-delete-contract.ts +15 -0
- package/src/domain/branches.ts +263 -0
- package/src/domain/checkin-contract.ts +70 -0
- package/src/domain/closeout-contract.ts +30 -0
- package/src/domain/copied-merge.ts +42 -0
- package/src/domain/diff-base-xml.ts +65 -0
- package/src/domain/diff-pending-xml.ts +34 -0
- package/src/domain/merge-output.ts +327 -0
- package/src/domain/paths.ts +253 -0
- package/src/domain/pending.ts +499 -0
- package/src/domain/removal-contract.ts +25 -0
- package/src/domain/revisions.ts +301 -0
- package/src/domain/server-merge-contract.ts +45 -0
- package/src/domain/server-merge-resolutions.ts +61 -0
- package/src/domain/status-xml.ts +122 -0
- package/src/domain/switch-contract.ts +60 -0
- package/src/domain/switch-policy.ts +95 -0
- package/src/domain/undo-contract.ts +24 -0
- package/src/domain/update-contract.ts +16 -0
- package/src/domain/workspace-merge-contract.ts +41 -0
- package/src/execution/add-command.ts +118 -0
- package/src/execution/branch-create-command.ts +118 -0
- package/src/execution/branch-list-command.ts +75 -0
- package/src/execution/checkin-command.ts +116 -0
- package/src/execution/cli-version.ts +31 -0
- package/src/execution/cm.ts +59 -0
- package/src/execution/code-review-find-command.ts +75 -0
- package/src/execution/context.ts +20 -0
- package/src/execution/diff-revisions-command.ts +74 -0
- package/src/execution/process.ts +260 -0
- package/src/execution/removal-command.ts +118 -0
- package/src/execution/server-merge-command.ts +92 -0
- package/src/execution/shelveset-list-command.ts +75 -0
- package/src/execution/status-command.ts +29 -0
- package/src/execution/status-xml-command.ts +72 -0
- package/src/execution/status-xml-limits.ts +1 -0
- package/src/execution/switch-command.ts +118 -0
- package/src/execution/test-seams.ts +10 -0
- package/src/execution/undo-command.ts +118 -0
- package/src/execution/update-command.ts +118 -0
- package/src/execution/workspace-list-command.ts +75 -0
- package/src/execution/workspace-merge-command.ts +118 -0
- package/src/operations/add-receipt.ts +37 -0
- package/src/operations/arguments.ts +3 -0
- package/src/operations/branch-create.ts +74 -0
- package/src/operations/branch-delete-receipt.ts +25 -0
- package/src/operations/branch-list.ts +94 -0
- package/src/operations/branch-reads.ts +94 -0
- package/src/operations/branches.ts +111 -0
- package/src/operations/checkin-receipt.ts +140 -0
- package/src/operations/checkin.ts +102 -0
- package/src/operations/closeout-receipt.ts +74 -0
- package/src/operations/closeout.ts +19 -0
- package/src/operations/code-review-find.ts +97 -0
- package/src/operations/consolidated-diff.ts +144 -0
- package/src/operations/diff-revisions.ts +157 -0
- package/src/operations/diff.ts +53 -0
- package/src/operations/merge.ts +26 -0
- package/src/operations/object-delete-receipt.ts +21 -0
- package/src/operations/object-write-receipt.ts +105 -0
- package/src/operations/patch-receipt.ts +96 -0
- package/src/operations/patch-support.ts +375 -0
- package/src/operations/patch.ts +25 -0
- package/src/operations/removal-receipt.ts +42 -0
- package/src/operations/reviews.ts +90 -0
- package/src/operations/server-merge.ts +130 -0
- package/src/operations/shelveset-list.ts +90 -0
- package/src/operations/shelvesets.ts +90 -0
- package/src/operations/status.ts +129 -0
- package/src/operations/switch-receipt.ts +85 -0
- package/src/operations/switch.ts +25 -0
- package/src/operations/undo-receipt.ts +37 -0
- package/src/operations/update-receipt.ts +35 -0
- package/src/operations/workspace-list.ts +92 -0
- package/src/operations/workspace-merge-receipt.ts +50 -0
- package/src/operations/workspace.ts +120 -0
- package/src/pi/add-output.ts +52 -0
- package/src/pi/arguments.ts +298 -0
- package/src/pi/branch-create-output.ts +83 -0
- package/src/pi/branch-delete-output.ts +46 -0
- package/src/pi/branch-list-output.ts +59 -0
- package/src/pi/branch-output.ts +63 -0
- package/src/pi/capability-diagnostics.ts +23 -0
- package/src/pi/checkin-output.ts +68 -0
- package/src/pi/closeout-output.ts +87 -0
- package/src/pi/code-review-find-output.ts +50 -0
- package/src/pi/diff-output.ts +66 -0
- package/src/pi/diff-revisions-output.ts +55 -0
- package/src/pi/object-delete-output.ts +15 -0
- package/src/pi/object-write-output.ts +54 -0
- package/src/pi/patch-output.ts +69 -0
- package/src/pi/register.ts +188 -0
- package/src/pi/removal-output.ts +59 -0
- package/src/pi/schemas.ts +146 -0
- package/src/pi/server-merge-output.ts +83 -0
- package/src/pi/shelveset-list-output.ts +50 -0
- package/src/pi/status-output.ts +149 -0
- package/src/pi/switch-output.ts +80 -0
- package/src/pi/tool-registry.ts +72 -0
- package/src/pi/undo-output.ts +52 -0
- package/src/pi/update-output.ts +48 -0
- package/src/pi/workspace-list-output.ts +53 -0
- package/src/pi/workspace-merge-output.ts +46 -0
- package/src/plastic-core.ts +14 -5775
- package/src/plastic-renderers.ts +102 -22
- package/src/plastic-tool-loading.ts +7 -12
- package/src/presentation/add-results.ts +5 -0
- package/src/presentation/branch-create.ts +7 -0
- package/src/presentation/branch-delete-results.ts +7 -0
- package/src/presentation/checkin-results.ts +14 -0
- package/src/presentation/closeout-results.ts +2 -0
- package/src/presentation/diff-results.ts +237 -0
- package/src/presentation/removal-results.ts +7 -0
- package/src/presentation/results.ts +84 -0
- package/src/presentation/switch-results.ts +7 -0
- package/src/presentation/undo-results.ts +5 -0
- package/src/presentation/update-results.ts +5 -0
- package/src/presentation/workspace-merge-results.ts +6 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { tool } from "../tool-definition";
|
|
2
|
+
import { analyzeMergeStatusOutput } from "../domain/merge-output";
|
|
3
|
+
import { getCmVersion } from "../execution/cli-version";
|
|
4
|
+
|
|
5
|
+
export const formatStatusText = (output: string, mergeState: ReturnType<typeof analyzeMergeStatusOutput>): string =>
|
|
6
|
+
{
|
|
7
|
+
return mergeState.hasMergeInProgress || mergeState.hasPendingMergeLinks
|
|
8
|
+
? [
|
|
9
|
+
output,
|
|
10
|
+
"",
|
|
11
|
+
"## Merge State",
|
|
12
|
+
`- Pending merge links: ${mergeState.pendingMergeLinks.length}`,
|
|
13
|
+
`- Merge-in-progress hints: ${mergeState.mergeInProgressHints.length}`,
|
|
14
|
+
...(mergeState.hasMergeInProgress ? ["- Checkin may be blocked until merge metadata is finalized. If files are resolved, run plastic_finalizeMerge(...)."] : []),
|
|
15
|
+
].join("\n")
|
|
16
|
+
: output;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const TOOL_VERSION = "v2.0.0";
|
|
20
|
+
|
|
21
|
+
export type OutputFormat = "text" | "json";
|
|
22
|
+
|
|
23
|
+
export const outputFormatArg = tool.schema.enum(["text", "json"]).optional().describe("Output format. Defaults to text.");
|
|
24
|
+
|
|
25
|
+
export const formatPreflightText = (title: string, lines: string[]): string =>
|
|
26
|
+
{
|
|
27
|
+
return [title, "", ...lines].join("\n");
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const toStructuredResult = async (
|
|
31
|
+
action: string,
|
|
32
|
+
format: OutputFormat,
|
|
33
|
+
text: string,
|
|
34
|
+
data: Record<string, unknown>,
|
|
35
|
+
workdir?: string,
|
|
36
|
+
warnings?: string[],
|
|
37
|
+
nextSuggestedAction?: string,
|
|
38
|
+
): Promise<string> =>
|
|
39
|
+
{
|
|
40
|
+
if (format !== "json")
|
|
41
|
+
{
|
|
42
|
+
return text;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const payload: Record<string, unknown> = {
|
|
46
|
+
ok: true,
|
|
47
|
+
action,
|
|
48
|
+
toolVersion: TOOL_VERSION,
|
|
49
|
+
cliVersion: await getCmVersion(workdir),
|
|
50
|
+
data,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
if (warnings && warnings.length > 0)
|
|
54
|
+
{
|
|
55
|
+
payload.warnings = warnings;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (nextSuggestedAction)
|
|
59
|
+
{
|
|
60
|
+
payload.nextSuggestedAction = nextSuggestedAction;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return `## ${action}\n\n\`\`\`json\n${JSON.stringify(payload, null, 2)}\n\`\`\``;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const formatServerMergeResult = async (
|
|
67
|
+
format: OutputFormat,
|
|
68
|
+
outcome: "preflight" | "analyzed" | "completed" | "no-op" | "conflict" | "uncertain" | "unsupported" | "failed",
|
|
69
|
+
text: string,
|
|
70
|
+
data: Record<string, unknown>,
|
|
71
|
+
): Promise<string> =>
|
|
72
|
+
{
|
|
73
|
+
if (format === "text")
|
|
74
|
+
{
|
|
75
|
+
return text;
|
|
76
|
+
}
|
|
77
|
+
return `## merge-branches\n\n\`\`\`json\n${JSON.stringify({
|
|
78
|
+
ok: outcome === "completed" || outcome === "preflight" || outcome === "no-op",
|
|
79
|
+
action: "merge-branches",
|
|
80
|
+
outcome,
|
|
81
|
+
toolVersion: TOOL_VERSION,
|
|
82
|
+
data,
|
|
83
|
+
}, null, 2)}\n\`\`\``;
|
|
84
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SwitchReceipt } from "../domain/switch-contract";
|
|
2
|
+
export function presentSwitchReceipt(dto: SwitchReceipt, format: "text" | "json" = "text"): string {
|
|
3
|
+
const summary = dto.ok ? `Switch ${dto.outcome}. Strategy: ${dto.data.strategy}. Effect: ${dto.data.effect}.` : `Switch ${dto.outcome}. ${dto.error.message} Effect: ${dto.data.effect}.`;
|
|
4
|
+
if (format === "text") return summary;
|
|
5
|
+
// Core JSON compatibility is a view of the same observation, not a source for native data.
|
|
6
|
+
return "```json\n" + JSON.stringify({ action: "switch-branch", ok: dto.ok, outcome: dto.outcome, data: { strategy: dto.data.strategy, branchBefore: dto.data.branchBefore?.branch ?? null, branchAfter: dto.data.branchAfter?.branch ?? null, branchTarget: dto.data.requestedTarget, pendingSummaryDetailed: dto.data.pendingBefore, pendingPolicy: dto.data.pendingPolicy, defaultedPolicy: dto.data.defaultedPolicy, usedNoChangesShelveRecovery: dto.data.usedNoChangesShelveRecovery, effect: dto.data.effect, wouldRun: dto.data.wouldRun }, ...(!dto.ok ? {error:dto.error} : {}) }, null, 2) + "\n```";
|
|
7
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { UndoReceipt } from "../domain/undo-contract";
|
|
2
|
+
export function presentUndoReceipt(dto: UndoReceipt): string {
|
|
3
|
+
return dto.ok ? `Undo command completed for ${dto.data.requestedOperandCount} requested operands, not a verified undone-item count. Workspace identity, undone items, restored content, expanded scope and preservation remain unverified.` :
|
|
4
|
+
`Undo ${dto.outcome}: ${dto.error.message} Effects: ${dto.data.effect}. Do not retry automatically.`;
|
|
5
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { UpdateReceipt } from "../domain/update-contract";
|
|
2
|
+
export function presentUpdateReceipt(dto: UpdateReceipt): string {
|
|
3
|
+
return dto.ok ? "Update command completed. Workspace identity, changed items, preservation, cleanliness and merge readiness remain unverified." :
|
|
4
|
+
`Update ${dto.outcome}: ${dto.error.message} Effects: ${dto.data.effect}. Do not retry automatically.`;
|
|
5
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { WorkspaceMergeReceipt } from "../domain/workspace-merge-contract";
|
|
2
|
+
export function presentWorkspaceMergeReceipt(dto:WorkspaceMergeReceipt):string {
|
|
3
|
+
if(dto.data.outputFormatRequested==="json")return JSON.stringify(dto,null,2);
|
|
4
|
+
const title=dto.action==="merge"?"Workspace Merge":"Merge Finalization";
|
|
5
|
+
return dto.ok?dto.outcome==="preflight"?title+" command-only preview; no readiness analysis or command executed.\ncm "+dto.data.intendedArgv.join(" "):title+" command completed; admitted observations contain no unresolved signals. Conflict resolution/finalized metadata/preservation and complete affected scope remain unverified.":title+" "+dto.outcome+": "+dto.error.message+" Applying command completed: "+dto.data.commandCompleted+". No automatic retry, checkin, rollback or strategy change.";
|
|
6
|
+
}
|