@unbrained/pm-cli 2026.3.12 → 2026.5.1-2
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/.agents/pm/extensions/.managed-extensions.json +42 -0
- package/.agents/pm/extensions/beads/index.js +109 -0
- package/.agents/pm/extensions/beads/manifest.json +7 -0
- package/{dist/cli/commands/beads.js → .agents/pm/extensions/beads/runtime.js} +31 -21
- package/.agents/pm/extensions/beads/runtime.ts +702 -0
- package/.agents/pm/extensions/todos/index.js +126 -0
- package/.agents/pm/extensions/todos/manifest.json +7 -0
- package/{dist/extensions/builtins/todos/import-export.js → .agents/pm/extensions/todos/runtime.js} +39 -29
- package/.agents/pm/extensions/todos/runtime.ts +568 -0
- package/AGENTS.md +196 -92
- package/CHANGELOG.md +404 -0
- package/CODE_OF_CONDUCT.md +42 -0
- package/CONTRIBUTING.md +144 -0
- package/PRD.md +512 -164
- package/README.md +1053 -2
- package/SECURITY.md +51 -0
- package/dist/cli/commands/activity.d.ts +5 -0
- package/dist/cli/commands/activity.js +66 -3
- package/dist/cli/commands/activity.js.map +1 -1
- package/dist/cli/commands/aggregate.d.ts +54 -0
- package/dist/cli/commands/aggregate.js +181 -0
- package/dist/cli/commands/aggregate.js.map +1 -0
- package/dist/cli/commands/append.js +4 -1
- package/dist/cli/commands/append.js.map +1 -1
- package/dist/cli/commands/calendar.d.ts +109 -0
- package/dist/cli/commands/calendar.js +797 -0
- package/dist/cli/commands/calendar.js.map +1 -0
- package/dist/cli/commands/claim.d.ts +5 -1
- package/dist/cli/commands/claim.js +42 -21
- package/dist/cli/commands/claim.js.map +1 -1
- package/dist/cli/commands/close.d.ts +1 -0
- package/dist/cli/commands/close.js +54 -5
- package/dist/cli/commands/close.js.map +1 -1
- package/dist/cli/commands/comments-audit.d.ts +91 -0
- package/dist/cli/commands/comments-audit.js +195 -0
- package/dist/cli/commands/comments-audit.js.map +1 -0
- package/dist/cli/commands/comments.d.ts +1 -0
- package/dist/cli/commands/comments.js +70 -21
- package/dist/cli/commands/comments.js.map +1 -1
- package/dist/cli/commands/completion.d.ts +10 -4
- package/dist/cli/commands/completion.js +1184 -137
- package/dist/cli/commands/completion.js.map +1 -1
- package/dist/cli/commands/config.d.ts +35 -3
- package/dist/cli/commands/config.js +968 -13
- package/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/context.d.ts +86 -0
- package/dist/cli/commands/context.js +299 -0
- package/dist/cli/commands/context.js.map +1 -0
- package/dist/cli/commands/contracts.d.ts +78 -0
- package/dist/cli/commands/contracts.js +920 -0
- package/dist/cli/commands/contracts.js.map +1 -0
- package/dist/cli/commands/create.d.ts +48 -14
- package/dist/cli/commands/create.js +1331 -160
- package/dist/cli/commands/create.js.map +1 -1
- package/dist/cli/commands/dedupe-audit.d.ts +81 -0
- package/dist/cli/commands/dedupe-audit.js +330 -0
- package/dist/cli/commands/dedupe-audit.js.map +1 -0
- package/dist/cli/commands/deps.d.ts +52 -0
- package/dist/cli/commands/deps.js +204 -0
- package/dist/cli/commands/deps.js.map +1 -0
- package/dist/cli/commands/docs.d.ts +19 -0
- package/dist/cli/commands/docs.js +212 -13
- package/dist/cli/commands/docs.js.map +1 -1
- package/dist/cli/commands/extension.d.ts +122 -0
- package/dist/cli/commands/extension.js +1850 -0
- package/dist/cli/commands/extension.js.map +1 -0
- package/dist/cli/commands/files.d.ts +52 -1
- package/dist/cli/commands/files.js +455 -13
- package/dist/cli/commands/files.js.map +1 -1
- package/dist/cli/commands/gc.d.ts +11 -1
- package/dist/cli/commands/gc.js +89 -11
- package/dist/cli/commands/gc.js.map +1 -1
- package/dist/cli/commands/get.d.ts +13 -0
- package/dist/cli/commands/get.js +35 -3
- package/dist/cli/commands/get.js.map +1 -1
- package/dist/cli/commands/health.d.ts +10 -2
- package/dist/cli/commands/health.js +774 -23
- package/dist/cli/commands/health.js.map +1 -1
- package/dist/cli/commands/history.d.ts +20 -0
- package/dist/cli/commands/history.js +152 -6
- package/dist/cli/commands/history.js.map +1 -1
- package/dist/cli/commands/index.d.ts +16 -3
- package/dist/cli/commands/index.js +16 -3
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/init.d.ts +7 -2
- package/dist/cli/commands/init.js +137 -5
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/learnings.d.ts +17 -0
- package/dist/cli/commands/learnings.js +129 -0
- package/dist/cli/commands/learnings.js.map +1 -0
- package/dist/cli/commands/list.d.ts +29 -1
- package/dist/cli/commands/list.js +289 -53
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/cli/commands/normalize.d.ts +51 -0
- package/dist/cli/commands/normalize.js +298 -0
- package/dist/cli/commands/normalize.js.map +1 -0
- package/dist/cli/commands/notes.d.ts +17 -0
- package/dist/cli/commands/notes.js +129 -0
- package/dist/cli/commands/notes.js.map +1 -0
- package/dist/cli/commands/reindex.d.ts +1 -0
- package/dist/cli/commands/reindex.js +208 -32
- package/dist/cli/commands/reindex.js.map +1 -1
- package/dist/cli/commands/restore.js +164 -30
- package/dist/cli/commands/restore.js.map +1 -1
- package/dist/cli/commands/search.d.ts +14 -1
- package/dist/cli/commands/search.js +475 -81
- package/dist/cli/commands/search.js.map +1 -1
- package/dist/cli/commands/stats.js +26 -10
- package/dist/cli/commands/stats.js.map +1 -1
- package/dist/cli/commands/templates.d.ts +26 -0
- package/dist/cli/commands/templates.js +179 -0
- package/dist/cli/commands/templates.js.map +1 -0
- package/dist/cli/commands/test-all.d.ts +19 -1
- package/dist/cli/commands/test-all.js +161 -13
- package/dist/cli/commands/test-all.js.map +1 -1
- package/dist/cli/commands/test-runs.d.ts +63 -0
- package/dist/cli/commands/test-runs.js +179 -0
- package/dist/cli/commands/test-runs.js.map +1 -0
- package/dist/cli/commands/test.d.ts +75 -1
- package/dist/cli/commands/test.js +1360 -41
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/commands/update-many.d.ts +57 -0
- package/dist/cli/commands/update-many.js +631 -0
- package/dist/cli/commands/update-many.js.map +1 -0
- package/dist/cli/commands/update.d.ts +30 -0
- package/dist/cli/commands/update.js +1393 -84
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/commands/validate.d.ts +30 -0
- package/dist/cli/commands/validate.js +1151 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/error-guidance.d.ts +33 -0
- package/dist/cli/error-guidance.js +337 -0
- package/dist/cli/error-guidance.js.map +1 -0
- package/dist/cli/extension-command-options.d.ts +1 -0
- package/dist/cli/extension-command-options.js +92 -0
- package/dist/cli/extension-command-options.js.map +1 -1
- package/dist/cli/help-content.d.ts +20 -0
- package/dist/cli/help-content.js +543 -0
- package/dist/cli/help-content.js.map +1 -0
- package/dist/cli/main.js +3625 -445
- package/dist/cli/main.js.map +1 -1
- package/dist/core/extensions/index.d.ts +13 -1
- package/dist/core/extensions/index.js +108 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/item-fields.d.ts +2 -0
- package/dist/core/extensions/item-fields.js +79 -0
- package/dist/core/extensions/item-fields.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +322 -9
- package/dist/core/extensions/loader.js +911 -20
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runtime-registrations.d.ts +5 -0
- package/dist/core/extensions/runtime-registrations.js +51 -0
- package/dist/core/extensions/runtime-registrations.js.map +1 -0
- package/dist/core/history/history-stream-policy.d.ts +20 -0
- package/dist/core/history/history-stream-policy.js +53 -0
- package/dist/core/history/history-stream-policy.js.map +1 -0
- package/dist/core/history/history.js +90 -1
- package/dist/core/history/history.js.map +1 -1
- package/dist/core/item/id.js +4 -1
- package/dist/core/item/id.js.map +1 -1
- package/dist/core/item/index.d.ts +1 -0
- package/dist/core/item/index.js +1 -0
- package/dist/core/item/index.js.map +1 -1
- package/dist/core/item/item-format.d.ts +11 -5
- package/dist/core/item/item-format.js +507 -24
- package/dist/core/item/item-format.js.map +1 -1
- package/dist/core/item/parent-reference-policy.d.ts +6 -0
- package/dist/core/item/parent-reference-policy.js +32 -0
- package/dist/core/item/parent-reference-policy.js.map +1 -0
- package/dist/core/item/parse.d.ts +5 -0
- package/dist/core/item/parse.js +216 -19
- package/dist/core/item/parse.js.map +1 -1
- package/dist/core/item/sprint-release-format.d.ts +6 -0
- package/dist/core/item/sprint-release-format.js +33 -0
- package/dist/core/item/sprint-release-format.js.map +1 -0
- package/dist/core/item/status.d.ts +3 -0
- package/dist/core/item/status.js +24 -0
- package/dist/core/item/status.js.map +1 -0
- package/dist/core/item/type-registry.d.ts +37 -0
- package/dist/core/item/type-registry.js +706 -0
- package/dist/core/item/type-registry.js.map +1 -0
- package/dist/core/lock/lock.d.ts +1 -1
- package/dist/core/lock/lock.js +101 -12
- package/dist/core/lock/lock.js.map +1 -1
- package/dist/core/output/command-aware.d.ts +1 -0
- package/dist/core/output/command-aware.js +394 -0
- package/dist/core/output/command-aware.js.map +1 -0
- package/dist/core/output/output.d.ts +3 -0
- package/dist/core/output/output.js +124 -6
- package/dist/core/output/output.js.map +1 -1
- package/dist/core/schema/runtime-field-filters.d.ts +3 -0
- package/dist/core/schema/runtime-field-filters.js +39 -0
- package/dist/core/schema/runtime-field-filters.js.map +1 -0
- package/dist/core/schema/runtime-field-values.d.ts +8 -0
- package/dist/core/schema/runtime-field-values.js +154 -0
- package/dist/core/schema/runtime-field-values.js.map +1 -0
- package/dist/core/schema/runtime-schema.d.ts +68 -0
- package/dist/core/schema/runtime-schema.js +554 -0
- package/dist/core/schema/runtime-schema.js.map +1 -0
- package/dist/core/search/cache.d.ts +13 -1
- package/dist/core/search/cache.js +123 -14
- package/dist/core/search/cache.js.map +1 -1
- package/dist/core/search/semantic-defaults.d.ts +6 -0
- package/dist/core/search/semantic-defaults.js +120 -0
- package/dist/core/search/semantic-defaults.js.map +1 -0
- package/dist/core/search/vector-stores.js +3 -1
- package/dist/core/search/vector-stores.js.map +1 -1
- package/dist/core/shared/command-types.d.ts +2 -0
- package/dist/core/shared/conflict-markers.d.ts +7 -0
- package/dist/core/shared/conflict-markers.js +27 -0
- package/dist/core/shared/conflict-markers.js.map +1 -0
- package/dist/core/shared/constants.d.ts +15 -4
- package/dist/core/shared/constants.js +141 -1
- package/dist/core/shared/constants.js.map +1 -1
- package/dist/core/shared/errors.d.ts +10 -1
- package/dist/core/shared/errors.js +3 -1
- package/dist/core/shared/errors.js.map +1 -1
- package/dist/core/shared/text-normalization.d.ts +4 -0
- package/dist/core/shared/text-normalization.js +33 -0
- package/dist/core/shared/text-normalization.js.map +1 -0
- package/dist/core/shared/time.d.ts +1 -2
- package/dist/core/shared/time.js +98 -11
- package/dist/core/shared/time.js.map +1 -1
- package/dist/core/store/index.d.ts +1 -0
- package/dist/core/store/index.js +1 -0
- package/dist/core/store/index.js.map +1 -1
- package/dist/core/store/item-format-migration.d.ts +9 -0
- package/dist/core/store/item-format-migration.js +87 -0
- package/dist/core/store/item-format-migration.js.map +1 -0
- package/dist/core/store/item-store.d.ts +13 -4
- package/dist/core/store/item-store.js +238 -51
- package/dist/core/store/item-store.js.map +1 -1
- package/dist/core/store/paths.d.ts +21 -3
- package/dist/core/store/paths.js +59 -4
- package/dist/core/store/paths.js.map +1 -1
- package/dist/core/store/settings.d.ts +14 -1
- package/dist/core/store/settings.js +463 -7
- package/dist/core/store/settings.js.map +1 -1
- package/dist/core/telemetry/consent.d.ts +2 -0
- package/dist/core/telemetry/consent.js +79 -0
- package/dist/core/telemetry/consent.js.map +1 -0
- package/dist/core/telemetry/runtime.d.ts +38 -0
- package/dist/core/telemetry/runtime.js +733 -0
- package/dist/core/telemetry/runtime.js.map +1 -0
- package/dist/core/test/background-runs.d.ts +117 -0
- package/dist/core/test/background-runs.js +760 -0
- package/dist/core/test/background-runs.js.map +1 -0
- package/dist/core/test/item-test-run-tracking.d.ts +9 -0
- package/dist/core/test/item-test-run-tracking.js +50 -0
- package/dist/core/test/item-test-run-tracking.js.map +1 -0
- package/dist/sdk/cli-contracts.d.ts +92 -0
- package/dist/sdk/cli-contracts.js +2357 -0
- package/dist/sdk/cli-contracts.js.map +1 -0
- package/dist/sdk/index.d.ts +34 -0
- package/dist/sdk/index.js +23 -0
- package/dist/sdk/index.js.map +1 -0
- package/dist/types.d.ts +197 -3
- package/dist/types.js +48 -1
- package/dist/types.js.map +1 -1
- package/docs/ARCHITECTURE.md +368 -39
- package/docs/EXTENSIONS.md +454 -49
- package/docs/RELEASING.md +70 -19
- package/docs/SDK.md +123 -0
- package/docs/examples/starter-extension/README.md +48 -0
- package/docs/examples/starter-extension/index.js +191 -0
- package/docs/examples/starter-extension/manifest.json +17 -0
- package/docs/examples/starter-extension/package.json +10 -0
- package/package.json +41 -14
- package/.pi/extensions/pm-cli/index.ts +0 -778
- package/dist/cli/commands/beads.d.ts +0 -16
- package/dist/cli/commands/beads.js.map +0 -1
- package/dist/cli/commands/install.d.ts +0 -18
- package/dist/cli/commands/install.js +0 -87
- package/dist/cli/commands/install.js.map +0 -1
- package/dist/core/extensions/builtins.d.ts +0 -3
- package/dist/core/extensions/builtins.js +0 -47
- package/dist/core/extensions/builtins.js.map +0 -1
- package/dist/extensions/builtins/beads/index.d.ts +0 -8
- package/dist/extensions/builtins/beads/index.js +0 -33
- package/dist/extensions/builtins/beads/index.js.map +0 -1
- package/dist/extensions/builtins/todos/import-export.d.ts +0 -26
- package/dist/extensions/builtins/todos/import-export.js.map +0 -1
- package/dist/extensions/builtins/todos/index.d.ts +0 -8
- package/dist/extensions/builtins/todos/index.js +0 -38
- package/dist/extensions/builtins/todos/index.js.map +0 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
|
|
4
|
+
const PM_PACKAGE_ROOT_ENV = "PM_CLI_PACKAGE_ROOT";
|
|
5
|
+
|
|
6
|
+
export const manifest = {
|
|
7
|
+
name: "builtin-todos-import-export",
|
|
8
|
+
version: "0.1.0",
|
|
9
|
+
entry: "./index.js",
|
|
10
|
+
priority: 0,
|
|
11
|
+
capabilities: ["commands", "schema"],
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function asOptionalString(value) {
|
|
15
|
+
return typeof value === "string" ? value : undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function toImportOptions(options) {
|
|
19
|
+
return {
|
|
20
|
+
folder: asOptionalString(options.folder),
|
|
21
|
+
author: asOptionalString(options.author),
|
|
22
|
+
message: asOptionalString(options.message),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function toExportOptions(options) {
|
|
27
|
+
return {
|
|
28
|
+
folder: asOptionalString(options.folder),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function resolvePackageRootCandidates() {
|
|
33
|
+
const candidates = [];
|
|
34
|
+
const envRoot = process.env[PM_PACKAGE_ROOT_ENV];
|
|
35
|
+
if (typeof envRoot === "string" && envRoot.trim().length > 0) {
|
|
36
|
+
candidates.push(path.resolve(envRoot.trim()));
|
|
37
|
+
}
|
|
38
|
+
const argvEntry = typeof process.argv[1] === "string" ? process.argv[1].trim() : "";
|
|
39
|
+
if (argvEntry.length > 0) {
|
|
40
|
+
const resolvedEntry = path.resolve(argvEntry);
|
|
41
|
+
const entryDir = path.dirname(resolvedEntry);
|
|
42
|
+
candidates.push(path.resolve(entryDir, ".."));
|
|
43
|
+
candidates.push(path.resolve(entryDir, "../.."));
|
|
44
|
+
candidates.push(path.resolve(entryDir, "../../.."));
|
|
45
|
+
}
|
|
46
|
+
return [...new Set(candidates)];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function loadRuntimeModule() {
|
|
50
|
+
const attempted = [];
|
|
51
|
+
for (const packageRoot of resolvePackageRootCandidates()) {
|
|
52
|
+
const modulePath = path.join(packageRoot, ".agents", "pm", "extensions", "todos", "runtime.js");
|
|
53
|
+
attempted.push(modulePath);
|
|
54
|
+
try {
|
|
55
|
+
return await import(pathToFileURL(modulePath).href);
|
|
56
|
+
} catch {
|
|
57
|
+
// Try the next package-root candidate.
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
throw new Error(
|
|
61
|
+
"Unable to resolve bundled todos extension runtime module. " +
|
|
62
|
+
`Tried: ${attempted.join(", ")}. Ensure PM_CLI_PACKAGE_ROOT points to an installed pm package root.`,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function runTodosImportFromRuntime(options, global) {
|
|
67
|
+
const runtime = await loadRuntimeModule();
|
|
68
|
+
if (typeof runtime.runTodosImport !== "function") {
|
|
69
|
+
throw new Error('Bundled todos runtime module is missing runTodosImport().');
|
|
70
|
+
}
|
|
71
|
+
return runtime.runTodosImport(options, global);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function runTodosExportFromRuntime(options, global) {
|
|
75
|
+
const runtime = await loadRuntimeModule();
|
|
76
|
+
if (typeof runtime.runTodosExport !== "function") {
|
|
77
|
+
throw new Error('Bundled todos runtime module is missing runTodosExport().');
|
|
78
|
+
}
|
|
79
|
+
return runtime.runTodosExport(options, global);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function activate(api) {
|
|
83
|
+
api.registerCommand({
|
|
84
|
+
name: "todos import",
|
|
85
|
+
description: "Import Todo markdown files into pm items.",
|
|
86
|
+
flags: [
|
|
87
|
+
{
|
|
88
|
+
long: "--folder",
|
|
89
|
+
value_name: "path",
|
|
90
|
+
value_type: "string",
|
|
91
|
+
description: "Source folder containing Todo markdown files.",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
long: "--author",
|
|
95
|
+
value_name: "author",
|
|
96
|
+
value_type: "string",
|
|
97
|
+
description: "Override import mutation author.",
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
long: "--message",
|
|
101
|
+
value_name: "text",
|
|
102
|
+
value_type: "string",
|
|
103
|
+
description: "Override import history message.",
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
run: async (context) => runTodosImportFromRuntime(toImportOptions(context.options), context.global),
|
|
107
|
+
});
|
|
108
|
+
api.registerCommand({
|
|
109
|
+
name: "todos export",
|
|
110
|
+
description: "Export pm items into Todo markdown files.",
|
|
111
|
+
flags: [
|
|
112
|
+
{
|
|
113
|
+
long: "--folder",
|
|
114
|
+
value_name: "path",
|
|
115
|
+
value_type: "string",
|
|
116
|
+
description: "Destination folder for exported Todo markdown files.",
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
run: async (context) => runTodosExportFromRuntime(toExportOptions(context.options), context.global),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export default {
|
|
124
|
+
manifest,
|
|
125
|
+
activate,
|
|
126
|
+
};
|
package/{dist/extensions/builtins/todos/import-export.js → .agents/pm/extensions/todos/runtime.js}
RENAMED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { runActiveOnReadHooks, runActiveOnWriteHooks } from "
|
|
4
|
-
import { pathExists, removeFileIfExists, writeFileAtomic } from "
|
|
5
|
-
import { appendHistoryEntry, createHistoryEntry } from "
|
|
6
|
-
import { generateItemId, normalizeItemId } from "
|
|
7
|
-
import { canonicalDocument, normalizeFrontMatter, serializeItemDocument, splitFrontMatter } from "
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
3
|
+
import { getActiveExtensionRegistrations, runActiveOnReadHooks, runActiveOnWriteHooks } from "../../../../dist/core/extensions/index.js";
|
|
4
|
+
import { pathExists, removeFileIfExists, writeFileAtomic } from "../../../../dist/core/fs/fs-utils.js";
|
|
5
|
+
import { appendHistoryEntry, createHistoryEntry } from "../../../../dist/core/history/history.js";
|
|
6
|
+
import { generateItemId, normalizeItemId } from "../../../../dist/core/item/id.js";
|
|
7
|
+
import { canonicalDocument, normalizeFrontMatter, serializeItemDocument, splitFrontMatter } from "../../../../dist/core/item/item-format.js";
|
|
8
|
+
import { normalizeStatusInput } from "../../../../dist/core/item/status.js";
|
|
9
|
+
import { resolveItemTypeRegistry } from "../../../../dist/core/item/type-registry.js";
|
|
10
|
+
import { parseTags } from "../../../../dist/core/item/parse.js";
|
|
11
|
+
import { acquireLock } from "../../../../dist/core/lock/lock.js";
|
|
12
|
+
import { EXIT_CODE } from "../../../../dist/core/shared/constants.js";
|
|
13
|
+
import { PmCliError } from "../../../../dist/core/shared/errors.js";
|
|
14
|
+
import { nowIso } from "../../../../dist/core/shared/time.js";
|
|
15
|
+
import { listAllFrontMatter, locateItem, readLocatedItem } from "../../../../dist/core/store/item-store.js";
|
|
16
|
+
import { getHistoryPath, getItemPath, getSettingsPath, resolvePmRoot } from "../../../../dist/core/store/paths.js";
|
|
17
|
+
import { readSettings } from "../../../../dist/core/store/settings.js";
|
|
18
|
+
import { CONFIDENCE_TEXT_VALUES, ISSUE_SEVERITY_VALUES, RISK_VALUES } from "../../../../dist/types/index.js";
|
|
17
19
|
const DEFAULT_TODOS_FOLDER = ".pi/todos";
|
|
18
20
|
function isRecord(value) {
|
|
19
21
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -145,22 +147,26 @@ function toTags(value) {
|
|
|
145
147
|
}
|
|
146
148
|
return [];
|
|
147
149
|
}
|
|
148
|
-
function toItemType(value) {
|
|
150
|
+
function toItemType(value, typeNames) {
|
|
149
151
|
const normalized = toNonEmptyString(value)?.toLowerCase();
|
|
152
|
+
const fallbackType = typeNames.find((entry) => entry.toLowerCase() === "task") ?? typeNames[0] ?? "Task";
|
|
150
153
|
if (!normalized) {
|
|
151
|
-
return
|
|
154
|
+
return fallbackType;
|
|
152
155
|
}
|
|
153
|
-
for (const candidate of
|
|
156
|
+
for (const candidate of typeNames) {
|
|
154
157
|
if (candidate.toLowerCase() === normalized) {
|
|
155
158
|
return candidate;
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
|
-
return
|
|
161
|
+
return fallbackType;
|
|
159
162
|
}
|
|
160
163
|
function toStatus(value) {
|
|
161
|
-
const normalized = toNonEmptyString(value)
|
|
162
|
-
if (normalized
|
|
163
|
-
|
|
164
|
+
const normalized = toNonEmptyString(value);
|
|
165
|
+
if (normalized) {
|
|
166
|
+
const canonical = normalizeStatusInput(normalized);
|
|
167
|
+
if (canonical) {
|
|
168
|
+
return canonical;
|
|
169
|
+
}
|
|
164
170
|
}
|
|
165
171
|
return "open";
|
|
166
172
|
}
|
|
@@ -243,11 +249,12 @@ async function importTodoCandidate(candidate, runtime) {
|
|
|
243
249
|
: await generateItemId(runtime.pmRoot, runtime.settings.id_prefix);
|
|
244
250
|
const createdAt = toIsoString(candidate.frontMatter.created_at) ?? nowIso();
|
|
245
251
|
const updatedAt = toIsoString(candidate.frontMatter.updated_at) ?? createdAt;
|
|
246
|
-
const type = toItemType(candidate.frontMatter.type);
|
|
247
|
-
const
|
|
248
|
-
if (
|
|
252
|
+
const type = toItemType(candidate.frontMatter.type, runtime.typeNames);
|
|
253
|
+
const located = await locateItem(runtime.pmRoot, id, runtime.settings.id_prefix, runtime.settings.item_format, runtime.typeToFolder);
|
|
254
|
+
if (located) {
|
|
249
255
|
return { warning: `todos_import_item_exists:${id}` };
|
|
250
256
|
}
|
|
257
|
+
const itemPath = getItemPath(runtime.pmRoot, type, id, runtime.settings.item_format, runtime.typeToFolder);
|
|
251
258
|
const afterDocument = canonicalDocument({
|
|
252
259
|
front_matter: normalizeFrontMatter({
|
|
253
260
|
id,
|
|
@@ -309,7 +316,7 @@ async function importTodoCandidate(candidate, runtime) {
|
|
|
309
316
|
try {
|
|
310
317
|
const releaseLock = await acquireLock(runtime.pmRoot, id, runtime.settings.locks.ttl_seconds, runtime.author);
|
|
311
318
|
try {
|
|
312
|
-
await writeFileAtomic(itemPath, serializeItemDocument(afterDocument));
|
|
319
|
+
await writeFileAtomic(itemPath, serializeItemDocument(afterDocument, { format: runtime.settings.item_format }));
|
|
313
320
|
try {
|
|
314
321
|
const historyEntry = createHistoryEntry({
|
|
315
322
|
nowIso: nowIso(),
|
|
@@ -354,6 +361,7 @@ export async function runTodosImport(options, global) {
|
|
|
354
361
|
const pmRoot = resolvePmRoot(process.cwd(), global.path);
|
|
355
362
|
await ensureInitHasRun(pmRoot);
|
|
356
363
|
const settings = await readSettings(pmRoot);
|
|
364
|
+
const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
|
|
357
365
|
const folder = toNonEmptyString(options.folder) ?? DEFAULT_TODOS_FOLDER;
|
|
358
366
|
const sourceFolder = resolveFolderPath(folder);
|
|
359
367
|
let entries;
|
|
@@ -381,6 +389,8 @@ export async function runTodosImport(options, global) {
|
|
|
381
389
|
pmRoot,
|
|
382
390
|
sourceFolder,
|
|
383
391
|
settings,
|
|
392
|
+
typeNames: typeRegistry.types,
|
|
393
|
+
typeToFolder: typeRegistry.type_to_folder,
|
|
384
394
|
author,
|
|
385
395
|
message,
|
|
386
396
|
};
|
|
@@ -415,16 +425,17 @@ export async function runTodosExport(options, global) {
|
|
|
415
425
|
const pmRoot = resolvePmRoot(process.cwd(), global.path);
|
|
416
426
|
await ensureInitHasRun(pmRoot);
|
|
417
427
|
const settings = await readSettings(pmRoot);
|
|
428
|
+
const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
|
|
418
429
|
const folder = toNonEmptyString(options.folder) ?? DEFAULT_TODOS_FOLDER;
|
|
419
430
|
const destinationFolder = resolveFolderPath(folder);
|
|
420
431
|
await fs.mkdir(destinationFolder, { recursive: true });
|
|
421
432
|
const warnings = [];
|
|
422
433
|
const ids = [];
|
|
423
434
|
let exported = 0;
|
|
424
|
-
const items = await listAllFrontMatter(pmRoot);
|
|
435
|
+
const items = await listAllFrontMatter(pmRoot, settings.item_format, typeRegistry.type_to_folder);
|
|
425
436
|
const sorted = [...items].sort((left, right) => left.id.localeCompare(right.id));
|
|
426
437
|
for (const item of sorted) {
|
|
427
|
-
const located = await locateItem(pmRoot, item.id, settings.id_prefix);
|
|
438
|
+
const located = await locateItem(pmRoot, item.id, settings.id_prefix, settings.item_format, typeRegistry.type_to_folder);
|
|
428
439
|
if (!located) {
|
|
429
440
|
warnings.push(`todos_export_missing_item:${item.id}`);
|
|
430
441
|
continue;
|
|
@@ -456,5 +467,4 @@ export async function runTodosExport(options, global) {
|
|
|
456
467
|
ids,
|
|
457
468
|
warnings,
|
|
458
469
|
};
|
|
459
|
-
}
|
|
460
|
-
//# sourceMappingURL=import-export.js.map
|
|
470
|
+
}
|