@deepraxis/cli 0.3.0-dev.5085fb6 → 0.3.0-dev.5753565
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/COMMANDS.md +1 -1
- package/dist/praxis.js +731 -162
- package/package.json +1 -1
package/COMMANDS.md
CHANGED
|
@@ -16,7 +16,7 @@ Other lists use global `--limit` only for client-side display truncation, even i
|
|
|
16
16
|
|
|
17
17
|
Every generated command below is typed after `praxis api` (the `Command` column shows the full path); the word after `api` decides the form: an uppercase HTTP method is a raw request, anything else a generated command path.
|
|
18
18
|
|
|
19
|
-
Handwritten commands: `help [command…] [--json]`, `login`, `logout`, `whoami`, `org list`, `org switch <organization_id>`, `app create <name> [--dir <path>] [--template <dir>] [--no-install]`, `app publish [--dir <path>] [--no-build]`, `app rollback [--dir <path>] [--to <version_id>]`, `devops deploy plan [--env <name>] [--since <commit>]`, `devops engine deploy --env <develop|production> --environment-id <dve_…> [--project <dvp_…>] --commit <sha> [--targets a,b] [--plan-only] [--plan-dir <dir>] [--apply-plans <dir>] [--events-file <path>] [--engine-root <dir>] [--order callers-first]`, `devops deploy --env <develop|production> --environment-id <dve_…> [--project <dvp_…>] --commit <sha> [--targets a,b] [--plan-only] [--plan-dir <dir>] [--apply-plans <dir>] [--events-file <path>] [--engine-root <dir>] [--order callers-first]`, `devops test run --remote [--project <dvp_…>] [--no-wait] [--repeat <n>] [--select <kind:value>]`, `devops test [path…] [--size <small|medium|large|all>] [--tags <@tag…>] [--feature <title>] [--case <title>] [--e2e] [--all] [--affected [--since <commit>]] [--list] [--dry-run] [--retries <n>] [--ctrf <file>]`, `devops test report [path…] [--id <run>] [--upload [--project <dvp_…>]]`, `devops test new <file> [--e2e] [--port <n>]`, `devops test inspect <feature title> [--headed]`, `devops check [path] [--targets <a,b>]`, `devops check migrations [path]`, `devops check deprecations [path]`, `devops context [path] [--feature <topic>]`, `devops context topology [path]`, `devops context impact`, `devops context deps <path>`, `devops plan [--env <name>] [--since <commit>]`, `devops fmt [paths…] [--all]`, `devops install`, `devops build [path]`, `devops scaffold <package path>`, `devops refactor rename|check|apply`, `devops refactor rename --at <file:line:column> --to <identifier>`, `devops refactor check <digest>`, `devops refactor apply <digest>`, `devops flag sync [--check]`, `devops flag check`, `devops flag scaffold <key> [--out <dir>]`, `devops flag refs [key] [--report --project <dvp_…>]`, `devops flag remove <key>`, `devops change checkout <change>`, `agent events wait [--timeout <seconds>]`, `agent events channel`, `canvas import <file.pen> [--name <name>] [--canvas <cvs_…> --yes] [--frames <id,id>] [--image-root <dir>] [--dry-run]`, `skill [--install <dir>]`, `completion <bash|zsh|fish>`, `api <METHOD> <path> [--data …]`.
|
|
19
|
+
Handwritten commands: `help [command…] [--json]`, `login`, `logout`, `whoami`, `org list`, `org switch <organization_id>`, `app create <name> [--dir <path>] [--template <dir>] [--no-install]`, `app publish [--dir <path>] [--no-build]`, `app rollback [--dir <path>] [--to <version_id>]`, `devops deploy plan [--env <name>] [--since <commit>]`, `devops engine deploy --env <develop|production> --environment-id <dve_…> [--project <dvp_…>] --commit <sha> [--targets a,b] [--plan-only] [--plan-dir <dir>] [--apply-plans <dir>] [--events-file <path>] [--engine-root <dir>] [--order callers-first]`, `devops deploy --env <develop|production> --environment-id <dve_…> [--project <dvp_…>] --commit <sha> [--targets a,b] [--plan-only] [--plan-dir <dir>] [--apply-plans <dir>] [--events-file <path>] [--engine-root <dir>] [--order callers-first]`, `devops test run --remote [--project <dvp_…>] [--no-wait] [--repeat <n>] [--select <kind:value>]`, `devops test [path…] [--size <small|medium|large|all>] [--tags <@tag…>] [--feature <title>] [--case <title>] [--e2e] [--all] [--affected [--since <commit>]] [--list] [--dry-run] [--retries <n>] [--ctrf <file>]`, `devops test report [path…] [--id <run>] [--upload [--project <dvp_…>]]`, `devops test new <file> [--e2e] [--port <n>]`, `devops test inspect <feature title> [--headed]`, `devops check [path] [--targets <a,b>]`, `devops check migrations [path]`, `devops check deprecations [path]`, `devops context [path] [--feature <topic>]`, `devops context topology [path]`, `devops context impact`, `devops context deps <path>`, `devops plan [--env <name>] [--since <commit>]`, `devops fmt [paths…] [--all]`, `devops install`, `devops build [path]`, `devops scaffold <package path>`, `devops refactor rename|check|apply`, `devops refactor rename --at <file:line:column> --to <identifier>`, `devops refactor check <digest>`, `devops refactor apply <digest>`, `devops flag sync [--check]`, `devops flag check`, `devops flag scaffold <key> [--out <dir>]`, `devops flag refs [key] [--report --project <dvp_…>]`, `devops flag remove <key>`, `devops change checkout <change>`, `agent events wait [--timeout <seconds>]`, `agent memory [--hook SessionStart|UserPromptSubmit]`, `agent recall [--words <w,w>] [--handles <id,id>]`, `agent remember --text <experience> [--about <id,id>]`, `agent events channel`, `canvas import <file.pen> [--name <name>] [--canvas <cvs_…> --yes] [--frames <id,id>] [--image-root <dir>] [--dry-run]`, `skill [--install <dir>]`, `completion <bash|zsh|fish>`, `api <METHOD> <path> [--data …]`.
|
|
20
20
|
|
|
21
21
|
| Command | SDK method | HTTP | Parameter options |
|
|
22
22
|
|---|---|---|---|
|
package/dist/praxis.js
CHANGED
|
@@ -13983,9 +13983,14 @@ var FLAGS;
|
|
|
13983
13983
|
var init_flag_registry_generated = __esm(() => {
|
|
13984
13984
|
FLAGS = {
|
|
13985
13985
|
"agent-cognition-idle-wake": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "genius", ticket: 540, expires: "2026-11-30", system: "flagship" },
|
|
13986
|
+
"agent-process-mode-base": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "agent_7a4aeaa9-73ff-4ef2-a73c-5fdee7c6138e", ticket: 2365, expires: "2026-12-16", system: "devops" },
|
|
13987
|
+
"cognition-per-agent": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2506, expires: "2026-11-30", system: "devops" },
|
|
13986
13988
|
"cognition-weight-driven": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "praxis-bd", ticket: 1760, expires: "2026-12-05", system: "devops" },
|
|
13989
|
+
"computer-archive-volume": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2419, expires: "2026-11-30", system: "devops" },
|
|
13987
13990
|
crm: { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_rv860m7z9h8szkgma56cd14n", ticket: 2179, expires: "2026-12-31", system: "devops" },
|
|
13988
13991
|
"delivery-rules-v2": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2048, expires: "2026-11-28", system: "devops" },
|
|
13992
|
+
"end-users": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2312, expires: "2026-12-15", system: "devops" },
|
|
13993
|
+
"letters-email-delivery": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "agent_9261c17c-1f22-46c5-8b17-e4bfb749424a", ticket: 2150, expires: "2026-11-29", system: "devops" },
|
|
13989
13994
|
"model-access-gate": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 1933, expires: "2026-12-15", system: "devops" },
|
|
13990
13995
|
"open-project": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "praxis-51", ticket: 1488, expires: "2026-11-25", system: "devops" },
|
|
13991
13996
|
"requests-never-hold": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2119, expires: "2026-11-29", system: "devops" },
|
|
@@ -30308,7 +30313,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
30308
30313
|
resource: "file.uploads",
|
|
30309
30314
|
method: "createSigned",
|
|
30310
30315
|
summary: "Create a one-time upload URL",
|
|
30311
|
-
description: "Upload a local file of up to 20 GiB from a coding agent without sending bytes through the model. Provide filename (the stored basename), exact byte count and MIME type. Up to 104857600 bytes, PUT the file to url with curl -T photo.png -H 'Content-Type: image/png' '<url>'; success returns 201 with the file object, and reuse returns 410 CAPABILITY_USED. Above that threshold, split the file into part_size chunks (default 64000000 bytes) and PUT each chunk to its numbered parts[].url in any order; an interrupted client GETs status_url to see the received parts and resends only what is missing, then POSTs complete_url without a body. Part PUTs return 200; completion returns 201 with the file object, including its state, or 400 if a part is missing. A processing file can be polled with files.retrieve until active. Identical part bytes may be retried; changed bytes at the same number return 400. Completion reuse returns 410 CAPABILITY_USED. Each PUT requires the exact signed Content-Length; single-PUT Content-Type must match content_type or be omitted. Expired, revoked, invalid
|
|
30316
|
+
description: "Upload a local file of up to 20 GiB from a coding agent without sending bytes through the model. Provide filename (the stored basename), exact byte count and MIME type. Up to 104857600 bytes, PUT the file to url with curl -T photo.png -H 'Content-Type: image/png' '<url>'; success returns 201 with the file object, and reuse returns 410 CAPABILITY_USED. Above that threshold, split the file into part_size chunks (default 64000000 bytes) and PUT each chunk to its numbered parts[].url in any order; an interrupted client GETs status_url to see the received parts and resends only what is missing, then POSTs complete_url without a body. Part PUTs return 200; completion returns 201 with the file object, including its state, or 400 if a part is missing. A processing file can be polled with files.retrieve until active. Identical part bytes may be retried; changed bytes at the same number return 400. Completion reuse returns 410 CAPABILITY_USED. Each PUT requires the exact signed Content-Length; single-PUT Content-Type must match content_type or be omitted. Expired, revoked, invalid or cross-organization URLs return 404, and so does a link whose upload record no longer exists. A URL that is authentic but names another action returns 403 CAPABILITY_MISMATCH: a status link posted to complete_url answers it, and so does a completion link fetched as status_url. URL lifetime defaults to 900 seconds for single PUT or 604800 (7 days) for multipart, at most 604800; all multipart URLs, including status_url, share an expiry. Multipart creation reserves storage quota. Issuance requires the same unscoped credential as direct file creation. Each issuance creates a new upload and is not idempotent. Example body: {\"filename\":\"photo.png\",\"bytes\":2048,\"content_type\":\"image/png\"}.",
|
|
30312
30317
|
http: "POST",
|
|
30313
30318
|
path: "/file/v1/uploads/signed",
|
|
30314
30319
|
streaming: "no",
|
|
@@ -61950,6 +61955,27 @@ var workflows = [
|
|
|
61950
61955
|
example: "PRAXIS_ASSUME_AGENT=R1M9TQ2X praxis agent events wait",
|
|
61951
61956
|
network: "online"
|
|
61952
61957
|
},
|
|
61958
|
+
{
|
|
61959
|
+
words: ["agent", "memory"],
|
|
61960
|
+
usage: "agent memory [--hook SessionStart|UserPromptSubmit]",
|
|
61961
|
+
summary: "Print your assume agent's memory as it stands now (PRAXIS_ASSUME_AGENT): who it is, its post, manager, duties and the charters it works under, drawn from its organization. With --hook it reads the Claude Code hook input on stdin and prints the hook's JSON: the whole memory at SessionStart, only what is new since that session last read it at UserPromptSubmit; it never fails the hook.",
|
|
61962
|
+
example: "praxis agent memory",
|
|
61963
|
+
network: "online"
|
|
61964
|
+
},
|
|
61965
|
+
{
|
|
61966
|
+
words: ["agent", "recall"],
|
|
61967
|
+
usage: "agent recall [--words <w,w>] [--handles <id,id>]",
|
|
61968
|
+
summary: "Recall from your assume agent's memory: with no flags, what else comes to mind; with words, what was filed under them; with handles, that entry and its original.",
|
|
61969
|
+
example: "praxis agent recall --words 章程,运维部",
|
|
61970
|
+
network: "online"
|
|
61971
|
+
},
|
|
61972
|
+
{
|
|
61973
|
+
words: ["agent", "remember"],
|
|
61974
|
+
usage: "agent remember --text <experience> [--about <id,id>]",
|
|
61975
|
+
summary: "Keep an experience in your assume agent's memory: it is consolidated in the background like a lived conversation, and recall finds it afterwards.",
|
|
61976
|
+
example: 'praxis agent remember --text "Sean 定了副总裁用钩子载入认知"',
|
|
61977
|
+
network: "online"
|
|
61978
|
+
},
|
|
61953
61979
|
{
|
|
61954
61980
|
words: ["agent", "events", "channel"],
|
|
61955
61981
|
usage: "agent events channel",
|
|
@@ -63549,12 +63575,216 @@ function wranglerEdges(nodes) {
|
|
|
63549
63575
|
}
|
|
63550
63576
|
return edges;
|
|
63551
63577
|
}
|
|
63578
|
+
// ../../packages/praxis/deploy-core/src/job-events.ts
|
|
63579
|
+
var DEFAULT_EXPIRE_MINUTES = 60;
|
|
63580
|
+
var DEFAULT_PHASE_ID = "stable";
|
|
63581
|
+
function jobStatesOf(outcome) {
|
|
63582
|
+
switch (outcome.kind) {
|
|
63583
|
+
case "succeeded":
|
|
63584
|
+
return { jobState: "succeeded", jobRunState: "succeeded" };
|
|
63585
|
+
case "failed":
|
|
63586
|
+
return { jobState: "failed", jobRunState: "failed" };
|
|
63587
|
+
case "disabled":
|
|
63588
|
+
return { jobState: "disabled", jobRunState: "unspecified" };
|
|
63589
|
+
case "skipped":
|
|
63590
|
+
return { jobState: "skipped", jobRunState: "unspecified" };
|
|
63591
|
+
}
|
|
63592
|
+
}
|
|
63593
|
+
function formatDeployEvent(event) {
|
|
63594
|
+
return `${JSON.stringify(event)}
|
|
63595
|
+
`;
|
|
63596
|
+
}
|
|
63597
|
+
function expireTimeOf(startedAt, expireMinutes = DEFAULT_EXPIRE_MINUTES) {
|
|
63598
|
+
const start = Date.parse(startedAt);
|
|
63599
|
+
if (Number.isNaN(start))
|
|
63600
|
+
throw new Error(`--events-file needs a parseable start time, got ${JSON.stringify(startedAt)}`);
|
|
63601
|
+
const minutes = Number(expireMinutes);
|
|
63602
|
+
if (!Number.isFinite(minutes) || minutes <= 0)
|
|
63603
|
+
throw new Error(`--expire-minutes must be a positive number, got ${JSON.stringify(expireMinutes)}`);
|
|
63604
|
+
return new Date(start + minutes * 60000).toISOString();
|
|
63605
|
+
}
|
|
63606
|
+
function decidePhaseState(states) {
|
|
63607
|
+
if (states.length === 0)
|
|
63608
|
+
return "unspecified";
|
|
63609
|
+
if (states.some((state) => state === "failed" || state === "aborted"))
|
|
63610
|
+
return "failed";
|
|
63611
|
+
if (states.some((state) => state === "in_progress" || state === "pending"))
|
|
63612
|
+
return "in_progress";
|
|
63613
|
+
const neverRan = states.every((state) => state === "skipped" || state === "disabled");
|
|
63614
|
+
return neverRan ? "skipped" : "succeeded";
|
|
63615
|
+
}
|
|
63616
|
+
function decideRolloutState(jobs, options = {}) {
|
|
63617
|
+
const states = [...jobs.values()];
|
|
63618
|
+
if (states.some((state) => state === "failed" || state === "aborted"))
|
|
63619
|
+
return "failed";
|
|
63620
|
+
const deploy = jobs.get("deploy");
|
|
63621
|
+
if (deploy === undefined || deploy === "pending" || deploy === "in_progress" || deploy === "disabled")
|
|
63622
|
+
return "pending";
|
|
63623
|
+
if (deploy === "skipped" && options.artifactIdentical !== true)
|
|
63624
|
+
return "pending";
|
|
63625
|
+
if (states.every((state) => state === "succeeded" || state === "skipped" || state === "disabled" || state === "ignored")) {
|
|
63626
|
+
return options.artifactIdentical === true ? "skipped" : "succeeded";
|
|
63627
|
+
}
|
|
63628
|
+
return "pending";
|
|
63629
|
+
}
|
|
63630
|
+
function decideFinishedState(rollouts) {
|
|
63631
|
+
if (rollouts.length === 0)
|
|
63632
|
+
return "failed";
|
|
63633
|
+
const count3 = (wanted) => rollouts.filter((state) => wanted.includes(state)).length;
|
|
63634
|
+
const succeeded = count3(["succeeded", "skipped"]);
|
|
63635
|
+
const failed = count3(["failed"]);
|
|
63636
|
+
const waiting = count3(["pending"]);
|
|
63637
|
+
if (failed === 0)
|
|
63638
|
+
return succeeded === rollouts.length ? "succeeded" : "failed";
|
|
63639
|
+
return succeeded > 0 && waiting > 0 ? "halted" : "failed";
|
|
63640
|
+
}
|
|
63641
|
+
// ../../packages/praxis/deploy-core/node_modules/yaml/dist/index.js
|
|
63642
|
+
var composer = require_composer2();
|
|
63643
|
+
var Document = require_Document2();
|
|
63644
|
+
var Schema = require_Schema2();
|
|
63645
|
+
var errors = require_errors2();
|
|
63646
|
+
var Alias = require_Alias2();
|
|
63647
|
+
var identity = require_identity2();
|
|
63648
|
+
var Pair = require_Pair2();
|
|
63649
|
+
var Scalar = require_Scalar2();
|
|
63650
|
+
var YAMLMap = require_YAMLMap2();
|
|
63651
|
+
var YAMLSeq = require_YAMLSeq2();
|
|
63652
|
+
var cst = require_cst2();
|
|
63653
|
+
var lexer = require_lexer2();
|
|
63654
|
+
var lineCounter = require_line_counter2();
|
|
63655
|
+
var parser = require_parser2();
|
|
63656
|
+
var publicApi = require_public_api2();
|
|
63657
|
+
var visit = require_visit2();
|
|
63658
|
+
var $Composer = composer.Composer;
|
|
63659
|
+
var $Document = Document.Document;
|
|
63660
|
+
var $Schema = Schema.Schema;
|
|
63661
|
+
var $YAMLError = errors.YAMLError;
|
|
63662
|
+
var $YAMLParseError = errors.YAMLParseError;
|
|
63663
|
+
var $YAMLWarning = errors.YAMLWarning;
|
|
63664
|
+
var $Alias = Alias.Alias;
|
|
63665
|
+
var $isAlias = identity.isAlias;
|
|
63666
|
+
var $isCollection = identity.isCollection;
|
|
63667
|
+
var $isDocument = identity.isDocument;
|
|
63668
|
+
var $isMap = identity.isMap;
|
|
63669
|
+
var $isNode = identity.isNode;
|
|
63670
|
+
var $isPair = identity.isPair;
|
|
63671
|
+
var $isScalar = identity.isScalar;
|
|
63672
|
+
var $isSeq = identity.isSeq;
|
|
63673
|
+
var $Pair = Pair.Pair;
|
|
63674
|
+
var $Scalar = Scalar.Scalar;
|
|
63675
|
+
var $YAMLMap = YAMLMap.YAMLMap;
|
|
63676
|
+
var $YAMLSeq = YAMLSeq.YAMLSeq;
|
|
63677
|
+
var $Lexer = lexer.Lexer;
|
|
63678
|
+
var $LineCounter = lineCounter.LineCounter;
|
|
63679
|
+
var $Parser = parser.Parser;
|
|
63680
|
+
var $parse = publicApi.parse;
|
|
63681
|
+
var $parseAllDocuments = publicApi.parseAllDocuments;
|
|
63682
|
+
var $parseDocument = publicApi.parseDocument;
|
|
63683
|
+
var $stringify = publicApi.stringify;
|
|
63684
|
+
var $visit = visit.visit;
|
|
63685
|
+
var $visitAsync = visit.visitAsync;
|
|
63686
|
+
|
|
63552
63687
|
// ../../packages/praxis/deploy-core/src/lambda-function.ts
|
|
63553
63688
|
var LAMBDA_FUNCTIONS_ROOT = "services/lambda/functions";
|
|
63554
63689
|
var UPSTREAM = "aliyun-fc";
|
|
63555
|
-
var
|
|
63690
|
+
var PROJECT_FILE = "praxis.yaml";
|
|
63691
|
+
function lambdaFunctionRootOwner(root) {
|
|
63692
|
+
return root.split("/").filter((segment) => segment !== "").slice(0, -1).join("/");
|
|
63693
|
+
}
|
|
63694
|
+
function normalizeRoot(root) {
|
|
63695
|
+
return root.replace(/^\.\//, "").split("/").filter((segment) => segment !== "" && segment !== ".").join("/");
|
|
63696
|
+
}
|
|
63697
|
+
var DEFAULT_ROOTS = [
|
|
63698
|
+
{ root: LAMBDA_FUNCTIONS_ROOT, owner: lambdaFunctionRootOwner(LAMBDA_FUNCTIONS_ROOT) }
|
|
63699
|
+
];
|
|
63556
63700
|
var isText = (value) => typeof value === "string" && value !== "";
|
|
63701
|
+
function lambdaFunctionRootsOf(text) {
|
|
63702
|
+
if (text === null)
|
|
63703
|
+
return { roots: DEFAULT_ROOTS, warnings: [] };
|
|
63704
|
+
let parsed;
|
|
63705
|
+
try {
|
|
63706
|
+
parsed = $parse(text);
|
|
63707
|
+
} catch (cause) {
|
|
63708
|
+
return {
|
|
63709
|
+
roots: DEFAULT_ROOTS,
|
|
63710
|
+
warnings: [`${PROJECT_FILE}: does not parse, so its recipe roots are not read`]
|
|
63711
|
+
};
|
|
63712
|
+
}
|
|
63713
|
+
const declared = readPath(parsed, ["devops", "deploy", "recipes"]);
|
|
63714
|
+
if (declared === undefined)
|
|
63715
|
+
return { roots: DEFAULT_ROOTS, warnings: [] };
|
|
63716
|
+
if (!Array.isArray(declared)) {
|
|
63717
|
+
return {
|
|
63718
|
+
roots: DEFAULT_ROOTS,
|
|
63719
|
+
warnings: [
|
|
63720
|
+
`${PROJECT_FILE}: devops.deploy.recipes is not a list, so its recipe roots are not read`
|
|
63721
|
+
]
|
|
63722
|
+
};
|
|
63723
|
+
}
|
|
63724
|
+
const roots = [];
|
|
63725
|
+
const warnings = [];
|
|
63726
|
+
declared.forEach((entry, index) => {
|
|
63727
|
+
const root = typeof entry === "string" ? entry : typeof entry === "object" && entry !== null ? entry.root : undefined;
|
|
63728
|
+
if (!isText(root)) {
|
|
63729
|
+
warnings.push(`${PROJECT_FILE}: devops.deploy.recipes[${index}] names no root`);
|
|
63730
|
+
return;
|
|
63731
|
+
}
|
|
63732
|
+
const declaredOwner = typeof entry === "object" && entry !== null ? entry.owner : undefined;
|
|
63733
|
+
if (declaredOwner !== undefined && !isText(declaredOwner)) {
|
|
63734
|
+
warnings.push(`${PROJECT_FILE}: devops.deploy.recipes[${index}] names no owner`);
|
|
63735
|
+
return;
|
|
63736
|
+
}
|
|
63737
|
+
const normalized = normalizeRoot(root);
|
|
63738
|
+
if (normalized === "") {
|
|
63739
|
+
warnings.push(`${PROJECT_FILE}: devops.deploy.recipes[${index}] names no root`);
|
|
63740
|
+
return;
|
|
63741
|
+
}
|
|
63742
|
+
if (roots.some((known) => known.root === normalized))
|
|
63743
|
+
return;
|
|
63744
|
+
roots.push({
|
|
63745
|
+
root: normalized,
|
|
63746
|
+
owner: declaredOwner === undefined ? lambdaFunctionRootOwner(normalized) : normalizeRoot(declaredOwner)
|
|
63747
|
+
});
|
|
63748
|
+
});
|
|
63749
|
+
if (roots.length === 0 && warnings.length === 0) {
|
|
63750
|
+
warnings.push(`${PROJECT_FILE}: devops.deploy.recipes declares no root, so no function recipe is a target`);
|
|
63751
|
+
}
|
|
63752
|
+
return { roots, warnings };
|
|
63753
|
+
}
|
|
63754
|
+
function readPath(value, segments) {
|
|
63755
|
+
let current = value;
|
|
63756
|
+
for (const segment of segments) {
|
|
63757
|
+
if (current === null || typeof current !== "object" || Array.isArray(current))
|
|
63758
|
+
return;
|
|
63759
|
+
current = current[segment];
|
|
63760
|
+
}
|
|
63761
|
+
return current;
|
|
63762
|
+
}
|
|
63557
63763
|
var isCount = (value, min, max) => typeof value === "number" && Number.isInteger(value) && value >= min && value <= max;
|
|
63764
|
+
function lambdaFunctionCodeOf(value) {
|
|
63765
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
63766
|
+
return null;
|
|
63767
|
+
const declared = value;
|
|
63768
|
+
if (!isText(declared.entry) || !isText(declared.artifact))
|
|
63769
|
+
return null;
|
|
63770
|
+
if (!isText(declared.runtime) || !isText(declared.handler))
|
|
63771
|
+
return null;
|
|
63772
|
+
if (!Array.isArray(declared.layers) || !declared.layers.every(isText))
|
|
63773
|
+
return null;
|
|
63774
|
+
if (!Array.isArray(declared.command) || declared.command.length === 0 || !declared.command.every(isText))
|
|
63775
|
+
return null;
|
|
63776
|
+
if (!isCount(declared.port, 1, 65535))
|
|
63777
|
+
return null;
|
|
63778
|
+
return {
|
|
63779
|
+
entry: declared.entry,
|
|
63780
|
+
artifact: declared.artifact,
|
|
63781
|
+
runtime: declared.runtime,
|
|
63782
|
+
handler: declared.handler,
|
|
63783
|
+
layers: [...declared.layers],
|
|
63784
|
+
command: [...declared.command],
|
|
63785
|
+
port: declared.port
|
|
63786
|
+
};
|
|
63787
|
+
}
|
|
63558
63788
|
function lambdaFunctionOf(text) {
|
|
63559
63789
|
const parsed = text === null ? null : parseJsonc2(text);
|
|
63560
63790
|
if (parsed === null)
|
|
@@ -63573,6 +63803,15 @@ function lambdaFunctionOf(text) {
|
|
|
63573
63803
|
return null;
|
|
63574
63804
|
if (!isCount(parsed.concurrency, 1, 1024))
|
|
63575
63805
|
return null;
|
|
63806
|
+
if (parsed.diskSizeMb !== undefined && !isCount(parsed.diskSizeMb, 512, 10240))
|
|
63807
|
+
return null;
|
|
63808
|
+
let code;
|
|
63809
|
+
if (parsed.code !== undefined) {
|
|
63810
|
+
const declared = lambdaFunctionCodeOf(parsed.code);
|
|
63811
|
+
if (declared === null)
|
|
63812
|
+
return null;
|
|
63813
|
+
code = declared;
|
|
63814
|
+
}
|
|
63576
63815
|
return {
|
|
63577
63816
|
name: parsed.name,
|
|
63578
63817
|
upstream: parsed.upstream,
|
|
@@ -63581,35 +63820,39 @@ function lambdaFunctionOf(text) {
|
|
|
63581
63820
|
cpu: parsed.cpu,
|
|
63582
63821
|
memoryMb: parsed.memoryMb,
|
|
63583
63822
|
timeoutSeconds: parsed.timeoutSeconds,
|
|
63584
|
-
concurrency: parsed.concurrency
|
|
63823
|
+
concurrency: parsed.concurrency,
|
|
63824
|
+
...parsed.diskSizeMb === undefined ? {} : { diskSizeMb: parsed.diskSizeMb },
|
|
63825
|
+
...code === undefined ? {} : { code }
|
|
63585
63826
|
};
|
|
63586
63827
|
}
|
|
63587
|
-
|
|
63588
|
-
return { path: `${LAMBDA_FUNCTIONS_ROOT}/${recipe.name}`, name: `lambda-${recipe.name}` };
|
|
63589
|
-
}
|
|
63590
|
-
function lambdaFunctionOwner(path) {
|
|
63591
|
-
return path.split("/").slice(0, -2).join("/");
|
|
63592
|
-
}
|
|
63828
|
+
var escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
63593
63829
|
async function scanRecipes(facts) {
|
|
63830
|
+
const declared = lambdaFunctionRootsOf(await facts.read(PROJECT_FILE));
|
|
63594
63831
|
const found = [];
|
|
63595
|
-
const warnings = [];
|
|
63832
|
+
const warnings = [...declared.warnings];
|
|
63833
|
+
const matchers = declared.roots.map((root) => ({
|
|
63834
|
+
root,
|
|
63835
|
+
pattern: new RegExp(`^${escapeRegExp(root.root)}/([^/]+)/function\\.json$`)
|
|
63836
|
+
}));
|
|
63596
63837
|
for (const path of [...facts.tree].sort()) {
|
|
63597
|
-
const
|
|
63598
|
-
|
|
63599
|
-
|
|
63600
|
-
|
|
63601
|
-
|
|
63602
|
-
|
|
63603
|
-
|
|
63604
|
-
|
|
63605
|
-
|
|
63606
|
-
|
|
63607
|
-
|
|
63608
|
-
|
|
63609
|
-
|
|
63610
|
-
|
|
63838
|
+
for (const { root, pattern } of matchers) {
|
|
63839
|
+
const match = pattern.exec(path);
|
|
63840
|
+
if (match === null)
|
|
63841
|
+
continue;
|
|
63842
|
+
const dir = path.slice(0, -"/function.json".length);
|
|
63843
|
+
const recipe = lambdaFunctionOf(await facts.read(path));
|
|
63844
|
+
if (recipe === null) {
|
|
63845
|
+
warnings.push(`${dir}: function.json is not a recipe`);
|
|
63846
|
+
continue;
|
|
63847
|
+
}
|
|
63848
|
+
if (recipe.upstream !== UPSTREAM)
|
|
63849
|
+
continue;
|
|
63850
|
+
if (recipe.name !== match[1]) {
|
|
63851
|
+
warnings.push(`${dir}: function.json names ${JSON.stringify(recipe.name)}, not the directory name`);
|
|
63852
|
+
continue;
|
|
63853
|
+
}
|
|
63854
|
+
found.push({ recipe, path: dir, root });
|
|
63611
63855
|
}
|
|
63612
|
-
found.push(recipe);
|
|
63613
63856
|
}
|
|
63614
63857
|
return { found, warnings };
|
|
63615
63858
|
}
|
|
@@ -63624,13 +63867,14 @@ function lambdaFunctionProvider(_options = {}) {
|
|
|
63624
63867
|
const scan = await scanRecipes(facts);
|
|
63625
63868
|
const targets = [];
|
|
63626
63869
|
const byOwner = new Map;
|
|
63627
|
-
for (const recipe of scan.found) {
|
|
63628
|
-
const
|
|
63870
|
+
for (const { recipe, path, root } of scan.found) {
|
|
63871
|
+
const name = `lambda-${recipe.name}`;
|
|
63629
63872
|
if (claimed.has(path))
|
|
63630
63873
|
continue;
|
|
63631
63874
|
targets.push({ path, name, destination: "aliyun-fc", production: true, onTrain: true });
|
|
63632
|
-
|
|
63633
|
-
|
|
63875
|
+
if (root.owner === "")
|
|
63876
|
+
continue;
|
|
63877
|
+
byOwner.set(root.owner, [...byOwner.get(root.owner) ?? [], path]);
|
|
63634
63878
|
}
|
|
63635
63879
|
const refined = partial.targets.map((target) => {
|
|
63636
63880
|
const paths = byOwner.get(target.path);
|
|
@@ -63693,52 +63937,6 @@ function environmentsOf(lifecycle) {
|
|
|
63693
63937
|
const named = environments.filter((entry) => typeof entry === "string");
|
|
63694
63938
|
return named.length === 0 ? undefined : named;
|
|
63695
63939
|
}
|
|
63696
|
-
// ../../packages/praxis/deploy-core/node_modules/yaml/dist/index.js
|
|
63697
|
-
var composer = require_composer2();
|
|
63698
|
-
var Document = require_Document2();
|
|
63699
|
-
var Schema = require_Schema2();
|
|
63700
|
-
var errors = require_errors2();
|
|
63701
|
-
var Alias = require_Alias2();
|
|
63702
|
-
var identity = require_identity2();
|
|
63703
|
-
var Pair = require_Pair2();
|
|
63704
|
-
var Scalar = require_Scalar2();
|
|
63705
|
-
var YAMLMap = require_YAMLMap2();
|
|
63706
|
-
var YAMLSeq = require_YAMLSeq2();
|
|
63707
|
-
var cst = require_cst2();
|
|
63708
|
-
var lexer = require_lexer2();
|
|
63709
|
-
var lineCounter = require_line_counter2();
|
|
63710
|
-
var parser = require_parser2();
|
|
63711
|
-
var publicApi = require_public_api2();
|
|
63712
|
-
var visit = require_visit2();
|
|
63713
|
-
var $Composer = composer.Composer;
|
|
63714
|
-
var $Document = Document.Document;
|
|
63715
|
-
var $Schema = Schema.Schema;
|
|
63716
|
-
var $YAMLError = errors.YAMLError;
|
|
63717
|
-
var $YAMLParseError = errors.YAMLParseError;
|
|
63718
|
-
var $YAMLWarning = errors.YAMLWarning;
|
|
63719
|
-
var $Alias = Alias.Alias;
|
|
63720
|
-
var $isAlias = identity.isAlias;
|
|
63721
|
-
var $isCollection = identity.isCollection;
|
|
63722
|
-
var $isDocument = identity.isDocument;
|
|
63723
|
-
var $isMap = identity.isMap;
|
|
63724
|
-
var $isNode = identity.isNode;
|
|
63725
|
-
var $isPair = identity.isPair;
|
|
63726
|
-
var $isScalar = identity.isScalar;
|
|
63727
|
-
var $isSeq = identity.isSeq;
|
|
63728
|
-
var $Pair = Pair.Pair;
|
|
63729
|
-
var $Scalar = Scalar.Scalar;
|
|
63730
|
-
var $YAMLMap = YAMLMap.YAMLMap;
|
|
63731
|
-
var $YAMLSeq = YAMLSeq.YAMLSeq;
|
|
63732
|
-
var $Lexer = lexer.Lexer;
|
|
63733
|
-
var $LineCounter = lineCounter.LineCounter;
|
|
63734
|
-
var $Parser = parser.Parser;
|
|
63735
|
-
var $parse = publicApi.parse;
|
|
63736
|
-
var $parseAllDocuments = publicApi.parseAllDocuments;
|
|
63737
|
-
var $parseDocument = publicApi.parseDocument;
|
|
63738
|
-
var $stringify = publicApi.stringify;
|
|
63739
|
-
var $visit = visit.visit;
|
|
63740
|
-
var $visitAsync = visit.visitAsync;
|
|
63741
|
-
|
|
63742
63940
|
// ../../packages/praxis/deploy-core/src/workspace.ts
|
|
63743
63941
|
function packageJsonIn(dir) {
|
|
63744
63942
|
return dir === "." ? "package.json" : `${dir}/package.json`;
|
|
@@ -63750,6 +63948,16 @@ function dirOfPackageJson(path) {
|
|
|
63750
63948
|
return;
|
|
63751
63949
|
return path.slice(0, -"/package.json".length);
|
|
63752
63950
|
}
|
|
63951
|
+
function packageDirOf(path, dirs) {
|
|
63952
|
+
let found = null;
|
|
63953
|
+
for (const dir of dirs) {
|
|
63954
|
+
if (path !== dir && !path.startsWith(`${dir}/`))
|
|
63955
|
+
continue;
|
|
63956
|
+
if (found === null || dir.length > found.length)
|
|
63957
|
+
found = dir;
|
|
63958
|
+
}
|
|
63959
|
+
return found;
|
|
63960
|
+
}
|
|
63753
63961
|
function dirOfManifest(path) {
|
|
63754
63962
|
for (const name of BUILD_MANIFESTS) {
|
|
63755
63963
|
if (path === name)
|
|
@@ -64157,68 +64365,216 @@ function stronglyConnected(count3, edges) {
|
|
|
64157
64365
|
visit2(node2);
|
|
64158
64366
|
return components;
|
|
64159
64367
|
}
|
|
64160
|
-
// ../../packages/praxis/deploy-core/src/
|
|
64161
|
-
var
|
|
64162
|
-
var
|
|
64163
|
-
function
|
|
64164
|
-
|
|
64165
|
-
|
|
64166
|
-
|
|
64167
|
-
|
|
64168
|
-
|
|
64169
|
-
|
|
64170
|
-
|
|
64171
|
-
|
|
64172
|
-
return { jobState: "skipped", jobRunState: "unspecified" };
|
|
64368
|
+
// ../../packages/praxis/deploy-core/src/root-ownership.ts
|
|
64369
|
+
var ROOT_OWNERSHIP_FILE = "root-ownership.yaml";
|
|
64370
|
+
var ROOT_OWNERSHIP_DEFAULT = "widen";
|
|
64371
|
+
function rootPatternMatches(match, path) {
|
|
64372
|
+
const directory = match.endsWith("/");
|
|
64373
|
+
const pattern = match.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
64374
|
+
if (!directory)
|
|
64375
|
+
return matchesPattern(pattern, path);
|
|
64376
|
+
const segments = path.split("/");
|
|
64377
|
+
for (let take = 1;take <= segments.length; take += 1) {
|
|
64378
|
+
if (matchesPattern(pattern, segments.slice(0, take).join("/")))
|
|
64379
|
+
return true;
|
|
64173
64380
|
}
|
|
64381
|
+
return false;
|
|
64174
64382
|
}
|
|
64175
|
-
function
|
|
64176
|
-
|
|
64177
|
-
|
|
64178
|
-
|
|
64179
|
-
|
|
64180
|
-
|
|
64181
|
-
|
|
64182
|
-
|
|
64183
|
-
|
|
64184
|
-
if (!Number.isFinite(minutes) || minutes <= 0)
|
|
64185
|
-
throw new Error(`--expire-minutes must be a positive number, got ${JSON.stringify(expireMinutes)}`);
|
|
64186
|
-
return new Date(start + minutes * 60000).toISOString();
|
|
64187
|
-
}
|
|
64188
|
-
function decidePhaseState(states) {
|
|
64189
|
-
if (states.length === 0)
|
|
64190
|
-
return "unspecified";
|
|
64191
|
-
if (states.some((state) => state === "failed" || state === "aborted"))
|
|
64192
|
-
return "failed";
|
|
64193
|
-
if (states.some((state) => state === "in_progress" || state === "pending"))
|
|
64194
|
-
return "in_progress";
|
|
64195
|
-
const neverRan = states.every((state) => state === "skipped" || state === "disabled");
|
|
64196
|
-
return neverRan ? "skipped" : "succeeded";
|
|
64197
|
-
}
|
|
64198
|
-
function decideRolloutState(jobs, options = {}) {
|
|
64199
|
-
const states = [...jobs.values()];
|
|
64200
|
-
if (states.some((state) => state === "failed" || state === "aborted"))
|
|
64201
|
-
return "failed";
|
|
64202
|
-
const deploy = jobs.get("deploy");
|
|
64203
|
-
if (deploy === undefined || deploy === "pending" || deploy === "in_progress" || deploy === "disabled")
|
|
64204
|
-
return "pending";
|
|
64205
|
-
if (deploy === "skipped" && options.artifactIdentical !== true)
|
|
64206
|
-
return "pending";
|
|
64207
|
-
if (states.every((state) => state === "succeeded" || state === "skipped" || state === "disabled" || state === "ignored")) {
|
|
64208
|
-
return options.artifactIdentical === true ? "skipped" : "succeeded";
|
|
64383
|
+
function rootOwnershipMatchOf(path, table) {
|
|
64384
|
+
if (table === null)
|
|
64385
|
+
return { kind: "unknown" };
|
|
64386
|
+
for (const rule of table.rules) {
|
|
64387
|
+
if (!rootPatternMatches(rule.match, path))
|
|
64388
|
+
continue;
|
|
64389
|
+
if (rule.kind === "package")
|
|
64390
|
+
return { kind: "package", package: rule.package ?? "" };
|
|
64391
|
+
return { kind: rule.kind };
|
|
64209
64392
|
}
|
|
64210
|
-
return "
|
|
64393
|
+
return { kind: "unknown" };
|
|
64211
64394
|
}
|
|
64212
|
-
|
|
64213
|
-
|
|
64214
|
-
|
|
64215
|
-
|
|
64216
|
-
|
|
64217
|
-
|
|
64218
|
-
|
|
64219
|
-
|
|
64220
|
-
|
|
64221
|
-
|
|
64395
|
+
var KINDS = ["resolving", "package", "none"];
|
|
64396
|
+
function parseRootOwnership(text, options) {
|
|
64397
|
+
if (text === null) {
|
|
64398
|
+
return {
|
|
64399
|
+
kind: "invalid",
|
|
64400
|
+
problems: [
|
|
64401
|
+
{
|
|
64402
|
+
rule: -1,
|
|
64403
|
+
match: ROOT_OWNERSHIP_FILE,
|
|
64404
|
+
problem: `${ROOT_OWNERSHIP_FILE} is missing at this commit`
|
|
64405
|
+
}
|
|
64406
|
+
]
|
|
64407
|
+
};
|
|
64408
|
+
}
|
|
64409
|
+
let parsed;
|
|
64410
|
+
try {
|
|
64411
|
+
parsed = $parse(text);
|
|
64412
|
+
} catch (error) {
|
|
64413
|
+
return {
|
|
64414
|
+
kind: "invalid",
|
|
64415
|
+
problems: [
|
|
64416
|
+
{ rule: -1, match: ROOT_OWNERSHIP_FILE, problem: `not YAML: ${error.message}` }
|
|
64417
|
+
]
|
|
64418
|
+
};
|
|
64419
|
+
}
|
|
64420
|
+
const problems = [];
|
|
64421
|
+
const document2 = parsed ?? null;
|
|
64422
|
+
if (document2 === null || typeof document2 !== "object" || Array.isArray(document2)) {
|
|
64423
|
+
return {
|
|
64424
|
+
kind: "invalid",
|
|
64425
|
+
problems: [
|
|
64426
|
+
{ rule: -1, match: ROOT_OWNERSHIP_FILE, problem: "the document is not a mapping" }
|
|
64427
|
+
]
|
|
64428
|
+
};
|
|
64429
|
+
}
|
|
64430
|
+
if (document2.version !== 1) {
|
|
64431
|
+
problems.push({
|
|
64432
|
+
rule: -1,
|
|
64433
|
+
match: "version",
|
|
64434
|
+
problem: `version must be 1, found ${JSON.stringify(document2.version)}`
|
|
64435
|
+
});
|
|
64436
|
+
}
|
|
64437
|
+
if (document2.default !== ROOT_OWNERSHIP_DEFAULT) {
|
|
64438
|
+
problems.push({
|
|
64439
|
+
rule: -1,
|
|
64440
|
+
match: "default",
|
|
64441
|
+
problem: `default must be "${ROOT_OWNERSHIP_DEFAULT}" — a path no rule claims may never narrow the run`
|
|
64442
|
+
});
|
|
64443
|
+
}
|
|
64444
|
+
if (!Array.isArray(document2.rules)) {
|
|
64445
|
+
problems.push({ rule: -1, match: "rules", problem: "rules must be a list" });
|
|
64446
|
+
return { kind: "invalid", problems };
|
|
64447
|
+
}
|
|
64448
|
+
const workspace = new Set(options.workspaceDirs);
|
|
64449
|
+
const rules = [];
|
|
64450
|
+
document2.rules.forEach((entry, index) => {
|
|
64451
|
+
const rule = entry ?? null;
|
|
64452
|
+
if (rule === null || typeof rule !== "object" || Array.isArray(rule)) {
|
|
64453
|
+
problems.push({
|
|
64454
|
+
rule: index,
|
|
64455
|
+
match: "",
|
|
64456
|
+
problem: "a rule must be a mapping with match and kind"
|
|
64457
|
+
});
|
|
64458
|
+
return;
|
|
64459
|
+
}
|
|
64460
|
+
const match = typeof rule.match === "string" ? rule.match.trim() : "";
|
|
64461
|
+
const kind = typeof rule.kind === "string" ? rule.kind : "";
|
|
64462
|
+
if (match === "") {
|
|
64463
|
+
problems.push({ rule: index, match: "", problem: "match must be a non-empty string" });
|
|
64464
|
+
return;
|
|
64465
|
+
}
|
|
64466
|
+
if (!KINDS.includes(kind)) {
|
|
64467
|
+
problems.push({
|
|
64468
|
+
rule: index,
|
|
64469
|
+
match,
|
|
64470
|
+
problem: `kind must be one of ${KINDS.join(" / ")}, found ${JSON.stringify(rule.kind)}`
|
|
64471
|
+
});
|
|
64472
|
+
return;
|
|
64473
|
+
}
|
|
64474
|
+
const evidence = typeof rule.evidence === "string" ? rule.evidence.trim() : "";
|
|
64475
|
+
const why = typeof rule.why === "string" ? rule.why.trim() : "";
|
|
64476
|
+
if (kind === "package") {
|
|
64477
|
+
const owner = typeof rule.package === "string" ? rule.package.trim() : "";
|
|
64478
|
+
if (owner === "") {
|
|
64479
|
+
problems.push({
|
|
64480
|
+
rule: index,
|
|
64481
|
+
match,
|
|
64482
|
+
problem: "kind: package needs the workspace directory it belongs to"
|
|
64483
|
+
});
|
|
64484
|
+
return;
|
|
64485
|
+
}
|
|
64486
|
+
if (!workspace.has(owner)) {
|
|
64487
|
+
problems.push({
|
|
64488
|
+
rule: index,
|
|
64489
|
+
match,
|
|
64490
|
+
problem: `package "${owner}" is not a workspace package directory at this commit`
|
|
64491
|
+
});
|
|
64492
|
+
return;
|
|
64493
|
+
}
|
|
64494
|
+
if (evidence === "") {
|
|
64495
|
+
rules.push({ match, kind: "resolving", evidenceMissing: true, ...why === "" ? {} : { why } });
|
|
64496
|
+
return;
|
|
64497
|
+
}
|
|
64498
|
+
rules.push({ match, kind: "package", package: owner, evidence, ...why === "" ? {} : { why } });
|
|
64499
|
+
return;
|
|
64500
|
+
}
|
|
64501
|
+
if (rule.package !== undefined) {
|
|
64502
|
+
problems.push({
|
|
64503
|
+
rule: index,
|
|
64504
|
+
match,
|
|
64505
|
+
problem: `package is only allowed on kind: package (this rule is ${kind})`
|
|
64506
|
+
});
|
|
64507
|
+
return;
|
|
64508
|
+
}
|
|
64509
|
+
if (kind === "none" && evidence === "") {
|
|
64510
|
+
rules.push({ match, kind: "resolving", evidenceMissing: true, ...why === "" ? {} : { why } });
|
|
64511
|
+
return;
|
|
64512
|
+
}
|
|
64513
|
+
rules.push({
|
|
64514
|
+
match,
|
|
64515
|
+
kind,
|
|
64516
|
+
...evidence === "" ? {} : { evidence },
|
|
64517
|
+
...why === "" ? {} : { why }
|
|
64518
|
+
});
|
|
64519
|
+
});
|
|
64520
|
+
if (problems.length > 0)
|
|
64521
|
+
return { kind: "invalid", problems };
|
|
64522
|
+
const table = { version: 1, rules, default: ROOT_OWNERSHIP_DEFAULT };
|
|
64523
|
+
if (rootOwnershipMatchOf(ROOT_OWNERSHIP_FILE, table).kind !== "resolving") {
|
|
64524
|
+
return {
|
|
64525
|
+
kind: "invalid",
|
|
64526
|
+
problems: [
|
|
64527
|
+
{
|
|
64528
|
+
rule: -1,
|
|
64529
|
+
match: ROOT_OWNERSHIP_FILE,
|
|
64530
|
+
problem: `${ROOT_OWNERSHIP_FILE} must classify itself as resolving: a change to the table can change every package's inputs`
|
|
64531
|
+
}
|
|
64532
|
+
]
|
|
64533
|
+
};
|
|
64534
|
+
}
|
|
64535
|
+
return { kind: "table", table };
|
|
64536
|
+
}
|
|
64537
|
+
function namedPackagesOf(input) {
|
|
64538
|
+
const named = new Set;
|
|
64539
|
+
for (const path of input.changedPaths) {
|
|
64540
|
+
const dir = packageDirOf(path, input.workspaceDirs);
|
|
64541
|
+
if (dir !== null)
|
|
64542
|
+
named.add(dir);
|
|
64543
|
+
}
|
|
64544
|
+
const roots = rootOwnershipDecisionOf(input);
|
|
64545
|
+
for (const dir of roots.packages)
|
|
64546
|
+
if (input.workspaceDirs.includes(dir))
|
|
64547
|
+
named.add(dir);
|
|
64548
|
+
return { packages: roots.widened ? [] : [...named].sort(), roots };
|
|
64549
|
+
}
|
|
64550
|
+
function rootOwnershipDecisionOf(input) {
|
|
64551
|
+
const unclaimed = input.changedPaths.filter((path) => packageDirOf(path, input.workspaceDirs) === null);
|
|
64552
|
+
const named = new Set;
|
|
64553
|
+
const traces = [];
|
|
64554
|
+
let widened = false;
|
|
64555
|
+
for (const path of unclaimed) {
|
|
64556
|
+
if (input.table === null) {
|
|
64557
|
+
widened = true;
|
|
64558
|
+
traces.push({ path, reason: "table-unreadable" });
|
|
64559
|
+
continue;
|
|
64560
|
+
}
|
|
64561
|
+
const match = rootOwnershipMatchOf(path, input.table);
|
|
64562
|
+
if (match.kind === "package")
|
|
64563
|
+
named.add(match.package);
|
|
64564
|
+
else if (match.kind === "none")
|
|
64565
|
+
continue;
|
|
64566
|
+
else {
|
|
64567
|
+
widened = true;
|
|
64568
|
+
traces.push({ path, reason: match.kind });
|
|
64569
|
+
}
|
|
64570
|
+
}
|
|
64571
|
+
return {
|
|
64572
|
+
unclaimed,
|
|
64573
|
+
widened,
|
|
64574
|
+
traces,
|
|
64575
|
+
packages: widened ? [] : [...named].sort(),
|
|
64576
|
+
allNone: !widened && unclaimed.length > 0 && named.size === 0
|
|
64577
|
+
};
|
|
64222
64578
|
}
|
|
64223
64579
|
// ../../packages/praxis/deploy-core/src/job-events-file.ts
|
|
64224
64580
|
import { appendFileSync, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
@@ -64337,7 +64693,7 @@ function reportBlockedTarget(events, target, message) {
|
|
|
64337
64693
|
}
|
|
64338
64694
|
|
|
64339
64695
|
// src/commands/devops.ts
|
|
64340
|
-
var
|
|
64696
|
+
var import_yaml4 = __toESM(require_dist(), 1);
|
|
64341
64697
|
|
|
64342
64698
|
// src/commands/devops-deploy-plan.ts
|
|
64343
64699
|
import { resolve as resolve3 } from "node:path";
|
|
@@ -65722,7 +66078,7 @@ async function devopsDeployTofu(flags, ports) {
|
|
|
65722
66078
|
const projectYaml = await ports.readFile(join5(ports.cwd, "praxis.yaml"));
|
|
65723
66079
|
let parsedYaml;
|
|
65724
66080
|
try {
|
|
65725
|
-
parsedYaml = projectYaml === null ? undefined :
|
|
66081
|
+
parsedYaml = projectYaml === null ? undefined : import_yaml4.parse(projectYaml);
|
|
65726
66082
|
} catch (error) {
|
|
65727
66083
|
throw new UsageError(`praxis.yaml is not valid YAML: ${error.message}`);
|
|
65728
66084
|
}
|
|
@@ -65972,17 +66328,6 @@ function selectAffected(input) {
|
|
|
65972
66328
|
reasons[spelled.get(relative2)] = reason;
|
|
65973
66329
|
return { tests: selected.map(({ relative: relative2 }) => spelled.get(relative2)), features, reasons, openIssues: [...AFFECTED_OPEN_ISSUES] };
|
|
65974
66330
|
}
|
|
65975
|
-
function nearestPackage(path, packages) {
|
|
65976
|
-
let found = null;
|
|
65977
|
-
for (const candidate of packages) {
|
|
65978
|
-
const root = candidate.replace(/\/+$/, "");
|
|
65979
|
-
if (!root || !(path === root || path.startsWith(`${root}/`)))
|
|
65980
|
-
continue;
|
|
65981
|
-
if (found === null || root.length > found.length)
|
|
65982
|
-
found = root;
|
|
65983
|
-
}
|
|
65984
|
-
return found;
|
|
65985
|
-
}
|
|
65986
66331
|
var BUN_FILE_HEADER = /^(\S.*\.(?:test|spec)\.(?:ts|tsx|js|mjs)):$/;
|
|
65987
66332
|
var BUN_COUNT = /^\s*(\d+)\s+(pass|fail|skip|todo)\b/;
|
|
65988
66333
|
var BUN_RAN = /^Ran (\d+) tests? across/;
|
|
@@ -66109,38 +66454,69 @@ async function changedSelection(since, ports) {
|
|
|
66109
66454
|
const roots = await ports.checkout.roots();
|
|
66110
66455
|
const grouped = new Map;
|
|
66111
66456
|
for (const file of files) {
|
|
66112
|
-
const owner =
|
|
66457
|
+
const owner = packageDirOf(file, roots);
|
|
66113
66458
|
if (owner === null)
|
|
66114
66459
|
continue;
|
|
66115
66460
|
grouped.set(owner, [...grouped.get(owner) ?? [], file]);
|
|
66116
66461
|
}
|
|
66462
|
+
const parsed = parseRootOwnership(await ports.checkout.read(ROOT_OWNERSHIP_FILE), { workspaceDirs: roots });
|
|
66463
|
+
const named = namedPackagesOf({ changedPaths: files, workspaceDirs: roots, table: parsed.kind === "table" ? parsed.table : null });
|
|
66464
|
+
const widen = named.roots.widened ? { paths: named.roots.traces.map((trace) => trace.path), reason: widenReason(named.roots.traces.map((trace) => trace.reason)) } : null;
|
|
66465
|
+
const failed = widen === null && files.length > 0 && named.packages.length === 0 && !named.roots.allNone ? { paths: [...named.roots.unclaimed].sort() } : null;
|
|
66466
|
+
const namedByTable = new Set(named.packages.filter((dir) => !grouped.has(dir)));
|
|
66467
|
+
const selectedRoots = widen !== null ? [...roots].sort((a, b) => a.localeCompare(b, "en")) : [...new Set([...grouped.keys(), ...namedByTable])].sort((a, b) => a.localeCompare(b, "en"));
|
|
66117
66468
|
const groups = [];
|
|
66118
|
-
for (const root of
|
|
66469
|
+
for (const root of selectedRoots) {
|
|
66119
66470
|
const packagePath = join6(ports.checkout.root, root);
|
|
66120
|
-
groups.push({
|
|
66471
|
+
groups.push({
|
|
66472
|
+
root,
|
|
66473
|
+
path: packagePath,
|
|
66474
|
+
whole: widen !== null || namedByTable.has(root),
|
|
66475
|
+
selection: selectAffected({ changed: grouped.get(root) ?? [], files: await ports.checkout.sources(packagePath), packageRoot: root })
|
|
66476
|
+
});
|
|
66121
66477
|
}
|
|
66122
66478
|
const owned = new Set([...grouped.values()].flat());
|
|
66123
|
-
return { base, files, groups, unowned: files.filter((file) => !owned.has(file)) };
|
|
66479
|
+
return { base, files, groups, unowned: files.filter((file) => !owned.has(file)), widen, failed };
|
|
66480
|
+
}
|
|
66481
|
+
function widenReason(reasons) {
|
|
66482
|
+
if (reasons.includes("table-unreadable"))
|
|
66483
|
+
return `${ROOT_OWNERSHIP_FILE} 读不出来(缺失或不合法),按整仓跑`;
|
|
66484
|
+
if (reasons.includes("unknown"))
|
|
66485
|
+
return "有仓库根路径没被表判定,按整仓跑";
|
|
66486
|
+
return "改到了仓库根的解析类文件(整仓都可能受影响)";
|
|
66124
66487
|
}
|
|
66125
66488
|
async function runAffected(list, since, ports) {
|
|
66126
|
-
const { base, files, groups, unowned } = await changedSelection(since, ports);
|
|
66489
|
+
const { base, files, groups, unowned, widen, failed } = await changedSelection(since, ports);
|
|
66127
66490
|
const view = {
|
|
66128
66491
|
since: base,
|
|
66129
66492
|
packages: groups.map((group) => ({
|
|
66130
66493
|
path: group.root,
|
|
66131
66494
|
tests: group.selection.tests.map((file) => ({ file, reason: group.selection.reasons[file] })),
|
|
66132
|
-
features: group.selection.features
|
|
66495
|
+
features: group.selection.features,
|
|
66496
|
+
...group.whole ? { whole: true } : {}
|
|
66133
66497
|
})),
|
|
66134
66498
|
tests: groups.flatMap((group) => group.selection.tests),
|
|
66135
66499
|
features: groups.flatMap((group) => group.selection.features),
|
|
66136
66500
|
unowned,
|
|
66501
|
+
widen,
|
|
66502
|
+
failed,
|
|
66137
66503
|
openIssues: [...selectAffected({ changed: [], files: new Map, packageRoot: "" }).openIssues]
|
|
66138
66504
|
};
|
|
66139
|
-
const lines = [
|
|
66140
|
-
...
|
|
66141
|
-
...
|
|
66142
|
-
|
|
66143
|
-
|
|
66505
|
+
const lines = [
|
|
66506
|
+
...widen === null ? [] : [`${widen.reason}:${widen.paths.join("、")} → 每个包整套测试`],
|
|
66507
|
+
...view.packages.flatMap((entry) => [
|
|
66508
|
+
...entry.tests.map(({ file, reason }) => `${file} (${reason})`),
|
|
66509
|
+
...entry.features.map((feature) => `${feature.file} (feature: ${feature.title})`)
|
|
66510
|
+
]),
|
|
66511
|
+
...view.openIssues.map((issue) => `note: ${issue}`)
|
|
66512
|
+
];
|
|
66513
|
+
if (failed !== null) {
|
|
66514
|
+
ports.emit({ kind: "object", data: view });
|
|
66515
|
+
ports.human([`选包塌成 0 个包:这些仓库根路径没有对应的包,也不在 ${ROOT_OWNERSHIP_FILE} 里被判成 none——先补表,别让它静默少跑:`, ...failed.paths].join(`
|
|
66516
|
+
`));
|
|
66517
|
+
return 1;
|
|
66518
|
+
}
|
|
66519
|
+
if (list || !groups.some((group) => group.whole) && view.tests.length === 0 && view.features.length === 0) {
|
|
66144
66520
|
ports.emit({ kind: "object", data: view });
|
|
66145
66521
|
ports.human([files.length === 0 ? `nothing changed since ${base}` : `${view.tests.length} test file(s) and ${view.features.length} feature(s) affected since ${base}:`, ...lines].join(`
|
|
66146
66522
|
`));
|
|
@@ -66148,9 +66524,9 @@ async function runAffected(list, since, ports) {
|
|
|
66148
66524
|
}
|
|
66149
66525
|
const runs = [];
|
|
66150
66526
|
for (const group of groups) {
|
|
66151
|
-
const
|
|
66152
|
-
if (
|
|
66153
|
-
const result = await ports.checkout.runTests(group.path,
|
|
66527
|
+
const selected = group.whole ? [] : group.selection.tests.map((file) => stripRoot(file, group.root));
|
|
66528
|
+
if (group.whole || selected.length) {
|
|
66529
|
+
const result = await ports.checkout.runTests(group.path, selected);
|
|
66154
66530
|
runs.push(bunTestRun(group.root, result.code, result.output));
|
|
66155
66531
|
}
|
|
66156
66532
|
for (const feature of group.selection.features)
|
|
@@ -66389,7 +66765,16 @@ async function localCheckout(cwd, spawn5) {
|
|
|
66389
66765
|
await walk(packagePath);
|
|
66390
66766
|
return files;
|
|
66391
66767
|
},
|
|
66392
|
-
runTests: (packagePath, files) => spawn5("nice", ["-n", "10", "bun", "test", ...files], { cwd: packagePath })
|
|
66768
|
+
runTests: (packagePath, files) => spawn5("nice", ["-n", "10", "bun", "test", ...files], { cwd: packagePath }),
|
|
66769
|
+
read: async (path) => {
|
|
66770
|
+
try {
|
|
66771
|
+
return await readFile4(join6(root, path), "utf8");
|
|
66772
|
+
} catch (error) {
|
|
66773
|
+
if (error.code === "ENOENT")
|
|
66774
|
+
return null;
|
|
66775
|
+
throw error;
|
|
66776
|
+
}
|
|
66777
|
+
}
|
|
66393
66778
|
};
|
|
66394
66779
|
}
|
|
66395
66780
|
async function withEngineStdoutOnStderr(body) {
|
|
@@ -70056,6 +70441,131 @@ async function runChannel(ports) {
|
|
|
70056
70441
|
return 0;
|
|
70057
70442
|
}
|
|
70058
70443
|
|
|
70444
|
+
// src/commands/agent-memory.ts
|
|
70445
|
+
var MEMORY_TOOL = "praxis_assume_memory";
|
|
70446
|
+
var RECALL_TOOL = "praxis_assume_recall";
|
|
70447
|
+
var REMEMBER_TOOL = "praxis_assume_remember";
|
|
70448
|
+
function mcpUrl(apiUrl, agent) {
|
|
70449
|
+
return `${apiUrl}/agent/v1/agents/${encodeURIComponent(agent)}/mcp`;
|
|
70450
|
+
}
|
|
70451
|
+
function rpcAnswerOf(body, id) {
|
|
70452
|
+
const candidates2 = body.trimStart().startsWith("{") ? [body] : body.split(`
|
|
70453
|
+
`).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trim());
|
|
70454
|
+
for (const candidate of candidates2) {
|
|
70455
|
+
try {
|
|
70456
|
+
const parsed = JSON.parse(candidate);
|
|
70457
|
+
if (parsed.id === id)
|
|
70458
|
+
return parsed;
|
|
70459
|
+
} catch {}
|
|
70460
|
+
}
|
|
70461
|
+
return null;
|
|
70462
|
+
}
|
|
70463
|
+
function toolTextOf(result) {
|
|
70464
|
+
const value = result;
|
|
70465
|
+
const text3 = (value?.content ?? []).filter((part) => part.type === "text" && typeof part.text === "string").map((part) => part.text).join(`
|
|
70466
|
+
`).trim();
|
|
70467
|
+
return value?.isError === true ? { ok: false, reason: text3 || "the tool refused" } : { ok: true, text: text3 };
|
|
70468
|
+
}
|
|
70469
|
+
async function callAgentTool(ports, url, name, args, signal) {
|
|
70470
|
+
const base = { ...await ports.headers(), "Content-Type": "application/json", Accept: "application/json, text/event-stream" };
|
|
70471
|
+
const post = (body, session2) => ports.fetch(url, {
|
|
70472
|
+
method: "POST",
|
|
70473
|
+
headers: { ...base, ...session2 === undefined ? {} : { "Mcp-Session-Id": session2 } },
|
|
70474
|
+
body: JSON.stringify(body),
|
|
70475
|
+
...signal === undefined ? {} : { signal },
|
|
70476
|
+
redirect: "error"
|
|
70477
|
+
});
|
|
70478
|
+
const init = await post({ jsonrpc: "2.0", id: 1, method: "initialize", params: {
|
|
70479
|
+
protocolVersion: "2025-06-18",
|
|
70480
|
+
capabilities: {},
|
|
70481
|
+
clientInfo: { name: "praxis-cli-memory", version: "1" }
|
|
70482
|
+
} });
|
|
70483
|
+
const initBody = await init.text();
|
|
70484
|
+
if (!init.ok)
|
|
70485
|
+
throw new Error(`HTTP ${init.status} on initialize`);
|
|
70486
|
+
const session = init.headers.get("Mcp-Session-Id") ?? undefined;
|
|
70487
|
+
const initAnswer = rpcAnswerOf(initBody, 1);
|
|
70488
|
+
if (initAnswer?.error)
|
|
70489
|
+
throw new Error(initAnswer.error.message ?? "initialize failed");
|
|
70490
|
+
await post({ jsonrpc: "2.0", method: "notifications/initialized" }, session).then((r) => r.text()).catch(() => "");
|
|
70491
|
+
const call3 = await post({ jsonrpc: "2.0", id: 2, method: "tools/call", params: { name, arguments: args } }, session);
|
|
70492
|
+
const callBody = await call3.text();
|
|
70493
|
+
if (!call3.ok)
|
|
70494
|
+
throw new Error(`HTTP ${call3.status} on ${name}`);
|
|
70495
|
+
const answer = rpcAnswerOf(callBody, 2);
|
|
70496
|
+
if (answer === null)
|
|
70497
|
+
throw new Error(`no answer from ${name}`);
|
|
70498
|
+
if (answer.error)
|
|
70499
|
+
throw new Error(answer.error.message ?? `${name} failed`);
|
|
70500
|
+
const text3 = toolTextOf(answer.result);
|
|
70501
|
+
if (!text3.ok)
|
|
70502
|
+
throw new Error(text3.reason);
|
|
70503
|
+
return text3.text;
|
|
70504
|
+
}
|
|
70505
|
+
function memoryBodyOf(text3) {
|
|
70506
|
+
return text3.split(`
|
|
70507
|
+
`).filter((line) => {
|
|
70508
|
+
const trimmed = line.trim();
|
|
70509
|
+
return !/^shell: acon_/.test(trimmed) && !/^你有 \d+ 封未读信/.test(trimmed) && !/^You have \d+ unread letter/.test(trimmed);
|
|
70510
|
+
}).join(`
|
|
70511
|
+
`).trim();
|
|
70512
|
+
}
|
|
70513
|
+
function paragraphKey(paragraph) {
|
|
70514
|
+
return paragraph.replace(/\s*\[n\d+\]/g, "").replace(/\s+/g, " ").trim();
|
|
70515
|
+
}
|
|
70516
|
+
function newParagraphs(memory, seen) {
|
|
70517
|
+
const seenKeys = new Set([...seen].map(paragraphKey));
|
|
70518
|
+
return memory.split(/\n{2,}/).map((part) => part.trim()).filter((part) => part !== "" && !seenKeys.has(paragraphKey(part)));
|
|
70519
|
+
}
|
|
70520
|
+
var MEMORY_FRAME = (body) => `<memory source="praxis-assume" note="your memory as this agent, drawn from your organization just now; recall with praxis_assume_recall">
|
|
70521
|
+
${body}
|
|
70522
|
+
</memory>`;
|
|
70523
|
+
var MEMORY_CHANGED_FRAME = (body) => `<memory_since_start source="praxis-assume" note="what came to mind since this conversation last read your memory">
|
|
70524
|
+
${body}
|
|
70525
|
+
</memory_since_start>`;
|
|
70526
|
+
function hookOutput(event, context) {
|
|
70527
|
+
if (context === null || context.trim() === "")
|
|
70528
|
+
return null;
|
|
70529
|
+
return JSON.stringify({ hookSpecificOutput: { hookEventName: event, additionalContext: context } });
|
|
70530
|
+
}
|
|
70531
|
+
function hookInputOf(raw) {
|
|
70532
|
+
try {
|
|
70533
|
+
const parsed = JSON.parse(raw);
|
|
70534
|
+
const sessionId = typeof parsed.session_id === "string" && /^[A-Za-z0-9_-]{1,128}$/.test(parsed.session_id) ? parsed.session_id : null;
|
|
70535
|
+
return { sessionId, source: typeof parsed.source === "string" ? parsed.source : null };
|
|
70536
|
+
} catch {
|
|
70537
|
+
return { sessionId: null, source: null };
|
|
70538
|
+
}
|
|
70539
|
+
}
|
|
70540
|
+
async function runMemoryHook(event, input, ports) {
|
|
70541
|
+
try {
|
|
70542
|
+
const memory = memoryBodyOf(await callAgentTool(ports, ports.url, MEMORY_TOOL, {}, AbortSignal.timeout(ports.timeoutMs)));
|
|
70543
|
+
if (memory === "")
|
|
70544
|
+
return null;
|
|
70545
|
+
const all = newParagraphs(memory, new Set);
|
|
70546
|
+
if (event === "SessionStart") {
|
|
70547
|
+
if (input.sessionId !== null)
|
|
70548
|
+
await ports.writeSeen(input.sessionId, all).catch(() => {
|
|
70549
|
+
return;
|
|
70550
|
+
});
|
|
70551
|
+
return hookOutput(event, MEMORY_FRAME(memory));
|
|
70552
|
+
}
|
|
70553
|
+
const seen = input.sessionId === null ? [] : await ports.readSeen(input.sessionId).catch(() => []);
|
|
70554
|
+
const fresh = newParagraphs(memory, new Set(seen));
|
|
70555
|
+
if (fresh.length === 0)
|
|
70556
|
+
return null;
|
|
70557
|
+
if (input.sessionId !== null)
|
|
70558
|
+
await ports.writeSeen(input.sessionId, [...seen, ...fresh]).catch(() => {
|
|
70559
|
+
return;
|
|
70560
|
+
});
|
|
70561
|
+
return hookOutput(event, MEMORY_CHANGED_FRAME(fresh.join(`
|
|
70562
|
+
|
|
70563
|
+
`)));
|
|
70564
|
+
} catch {
|
|
70565
|
+
return null;
|
|
70566
|
+
}
|
|
70567
|
+
}
|
|
70568
|
+
|
|
70059
70569
|
// src/main.ts
|
|
70060
70570
|
import { spawnSync } from "node:child_process";
|
|
70061
70571
|
|
|
@@ -70692,7 +71202,7 @@ function startProgress(ctx, write = (text3) => writeOutput({ stderr: text3 })) {
|
|
|
70692
71202
|
}
|
|
70693
71203
|
|
|
70694
71204
|
// src/main.ts
|
|
70695
|
-
var version = "0.3.0-dev.
|
|
71205
|
+
var version = "0.3.0-dev.5753565";
|
|
70696
71206
|
var commands = commandTree(operations);
|
|
70697
71207
|
var manual = [...workflows.map((w) => w.words), [API_WORD]];
|
|
70698
71208
|
function route(argv) {
|
|
@@ -70871,6 +71381,17 @@ var appOptions = {
|
|
|
70871
71381
|
{ name: "report", type: "boolean", description: "Post this checkout's scan to the platform, so archiving a flag is refused while code still names it (ADR-125 §4)." },
|
|
70872
71382
|
{ name: "project", type: "string", description: "With --report: the DevOps project id (dvp_…) whose flags the scan is reported into. Required." }
|
|
70873
71383
|
],
|
|
71384
|
+
"agent memory": [
|
|
71385
|
+
{ name: "hook", type: "string", description: "Run as a Claude Code hook (SessionStart or UserPromptSubmit): read the hook input on stdin, print the hook JSON or nothing, always exit 0." }
|
|
71386
|
+
],
|
|
71387
|
+
"agent recall": [
|
|
71388
|
+
{ name: "words", type: "string", repeated: true, description: "Distinctive words to recall by, comma-separated or repeated." },
|
|
71389
|
+
{ name: "handles", type: "string", repeated: true, description: "Entry handles or ids from memory to recall, comma-separated or repeated." }
|
|
71390
|
+
],
|
|
71391
|
+
"agent remember": [
|
|
71392
|
+
{ name: "text", type: "string", description: "The experience, in your own words: what happened, who, what was decided and why, what is still open." },
|
|
71393
|
+
{ name: "about", type: "string", repeated: true, description: "Ids of entities it is about, comma-separated or repeated." }
|
|
71394
|
+
],
|
|
70874
71395
|
"agent events wait": [
|
|
70875
71396
|
{ name: "timeout", type: "string", description: "Give up after this many seconds, print that nothing arrived and exit 0 (default: wait until a letter arrives)." },
|
|
70876
71397
|
{ name: "session", type: "string", description: "The Claude Code session this waiter wakes: its announced letters and pid file are kept per session, and a second waiter for the same session exits at once (default: one waiter per agent)." }
|
|
@@ -71481,6 +72002,54 @@ Examples:
|
|
|
71481
72002
|
}
|
|
71482
72003
|
});
|
|
71483
72004
|
}
|
|
72005
|
+
case "agent memory":
|
|
72006
|
+
case "agent recall":
|
|
72007
|
+
case "agent remember": {
|
|
72008
|
+
const agent = assumeAgentOf(ports.env);
|
|
72009
|
+
const mcpPorts = {
|
|
72010
|
+
fetch: (url2, init) => wireFetch(url2, init),
|
|
72011
|
+
headers: async () => {
|
|
72012
|
+
const credential = await auth.get(org);
|
|
72013
|
+
return { Authorization: `Bearer ${credential.token}`, ...credential.source === "api-key" ? { "X-API-Key": credential.token } : {} };
|
|
72014
|
+
}
|
|
72015
|
+
};
|
|
72016
|
+
const url = mcpUrl(config.apiUrl, agent);
|
|
72017
|
+
const hook = parsed.flags.hook?.[0];
|
|
72018
|
+
if (name === "agent memory" && hook !== undefined) {
|
|
72019
|
+
if (hook !== "SessionStart" && hook !== "UserPromptSubmit")
|
|
72020
|
+
throw new UsageError(`--hook takes SessionStart or UserPromptSubmit, not ${hook}`, "Example: praxis agent memory --hook SessionStart");
|
|
72021
|
+
process.stdin.setEncoding("utf8");
|
|
72022
|
+
let raw = "";
|
|
72023
|
+
if (!process.stdin.isTTY)
|
|
72024
|
+
for await (const chunk of process.stdin)
|
|
72025
|
+
raw += chunk;
|
|
72026
|
+
const input = hookInputOf(raw);
|
|
72027
|
+
const seenDir = join12(ports.env.HOME || homedir3(), ".praxis", "cli", "memory-seen");
|
|
72028
|
+
const out = await runMemoryHook(hook, input, {
|
|
72029
|
+
...mcpPorts,
|
|
72030
|
+
url,
|
|
72031
|
+
timeoutMs: 25000,
|
|
72032
|
+
readSeen: async (id) => JSON.parse(await readFile7(join12(seenDir, `${id}.json`), "utf8")),
|
|
72033
|
+
writeSeen: async (id, paragraphs) => {
|
|
72034
|
+
await mkdir4(seenDir, { recursive: true, mode: 448 });
|
|
72035
|
+
await writeFile5(join12(seenDir, `${id}.json`), JSON.stringify(paragraphs), { mode: 384 });
|
|
72036
|
+
}
|
|
72037
|
+
});
|
|
72038
|
+
if (out !== null)
|
|
72039
|
+
process.stdout.write(out + `
|
|
72040
|
+
`);
|
|
72041
|
+
return 0;
|
|
72042
|
+
}
|
|
72043
|
+
const list = (flag) => (parsed.flags[flag] ?? []).flatMap((value) => value.split(",")).map((value) => value.trim()).filter(Boolean);
|
|
72044
|
+
const args = name === "agent recall" ? { ...list("handles").length ? { handles: list("handles") } : {}, ...list("words").length ? { words: list("words") } : {} } : name === "agent remember" ? { text: parsed.flags.text?.[0] ?? "", ...list("about").length ? { about: list("about") } : {} } : {};
|
|
72045
|
+
if (name === "agent remember" && String(args.text).trim() === "")
|
|
72046
|
+
throw new UsageError("--text is required", 'Example: praxis agent remember --text "今天定了……"');
|
|
72047
|
+
const tool = name === "agent memory" ? MEMORY_TOOL : name === "agent recall" ? RECALL_TOOL : REMEMBER_TOOL;
|
|
72048
|
+
const text3 = memoryBodyOf(await callAgentTool(mcpPorts, url, tool, args, AbortSignal.timeout(60000)));
|
|
72049
|
+
process.stdout.write(text3 + `
|
|
72050
|
+
`);
|
|
72051
|
+
return 0;
|
|
72052
|
+
}
|
|
71484
72053
|
case "agent events wait": {
|
|
71485
72054
|
const agent = assumeAgentOf(ports.env);
|
|
71486
72055
|
const timeoutMs = (() => {
|