@dac-tech-team-tw/itsaplan-cli 0.0.0-stage → 0.1.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/README.md +223 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +329 -0
- package/dist/commands.d.ts +15 -0
- package/dist/commands.js +521 -0
- package/dist/config.d.ts +23 -0
- package/dist/config.js +548 -0
- package/dist/contracts.d.ts +47 -0
- package/dist/contracts.js +14 -0
- package/dist/development.d.ts +9 -0
- package/dist/development.js +220 -0
- package/dist/documents.d.ts +9 -0
- package/dist/documents.js +256 -0
- package/dist/http.d.ts +11 -0
- package/dist/http.js +306 -0
- package/dist/issues.d.ts +61 -0
- package/dist/issues.js +709 -0
- package/dist/writes.d.ts +8 -0
- package/dist/writes.js +57 -0
- package/package.json +44 -4
package/dist/writes.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Actor, type Context, type ObjectData, type Result } from "./contracts.js";
|
|
2
|
+
import { type IssueOptions } from "./issues.js";
|
|
3
|
+
/** Preflight failures are never mistaken for a write with an unknown outcome. */
|
|
4
|
+
export declare function withWrite(options: IssueOptions, operation: (actor: Actor) => Promise<Result>): Promise<Result>;
|
|
5
|
+
export declare function preview(ctx: Context, actor: Actor, data: ObjectData, path: string, body: ObjectData, warnings?: string[]): Promise<Result>;
|
|
6
|
+
export declare function writeFailure(error: unknown, data: ObjectData, actor: Actor): Result;
|
|
7
|
+
export declare function verificationFailed(data: ObjectData, actor: Actor): Result;
|
|
8
|
+
export declare function applied(data: ObjectData, actor: Actor): Result;
|
package/dist/writes.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CliError, } from "./contracts.js";
|
|
2
|
+
import { actorFor, me, writeFailure as issueWriteFailure, verificationFailed as issueVerificationFailed, } from "./issues.js";
|
|
3
|
+
/** Preflight failures are never mistaken for a write with an unknown outcome. */
|
|
4
|
+
export async function withWrite(options, operation) {
|
|
5
|
+
let actor;
|
|
6
|
+
try {
|
|
7
|
+
actor = actorFor(options);
|
|
8
|
+
return await operation(actor);
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
if (error instanceof CliError) {
|
|
12
|
+
error.details = {
|
|
13
|
+
...error.details,
|
|
14
|
+
outcome: "not_applied",
|
|
15
|
+
verification: "not_run",
|
|
16
|
+
...(actor ? { meta: { actor } } : {}),
|
|
17
|
+
retryable: false,
|
|
18
|
+
};
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
throw new CliError("WRITE_PREFLIGHT_FAILED", "Write preflight failed; no write was sent", 1, {
|
|
22
|
+
outcome: "not_applied",
|
|
23
|
+
verification: "not_run",
|
|
24
|
+
...(actor ? { meta: { actor } } : {}),
|
|
25
|
+
retryable: false,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export async function preview(ctx, actor, data, path, body, warnings = []) {
|
|
30
|
+
return {
|
|
31
|
+
data: {
|
|
32
|
+
...data,
|
|
33
|
+
dryRun: true,
|
|
34
|
+
identity: await me(ctx),
|
|
35
|
+
request: { method: "POST", path, body },
|
|
36
|
+
warnings: [
|
|
37
|
+
"Preview sends no writes and does not guarantee server permissions or concurrent state.",
|
|
38
|
+
...warnings,
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
meta: { actor },
|
|
42
|
+
outcome: "not_applied",
|
|
43
|
+
verification: "not_run",
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function writeFailure(error, data, actor) {
|
|
47
|
+
const result = issueWriteFailure(error, data, actor, "document or relation");
|
|
48
|
+
if (result.outcome === "unknown")
|
|
49
|
+
delete data.changed;
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
export function verificationFailed(data, actor) {
|
|
53
|
+
return issueVerificationFailed(data, actor, "document or relation");
|
|
54
|
+
}
|
|
55
|
+
export function applied(data, actor) {
|
|
56
|
+
return { data, meta: { actor }, outcome: "applied", verification: "passed" };
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dac-tech-team-tw/itsaplan-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Composable It's a Plan CLI for humans and coding agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/dac-tech-team-tw/itsaplan-cli.git"
|
|
9
|
+
},
|
|
10
|
+
"packageManager": "pnpm@12.14.0",
|
|
11
|
+
"bin": {
|
|
12
|
+
"iap": "dist/cli.js",
|
|
13
|
+
"itsaplan": "dist/cli.js"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=22"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public",
|
|
24
|
+
"provenance": false
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"typecheck": "tsc --noEmit && tsc -p tsconfig.test.json",
|
|
29
|
+
"test": "tsx --test test/*.test.ts",
|
|
30
|
+
"format": "prettier --write src test package.json tsconfig*.json",
|
|
31
|
+
"prepack": "npm run build",
|
|
32
|
+
"install-local": "node scripts/install-local.mjs"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@inquirer/prompts": "^7.10.1",
|
|
36
|
+
"@napi-rs/keyring": "^1.2.0",
|
|
37
|
+
"commander": "^14.0.2",
|
|
38
|
+
"smol-toml": "^1.4.2"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^22.19.0",
|
|
42
|
+
"prettier": "^3.6.2",
|
|
43
|
+
"tsx": "^4.20.6",
|
|
44
|
+
"typescript": "^5.9.3"
|
|
45
|
+
}
|
|
46
|
+
}
|