perttool 0.6.0 → 0.7.1
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 +56 -1
- package/README.md +113 -33
- package/dist/application/advance-history.d.ts +2 -0
- package/dist/application/advance-history.d.ts.map +1 -1
- package/dist/application/advance-history.js +21 -12
- package/dist/application/advance-history.js.map +1 -1
- package/dist/application/contract7-assurance.d.ts +57 -0
- package/dist/application/contract7-assurance.d.ts.map +1 -0
- package/dist/application/contract7-assurance.js +248 -0
- package/dist/application/contract7-assurance.js.map +1 -0
- package/dist/application/contract7-mermaid.d.ts +9 -0
- package/dist/application/contract7-mermaid.d.ts.map +1 -0
- package/dist/application/contract7-mermaid.js +73 -0
- package/dist/application/contract7-mermaid.js.map +1 -0
- package/dist/application/contract7-mutation.d.ts +21 -0
- package/dist/application/contract7-mutation.d.ts.map +1 -0
- package/dist/application/contract7-mutation.js +181 -0
- package/dist/application/contract7-mutation.js.map +1 -0
- package/dist/application/contract7-project.d.ts +10 -0
- package/dist/application/contract7-project.d.ts.map +1 -0
- package/dist/application/contract7-project.js +29 -0
- package/dist/application/contract7-project.js.map +1 -0
- package/dist/application/contract7-projection.d.ts +9 -0
- package/dist/application/contract7-projection.d.ts.map +1 -0
- package/dist/application/contract7-projection.js +100 -0
- package/dist/application/contract7-projection.js.map +1 -0
- package/dist/application/contract7-source.d.ts +24 -0
- package/dist/application/contract7-source.d.ts.map +1 -0
- package/dist/application/contract7-source.js +54 -0
- package/dist/application/contract7-source.js.map +1 -0
- package/dist/application/contract7-unit-migration.d.ts +13 -0
- package/dist/application/contract7-unit-migration.d.ts.map +1 -0
- package/dist/application/contract7-unit-migration.js +13 -0
- package/dist/application/contract7-unit-migration.js.map +1 -0
- package/dist/application/init.d.ts +1 -1
- package/dist/application/init.js +3 -3
- package/dist/application/mutate.d.ts +5 -1
- package/dist/application/mutate.d.ts.map +1 -1
- package/dist/application/mutate.js +2 -2
- package/dist/application/mutate.js.map +1 -1
- package/dist/application/target-actuals-analysis.d.ts +5 -4
- package/dist/application/target-actuals-analysis.d.ts.map +1 -1
- package/dist/application/target-actuals-analysis.js +18 -11
- package/dist/application/target-actuals-analysis.js.map +1 -1
- package/dist/application/target-actuals-mutation.d.ts +5 -3
- package/dist/application/target-actuals-mutation.d.ts.map +1 -1
- package/dist/application/target-actuals-mutation.js +16 -8
- package/dist/application/target-actuals-mutation.js.map +1 -1
- package/dist/application/target-assurance-advance-history.d.ts +19 -0
- package/dist/application/target-assurance-advance-history.d.ts.map +1 -0
- package/dist/application/target-assurance-advance-history.js +61 -0
- package/dist/application/target-assurance-advance-history.js.map +1 -0
- package/dist/application/target-assurance-analysis.d.ts +34 -0
- package/dist/application/target-assurance-analysis.d.ts.map +1 -0
- package/dist/application/target-assurance-analysis.js +103 -0
- package/dist/application/target-assurance-analysis.js.map +1 -0
- package/dist/application/target-assurance-inspection.d.ts +38 -0
- package/dist/application/target-assurance-inspection.d.ts.map +1 -0
- package/dist/application/target-assurance-inspection.js +356 -0
- package/dist/application/target-assurance-inspection.js.map +1 -0
- package/dist/application/target-assurance-write.d.ts +22 -0
- package/dist/application/target-assurance-write.d.ts.map +1 -0
- package/dist/application/target-assurance-write.js +73 -0
- package/dist/application/target-assurance-write.js.map +1 -0
- package/dist/application/target-governance-init.d.ts +3 -3
- package/dist/application/target-governance-init.d.ts.map +1 -1
- package/dist/application/target-governance-init.js +14 -10
- package/dist/application/target-governance-init.js.map +1 -1
- package/dist/application/target-governance-project.d.ts +6 -4
- package/dist/application/target-governance-project.d.ts.map +1 -1
- package/dist/application/target-governance-project.js +18 -4
- package/dist/application/target-governance-project.js.map +1 -1
- package/dist/application/target-mutate.d.ts +7 -1
- package/dist/application/target-mutate.d.ts.map +1 -1
- package/dist/application/target-mutate.js +50 -3
- package/dist/application/target-mutate.js.map +1 -1
- package/dist/application/target-project-history.d.ts +4 -4
- package/dist/application/target-project-history.d.ts.map +1 -1
- package/dist/application/target-project-history.js +2 -2
- package/dist/application/target-project-history.js.map +1 -1
- package/dist/application/target-unit-migration-candidate.d.ts +29 -6
- package/dist/application/target-unit-migration-candidate.d.ts.map +1 -1
- package/dist/application/target-unit-migration-candidate.js +204 -3
- package/dist/application/target-unit-migration-candidate.js.map +1 -1
- package/dist/application/target-unit-migration-result.d.ts +2 -2
- package/dist/application/target-unit-migration-result.d.ts.map +1 -1
- package/dist/application/target-unit-migration-result.js +4 -2
- package/dist/application/target-unit-migration-result.js.map +1 -1
- package/dist/application/target-velocity-observation.d.ts +1 -1
- package/dist/application/target-velocity-observation.js +1 -1
- package/dist/assurance/advance.d.ts +45 -0
- package/dist/assurance/advance.d.ts.map +1 -0
- package/dist/assurance/advance.js +507 -0
- package/dist/assurance/advance.js.map +1 -0
- package/dist/assurance/authority.d.ts +86 -0
- package/dist/assurance/authority.d.ts.map +1 -0
- package/dist/assurance/authority.js +269 -0
- package/dist/assurance/authority.js.map +1 -0
- package/dist/assurance/canonical.d.ts +13 -0
- package/dist/assurance/canonical.d.ts.map +1 -0
- package/dist/assurance/canonical.js +320 -0
- package/dist/assurance/canonical.js.map +1 -0
- package/dist/assurance/compatibility.d.ts +62 -0
- package/dist/assurance/compatibility.d.ts.map +1 -0
- package/dist/assurance/compatibility.js +163 -0
- package/dist/assurance/compatibility.js.map +1 -0
- package/dist/assurance/evaluate.d.ts +4 -0
- package/dist/assurance/evaluate.d.ts.map +1 -0
- package/dist/assurance/evaluate.js +631 -0
- package/dist/assurance/evaluate.js.map +1 -0
- package/dist/assurance/governance.d.ts +42 -0
- package/dist/assurance/governance.d.ts.map +1 -0
- package/dist/assurance/governance.js +95 -0
- package/dist/assurance/governance.js.map +1 -0
- package/dist/assurance/mermaid.d.ts +40 -0
- package/dist/assurance/mermaid.d.ts.map +1 -0
- package/dist/assurance/mermaid.js +401 -0
- package/dist/assurance/mermaid.js.map +1 -0
- package/dist/assurance/mutation.d.ts +96 -0
- package/dist/assurance/mutation.d.ts.map +1 -0
- package/dist/assurance/mutation.js +757 -0
- package/dist/assurance/mutation.js.map +1 -0
- package/dist/assurance/source.d.ts +20 -0
- package/dist/assurance/source.d.ts.map +1 -0
- package/dist/assurance/source.js +313 -0
- package/dist/assurance/source.js.map +1 -0
- package/dist/assurance/types.d.ts +166 -0
- package/dist/assurance/types.d.ts.map +1 -0
- package/dist/assurance/types.js +3 -0
- package/dist/assurance/types.js.map +1 -0
- package/dist/cli.js +356 -60
- package/dist/cli.js.map +1 -1
- package/dist/command/assurance-discovery.d.ts +17 -0
- package/dist/command/assurance-discovery.d.ts.map +1 -0
- package/dist/command/assurance-discovery.js +297 -0
- package/dist/command/assurance-discovery.js.map +1 -0
- package/dist/command/assurance-usage.d.ts +20 -0
- package/dist/command/assurance-usage.d.ts.map +1 -0
- package/dist/command/assurance-usage.js +66 -0
- package/dist/command/assurance-usage.js.map +1 -0
- package/dist/conversion/mermaid.d.ts +2 -1
- package/dist/conversion/mermaid.d.ts.map +1 -1
- package/dist/conversion/mermaid.js +2 -2
- package/dist/conversion/mermaid.js.map +1 -1
- package/dist/formatter/source-formatter.d.ts +1 -1
- package/dist/formatter/source-formatter.d.ts.map +1 -1
- package/dist/formatter/source-formatter.js +56 -4
- package/dist/formatter/source-formatter.js.map +1 -1
- package/dist/formatter/target-source-formatter.d.ts +2 -1
- package/dist/formatter/target-source-formatter.d.ts.map +1 -1
- package/dist/formatter/target-source-formatter.js +18 -2
- package/dist/formatter/target-source-formatter.js.map +1 -1
- package/dist/help/assurance-guide.d.ts +10 -0
- package/dist/help/assurance-guide.d.ts.map +1 -0
- package/dist/help/assurance-guide.js +227 -0
- package/dist/help/assurance-guide.js.map +1 -0
- package/dist/help/guide.d.ts +1 -1
- package/dist/help/guide.d.ts.map +1 -1
- package/dist/history/advance-history.d.ts +4 -2
- package/dist/history/advance-history.d.ts.map +1 -1
- package/dist/history/advance-history.js +47 -1
- package/dist/history/advance-history.js.map +1 -1
- package/dist/history/project-history.d.ts +14 -5
- package/dist/history/project-history.d.ts.map +1 -1
- package/dist/history/project-history.js +27 -20
- package/dist/history/project-history.js.map +1 -1
- package/dist/history/velocity-observation.js +1 -1
- package/dist/history/velocity-observation.js.map +1 -1
- package/dist/index.d.ts +31 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -15
- package/dist/index.js.map +1 -1
- package/dist/io/target-safe-write.d.ts +4 -1
- package/dist/io/target-safe-write.d.ts.map +1 -1
- package/dist/io/target-safe-write.js +19 -1
- package/dist/io/target-safe-write.js.map +1 -1
- package/dist/migration/grammar-boundary.d.ts +1 -1
- package/dist/migration/grammar-boundary.d.ts.map +1 -1
- package/dist/migration/grammar-boundary.js +7 -3
- package/dist/migration/grammar-boundary.js.map +1 -1
- package/dist/model/declaration-fields.d.ts +12 -0
- package/dist/model/declaration-fields.d.ts.map +1 -1
- package/dist/model/declaration-fields.js +45 -0
- package/dist/model/declaration-fields.js.map +1 -1
- package/dist/model/syntax.d.ts +17 -1
- package/dist/model/syntax.d.ts.map +1 -1
- package/dist/model/syntax.js.map +1 -1
- package/dist/mutation/actuals.js +1 -1
- package/dist/mutation/actuals.js.map +1 -1
- package/dist/mutation/advance.d.ts +18 -1
- package/dist/mutation/advance.d.ts.map +1 -1
- package/dist/mutation/advance.js +20 -0
- package/dist/mutation/advance.js.map +1 -1
- package/dist/mutation/project.d.ts +2 -1
- package/dist/mutation/project.d.ts.map +1 -1
- package/dist/mutation/project.js +21 -0
- package/dist/mutation/project.js.map +1 -1
- package/dist/parser/document-parser.d.ts +7 -0
- package/dist/parser/document-parser.d.ts.map +1 -1
- package/dist/parser/document-parser.js +227 -12
- package/dist/parser/document-parser.js.map +1 -1
- package/dist/recommendation/override-types.d.ts +2 -2
- package/dist/recommendation/override.d.ts +2 -2
- package/dist/recommendation/override.d.ts.map +1 -1
- package/dist/recommendation/override.js +13 -5
- package/dist/recommendation/override.js.map +1 -1
- package/dist/schema/registry.d.ts +1 -1
- package/dist/schema/registry.d.ts.map +1 -1
- package/dist/schema/registry.js +8 -7
- package/dist/schema/registry.js.map +1 -1
- package/dist/semantic/target-validator.d.ts +12 -1
- package/dist/semantic/target-validator.d.ts.map +1 -1
- package/dist/semantic/target-validator.js +47 -2
- package/dist/semantic/target-validator.js.map +1 -1
- package/dist/semantic/validator.d.ts +1 -0
- package/dist/semantic/validator.d.ts.map +1 -1
- package/dist/semantic/validator.js +304 -0
- package/dist/semantic/validator.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schemas/{Perttool.AdvanceResult.v1.schema.json → Perttool.AdvanceResult.v2.schema.json} +85 -5
- package/schemas/Perttool.AgentGuidanceResult.v1.schema.json +1 -1
- package/schemas/{Perttool.AnalysisResult.v4.schema.json → Perttool.AnalysisResult.v5.schema.json} +10 -6
- package/schemas/{Perttool.CheckResult.v3.schema.json → Perttool.CheckResult.v4.schema.json} +14 -6
- package/schemas/Perttool.CliError.v1.schema.json +1 -1
- package/schemas/Perttool.CommandHelpResult.v1.schema.json +2 -2
- package/schemas/Perttool.Common.v1.schema.json +300 -4
- package/schemas/Perttool.ExportResult.v1.schema.json +1 -1
- package/schemas/Perttool.FormatResult.v1.schema.json +1 -1
- package/schemas/Perttool.GuideResult.v1.schema.json +1 -1
- package/schemas/Perttool.ImportResult.v1.schema.json +1 -1
- package/schemas/Perttool.InitResult.v1.schema.json +1 -1
- package/schemas/{Perttool.MutationResult.v3.schema.json → Perttool.MutationResult.v4.schema.json} +16 -5
- package/schemas/{Perttool.NextResult.v5.schema.json → Perttool.NextResult.v6.schema.json} +53 -8
- package/schemas/Perttool.OverrideDecision.v1.schema.json +1 -1
- package/schemas/Perttool.PlanAssuranceResult.v1.schema.json +77 -0
- package/schemas/Perttool.ProjectHistoryResult.v1.schema.json +1 -1
- package/schemas/{Perttool.ProjectResult.v3.schema.json → Perttool.ProjectResult.v4.schema.json} +15 -7
- package/schemas/Perttool.SchemaResult.v1.schema.json +1 -1
- package/schemas/Perttool.UnitMigrationResult.v3.schema.json +5 -3
- package/schemas/Perttool.VelocityObservationResult.v1.schema.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2,37 +2,42 @@
|
|
|
2
2
|
import { lstat, readFile } from "node:fs/promises";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { TextDecoder } from "node:util";
|
|
5
|
-
import { analyzeDocument, selectNextTasks, } from "./application/
|
|
6
|
-
import {
|
|
7
|
-
import { planFormat } from "./application/format.js";
|
|
5
|
+
import { analyzeDocument, checkDocument, selectNextTasks, } from "./application/contract7-assurance.js";
|
|
6
|
+
import { planFormat, } from "./application/contract7-source.js";
|
|
8
7
|
import { planProjectInit, projectInitResultToJson, renderProjectInitResult, withProjectInitOutput, } from "./application/init.js";
|
|
9
|
-
import { planUnitMigration, withUnitMigrationWrite, } from "./application/unit-migration.js";
|
|
10
|
-
import { getProjectMetadata, } from "./application/project.js";
|
|
11
|
-
import { planAdvance, planBatchMutation, planFinishActuals, planLifecycle, planMutation, } from "./application/
|
|
12
|
-
import { renderTargetGovernanceDecision,
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
8
|
+
import { planUnitMigration, withUnitMigrationWrite, } from "./application/contract7-unit-migration.js";
|
|
9
|
+
import { getProjectMetadata, } from "./application/contract7-project.js";
|
|
10
|
+
import { planAdvance, planBatchMutation, planFinishActuals, planLifecycle, planMutation, planAssuranceMutation, } from "./application/contract7-mutation.js";
|
|
11
|
+
import { renderTargetGovernanceDecision, } from "./application/target-governance-projection.js";
|
|
12
|
+
import { contract7InspectionResultToJson, contract7MutationResultToJson, contract7SnakeJson, } from "./application/contract7-projection.js";
|
|
13
|
+
import { contract7ProjectResultToJson, renderContract7ProjectText, } from "./application/contract7-project.js";
|
|
14
|
+
import { contract6WorkEventToJson, } from "./application/contract6-projection.js";
|
|
15
|
+
import { renderAdvanceHistoryGuard, } from "./application/advance-history.js";
|
|
16
|
+
import { prepareTargetPlanAssuranceAdvanceHistory, withTargetPlanAssuranceAdvanceHistoryRace, } from "./application/target-assurance-advance-history.js";
|
|
17
|
+
import { persistTargetPlanAssuranceResult, } from "./application/target-assurance-write.js";
|
|
18
|
+
import { inspectTargetPlanAssurance, } from "./application/target-assurance-inspection.js";
|
|
16
19
|
import { inspectTargetProjectHistoryFile, renderTargetProjectHistoryText, targetProjectHistoryResultToJson, } from "./application/target-project-history.js";
|
|
17
20
|
import { observeTargetProjectVelocity, renderTargetVelocityObservationText, targetVelocityObservationResultToJson, } from "./application/target-velocity-observation.js";
|
|
18
21
|
import { getAgentHelp } from "./application/agent-help.js";
|
|
19
22
|
import { exportMermaid, } from "./conversion/mermaid.js";
|
|
20
23
|
import { importMermaid } from "./conversion/mermaid-import.js";
|
|
21
|
-
import {
|
|
24
|
+
import { getAssuranceGuide, renderAssuranceGuideResult, serializeAssuranceGuideResult, } from "./help/assurance-guide.js";
|
|
22
25
|
import { commandOptionSets, } from "./command/registry.js";
|
|
23
|
-
import {
|
|
26
|
+
import { ASSURANCE_COMMAND_REGISTRY, getAssuranceCommandDiscovery, renderAssuranceCommandHelpResult, serializeAssuranceCommandHelpResult, } from "./command/assurance-discovery.js";
|
|
24
27
|
import { handlerCommandUsageError, } from "./command/usage.js";
|
|
25
|
-
import {
|
|
28
|
+
import { renderAssuranceCommandUsageError, serializeAssuranceCommandUsageError, validateAssuranceCommandInvocation, } from "./command/assurance-usage.js";
|
|
26
29
|
import { agentGuidanceResultToJson } from "./guidance/projection.js";
|
|
27
30
|
import { agentGuidanceExitCode, renderAgentGuidanceText, } from "./guidance/text.js";
|
|
28
31
|
import { documentContentFromBytes, readDocumentFile, } from "./io/document-file.js";
|
|
29
32
|
import { recheckAdvanceHistoryBaseline, } from "./history/git-probe.js";
|
|
30
|
-
import { createArtifactFile,
|
|
33
|
+
import { createArtifactFile, SafeWriteConflictError, SafeWriteVerificationError, } from "./io/safe-write.js";
|
|
31
34
|
import { formatDecimal } from "./model/rational.js";
|
|
32
35
|
import { convertWithVelocity, durationSuffix } from "./model/units.js";
|
|
33
36
|
import { recommendationInvariantExitCode } from "./recommendation/failure.js";
|
|
34
37
|
import { recommendationAnalysisToJson } from "./recommendation/json.js";
|
|
35
|
-
import {
|
|
38
|
+
import { TARGET_GRAMMAR_6_CAPABILITY, } from "./parser/document-parser.js";
|
|
39
|
+
import { createTargetGrammar6DocumentFile, replaceTargetGrammar6DocumentFile, } from "./io/target-safe-write.js";
|
|
40
|
+
import { exportPlanAssuranceMermaid, importPlanAssuranceMermaid, } from "./assurance/mermaid.js";
|
|
36
41
|
import { getJsonSchemaResult, renderJsonSchemaResult, serializeJsonSchemaResult, } from "./schema/registry.js";
|
|
37
42
|
import { TOOL_VERSION } from "./version.js";
|
|
38
43
|
class UsageError extends Error {
|
|
@@ -88,7 +93,7 @@ function parseOptions(args, valueOptions, flagOptions, repeatableOptions = new S
|
|
|
88
93
|
return { positionals, values, repeatedValues, flags };
|
|
89
94
|
}
|
|
90
95
|
function parseCommandOptions(operation, args) {
|
|
91
|
-
const descriptor =
|
|
96
|
+
const descriptor = ASSURANCE_COMMAND_REGISTRY.find((candidate) => candidate.operation === operation);
|
|
92
97
|
if (descriptor === undefined) {
|
|
93
98
|
throw new Error(`command descriptor is missing for ${operation}`);
|
|
94
99
|
}
|
|
@@ -243,7 +248,7 @@ function cliError(error, exitCode, operation, json) {
|
|
|
243
248
|
if (json) {
|
|
244
249
|
writeJson({
|
|
245
250
|
schema_version: "Perttool.CliError.v1",
|
|
246
|
-
cli_contract_version:
|
|
251
|
+
cli_contract_version: 7,
|
|
247
252
|
tool_version: TOOL_VERSION,
|
|
248
253
|
operation,
|
|
249
254
|
ok: false,
|
|
@@ -279,7 +284,7 @@ async function runCheck(args) {
|
|
|
279
284
|
if (format === "json") {
|
|
280
285
|
writeJson({
|
|
281
286
|
schema_version: result.schemaVersion,
|
|
282
|
-
cli_contract_version:
|
|
287
|
+
cli_contract_version: 7,
|
|
283
288
|
tool_version: TOOL_VERSION,
|
|
284
289
|
operation: "document.check",
|
|
285
290
|
ok,
|
|
@@ -297,6 +302,8 @@ async function runCheck(args) {
|
|
|
297
302
|
model_version: result.actualsInputs.modelVersion,
|
|
298
303
|
events: result.actualsInputs.events.map(contract6WorkEventToJson),
|
|
299
304
|
},
|
|
305
|
+
assurance: contract7SnakeJson(result.assurance),
|
|
306
|
+
assurance_state_counts: contract7SnakeJson(result.assuranceStateCounts),
|
|
300
307
|
});
|
|
301
308
|
}
|
|
302
309
|
else {
|
|
@@ -335,11 +342,11 @@ async function runProjectShow(args) {
|
|
|
335
342
|
result.diagnostics.some((diagnostic) => diagnostic.severity === "warning"));
|
|
336
343
|
const ok = result.ok && !warningFailure;
|
|
337
344
|
if (format === "json") {
|
|
338
|
-
writeJson(
|
|
345
|
+
writeJson(contract7ProjectResultToJson(result, source, input.digest, ok));
|
|
339
346
|
}
|
|
340
347
|
else {
|
|
341
348
|
if (ok && result.project !== null) {
|
|
342
|
-
process.stdout.write(
|
|
349
|
+
process.stdout.write(renderContract7ProjectText(result.project));
|
|
343
350
|
}
|
|
344
351
|
for (const diagnostic of result.diagnostics) {
|
|
345
352
|
process.stderr.write(`${renderDiagnostic(diagnostic, source, color)}\n`);
|
|
@@ -396,7 +403,7 @@ async function runProjectInit(args) {
|
|
|
396
403
|
const output = parsed.values.get("out");
|
|
397
404
|
if (result.ok && output !== undefined) {
|
|
398
405
|
try {
|
|
399
|
-
writeResult = await
|
|
406
|
+
writeResult = await createTargetGrammar6DocumentFile(output, result.candidateText, TARGET_GRAMMAR_6_CAPABILITY);
|
|
400
407
|
result = withProjectInitOutput(result, writeResult);
|
|
401
408
|
}
|
|
402
409
|
catch (error) {
|
|
@@ -513,7 +520,7 @@ async function persistGovernedResult(result, request, sourceOperand) {
|
|
|
513
520
|
written: false,
|
|
514
521
|
});
|
|
515
522
|
}
|
|
516
|
-
return
|
|
523
|
+
return persistTargetPlanAssuranceResult(result, TARGET_GRAMMAR_6_CAPABILITY, request.mode === "in_place"
|
|
517
524
|
? {
|
|
518
525
|
mode: "in_place",
|
|
519
526
|
target: request.target,
|
|
@@ -539,13 +546,13 @@ async function commitCandidate(request, candidateText, initialDigest) {
|
|
|
539
546
|
throw new SafeWriteVerificationError("invalid_candidate", "successful editing result has no candidate text");
|
|
540
547
|
}
|
|
541
548
|
return request.mode === "in_place"
|
|
542
|
-
?
|
|
549
|
+
? replaceTargetGrammar6DocumentFile(request.target, candidateText, TARGET_GRAMMAR_6_CAPABILITY, {
|
|
543
550
|
initialDigest,
|
|
544
551
|
...(request.expectedDigest === undefined
|
|
545
552
|
? {}
|
|
546
553
|
: { expectedDigest: request.expectedDigest }),
|
|
547
554
|
})
|
|
548
|
-
:
|
|
555
|
+
: createTargetGrammar6DocumentFile(request.target, candidateText, TARGET_GRAMMAR_6_CAPABILITY);
|
|
549
556
|
}
|
|
550
557
|
function writeFailureExit(error, operation, json) {
|
|
551
558
|
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
@@ -605,7 +612,7 @@ async function runFormat(args) {
|
|
|
605
612
|
if (format === "json") {
|
|
606
613
|
writeJson({
|
|
607
614
|
schema_version: "Perttool.FormatResult.v1",
|
|
608
|
-
cli_contract_version:
|
|
615
|
+
cli_contract_version: 7,
|
|
609
616
|
tool_version: TOOL_VERSION,
|
|
610
617
|
operation: "document.format",
|
|
611
618
|
ok,
|
|
@@ -1214,7 +1221,7 @@ async function runMutation(resource, action, args) {
|
|
|
1214
1221
|
}
|
|
1215
1222
|
}
|
|
1216
1223
|
if (format === "json") {
|
|
1217
|
-
writeJson(
|
|
1224
|
+
writeJson(contract7MutationResultToJson(ok ? result : Object.freeze({ ...result, ok: false }), operation, source, writeResult));
|
|
1218
1225
|
}
|
|
1219
1226
|
else {
|
|
1220
1227
|
if (ok) {
|
|
@@ -1297,7 +1304,7 @@ async function runLifecycleMutation(action, args) {
|
|
|
1297
1304
|
}
|
|
1298
1305
|
}
|
|
1299
1306
|
if (format === "json") {
|
|
1300
|
-
writeJson(
|
|
1307
|
+
writeJson(contract7MutationResultToJson(ok ? result : Object.freeze({ ...result, ok: false }), operation, source, writeResult));
|
|
1301
1308
|
}
|
|
1302
1309
|
else {
|
|
1303
1310
|
if (ok) {
|
|
@@ -1336,7 +1343,7 @@ function unitMigrationJson(result, source, sourceDigest, ok) {
|
|
|
1336
1343
|
});
|
|
1337
1344
|
return {
|
|
1338
1345
|
schema_version: result.schemaVersion,
|
|
1339
|
-
cli_contract_version:
|
|
1346
|
+
cli_contract_version: 7,
|
|
1340
1347
|
tool_version: TOOL_VERSION,
|
|
1341
1348
|
operation: "project.migrate-unit",
|
|
1342
1349
|
ok,
|
|
@@ -1481,7 +1488,7 @@ async function readHistoryForCommand(operation, parsed, format) {
|
|
|
1481
1488
|
...(parsed.repeatedValues.get("task") === undefined
|
|
1482
1489
|
? {}
|
|
1483
1490
|
: { taskIds: parsed.repeatedValues.get("task") }),
|
|
1484
|
-
},
|
|
1491
|
+
}, TARGET_GRAMMAR_6_CAPABILITY);
|
|
1485
1492
|
}
|
|
1486
1493
|
catch (error) {
|
|
1487
1494
|
return error instanceof Error ? error : new Error(String(error));
|
|
@@ -1552,6 +1559,15 @@ function renderAdvanceSummary(details) {
|
|
|
1552
1559
|
"",
|
|
1553
1560
|
].join("\n");
|
|
1554
1561
|
}
|
|
1562
|
+
function renderAssuranceGuard(guard) {
|
|
1563
|
+
const list = (values) => values.join(",") || "-";
|
|
1564
|
+
return [
|
|
1565
|
+
`ASSURANCE_GUARD status=${guard.status} cause=${guard.cause}`,
|
|
1566
|
+
`ASSURANCE_GUARD crossing_producers=${list(guard.crossingProducerTaskIds)} created_receipts=${list(guard.createdReceiptIds)} updated_receipts=${list(guard.updatedReceiptIds)} removed_receipts=${list(guard.removedReceiptIds)}`,
|
|
1567
|
+
...guard.retainedBasisChecks.map((check) => `ASSURANCE_BASIS task=${check.taskId} before=${check.beforeBasisHash ?? "-"} after=${check.afterBasisHash ?? "-"} equal=${check.equal}`),
|
|
1568
|
+
"",
|
|
1569
|
+
].join("\n");
|
|
1570
|
+
}
|
|
1555
1571
|
async function runAdvance(args) {
|
|
1556
1572
|
const parsed = parseCommandOptions("dag.advance", args);
|
|
1557
1573
|
if (parsed.positionals.length !== 1) {
|
|
@@ -1583,7 +1599,7 @@ async function runAdvance(args) {
|
|
|
1583
1599
|
const initialWarningFailure = parsed.flags.has("warnings-as-errors") &&
|
|
1584
1600
|
(planned.diagnosticsTruncated ||
|
|
1585
1601
|
planned.diagnostics.some((diagnostic) => diagnostic.severity === "warning"));
|
|
1586
|
-
const prepared = await
|
|
1602
|
+
const prepared = await prepareTargetPlanAssuranceAdvanceHistory(input.text, planned, TARGET_GRAMMAR_6_CAPABILITY, {
|
|
1587
1603
|
mode: writeRequest.mode === "out"
|
|
1588
1604
|
? "out"
|
|
1589
1605
|
: writeRequest.mode,
|
|
@@ -1617,7 +1633,7 @@ async function runAdvance(args) {
|
|
|
1617
1633
|
result.historyGuard?.status === "forced")) {
|
|
1618
1634
|
const recheck = await recheckAdvanceHistoryBaseline(prepared.baseline, sourceOperand);
|
|
1619
1635
|
if (!recheck.ok) {
|
|
1620
|
-
result =
|
|
1636
|
+
result = withTargetPlanAssuranceAdvanceHistoryRace(result, recheck, maxDiagnostics);
|
|
1621
1637
|
ok = false;
|
|
1622
1638
|
historyRace = true;
|
|
1623
1639
|
}
|
|
@@ -1631,7 +1647,7 @@ async function runAdvance(args) {
|
|
|
1631
1647
|
}
|
|
1632
1648
|
}
|
|
1633
1649
|
if (format === "json") {
|
|
1634
|
-
writeJson(
|
|
1650
|
+
writeJson(contract7MutationResultToJson(ok ? result : Object.freeze({ ...result, ok: false }), "dag.advance", source, writeResult));
|
|
1635
1651
|
}
|
|
1636
1652
|
else {
|
|
1637
1653
|
if (result.advance !== null) {
|
|
@@ -1655,6 +1671,9 @@ async function runAdvance(args) {
|
|
|
1655
1671
|
if (result.historyGuard !== null) {
|
|
1656
1672
|
process.stderr.write(renderAdvanceHistoryGuard(result.historyGuard));
|
|
1657
1673
|
}
|
|
1674
|
+
if (result.assuranceGuard !== null) {
|
|
1675
|
+
process.stderr.write(renderAssuranceGuard(result.assuranceGuard));
|
|
1676
|
+
}
|
|
1658
1677
|
if (result.governance !== null) {
|
|
1659
1678
|
process.stderr.write(renderTargetGovernanceDecision(result.governance));
|
|
1660
1679
|
}
|
|
@@ -1988,8 +2007,8 @@ async function runAnalyze(args) {
|
|
|
1988
2007
|
const ok = result.ok && !warningFailure;
|
|
1989
2008
|
if (format === "json") {
|
|
1990
2009
|
writeJson({
|
|
1991
|
-
schema_version:
|
|
1992
|
-
cli_contract_version:
|
|
2010
|
+
schema_version: result.schemaVersion,
|
|
2011
|
+
cli_contract_version: 7,
|
|
1993
2012
|
tool_version: TOOL_VERSION,
|
|
1994
2013
|
operation: "dag.analyze",
|
|
1995
2014
|
ok,
|
|
@@ -2021,6 +2040,7 @@ async function runAnalyze(args) {
|
|
|
2021
2040
|
? null
|
|
2022
2041
|
: resourceJson(result.resource, result.durationUnit, result.precision),
|
|
2023
2042
|
temporal: snakeJson(result.temporal),
|
|
2043
|
+
assurance: contract7SnakeJson(result.assurance),
|
|
2024
2044
|
});
|
|
2025
2045
|
}
|
|
2026
2046
|
else {
|
|
@@ -2083,12 +2103,39 @@ async function runRender(args) {
|
|
|
2083
2103
|
catch (error) {
|
|
2084
2104
|
return cliError(error instanceof Error ? error : new Error(String(error)), 3, "dag.render", format === "json");
|
|
2085
2105
|
}
|
|
2086
|
-
const
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2106
|
+
const sourceCheck = checkDocument(input.text, { maxDiagnostics });
|
|
2107
|
+
const grammar6 = sourceCheck.grammarVersion === 6;
|
|
2108
|
+
const assuranceExport = grammar6
|
|
2109
|
+
? exportPlanAssuranceMermaid(input.text, TARGET_GRAMMAR_6_CAPABILITY, {
|
|
2110
|
+
profile: profile === "perttool" ? 2 : "plain",
|
|
2111
|
+
allowLoss: !parsed.flags.has("strict-loss"),
|
|
2112
|
+
analysis,
|
|
2113
|
+
capacityOverrides: overrides,
|
|
2114
|
+
maxDiagnostics,
|
|
2115
|
+
})
|
|
2116
|
+
: null;
|
|
2117
|
+
const legacyExport = grammar6
|
|
2118
|
+
? null
|
|
2119
|
+
: exportMermaid(input.text, {
|
|
2120
|
+
profile,
|
|
2121
|
+
analysis,
|
|
2122
|
+
capacityOverrides: overrides,
|
|
2123
|
+
maxDiagnostics,
|
|
2124
|
+
});
|
|
2125
|
+
const result = assuranceExport === null
|
|
2126
|
+
? legacyExport
|
|
2127
|
+
: Object.freeze({
|
|
2128
|
+
ok: assuranceExport.ok,
|
|
2129
|
+
documentId: assuranceExport.documentId,
|
|
2130
|
+
diagnostics: assuranceExport.diagnostics,
|
|
2131
|
+
diagnosticsTruncated: assuranceExport.diagnosticsTruncated,
|
|
2132
|
+
profile,
|
|
2133
|
+
analysis,
|
|
2134
|
+
capacityOverrides: overrides,
|
|
2135
|
+
artifact: assuranceExport.artifact,
|
|
2136
|
+
artifactDigest: assuranceExport.artifactDigest,
|
|
2137
|
+
lossReport: assuranceExport.lossReport,
|
|
2138
|
+
});
|
|
2092
2139
|
const warningFailure = parsed.flags.has("warnings-as-errors") &&
|
|
2093
2140
|
(result.diagnosticsTruncated ||
|
|
2094
2141
|
result.diagnostics.some((diagnostic) => diagnostic.severity === "warning"));
|
|
@@ -2108,7 +2155,7 @@ async function runRender(args) {
|
|
|
2108
2155
|
if (format === "json") {
|
|
2109
2156
|
writeJson({
|
|
2110
2157
|
schema_version: "Perttool.ExportResult.v1",
|
|
2111
|
-
cli_contract_version:
|
|
2158
|
+
cli_contract_version: 7,
|
|
2112
2159
|
tool_version: TOOL_VERSION,
|
|
2113
2160
|
operation: "dag.render",
|
|
2114
2161
|
ok,
|
|
@@ -2180,7 +2227,28 @@ async function runImport(args) {
|
|
|
2180
2227
|
catch (error) {
|
|
2181
2228
|
return cliError(error instanceof Error ? error : new Error(String(error)), 3, "dag.import", format === "json");
|
|
2182
2229
|
}
|
|
2183
|
-
const
|
|
2230
|
+
const profile2 = input.text.startsWith("flowchart LR\n %% perttool:profile {\"schema_version\":\"Perttool.MermaidProfile.v2\"");
|
|
2231
|
+
const assuranceImport = profile2
|
|
2232
|
+
? importPlanAssuranceMermaid(input.text, TARGET_GRAMMAR_6_CAPABILITY)
|
|
2233
|
+
: null;
|
|
2234
|
+
const legacyImport = profile2
|
|
2235
|
+
? null
|
|
2236
|
+
: importMermaid(input.text, { maxDiagnostics });
|
|
2237
|
+
const result = assuranceImport === null
|
|
2238
|
+
? legacyImport
|
|
2239
|
+
: Object.freeze({
|
|
2240
|
+
ok: assuranceImport.ok,
|
|
2241
|
+
documentId: assuranceImport.documentId,
|
|
2242
|
+
diagnostics: assuranceImport.diagnostics,
|
|
2243
|
+
diagnosticsTruncated: assuranceImport.diagnosticsTruncated,
|
|
2244
|
+
profile: "perttool",
|
|
2245
|
+
analysis: assuranceImport.analysis,
|
|
2246
|
+
capacityOverrides: assuranceImport.capacityOverrides,
|
|
2247
|
+
artifact: assuranceImport.sourceText,
|
|
2248
|
+
artifactDigest: assuranceImport.sourceDigest,
|
|
2249
|
+
lossReport: assuranceImport.lossReport,
|
|
2250
|
+
generatedIds: Object.freeze([]),
|
|
2251
|
+
});
|
|
2184
2252
|
const warningFailure = parsed.flags.has("warnings-as-errors") &&
|
|
2185
2253
|
(result.diagnosticsTruncated ||
|
|
2186
2254
|
result.diagnostics.some((diagnostic) => diagnostic.severity === "warning"));
|
|
@@ -2191,7 +2259,7 @@ async function runImport(args) {
|
|
|
2191
2259
|
let writeResult = null;
|
|
2192
2260
|
if (ok && out !== null) {
|
|
2193
2261
|
try {
|
|
2194
|
-
writeResult = await
|
|
2262
|
+
writeResult = await createTargetGrammar6DocumentFile(out, result.artifact, TARGET_GRAMMAR_6_CAPABILITY);
|
|
2195
2263
|
}
|
|
2196
2264
|
catch (error) {
|
|
2197
2265
|
return writeFailureExit(error, "dag.import", format === "json");
|
|
@@ -2200,7 +2268,7 @@ async function runImport(args) {
|
|
|
2200
2268
|
if (format === "json") {
|
|
2201
2269
|
writeJson({
|
|
2202
2270
|
schema_version: "Perttool.ImportResult.v1",
|
|
2203
|
-
cli_contract_version:
|
|
2271
|
+
cli_contract_version: 7,
|
|
2204
2272
|
tool_version: TOOL_VERSION,
|
|
2205
2273
|
operation: "dag.import",
|
|
2206
2274
|
ok,
|
|
@@ -2509,7 +2577,7 @@ async function runNext(args) {
|
|
|
2509
2577
|
if (format === "json") {
|
|
2510
2578
|
writeJson({
|
|
2511
2579
|
schema_version: "Perttool.CliError.v1",
|
|
2512
|
-
cli_contract_version:
|
|
2580
|
+
cli_contract_version: 7,
|
|
2513
2581
|
tool_version: TOOL_VERSION,
|
|
2514
2582
|
operation: "dag.next",
|
|
2515
2583
|
ok: false,
|
|
@@ -2529,8 +2597,8 @@ async function runNext(args) {
|
|
|
2529
2597
|
const ok = result.ok && !warningFailure;
|
|
2530
2598
|
if (format === "json") {
|
|
2531
2599
|
writeJson({
|
|
2532
|
-
schema_version:
|
|
2533
|
-
cli_contract_version:
|
|
2600
|
+
schema_version: result.schemaVersion,
|
|
2601
|
+
cli_contract_version: 7,
|
|
2534
2602
|
recommendation_interface_version: 1,
|
|
2535
2603
|
tool_version: TOOL_VERSION,
|
|
2536
2604
|
operation: "dag.next",
|
|
@@ -2543,6 +2611,7 @@ async function runNext(args) {
|
|
|
2543
2611
|
grammar_version: result.grammarVersion,
|
|
2544
2612
|
...(result.durationUnit === null ? {} : nextJson(result)),
|
|
2545
2613
|
temporal: snakeJson(result.temporal),
|
|
2614
|
+
assurance: contract7SnakeJson(result.assurance),
|
|
2546
2615
|
});
|
|
2547
2616
|
}
|
|
2548
2617
|
else {
|
|
@@ -2566,12 +2635,12 @@ function runGuide(args) {
|
|
|
2566
2635
|
colorMode(parsed.values.get("color"), format);
|
|
2567
2636
|
const topicId = parsed.positionals.length === 0 ? null : parsed.positionals.join(".");
|
|
2568
2637
|
const level = helpLevel(parsed.values.get("level"), topicId !== null);
|
|
2569
|
-
const result =
|
|
2638
|
+
const result = getAssuranceGuide(topicId, level);
|
|
2570
2639
|
if (format === "json") {
|
|
2571
|
-
process.stdout.write(
|
|
2640
|
+
process.stdout.write(serializeAssuranceGuideResult(result));
|
|
2572
2641
|
}
|
|
2573
2642
|
else {
|
|
2574
|
-
const rendered =
|
|
2643
|
+
const rendered = renderAssuranceGuideResult(result);
|
|
2575
2644
|
if (result.ok) {
|
|
2576
2645
|
process.stdout.write(rendered);
|
|
2577
2646
|
}
|
|
@@ -2587,15 +2656,15 @@ function runCommandHelp(args) {
|
|
|
2587
2656
|
throw new UsageError("help accepts at most <resource> <action>");
|
|
2588
2657
|
}
|
|
2589
2658
|
const format = outputFormat(parsed.values.get("format"));
|
|
2590
|
-
const result =
|
|
2659
|
+
const result = getAssuranceCommandDiscovery({
|
|
2591
2660
|
resource: parsed.positionals[0] ?? null,
|
|
2592
2661
|
action: parsed.positionals[1] ?? null,
|
|
2593
2662
|
});
|
|
2594
2663
|
if (format === "json") {
|
|
2595
|
-
process.stdout.write(
|
|
2664
|
+
process.stdout.write(serializeAssuranceCommandHelpResult(result));
|
|
2596
2665
|
}
|
|
2597
2666
|
else {
|
|
2598
|
-
const rendered =
|
|
2667
|
+
const rendered = renderAssuranceCommandHelpResult(result);
|
|
2599
2668
|
if (result.ok) {
|
|
2600
2669
|
process.stdout.write(rendered);
|
|
2601
2670
|
}
|
|
@@ -2663,7 +2732,7 @@ function runAgentHelp(args) {
|
|
|
2663
2732
|
const { schema_version: schemaVersion, ...payload } = projected;
|
|
2664
2733
|
writeJson({
|
|
2665
2734
|
schema_version: schemaVersion,
|
|
2666
|
-
cli_contract_version:
|
|
2735
|
+
cli_contract_version: 7,
|
|
2667
2736
|
...payload,
|
|
2668
2737
|
});
|
|
2669
2738
|
}
|
|
@@ -2685,6 +2754,223 @@ function runAgentHelp(args) {
|
|
|
2685
2754
|
}
|
|
2686
2755
|
return agentGuidanceExitCode(result.diagnostics);
|
|
2687
2756
|
}
|
|
2757
|
+
function renderPlanAssuranceProjection(value) {
|
|
2758
|
+
const list = (values) => values.join(",") || "-";
|
|
2759
|
+
const lines = [
|
|
2760
|
+
`PLAN_ASSURANCE model=${value.modelVersion ?? "-"} hash_model=${value.hashModelVersion ?? "-"} coverage=${value.coverage}`,
|
|
2761
|
+
`REPLAN_REQUIRED ${list(value.replanRequiredTaskIds)}`,
|
|
2762
|
+
`ACTIVE_ATTENTION ${list(value.activeAttentionRequiredTaskIds)}`,
|
|
2763
|
+
];
|
|
2764
|
+
for (const task of value.taskResults) {
|
|
2765
|
+
lines.push(`TASK ${task.taskId} status=${task.status} contract=${task.contractHash ?? "-"} computed_basis=${task.computedBasisHash ?? "-"} accepted_basis=${task.acceptedBasisHash ?? "-"} exported=${task.exportedAssuranceHash ?? "-"}`);
|
|
2766
|
+
}
|
|
2767
|
+
return `${lines.join("\n")}\n`;
|
|
2768
|
+
}
|
|
2769
|
+
async function runPlanAssuranceInspection(action, args) {
|
|
2770
|
+
const operation = `plan-assurance.${action}`;
|
|
2771
|
+
const parsed = parseCommandOptions(operation, args);
|
|
2772
|
+
const format = outputFormat(parsed.values.get("format"));
|
|
2773
|
+
const color = colorMode(parsed.values.get("color"), format);
|
|
2774
|
+
const maxDiagnostics = boundedInteger(parsed.values.get("max-diagnostics"), "max-diagnostics", 100, 1, 1000);
|
|
2775
|
+
const sourceOperand = parsed.positionals[0];
|
|
2776
|
+
const source = sourceOperand === "-" ? "<stdin>" : sourceOperand;
|
|
2777
|
+
let input;
|
|
2778
|
+
try {
|
|
2779
|
+
input = await readDocument(sourceOperand);
|
|
2780
|
+
}
|
|
2781
|
+
catch (error) {
|
|
2782
|
+
return cliError(error instanceof Error ? error : new Error(String(error)), 3, operation, format === "json");
|
|
2783
|
+
}
|
|
2784
|
+
const result = inspectTargetPlanAssurance(input.text, action === "show"
|
|
2785
|
+
? {
|
|
2786
|
+
operation: "plan-assurance.show",
|
|
2787
|
+
taskIds: parsed.repeatedValues.get("task") ?? Object.freeze([]),
|
|
2788
|
+
}
|
|
2789
|
+
: {
|
|
2790
|
+
operation: "plan-assurance.hash",
|
|
2791
|
+
taskId: parsed.positionals[1],
|
|
2792
|
+
kind: requiredOption(parsed, "kind"),
|
|
2793
|
+
}, TARGET_GRAMMAR_6_CAPABILITY, { maxDiagnostics });
|
|
2794
|
+
const warningFailure = parsed.flags.has("warnings-as-errors") &&
|
|
2795
|
+
(result.diagnosticsTruncated || result.diagnostics.some(({ severity }) => severity === "warning"));
|
|
2796
|
+
const ok = result.ok && !warningFailure;
|
|
2797
|
+
if (format === "json") {
|
|
2798
|
+
writeJson(contract7InspectionResultToJson(ok ? result : Object.freeze({ ...result, ok: false }), source));
|
|
2799
|
+
}
|
|
2800
|
+
else if (ok) {
|
|
2801
|
+
if (action === "hash") {
|
|
2802
|
+
if (result.selectedHash === null) {
|
|
2803
|
+
throw new Error("successful assurance hash result has no digest");
|
|
2804
|
+
}
|
|
2805
|
+
process.stdout.write(`${result.selectedHash}\n`);
|
|
2806
|
+
}
|
|
2807
|
+
else if (result.assurance !== null) {
|
|
2808
|
+
process.stdout.write(renderPlanAssuranceProjection(result.assurance));
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
for (const diagnostic of result.diagnostics) {
|
|
2812
|
+
process.stderr.write(`${renderDiagnostic(diagnostic, source, color)}\n`);
|
|
2813
|
+
}
|
|
2814
|
+
if (result.diagnosticsTruncated) {
|
|
2815
|
+
process.stderr.write(`DIAGNOSTICS_TRUNCATED true limit=${maxDiagnostics}\n`);
|
|
2816
|
+
}
|
|
2817
|
+
return ok ? 0 : 1;
|
|
2818
|
+
}
|
|
2819
|
+
function dependencyMode(value) {
|
|
2820
|
+
return value === "execution-only"
|
|
2821
|
+
? "execution_only"
|
|
2822
|
+
: value === "planning-only"
|
|
2823
|
+
? "planning_only"
|
|
2824
|
+
: "both";
|
|
2825
|
+
}
|
|
2826
|
+
function assuranceMutationFromOptions(resource, action, parsed) {
|
|
2827
|
+
if (resource === "plan-assurance") {
|
|
2828
|
+
return action === "seal"
|
|
2829
|
+
? {
|
|
2830
|
+
kind: "plan_assurance.seal",
|
|
2831
|
+
reason: requiredOption(parsed, "reason"),
|
|
2832
|
+
}
|
|
2833
|
+
: {
|
|
2834
|
+
kind: "plan_assurance.reseal",
|
|
2835
|
+
taskIds: uniqueRepeated(parsed, "task"),
|
|
2836
|
+
reason: requiredOption(parsed, "reason"),
|
|
2837
|
+
};
|
|
2838
|
+
}
|
|
2839
|
+
const id = parsed.positionals[1];
|
|
2840
|
+
if (resource === "plan-dependency") {
|
|
2841
|
+
if (action === "add") {
|
|
2842
|
+
return {
|
|
2843
|
+
kind: "plan_dependency.add",
|
|
2844
|
+
id,
|
|
2845
|
+
predecessorTaskId: parsed.positionals[2],
|
|
2846
|
+
successorTaskId: parsed.positionals[3],
|
|
2847
|
+
mode: dependencyMode(requiredOption(parsed, "mode")),
|
|
2848
|
+
...(parsed.values.get("reason") === undefined
|
|
2849
|
+
? {}
|
|
2850
|
+
: { reason: parsed.values.get("reason") }),
|
|
2851
|
+
};
|
|
2852
|
+
}
|
|
2853
|
+
if (action === "remove")
|
|
2854
|
+
return { kind: "plan_dependency.remove", id };
|
|
2855
|
+
const clear = uniqueRepeated(parsed, "clear");
|
|
2856
|
+
return {
|
|
2857
|
+
kind: "plan_dependency.set",
|
|
2858
|
+
id,
|
|
2859
|
+
...(parsed.values.get("predecessor") === undefined
|
|
2860
|
+
? {}
|
|
2861
|
+
: { predecessorTaskId: parsed.values.get("predecessor") }),
|
|
2862
|
+
...(parsed.values.get("successor") === undefined
|
|
2863
|
+
? {}
|
|
2864
|
+
: { successorTaskId: parsed.values.get("successor") }),
|
|
2865
|
+
...(parsed.values.get("mode") === undefined
|
|
2866
|
+
? {}
|
|
2867
|
+
: { mode: dependencyMode(parsed.values.get("mode")) }),
|
|
2868
|
+
...(parsed.values.get("reason") === undefined
|
|
2869
|
+
? {}
|
|
2870
|
+
: { reason: parsed.values.get("reason") }),
|
|
2871
|
+
...(clear.includes("reason") ? { clearReason: true } : {}),
|
|
2872
|
+
};
|
|
2873
|
+
}
|
|
2874
|
+
if (action === "add") {
|
|
2875
|
+
return {
|
|
2876
|
+
kind: "task_outcome.add",
|
|
2877
|
+
id,
|
|
2878
|
+
taskId: parsed.positionals[2],
|
|
2879
|
+
status: requiredOption(parsed, "status"),
|
|
2880
|
+
...(parsed.values.get("summary") === undefined
|
|
2881
|
+
? {}
|
|
2882
|
+
: { summary: parsed.values.get("summary") }),
|
|
2883
|
+
reason: requiredOption(parsed, "reason"),
|
|
2884
|
+
};
|
|
2885
|
+
}
|
|
2886
|
+
if (action === "remove")
|
|
2887
|
+
return { kind: "task_outcome.remove", id };
|
|
2888
|
+
const clear = uniqueRepeated(parsed, "clear");
|
|
2889
|
+
return {
|
|
2890
|
+
kind: "task_outcome.set",
|
|
2891
|
+
id,
|
|
2892
|
+
...(parsed.values.get("status") === undefined
|
|
2893
|
+
? {}
|
|
2894
|
+
: {
|
|
2895
|
+
status: parsed.values.get("status"),
|
|
2896
|
+
}),
|
|
2897
|
+
...(parsed.values.get("summary") === undefined
|
|
2898
|
+
? {}
|
|
2899
|
+
: { summary: parsed.values.get("summary") }),
|
|
2900
|
+
...(clear.includes("summary") ? { clearSummary: true } : {}),
|
|
2901
|
+
...(parsed.values.get("reason") === undefined
|
|
2902
|
+
? {}
|
|
2903
|
+
: { reason: parsed.values.get("reason") }),
|
|
2904
|
+
...(parsed.flags.has("rebind-current-basis")
|
|
2905
|
+
? { rebindCurrentBasis: true }
|
|
2906
|
+
: {}),
|
|
2907
|
+
};
|
|
2908
|
+
}
|
|
2909
|
+
async function runAssuranceMutation(resource, action, args) {
|
|
2910
|
+
const operation = `${resource}.${action}`;
|
|
2911
|
+
const parsed = parseCommandOptions(operation, args);
|
|
2912
|
+
const format = outputFormat(parsed.values.get("format"));
|
|
2913
|
+
const color = colorMode(parsed.values.get("color"), format);
|
|
2914
|
+
const maxDiagnostics = boundedInteger(parsed.values.get("max-diagnostics"), "max-diagnostics", 100, 1, 1000);
|
|
2915
|
+
const sourceOperand = parsed.positionals[0];
|
|
2916
|
+
const source = sourceOperand === "-" ? "<stdin>" : sourceOperand;
|
|
2917
|
+
const writeRequest = editingWriteRequest(parsed, sourceOperand);
|
|
2918
|
+
let input;
|
|
2919
|
+
try {
|
|
2920
|
+
input = await readDocument(sourceOperand);
|
|
2921
|
+
}
|
|
2922
|
+
catch (error) {
|
|
2923
|
+
return cliError(error instanceof Error ? error : new Error(String(error)), 3, operation, format === "json");
|
|
2924
|
+
}
|
|
2925
|
+
const result = planAssuranceMutation(input.text, assuranceMutationFromOptions(resource, action, parsed), {
|
|
2926
|
+
maxDiagnostics,
|
|
2927
|
+
originalLabel: source,
|
|
2928
|
+
updatedLabel: "candidate",
|
|
2929
|
+
warningsAsErrors: parsed.flags.has("warnings-as-errors"),
|
|
2930
|
+
governance: governanceRequest(parsed, writeRequest),
|
|
2931
|
+
});
|
|
2932
|
+
let writeResult = Object.freeze({
|
|
2933
|
+
mode: writeRequest.mode,
|
|
2934
|
+
target: writeRequest.target,
|
|
2935
|
+
written: false,
|
|
2936
|
+
});
|
|
2937
|
+
if (result.ok && writeRequest.mode !== "preview") {
|
|
2938
|
+
try {
|
|
2939
|
+
writeResult = await persistGovernedResult(result, writeRequest, sourceOperand);
|
|
2940
|
+
}
|
|
2941
|
+
catch (error) {
|
|
2942
|
+
return writeFailureExit(error, operation, format === "json");
|
|
2943
|
+
}
|
|
2944
|
+
}
|
|
2945
|
+
if (format === "json") {
|
|
2946
|
+
writeJson(contract7MutationResultToJson(result, operation, source, writeResult));
|
|
2947
|
+
}
|
|
2948
|
+
else {
|
|
2949
|
+
if (result.ok) {
|
|
2950
|
+
if (writeRequest.mode === "preview") {
|
|
2951
|
+
process.stdout.write(parsed.flags.has("diff")
|
|
2952
|
+
? (result.diff ?? "")
|
|
2953
|
+
: (result.updatedText ?? ""));
|
|
2954
|
+
if (!parsed.flags.has("diff")) {
|
|
2955
|
+
process.stderr.write(`PREVIEW ${operation} changed=${result.changed} original_digest=${result.originalDigest} updated_digest=${result.updatedDigest}\n`);
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
else {
|
|
2959
|
+
process.stderr.write(renderGovernanceWriteSummary(operation, writeResult, result.updatedDigest));
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
if (result.governance !== null) {
|
|
2963
|
+
process.stderr.write(renderTargetGovernanceDecision(result.governance));
|
|
2964
|
+
}
|
|
2965
|
+
for (const diagnostic of result.diagnostics) {
|
|
2966
|
+
process.stderr.write(`${renderDiagnostic(diagnostic, source, color)}\n`);
|
|
2967
|
+
}
|
|
2968
|
+
if (result.diagnosticsTruncated) {
|
|
2969
|
+
process.stderr.write(`DIAGNOSTICS_TRUNCATED true limit=${maxDiagnostics}\n`);
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
return result.ok ? 0 : 1;
|
|
2973
|
+
}
|
|
2688
2974
|
async function dispatchCommand(descriptor, args) {
|
|
2689
2975
|
switch (descriptor.operation) {
|
|
2690
2976
|
case "help":
|
|
@@ -2725,6 +3011,16 @@ async function dispatchCommand(descriptor, args) {
|
|
|
2725
3011
|
return runLifecycleMutation("suspend", args);
|
|
2726
3012
|
case "task.resume":
|
|
2727
3013
|
return runLifecycleMutation("resume", args);
|
|
3014
|
+
case "plan-assurance.show":
|
|
3015
|
+
return runPlanAssuranceInspection("show", args);
|
|
3016
|
+
case "plan-assurance.hash":
|
|
3017
|
+
return runPlanAssuranceInspection("hash", args);
|
|
3018
|
+
}
|
|
3019
|
+
if (descriptor.path.length === 2 &&
|
|
3020
|
+
(descriptor.path[0] === "plan-assurance" ||
|
|
3021
|
+
descriptor.path[0] === "plan-dependency" ||
|
|
3022
|
+
descriptor.path[0] === "task-outcome")) {
|
|
3023
|
+
return runAssuranceMutation(descriptor.path[0], descriptor.path[1], args);
|
|
2728
3024
|
}
|
|
2729
3025
|
if (descriptor.path.length === 2
|
|
2730
3026
|
&& (descriptor.operation === "project.set"
|
|
@@ -2733,14 +3029,14 @@ async function dispatchCommand(descriptor, args) {
|
|
|
2733
3029
|
const [resource, action] = descriptor.path;
|
|
2734
3030
|
return runMutation(resource, action, args);
|
|
2735
3031
|
}
|
|
2736
|
-
throw new Error(`no Contract
|
|
3032
|
+
throw new Error(`no Contract 7 handler for ${descriptor.operation}`);
|
|
2737
3033
|
}
|
|
2738
3034
|
function emitCommandUsage(error, json) {
|
|
2739
3035
|
if (json) {
|
|
2740
|
-
process.stdout.write(
|
|
3036
|
+
process.stdout.write(serializeAssuranceCommandUsageError(error));
|
|
2741
3037
|
}
|
|
2742
3038
|
else {
|
|
2743
|
-
process.stderr.write(
|
|
3039
|
+
process.stderr.write(renderAssuranceCommandUsageError(error));
|
|
2744
3040
|
}
|
|
2745
3041
|
return 2;
|
|
2746
3042
|
}
|
|
@@ -2752,13 +3048,13 @@ async function main(argv) {
|
|
|
2752
3048
|
if (argv.length === 1 && argv[0] === "--help") {
|
|
2753
3049
|
return runCommandHelp([]);
|
|
2754
3050
|
}
|
|
2755
|
-
const validation =
|
|
3051
|
+
const validation = validateAssuranceCommandInvocation(argv);
|
|
2756
3052
|
if (!validation.ok) {
|
|
2757
3053
|
if (jsonRequested(argv)) {
|
|
2758
|
-
process.stdout.write(
|
|
3054
|
+
process.stdout.write(serializeAssuranceCommandUsageError(validation.error));
|
|
2759
3055
|
}
|
|
2760
3056
|
else {
|
|
2761
|
-
process.stderr.write(
|
|
3057
|
+
process.stderr.write(renderAssuranceCommandUsageError(validation.error));
|
|
2762
3058
|
}
|
|
2763
3059
|
return 2;
|
|
2764
3060
|
}
|