@kya-os/cli 1.8.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/build.js +2 -2
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/check.js +3 -3
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/checkpoint-init.d.ts +1 -1
- package/dist/commands/checkpoint-init.d.ts.map +1 -1
- package/dist/commands/checkpoint-init.js +8 -41
- package/dist/commands/checkpoint-init.js.map +1 -1
- package/dist/commands/claim.js +2 -2
- package/dist/commands/claim.js.map +1 -1
- package/dist/commands/dco.d.ts +38 -1
- package/dist/commands/dco.d.ts.map +1 -1
- package/dist/commands/dco.js +180 -7
- package/dist/commands/dco.js.map +1 -1
- package/dist/commands/dev.js +1 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +18 -24
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/env.js +6 -6
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/identity.js +3 -3
- package/dist/commands/identity.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +103 -65
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/register.d.ts +1 -1
- package/dist/commands/register.d.ts.map +1 -1
- package/dist/commands/register.js +35 -7
- package/dist/commands/register.js.map +1 -1
- package/dist/commands/rotate.js +4 -4
- package/dist/commands/rotate.js.map +1 -1
- package/dist/commands/start.js +3 -3
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/status.js +1 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/verify.js +6 -6
- package/dist/commands/verify.js.map +1 -1
- package/dist/dco.d.ts +4 -0
- package/dist/dco.d.ts.map +1 -0
- package/dist/dco.js +21 -0
- package/dist/dco.js.map +1 -0
- package/dist/index.js +8 -13
- package/dist/utils/checkpoint-api.d.ts +1 -1
- package/dist/utils/checkpoint-api.js +1 -1
- package/dist/utils/checkpoint-env.d.ts +1 -1
- package/dist/utils/checkpoint-env.js +2 -2
- package/dist/utils/checkpoint-env.js.map +1 -1
- package/dist/utils/checkpoint-scaffold.d.ts +1 -1
- package/dist/utils/checkpoint-scaffold.js +1 -1
- package/dist/utils/cli-kit/browser.d.ts +24 -0
- package/dist/utils/cli-kit/browser.d.ts.map +1 -0
- package/dist/utils/cli-kit/browser.js +58 -0
- package/dist/utils/cli-kit/browser.js.map +1 -0
- package/dist/utils/cli-kit/claim-polling.d.ts +18 -0
- package/dist/utils/cli-kit/claim-polling.d.ts.map +1 -0
- package/dist/utils/{claim-polling.js → cli-kit/claim-polling.js} +19 -26
- package/dist/utils/cli-kit/claim-polling.js.map +1 -0
- package/dist/utils/cli-kit/diagnostics.d.ts +9 -0
- package/dist/utils/cli-kit/diagnostics.d.ts.map +1 -0
- package/dist/utils/cli-kit/diagnostics.js +11 -0
- package/dist/utils/cli-kit/diagnostics.js.map +1 -0
- package/dist/utils/cli-kit/fs-safe.d.ts +14 -0
- package/dist/utils/cli-kit/fs-safe.d.ts.map +1 -0
- package/dist/utils/cli-kit/fs-safe.js +20 -0
- package/dist/utils/cli-kit/fs-safe.js.map +1 -0
- package/dist/utils/cli-kit/index.d.ts +15 -0
- package/dist/utils/cli-kit/index.d.ts.map +1 -0
- package/dist/utils/cli-kit/index.js +10 -0
- package/dist/utils/cli-kit/index.js.map +1 -0
- package/dist/utils/cli-kit/json-file.d.ts +21 -0
- package/dist/utils/cli-kit/json-file.d.ts.map +1 -0
- package/dist/utils/cli-kit/json-file.js +51 -0
- package/dist/utils/cli-kit/json-file.js.map +1 -0
- package/dist/utils/cli-kit/marker-block.d.ts +26 -0
- package/dist/utils/cli-kit/marker-block.d.ts.map +1 -0
- package/dist/utils/cli-kit/marker-block.js +61 -0
- package/dist/utils/cli-kit/marker-block.js.map +1 -0
- package/dist/utils/cli-kit/paths.d.ts +15 -0
- package/dist/utils/cli-kit/paths.d.ts.map +1 -0
- package/dist/utils/cli-kit/paths.js +21 -0
- package/dist/utils/cli-kit/paths.js.map +1 -0
- package/dist/utils/cli-kit/secure-storage.d.ts +14 -0
- package/dist/utils/cli-kit/secure-storage.d.ts.map +1 -0
- package/dist/utils/cli-kit/secure-storage.js +20 -0
- package/dist/utils/cli-kit/secure-storage.js.map +1 -0
- package/dist/utils/cli-kit/step-report.d.ts +16 -0
- package/dist/utils/cli-kit/step-report.d.ts.map +1 -0
- package/dist/utils/cli-kit/step-report.js +36 -0
- package/dist/utils/cli-kit/step-report.js.map +1 -0
- package/dist/utils/dco/agent-metadata.d.ts +1 -1
- package/dist/utils/dco/agent-metadata.js +1 -1
- package/dist/utils/dco/agent-metadata.js.map +1 -1
- package/dist/utils/dco/claude-config.d.ts +18 -14
- package/dist/utils/dco/claude-config.d.ts.map +1 -1
- package/dist/utils/dco/claude-config.js +31 -97
- package/dist/utils/dco/claude-config.js.map +1 -1
- package/dist/utils/dco/dispatch.d.ts +59 -0
- package/dist/utils/dco/dispatch.d.ts.map +1 -0
- package/dist/utils/dco/dispatch.js +332 -0
- package/dist/utils/dco/dispatch.js.map +1 -0
- package/dist/utils/dco/git-config.d.ts.map +1 -1
- package/dist/utils/dco/git-config.js +5 -3
- package/dist/utils/dco/git-config.js.map +1 -1
- package/dist/utils/dco/github.d.ts +8 -0
- package/dist/utils/dco/github.d.ts.map +1 -1
- package/dist/utils/dco/github.js +11 -0
- package/dist/utils/dco/github.js.map +1 -1
- package/dist/utils/dco/paths.d.ts +1 -8
- package/dist/utils/dco/paths.d.ts.map +1 -1
- package/dist/utils/dco/paths.js +3 -12
- package/dist/utils/dco/paths.js.map +1 -1
- package/dist/utils/dco/render.d.ts +1 -1
- package/dist/utils/dco/render.d.ts.map +1 -1
- package/dist/utils/dco/render.js +4 -21
- package/dist/utils/dco/render.js.map +1 -1
- package/dist/utils/dco/resolve-agent.d.ts +54 -0
- package/dist/utils/dco/resolve-agent.d.ts.map +1 -0
- package/dist/utils/dco/resolve-agent.js +164 -0
- package/dist/utils/dco/resolve-agent.js.map +1 -0
- package/dist/utils/dco/setup.d.ts +10 -7
- package/dist/utils/dco/setup.d.ts.map +1 -1
- package/dist/utils/dco/setup.js +304 -203
- package/dist/utils/dco/setup.js.map +1 -1
- package/dist/utils/dco/ssh-key.d.ts +13 -0
- package/dist/utils/dco/ssh-key.d.ts.map +1 -1
- package/dist/utils/dco/ssh-key.js +21 -0
- package/dist/utils/dco/ssh-key.js.map +1 -1
- package/dist/utils/dco/status.d.ts +1 -1
- package/dist/utils/dco/status.d.ts.map +1 -1
- package/dist/utils/dco/status.js +3 -3
- package/dist/utils/dco/status.js.map +1 -1
- package/dist/utils/dco/verify.d.ts +114 -0
- package/dist/utils/dco/verify.d.ts.map +1 -0
- package/dist/utils/dco/verify.js +383 -0
- package/dist/utils/dco/verify.js.map +1 -0
- package/dist/utils/gitignore.d.ts +17 -0
- package/dist/utils/gitignore.d.ts.map +1 -0
- package/dist/utils/gitignore.js +40 -0
- package/dist/utils/gitignore.js.map +1 -0
- package/dist/utils/identity-heal.d.ts +16 -0
- package/dist/utils/identity-heal.d.ts.map +1 -0
- package/dist/utils/identity-heal.js +37 -0
- package/dist/utils/identity-heal.js.map +1 -0
- package/dist/utils/poll.d.ts +1 -1
- package/dist/utils/poll.js +1 -1
- package/package.json +4 -3
- package/dist/utils/claim-polling.d.ts +0 -21
- package/dist/utils/claim-polling.d.ts.map +0 -1
- package/dist/utils/claim-polling.js.map +0 -1
- package/dist/utils/dco/fs-safe.d.ts +0 -14
- package/dist/utils/dco/fs-safe.d.ts.map +0 -1
- package/dist/utils/dco/fs-safe.js +0 -20
- package/dist/utils/dco/fs-safe.js.map +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atomic, symlink-safe file replace.
|
|
3
|
+
*
|
|
4
|
+
* The destination and its temp sibling may live in an untrusted working
|
|
5
|
+
* tree (e.g. a cloned repo). A tracked symlink planted at the predictable
|
|
6
|
+
* `<path>.mcpi-tmp` sibling would otherwise make a plain writeFileSync
|
|
7
|
+
* follow it and clobber an arbitrary file the caller can write. So: unlink
|
|
8
|
+
* any pre-existing temp (rmSync removes the link itself, never its
|
|
9
|
+
* target), then create it with O_EXCL (`wx`) so a planted or racing
|
|
10
|
+
* symlink makes the write fail closed instead of being followed.
|
|
11
|
+
* renameSync replaces the destination without following a symlink there.
|
|
12
|
+
*/
|
|
13
|
+
export declare function writeFileAtomicSafe(path: string, content: string, mode?: number): void;
|
|
14
|
+
//# sourceMappingURL=fs-safe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-safe.d.ts","sourceRoot":"","sources":["../../../src/utils/cli-kit/fs-safe.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,IAAI,SAAQ,GACX,IAAI,CAKN"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { renameSync, rmSync, writeFileSync } from "fs";
|
|
2
|
+
/**
|
|
3
|
+
* Atomic, symlink-safe file replace.
|
|
4
|
+
*
|
|
5
|
+
* The destination and its temp sibling may live in an untrusted working
|
|
6
|
+
* tree (e.g. a cloned repo). A tracked symlink planted at the predictable
|
|
7
|
+
* `<path>.mcpi-tmp` sibling would otherwise make a plain writeFileSync
|
|
8
|
+
* follow it and clobber an arbitrary file the caller can write. So: unlink
|
|
9
|
+
* any pre-existing temp (rmSync removes the link itself, never its
|
|
10
|
+
* target), then create it with O_EXCL (`wx`) so a planted or racing
|
|
11
|
+
* symlink makes the write fail closed instead of being followed.
|
|
12
|
+
* renameSync replaces the destination without following a symlink there.
|
|
13
|
+
*/
|
|
14
|
+
export function writeFileAtomicSafe(path, content, mode = 0o644) {
|
|
15
|
+
const tempPath = `${path}.mcpi-tmp`;
|
|
16
|
+
rmSync(tempPath, { force: true });
|
|
17
|
+
writeFileSync(tempPath, content, { flag: "wx", mode });
|
|
18
|
+
renameSync(tempPath, path);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=fs-safe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-safe.js","sourceRoot":"","sources":["../../../src/utils/cli-kit/fs-safe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAY,EACZ,OAAe,EACf,IAAI,GAAG,KAAK;IAEZ,MAAM,QAAQ,GAAG,GAAG,IAAI,WAAW,CAAC;IACpC,MAAM,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { writeFileAtomicSafe } from "./fs-safe.js";
|
|
2
|
+
export { upsertMarkerBlock } from "./marker-block.js";
|
|
3
|
+
export type { UpsertResult } from "./marker-block.js";
|
|
4
|
+
export { mergeJsonFile } from "./json-file.js";
|
|
5
|
+
export type { MergeJsonResult } from "./json-file.js";
|
|
6
|
+
export { renderSteps, statusLabel } from "./step-report.js";
|
|
7
|
+
export type { StepStatus, StepResult } from "./step-report.js";
|
|
8
|
+
export { SLUG_PATTERN, isValidSlug, stateDir } from "./paths.js";
|
|
9
|
+
export { ensureSecureDir, writeSecureFile } from "./secure-storage.js";
|
|
10
|
+
export { pollForClaimStatus } from "./claim-polling.js";
|
|
11
|
+
export type { ClaimPollingOptions } from "./claim-polling.js";
|
|
12
|
+
export { openUrlInBrowser } from "./browser.js";
|
|
13
|
+
export type { OpenUrlInBrowserOptions, OpenUrlInBrowserResult, } from "./browser.js";
|
|
14
|
+
export { runDiagnosticChecks } from "./diagnostics.js";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/cli-kit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC5D,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,YAAY,EACV,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { writeFileAtomicSafe } from "./fs-safe.js";
|
|
2
|
+
export { upsertMarkerBlock } from "./marker-block.js";
|
|
3
|
+
export { mergeJsonFile } from "./json-file.js";
|
|
4
|
+
export { renderSteps, statusLabel } from "./step-report.js";
|
|
5
|
+
export { SLUG_PATTERN, isValidSlug, stateDir } from "./paths.js";
|
|
6
|
+
export { ensureSecureDir, writeSecureFile } from "./secure-storage.js";
|
|
7
|
+
export { pollForClaimStatus } from "./claim-polling.js";
|
|
8
|
+
export { openUrlInBrowser } from "./browser.js";
|
|
9
|
+
export { runDiagnosticChecks } from "./diagnostics.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/cli-kit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG5D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAMhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type MergeJsonResult = "created" | "updated" | "unchanged" | "skipped-invalid" | "would-change";
|
|
2
|
+
/**
|
|
3
|
+
* Merge `patch` into a JSON file at `path`, preserving every other key.
|
|
4
|
+
*
|
|
5
|
+
* A file we cannot parse (or that doesn't hold a plain object) is left
|
|
6
|
+
* untouched and reported "skipped-invalid": clobbering a caller's existing
|
|
7
|
+
* config is worse than leaving the patch unapplied. Already-applied patches
|
|
8
|
+
* report "unchanged" without writing.
|
|
9
|
+
*
|
|
10
|
+
* `path` is used as given, with no containment check against a base
|
|
11
|
+
* directory (unlike `upsertMarkerBlock`, this function takes a fully
|
|
12
|
+
* resolved path, not a `cwd` + relative segment) — resolving it safely is
|
|
13
|
+
* the caller's responsibility.
|
|
14
|
+
*/
|
|
15
|
+
export declare function mergeJsonFile(path: string, patch: Record<string, unknown>, options?: {
|
|
16
|
+
dryRun?: boolean;
|
|
17
|
+
}): {
|
|
18
|
+
result: MergeJsonResult;
|
|
19
|
+
path: string;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=json-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-file.d.ts","sourceRoot":"","sources":["../../../src/utils/cli-kit/json-file.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,eAAe,GACvB,SAAS,GACT,SAAS,GACT,WAAW,GACX,iBAAiB,GACjB,cAAc,CAAC;AAEnB;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAoC3C"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync } from "fs";
|
|
2
|
+
import { dirname } from "path";
|
|
3
|
+
import { writeFileAtomicSafe } from "./fs-safe.js";
|
|
4
|
+
/**
|
|
5
|
+
* Merge `patch` into a JSON file at `path`, preserving every other key.
|
|
6
|
+
*
|
|
7
|
+
* A file we cannot parse (or that doesn't hold a plain object) is left
|
|
8
|
+
* untouched and reported "skipped-invalid": clobbering a caller's existing
|
|
9
|
+
* config is worse than leaving the patch unapplied. Already-applied patches
|
|
10
|
+
* report "unchanged" without writing.
|
|
11
|
+
*
|
|
12
|
+
* `path` is used as given, with no containment check against a base
|
|
13
|
+
* directory (unlike `upsertMarkerBlock`, this function takes a fully
|
|
14
|
+
* resolved path, not a `cwd` + relative segment) — resolving it safely is
|
|
15
|
+
* the caller's responsibility.
|
|
16
|
+
*/
|
|
17
|
+
export function mergeJsonFile(path, patch, options = {}) {
|
|
18
|
+
if (existsSync(path)) {
|
|
19
|
+
let settings;
|
|
20
|
+
try {
|
|
21
|
+
const parsed = JSON.parse(readFileSync(path, "utf-8"));
|
|
22
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
23
|
+
return { result: "skipped-invalid", path };
|
|
24
|
+
}
|
|
25
|
+
settings = parsed;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return { result: "skipped-invalid", path };
|
|
29
|
+
}
|
|
30
|
+
const alreadyApplied = Object.entries(patch).every(([key, value]) => settings[key] === value);
|
|
31
|
+
if (alreadyApplied) {
|
|
32
|
+
return { result: "unchanged", path };
|
|
33
|
+
}
|
|
34
|
+
if (options.dryRun) {
|
|
35
|
+
return { result: "would-change", path };
|
|
36
|
+
}
|
|
37
|
+
Object.assign(settings, patch);
|
|
38
|
+
writeFileAtomicSafe(path, JSON.stringify(settings, null, 2) + "\n");
|
|
39
|
+
return { result: "updated", path };
|
|
40
|
+
}
|
|
41
|
+
if (options.dryRun) {
|
|
42
|
+
return { result: "would-change", path };
|
|
43
|
+
}
|
|
44
|
+
const dir = dirname(path);
|
|
45
|
+
if (!existsSync(dir)) {
|
|
46
|
+
mkdirSync(dir, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
writeFileAtomicSafe(path, JSON.stringify(patch, null, 2) + "\n");
|
|
49
|
+
return { result: "created", path };
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=json-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-file.js","sourceRoot":"","sources":["../../../src/utils/cli-kit/json-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,IAAI,CAA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AE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QACpE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACrC,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;IAC1C,CAAC;IACD,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtC,CAAC;IACD,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACjE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type UpsertResult = "created" | "updated" | "unchanged" | "would-change";
|
|
2
|
+
/**
|
|
3
|
+
* Insert or replace a delimited block in a file, generalized over the
|
|
4
|
+
* target file, the start/end markers, and the block content — so a
|
|
5
|
+
* consumer can manage its own marker pair (e.g. `<!-- mcpi:dco:start -->`)
|
|
6
|
+
* in its own target file (e.g. `CLAUDE.md`) without duplicating this
|
|
7
|
+
* splice/append logic.
|
|
8
|
+
*
|
|
9
|
+
* Creates the file with just the block when missing, replaces an existing
|
|
10
|
+
* managed block in place, or appends with a blank-line separator when no
|
|
11
|
+
* managed block exists yet. A no-op write (content already matches) is
|
|
12
|
+
* reported as "unchanged" rather than touching the file.
|
|
13
|
+
*
|
|
14
|
+
* `relativePath` must never carry attacker- or config-file-influenced
|
|
15
|
+
* segments without validation upstream: it's resolved against `cwd` and
|
|
16
|
+
* rejected if it would escape it (e.g. `../../.ssh/authorized_keys`),
|
|
17
|
+
* but a crafted value that stays inside `cwd` (e.g. overwriting an
|
|
18
|
+
* unrelated tracked file) is still the caller's responsibility to guard.
|
|
19
|
+
*/
|
|
20
|
+
export declare function upsertMarkerBlock(cwd: string, relativePath: string, startMarker: string, endMarker: string, block: string, options?: {
|
|
21
|
+
dryRun?: boolean;
|
|
22
|
+
}): {
|
|
23
|
+
result: UpsertResult;
|
|
24
|
+
path: string;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=marker-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker-block.d.ts","sourceRoot":"","sources":["../../../src/utils/cli-kit/marker-block.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,cAAc,CAAC;AAEhF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA2CxC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync } from "fs";
|
|
2
|
+
import { dirname, resolve, sep } from "path";
|
|
3
|
+
import { writeFileAtomicSafe } from "./fs-safe.js";
|
|
4
|
+
/**
|
|
5
|
+
* Insert or replace a delimited block in a file, generalized over the
|
|
6
|
+
* target file, the start/end markers, and the block content — so a
|
|
7
|
+
* consumer can manage its own marker pair (e.g. `<!-- mcpi:dco:start -->`)
|
|
8
|
+
* in its own target file (e.g. `CLAUDE.md`) without duplicating this
|
|
9
|
+
* splice/append logic.
|
|
10
|
+
*
|
|
11
|
+
* Creates the file with just the block when missing, replaces an existing
|
|
12
|
+
* managed block in place, or appends with a blank-line separator when no
|
|
13
|
+
* managed block exists yet. A no-op write (content already matches) is
|
|
14
|
+
* reported as "unchanged" rather than touching the file.
|
|
15
|
+
*
|
|
16
|
+
* `relativePath` must never carry attacker- or config-file-influenced
|
|
17
|
+
* segments without validation upstream: it's resolved against `cwd` and
|
|
18
|
+
* rejected if it would escape it (e.g. `../../.ssh/authorized_keys`),
|
|
19
|
+
* but a crafted value that stays inside `cwd` (e.g. overwriting an
|
|
20
|
+
* unrelated tracked file) is still the caller's responsibility to guard.
|
|
21
|
+
*/
|
|
22
|
+
export function upsertMarkerBlock(cwd, relativePath, startMarker, endMarker, block, options = {}) {
|
|
23
|
+
const resolvedCwd = resolve(cwd);
|
|
24
|
+
const path = resolve(resolvedCwd, relativePath);
|
|
25
|
+
if (path !== resolvedCwd && !path.startsWith(resolvedCwd + sep)) {
|
|
26
|
+
throw new Error(`Invalid relativePath "${relativePath}": resolves outside cwd "${cwd}"`);
|
|
27
|
+
}
|
|
28
|
+
if (!existsSync(path)) {
|
|
29
|
+
if (options.dryRun) {
|
|
30
|
+
return { result: "would-change", path };
|
|
31
|
+
}
|
|
32
|
+
const dir = dirname(path);
|
|
33
|
+
if (!existsSync(dir)) {
|
|
34
|
+
mkdirSync(dir, { recursive: true });
|
|
35
|
+
}
|
|
36
|
+
writeFileAtomicSafe(path, block + "\n");
|
|
37
|
+
return { result: "created", path };
|
|
38
|
+
}
|
|
39
|
+
const existing = readFileSync(path, "utf-8");
|
|
40
|
+
const startIdx = existing.indexOf(startMarker);
|
|
41
|
+
const endIdx = existing.indexOf(endMarker);
|
|
42
|
+
let next;
|
|
43
|
+
if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {
|
|
44
|
+
const before = existing.slice(0, startIdx);
|
|
45
|
+
const after = existing.slice(endIdx + endMarker.length);
|
|
46
|
+
next = before + block + after;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
const separator = existing.endsWith("\n") ? "\n" : "\n\n";
|
|
50
|
+
next = existing + separator + block + "\n";
|
|
51
|
+
}
|
|
52
|
+
if (next === existing) {
|
|
53
|
+
return { result: "unchanged", path };
|
|
54
|
+
}
|
|
55
|
+
if (options.dryRun) {
|
|
56
|
+
return { result: "would-change", path };
|
|
57
|
+
}
|
|
58
|
+
writeFileAtomicSafe(path, next);
|
|
59
|
+
return { result: "updated", path };
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=marker-block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker-block.js","sourceRoot":"","sources":["../../../src/utils/cli-kit/marker-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAInD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,GAAW,EACX,YAAoB,EACpB,WAAmB,EACnB,SAAiB,EACjB,KAAa,EACb,UAAgC,EAAE;IAElC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAChD,IAAI,IAAI,KAAK,WAAW,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,GAAG,GAAG,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CACb,yBAAyB,YAAY,4BAA4B,GAAG,GAAG,CACxE,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;QAC1C,CAAC;QACD,MAAM,GA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C,MAAM,EAAE,CAAC;QACnB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;IAC1C,CAAC;IACD,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAChC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slugs are often sourced from a file or env var an untrusted cloned repo
|
|
3
|
+
* can influence, and become a path segment under a state directory, so
|
|
4
|
+
* every source must pass this same shape check.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SLUG_PATTERN: RegExp;
|
|
7
|
+
export declare function isValidSlug(slug: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Absolute path to a namespaced state directory under the user's home,
|
|
10
|
+
* e.g. `stateDir("mcpi", "keys")` -> `~/.mcpi/keys`. Each CLI (mcpi,
|
|
11
|
+
* kya-id, ...) picks its own namespace so their on-disk state never
|
|
12
|
+
* collides.
|
|
13
|
+
*/
|
|
14
|
+
export declare function stateDir(namespace: string, ...segments: string[]): string;
|
|
15
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/utils/cli-kit/paths.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAyB,CAAC;AAEnD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAEzE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { homedir } from "os";
|
|
2
|
+
import { join, resolve } from "path";
|
|
3
|
+
/**
|
|
4
|
+
* Slugs are often sourced from a file or env var an untrusted cloned repo
|
|
5
|
+
* can influence, and become a path segment under a state directory, so
|
|
6
|
+
* every source must pass this same shape check.
|
|
7
|
+
*/
|
|
8
|
+
export const SLUG_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
9
|
+
export function isValidSlug(slug) {
|
|
10
|
+
return SLUG_PATTERN.test(slug);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Absolute path to a namespaced state directory under the user's home,
|
|
14
|
+
* e.g. `stateDir("mcpi", "keys")` -> `~/.mcpi/keys`. Each CLI (mcpi,
|
|
15
|
+
* kya-id, ...) picks its own namespace so their on-disk state never
|
|
16
|
+
* collides.
|
|
17
|
+
*/
|
|
18
|
+
export function stateDir(namespace, ...segments) {
|
|
19
|
+
return resolve(join(homedir(), `.${namespace}`, ...segments));
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/utils/cli-kit/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAErC;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAEnD,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,SAAiB,EAAE,GAAG,QAAkB;IAC/D,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,SAAS,EAAE,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create (or reuse) a directory with 0700 permissions, recursively.
|
|
3
|
+
*/
|
|
4
|
+
export declare function ensureSecureDir(path: string, mode?: number): void;
|
|
5
|
+
/**
|
|
6
|
+
* Write credential/key material with 0600 permissions.
|
|
7
|
+
*
|
|
8
|
+
* The mode is set on write to avoid any window where the file exists with
|
|
9
|
+
* looser permissions, then re-asserted with chmod: the write-time mode
|
|
10
|
+
* option is ignored when the file already exists, so a pre-existing file
|
|
11
|
+
* with looser permissions would otherwise keep them.
|
|
12
|
+
*/
|
|
13
|
+
export declare function writeSecureFile(path: string, content: string, mode?: number): void;
|
|
14
|
+
//# sourceMappingURL=secure-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secure-storage.d.ts","sourceRoot":"","sources":["../../../src/utils/cli-kit/secure-storage.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,SAAQ,GAAG,IAAI,CAEhE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,IAAI,SAAQ,GACX,IAAI,CAGN"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { chmodSync, mkdirSync, writeFileSync } from "fs";
|
|
2
|
+
/**
|
|
3
|
+
* Create (or reuse) a directory with 0700 permissions, recursively.
|
|
4
|
+
*/
|
|
5
|
+
export function ensureSecureDir(path, mode = 0o700) {
|
|
6
|
+
mkdirSync(path, { recursive: true, mode });
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Write credential/key material with 0600 permissions.
|
|
10
|
+
*
|
|
11
|
+
* The mode is set on write to avoid any window where the file exists with
|
|
12
|
+
* looser permissions, then re-asserted with chmod: the write-time mode
|
|
13
|
+
* option is ignored when the file already exists, so a pre-existing file
|
|
14
|
+
* with looser permissions would otherwise keep them.
|
|
15
|
+
*/
|
|
16
|
+
export function writeSecureFile(path, content, mode = 0o600) {
|
|
17
|
+
writeFileSync(path, content, { mode });
|
|
18
|
+
chmodSync(path, mode);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=secure-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secure-storage.js","sourceRoot":"","sources":["../../../src/utils/cli-kit/secure-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAEzD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,IAAI,GAAG,KAAK;IACxD,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,OAAe,EACf,IAAI,GAAG,KAAK;IAEZ,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IACvC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type StepStatus = "done" | "skipped" | "failed" | "action-required" | "would-change";
|
|
2
|
+
export interface StepResult {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
status: StepStatus;
|
|
6
|
+
detail?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function statusLabel(status: StepStatus): string;
|
|
9
|
+
/**
|
|
10
|
+
* Render a step-report list as aligned `title status` lines, with a
|
|
11
|
+
* detail line under any step that isn't "done" or "skipped". Returns
|
|
12
|
+
* lines rather than printing them, so a consumer composes its own
|
|
13
|
+
* header/footer around the shared body.
|
|
14
|
+
*/
|
|
15
|
+
export declare function renderSteps(steps: StepResult[]): string[];
|
|
16
|
+
//# sourceMappingURL=step-report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-report.d.ts","sourceRoot":"","sources":["../../../src/utils/cli-kit/step-report.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,SAAS,GACT,QAAQ,GACR,iBAAiB,GACjB,cAAc,CAAC;AAEnB,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAatD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,EAAE,CAazD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
export function statusLabel(status) {
|
|
3
|
+
switch (status) {
|
|
4
|
+
case "done":
|
|
5
|
+
return chalk.green("done");
|
|
6
|
+
case "skipped":
|
|
7
|
+
return chalk.gray("skipped");
|
|
8
|
+
case "would-change":
|
|
9
|
+
return chalk.cyan("would change");
|
|
10
|
+
case "action-required":
|
|
11
|
+
return chalk.yellow("action required");
|
|
12
|
+
case "failed":
|
|
13
|
+
return chalk.red("failed");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Render a step-report list as aligned `title status` lines, with a
|
|
18
|
+
* detail line under any step that isn't "done" or "skipped". Returns
|
|
19
|
+
* lines rather than printing them, so a consumer composes its own
|
|
20
|
+
* header/footer around the shared body.
|
|
21
|
+
*/
|
|
22
|
+
export function renderSteps(steps) {
|
|
23
|
+
if (steps.length === 0) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
const width = Math.max(...steps.map((s) => s.title.length));
|
|
27
|
+
const lines = [];
|
|
28
|
+
for (const step of steps) {
|
|
29
|
+
lines.push(` ${step.title.padEnd(width)} ${statusLabel(step.status)}`);
|
|
30
|
+
if (step.detail && step.status !== "done" && step.status !== "skipped") {
|
|
31
|
+
lines.push(` ${" ".repeat(width)} ${chalk.gray(step.detail)}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return lines;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=step-report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-report.js","sourceRoot":"","sources":["../../../src/utils/cli-kit/step-report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAgB1B,MAAM,UAAU,WAAW,CAAC,MAAkB;IAC5C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,MAAM;YACT,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7B,KAAK,SAAS;YACZ,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/B,KAAK,cAAc;YACjB,OAAO,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACpC,KAAK,iBAAiB;YACpB,OAAO,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACzC,KAAK,QAAQ;YACX,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,KAAmB;IAC7C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACzE,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACvE,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Persistent agent metadata written at registration time so later commands
|
|
3
|
-
* (notably `
|
|
3
|
+
* (notably `dco setup`) know the agent's public name, slug, and URL
|
|
4
4
|
* without another API round trip. Lives next to identity.json but contains
|
|
5
5
|
* no key material (claimUrl may embed a short-lived claim capability; the
|
|
6
6
|
* whole .mcpi directory is gitignored).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync } from "fs";
|
|
2
2
|
import { join } from "path";
|
|
3
|
-
import { writeFileAtomicSafe } from "
|
|
3
|
+
import { writeFileAtomicSafe } from "../cli-kit/index.js";
|
|
4
4
|
const AGENT_METADATA_FILE = "agent.json";
|
|
5
5
|
function agentMetadataPath(cwd) {
|
|
6
6
|
return join(cwd, ".mcpi", AGENT_METADATA_FILE);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-metadata.js","sourceRoot":"","sources":["../../../src/utils/dco/agent-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"agent-metadata.js","sourceRoot":"","sources":["../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I,EAAE,CAAC;IAC9C,MAAM,MAAM,GAAkB,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC9C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,sEAAsE;QACtE,mEAAmE;QACnE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;YACvC,MAAkC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACnD,CAAC;IACH,CAAC;IACD,uEAAuE;IACvE,mBAAmB,CACjB,iBAAiB,CAAC,GAAG,CAAC,EACtB,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CACvC,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type MergeJsonResult, type UpsertResult as CliKitUpsertResult } from "../cli-kit/index.js";
|
|
1
2
|
/**
|
|
2
3
|
* Claude Code integration: a managed block in CLAUDE.md instructs the agent
|
|
3
4
|
* harness to attribute PRs to the registered agent, and .claude/settings.json
|
|
@@ -6,37 +7,40 @@
|
|
|
6
7
|
* The PR byline can only be influenced through instructions because the PR
|
|
7
8
|
* body is composed by the model at PR time; commit trailers are enforced
|
|
8
9
|
* mechanically by the git hook instead (see git-config.ts).
|
|
10
|
+
*
|
|
11
|
+
* The block used to interpolate a specific agent's name/URL/DID as literal
|
|
12
|
+
* strings. That was wrong for any repo that receives dispatched work from
|
|
13
|
+
* more than one agent: CLAUDE.md is committed, so the literal values only
|
|
14
|
+
* ever reflected whichever agent happened to run `dco setup` first, and
|
|
15
|
+
* every other agent's PRs in that repo would carry a false attribution with
|
|
16
|
+
* no way to correct it short of re-running `dco setup` (which a dispatch
|
|
17
|
+
* flow generally can't do per task). The block below is agent-agnostic
|
|
18
|
+
* instead: it tells the agent to run `dco whoami` and use whatever
|
|
19
|
+
* that reports, so the byline is always whichever identity is actually
|
|
20
|
+
* configured in the current checkout. See resolve-agent.ts.
|
|
9
21
|
*/
|
|
10
22
|
export declare const CLAUDE_MD_START = "<!-- mcpi:dco:start -->";
|
|
11
23
|
export declare const CLAUDE_MD_END = "<!-- mcpi:dco:end -->";
|
|
12
24
|
export interface AttributionBlockParams {
|
|
13
|
-
agentName: string;
|
|
14
|
-
agentUrl: string;
|
|
15
|
-
/**
|
|
16
|
-
* The agent's DID (e.g. `did:key:z6Mk...`). Included as a machine-readable
|
|
17
|
-
* companion to the human-readable byline so PR metadata resolves back to a
|
|
18
|
-
* specific KYA-OS registered agent identity, not just a display name.
|
|
19
|
-
*/
|
|
20
|
-
agentDid?: string;
|
|
21
25
|
/**
|
|
22
26
|
* When the git hook could not be installed (foreign hook, unsafe
|
|
23
27
|
* core.hooksPath, or install failure), trailer duty falls back to
|
|
24
28
|
* instructions.
|
|
25
29
|
*/
|
|
26
30
|
includeTrailerInstructions?: boolean;
|
|
27
|
-
humanName?: string;
|
|
28
|
-
humanEmail?: string;
|
|
29
|
-
agentEmail?: string;
|
|
30
31
|
}
|
|
31
|
-
export declare
|
|
32
|
-
export
|
|
32
|
+
export declare const DID_PATTERN: RegExp;
|
|
33
|
+
export declare const MAX_DID_LENGTH = 200;
|
|
34
|
+
export declare function isValidDid(value: string): boolean;
|
|
35
|
+
export declare function buildAttributionBlock(params?: AttributionBlockParams): string;
|
|
36
|
+
export type UpsertResult = CliKitUpsertResult;
|
|
33
37
|
export declare function upsertClaudeMdBlock(cwd: string, block: string, options?: {
|
|
34
38
|
dryRun?: boolean;
|
|
35
39
|
}): {
|
|
36
40
|
result: UpsertResult;
|
|
37
41
|
path: string;
|
|
38
42
|
};
|
|
39
|
-
export type SettingsResult =
|
|
43
|
+
export type SettingsResult = MergeJsonResult;
|
|
40
44
|
/**
|
|
41
45
|
* Set includeCoAuthoredBy: false in .claude/settings.json, preserving every
|
|
42
46
|
* other key. A file we cannot parse is left untouched: clobbering a user's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-config.d.ts","sourceRoot":"","sources":["../../../src/utils/dco/claude-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"claude-config.d.ts","sourceRoot":"","sources":["../../../src/utils/dco/claude-config.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,YAAY,IAAI,kBAAkB,EACxC,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,eAAe,4BAA4B,CAAC;AACzD,eAAO,MAAM,aAAa,0BAA0B,CAAC;AAErD,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC;AAQD,eAAO,MAAM,WAAW,QAAuC,CAAC;AAChE,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,wBAAgB,qBAAqB,CAAC,MAAM,GAAE,sBAA2B,GAAG,MAAM,CAqBjF;AAED,MAAM,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAE9C,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CASxC;AAED,MAAM,MAAM,cAAc,GAAG,eAAe,CAAC;AAE7C;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAG1C"}
|