akm-cli 0.7.4 → 0.8.0-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{CHANGELOG.md → .github/CHANGELOG.md} +34 -1
- package/.github/LICENSE +374 -0
- package/dist/cli/parse-args.js +43 -0
- package/dist/cli.js +1007 -593
- package/dist/commands/agent-dispatch.js +102 -0
- package/dist/commands/agent-support.js +62 -0
- package/dist/commands/config-cli.js +68 -84
- package/dist/commands/consolidate.js +823 -0
- package/dist/commands/curate.js +1 -0
- package/dist/commands/distill-promotion-policy.js +658 -0
- package/dist/commands/distill.js +250 -48
- package/dist/commands/eval-cases.js +40 -0
- package/dist/commands/events.js +12 -24
- package/dist/commands/graph.js +222 -0
- package/dist/commands/health.js +376 -0
- package/dist/commands/help/help-accept.md +9 -0
- package/dist/commands/help/help-improve.md +53 -0
- package/dist/commands/help/help-proposals.md +15 -0
- package/dist/commands/help/help-propose.md +17 -0
- package/dist/commands/help/help-reject.md +8 -0
- package/dist/commands/history.js +3 -30
- package/dist/commands/improve.js +1170 -0
- package/dist/commands/info.js +2 -2
- package/dist/commands/init.js +2 -2
- package/dist/commands/install-audit.js +5 -1
- package/dist/commands/installed-stashes.js +118 -138
- package/dist/commands/knowledge.js +133 -0
- package/dist/commands/lint/agent-linter.js +46 -0
- package/dist/commands/lint/base-linter.js +251 -0
- package/dist/commands/lint/command-linter.js +46 -0
- package/dist/commands/lint/default-linter.js +13 -0
- package/dist/commands/lint/index.js +107 -0
- package/dist/commands/lint/knowledge-linter.js +13 -0
- package/dist/commands/lint/memory-linter.js +58 -0
- package/dist/commands/lint/registry.js +33 -0
- package/dist/commands/lint/skill-linter.js +42 -0
- package/dist/commands/lint/task-linter.js +47 -0
- package/dist/commands/lint/types.js +1 -0
- package/dist/commands/lint/workflow-linter.js +53 -0
- package/dist/commands/lint.js +1 -0
- package/dist/commands/migration-help.js +2 -2
- package/dist/commands/proposal.js +8 -7
- package/dist/commands/propose.js +113 -43
- package/dist/commands/reflect.js +175 -41
- package/dist/commands/registry-search.js +2 -2
- package/dist/commands/remember.js +55 -1
- package/dist/commands/schema-repair.js +130 -0
- package/dist/commands/search.js +21 -5
- package/dist/commands/show.js +131 -52
- package/dist/commands/source-add.js +10 -10
- package/dist/commands/source-manage.js +11 -19
- package/dist/commands/tasks.js +385 -0
- package/dist/commands/url-checker.js +39 -0
- package/dist/commands/vault.js +7 -33
- package/dist/core/action-contributors.js +25 -0
- package/dist/core/asset-registry.js +5 -17
- package/dist/core/asset-spec.js +11 -1
- package/dist/core/common.js +94 -0
- package/dist/core/concurrent.js +22 -0
- package/dist/core/config.js +229 -122
- package/dist/core/events.js +87 -123
- package/dist/core/frontmatter.js +3 -1
- package/dist/core/markdown.js +17 -0
- package/dist/core/memory-improve.js +678 -0
- package/dist/core/parse.js +155 -0
- package/dist/core/paths.js +101 -3
- package/dist/core/proposal-validators.js +61 -0
- package/dist/core/proposals.js +49 -38
- package/dist/core/state-db.js +775 -0
- package/dist/core/time.js +51 -0
- package/dist/core/warn.js +59 -1
- package/dist/indexer/db-search.js +86 -472
- package/dist/indexer/db.js +392 -6
- package/dist/indexer/ensure-index.js +133 -0
- package/dist/indexer/graph-boost.js +247 -94
- package/dist/indexer/graph-db.js +201 -0
- package/dist/indexer/graph-dedup.js +99 -0
- package/dist/indexer/graph-extraction.js +417 -74
- package/dist/indexer/index-context.js +10 -0
- package/dist/indexer/indexer.js +466 -298
- package/dist/indexer/llm-cache.js +47 -0
- package/dist/indexer/match-contributors.js +141 -0
- package/dist/indexer/matchers.js +24 -190
- package/dist/indexer/memory-inference.js +63 -29
- package/dist/indexer/metadata-contributors.js +26 -0
- package/dist/indexer/metadata.js +188 -175
- package/dist/indexer/path-resolver.js +89 -0
- package/dist/indexer/ranking-contributors.js +204 -0
- package/dist/indexer/ranking.js +74 -0
- package/dist/indexer/search-hit-enrichers.js +22 -0
- package/dist/indexer/search-source.js +24 -9
- package/dist/indexer/semantic-status.js +2 -16
- package/dist/indexer/walker.js +25 -0
- package/dist/integrations/agent/config.js +175 -3
- package/dist/integrations/agent/index.js +3 -1
- package/dist/integrations/agent/pipeline.js +39 -0
- package/dist/integrations/agent/profiles.js +67 -5
- package/dist/integrations/agent/prompts.js +114 -29
- package/dist/integrations/agent/runners.js +31 -0
- package/dist/integrations/agent/sdk-runner.js +120 -0
- package/dist/integrations/agent/spawn.js +136 -28
- package/dist/integrations/lockfile.js +10 -18
- package/dist/integrations/session-logs/index.js +65 -0
- package/dist/integrations/session-logs/providers/claude-code.js +56 -0
- package/dist/integrations/session-logs/providers/opencode.js +52 -0
- package/dist/integrations/session-logs/types.js +1 -0
- package/dist/llm/call-ai.js +74 -0
- package/dist/llm/client.js +63 -86
- package/dist/llm/feature-gate.js +27 -16
- package/dist/llm/graph-extract.js +297 -64
- package/dist/llm/memory-infer.js +52 -71
- package/dist/llm/metadata-enhance.js +39 -22
- package/dist/llm/prompts/graph-extract-user-prompt.md +12 -0
- package/dist/output/cli-hints-full.md +277 -0
- package/dist/output/cli-hints-short.md +65 -0
- package/dist/output/cli-hints.js +2 -309
- package/dist/output/renderers.js +196 -124
- package/dist/output/shapes.js +41 -3
- package/dist/output/text.js +257 -21
- package/dist/registry/providers/skills-sh.js +61 -49
- package/dist/registry/providers/static-index.js +44 -48
- package/dist/setup/setup.js +510 -11
- package/dist/sources/provider-factory.js +2 -1
- package/dist/sources/providers/git.js +44 -2
- package/dist/sources/website-ingest.js +4 -0
- package/dist/tasks/backends/cron.js +200 -0
- package/dist/tasks/backends/exec-utils.js +25 -0
- package/dist/tasks/backends/index.js +32 -0
- package/dist/tasks/backends/launchd-template.xml +19 -0
- package/dist/tasks/backends/launchd.js +184 -0
- package/dist/tasks/backends/schtasks-template.xml +29 -0
- package/dist/tasks/backends/schtasks.js +212 -0
- package/dist/tasks/parser.js +198 -0
- package/dist/tasks/resolveAkmBin.js +84 -0
- package/dist/tasks/runner.js +432 -0
- package/dist/tasks/schedule.js +208 -0
- package/dist/tasks/schema.js +13 -0
- package/dist/tasks/validator.js +59 -0
- package/dist/wiki/index-template.md +12 -0
- package/dist/wiki/ingest-workflow-template.md +54 -0
- package/dist/wiki/log-template.md +8 -0
- package/dist/wiki/schema-template.md +61 -0
- package/dist/wiki/wiki-templates.js +12 -0
- package/dist/wiki/wiki.js +10 -61
- package/dist/workflows/authoring.js +5 -25
- package/dist/workflows/db.js +9 -0
- package/dist/workflows/renderer.js +8 -3
- package/dist/workflows/runs.js +73 -88
- package/dist/workflows/scope-key.js +76 -0
- package/dist/workflows/validator.js +1 -1
- package/dist/workflows/workflow-template.md +24 -0
- package/docs/README.md +3 -0
- package/docs/migration/release-notes/0.7.0.md +1 -1
- package/docs/migration/release-notes/0.7.4.md +1 -1
- package/docs/migration/release-notes/0.7.5.md +20 -0
- package/docs/migration/release-notes/0.8.0.md +43 -0
- package/package.json +4 -3
- package/dist/templates/wiki-templates.js +0 -100
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate a parsed {@link TaskDocument} for runnability.
|
|
3
|
+
*
|
|
4
|
+
* Enforces:
|
|
5
|
+
* • the schedule is parseable and translates to the active backend
|
|
6
|
+
* • the workflow ref resolves (workflow targets)
|
|
7
|
+
* • the asset/file source exists (prompt targets)
|
|
8
|
+
* • the agent profile resolves (prompt targets)
|
|
9
|
+
*
|
|
10
|
+
* Validation is deliberately split from parsing: callers that only want to
|
|
11
|
+
* read frontmatter (e.g. `tasks list`) can skip these checks, while
|
|
12
|
+
* `tasks add` and `tasks run` should always run them.
|
|
13
|
+
*/
|
|
14
|
+
import fs from "node:fs";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
import { parseAssetRef } from "../core/asset-ref";
|
|
17
|
+
import { resolveStashDir } from "../core/common";
|
|
18
|
+
import { loadConfig } from "../core/config";
|
|
19
|
+
import { NotFoundError } from "../core/errors";
|
|
20
|
+
import { requireAgentProfile } from "../integrations/agent";
|
|
21
|
+
import { resolveAssetPath } from "../sources/resolve";
|
|
22
|
+
import { parseSchedule } from "./schedule";
|
|
23
|
+
export async function validateTaskDocument(task, options) {
|
|
24
|
+
// Schedule must parse and translate.
|
|
25
|
+
parseSchedule(task.schedule, options.backend);
|
|
26
|
+
if (task.target.kind === "workflow") {
|
|
27
|
+
const stashDir = options.stashDir ?? resolveStashDir();
|
|
28
|
+
const ref = parseAssetRef(task.target.ref);
|
|
29
|
+
if (ref.type !== "workflow") {
|
|
30
|
+
throw new NotFoundError(`Task "${task.id}" workflow target must be a workflow ref (got "${task.target.ref}").`, "WORKFLOW_NOT_FOUND");
|
|
31
|
+
}
|
|
32
|
+
await resolveAssetPath(stashDir, "workflow", ref.name);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (task.target.kind !== "prompt") {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
// Prompt target. Resolve the profile unconditionally — when no profile is
|
|
39
|
+
// set on the task, requireAgentProfile falls back to config.agent.default
|
|
40
|
+
// and throws a clear error if neither is configured. Catching this at
|
|
41
|
+
// `tasks add` / `tasks sync` time is much more useful than failing only
|
|
42
|
+
// when the OS scheduler fires.
|
|
43
|
+
const config = loadConfig();
|
|
44
|
+
requireAgentProfile(config.agent, task.target.profile);
|
|
45
|
+
const src = task.target.source;
|
|
46
|
+
if (src.kind === "asset") {
|
|
47
|
+
const stashDir = options.stashDir ?? resolveStashDir();
|
|
48
|
+
const ref = parseAssetRef(src.ref);
|
|
49
|
+
await resolveAssetPath(stashDir, ref.type, ref.name);
|
|
50
|
+
}
|
|
51
|
+
else if (src.kind === "file") {
|
|
52
|
+
const taskDir = path.dirname(task.source.path);
|
|
53
|
+
const resolved = path.isAbsolute(src.path) ? src.path : path.resolve(taskDir, src.path);
|
|
54
|
+
if (!fs.existsSync(resolved) || !fs.statSync(resolved).isFile()) {
|
|
55
|
+
throw new NotFoundError(`Prompt file not found for task "${task.id}": ${src.path} (resolved to ${resolved}).`, "FILE_NOT_FOUND");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// inline source is always valid post-parse.
|
|
59
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Catalog of pages in the {{WIKI_NAME}} wiki. Regenerated by `akm index`.
|
|
3
|
+
wikiRole: index
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{WIKI_NAME}} — index
|
|
7
|
+
|
|
8
|
+
_This file is regenerated on every `akm index` run. Manual edits are
|
|
9
|
+
preserved until the next regeneration, then replaced._
|
|
10
|
+
|
|
11
|
+
_(no pages yet — create one with your editor, or ingest a source with `akm
|
|
12
|
+
wiki stash {{WIKI_NAME}} <path>`.)_
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Ingest workflow for wiki:{{WIKI_NAME}}
|
|
2
|
+
|
|
3
|
+
Wiki location: {{WIKI_DIR}}
|
|
4
|
+
Schema: {{SCHEMA_PATH}}
|
|
5
|
+
|
|
6
|
+
Follow these steps. akm commands handle the invariants; use your native
|
|
7
|
+
Read/Write/Edit tools for page edits.
|
|
8
|
+
|
|
9
|
+
1. **Read the schema.** Open `{{SCHEMA_PATH}}`. It defines the voice, page
|
|
10
|
+
kinds, contradiction policy, and any wiki-specific conventions. Do not
|
|
11
|
+
skip this step even on familiar wikis — the schema may have changed.
|
|
12
|
+
|
|
13
|
+
2. **File the source under `raw/`.**
|
|
14
|
+
```sh
|
|
15
|
+
akm wiki stash {{WIKI_NAME}} <path-or-url-to-source>
|
|
16
|
+
# or: cat <source> | akm wiki stash {{WIKI_NAME}} -
|
|
17
|
+
```
|
|
18
|
+
Returns `{ slug, path, ref }`. The raw copy is immutable — never edit it.
|
|
19
|
+
|
|
20
|
+
3. **Find related existing pages.**
|
|
21
|
+
```sh
|
|
22
|
+
akm wiki search {{WIKI_NAME}} "<key terms from the source>"
|
|
23
|
+
```
|
|
24
|
+
Read the top hits with `akm show wiki:{{WIKI_NAME}}/<page>`. Use
|
|
25
|
+
`akm show wiki:{{WIKI_NAME}}/<page> toc` for large pages.
|
|
26
|
+
|
|
27
|
+
4. **Decide for each candidate.** For each related page:
|
|
28
|
+
- **Append**: add a section or paragraph under the relevant heading.
|
|
29
|
+
Include the raw source in the page's `sources:` frontmatter list.
|
|
30
|
+
- **Contradict**: note the tension explicitly; don't silently overwrite.
|
|
31
|
+
Follow the schema's contradiction policy.
|
|
32
|
+
- **Skip**: source doesn't add to this page — move on.
|
|
33
|
+
|
|
34
|
+
5. **Create new pages for concepts/entities the source introduces.** Each
|
|
35
|
+
new page must have frontmatter with `description`, `pageKind`,
|
|
36
|
+
`xrefs`, and `sources`. Cross-reference with related pages both
|
|
37
|
+
directions.
|
|
38
|
+
|
|
39
|
+
6. **Update xrefs both ways.** If page A now xrefs page B, page B must xref
|
|
40
|
+
page A. `akm wiki lint {{WIKI_NAME}}` will flag violations.
|
|
41
|
+
|
|
42
|
+
7. **Append to `log.md`.** One entry per ingest: date, source slug, one-line
|
|
43
|
+
summary, refs to created/edited pages. Newest at the top.
|
|
44
|
+
|
|
45
|
+
8. **Regenerate the index + verify.**
|
|
46
|
+
```sh
|
|
47
|
+
akm index
|
|
48
|
+
akm wiki lint {{WIKI_NAME}}
|
|
49
|
+
```
|
|
50
|
+
Resolve any lint findings before calling the ingest done.
|
|
51
|
+
|
|
52
|
+
That's it. `akm` never calls an LLM — reasoning is your job; it just owns
|
|
53
|
+
the invariants (raw immutability, unique slugs, ref validation, index
|
|
54
|
+
regeneration, structural lint).
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Rules that govern this wiki. Read before ingesting, searching, or editing pages.
|
|
3
|
+
wikiRole: schema
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{WIKI_NAME}} wiki schema
|
|
7
|
+
|
|
8
|
+
This wiki follows the three-layer pattern:
|
|
9
|
+
|
|
10
|
+
- `raw/` — immutable ingested sources (never edit)
|
|
11
|
+
- `<page>.md` and `<topic>/<page>.md` — agent-authored pages
|
|
12
|
+
- `schema.md` (this file), `index.md`, `log.md` — wiki-level metadata
|
|
13
|
+
|
|
14
|
+
## Page frontmatter
|
|
15
|
+
|
|
16
|
+
Every page should carry frontmatter so akm can index and link it:
|
|
17
|
+
|
|
18
|
+
```yaml
|
|
19
|
+
---
|
|
20
|
+
description: one-sentence summary used in search and lint
|
|
21
|
+
pageKind: entity | concept | question | note | <your-custom-kind>
|
|
22
|
+
xrefs:
|
|
23
|
+
- wiki:{{WIKI_NAME}}/other-page
|
|
24
|
+
sources:
|
|
25
|
+
- raw/<slug>.md
|
|
26
|
+
---
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`pageKind` accepts any non-empty string. Add new categories freely; they
|
|
30
|
+
will surface in `index.md` as new sections after the next `akm index` run.
|
|
31
|
+
|
|
32
|
+
## Three operations
|
|
33
|
+
|
|
34
|
+
### Ingest
|
|
35
|
+
|
|
36
|
+
1. Copy the new source into `raw/` with `akm wiki stash {{WIKI_NAME}} <path>`.
|
|
37
|
+
2. Find related pages: `akm wiki search {{WIKI_NAME}} "<terms>"`.
|
|
38
|
+
3. For each related page: append a section, note a contradiction, or create a
|
|
39
|
+
new page. Update xrefs on both sides.
|
|
40
|
+
4. Cite the raw source in each touched page's `sources:` frontmatter.
|
|
41
|
+
5. Append one entry to `log.md` describing what was assimilated.
|
|
42
|
+
|
|
43
|
+
### Query
|
|
44
|
+
|
|
45
|
+
1. `akm wiki search {{WIKI_NAME}} "<question>"` — find candidate pages.
|
|
46
|
+
2. `akm show wiki:{{WIKI_NAME}}/<page>` — read the top hits.
|
|
47
|
+
3. Compose the answer from the wiki; cite raw sources only when the wiki
|
|
48
|
+
points at them.
|
|
49
|
+
|
|
50
|
+
### Lint
|
|
51
|
+
|
|
52
|
+
1. `akm wiki lint {{WIKI_NAME}}` — deterministic structural checks.
|
|
53
|
+
2. Resolve each finding: link orphans, fix broken xrefs, add descriptions,
|
|
54
|
+
cite uncited raws, refresh the index.
|
|
55
|
+
|
|
56
|
+
## Hard rules
|
|
57
|
+
|
|
58
|
+
- `raw/` is immutable. Never edit ingested sources.
|
|
59
|
+
- Cross-references must point at pages that actually exist.
|
|
60
|
+
- Prefer appending to an existing page over duplicating one.
|
|
61
|
+
- Cite the raw source id (e.g. `raw/2026-04-foo.md`) when copying claims.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import indexTemplate from "./index-template.md" with { type: "text" };
|
|
2
|
+
import logTemplate from "./log-template.md" with { type: "text" };
|
|
3
|
+
import schemaTemplate from "./schema-template.md" with { type: "text" };
|
|
4
|
+
export function buildSchemaMd(wikiName) {
|
|
5
|
+
return schemaTemplate.replaceAll("{{WIKI_NAME}}", wikiName);
|
|
6
|
+
}
|
|
7
|
+
export function buildIndexMd(wikiName) {
|
|
8
|
+
return indexTemplate.replaceAll("{{WIKI_NAME}}", wikiName);
|
|
9
|
+
}
|
|
10
|
+
export function buildLogMd(wikiName) {
|
|
11
|
+
return logTemplate.replaceAll("{{WIKI_NAME}}", wikiName);
|
|
12
|
+
}
|
package/dist/wiki/wiki.js
CHANGED
|
@@ -42,12 +42,13 @@ import fs from "node:fs";
|
|
|
42
42
|
import path from "node:path";
|
|
43
43
|
import { parse as yamlParse } from "yaml";
|
|
44
44
|
import { akmSearch } from "../commands/search";
|
|
45
|
-
import { isWithin } from "../core/common";
|
|
46
|
-
import { loadUserConfig, saveConfig } from "../core/config";
|
|
45
|
+
import { isWithin, todayIso } from "../core/common";
|
|
46
|
+
import { getSources, loadUserConfig, saveConfig } from "../core/config";
|
|
47
47
|
import { NotFoundError, UsageError } from "../core/errors";
|
|
48
48
|
import { parseFrontmatter, parseFrontmatterBlock } from "../core/frontmatter";
|
|
49
49
|
import { resolveSourceEntries } from "../indexer/search-source";
|
|
50
|
-
import
|
|
50
|
+
import ingestWorkflowTemplate from "./ingest-workflow-template.md" with { type: "text" };
|
|
51
|
+
import { buildIndexMd, buildLogMd, buildSchemaMd } from "./wiki-templates";
|
|
51
52
|
// ── Constants ───────────────────────────────────────────────────────────────
|
|
52
53
|
export const WIKIS_SUBDIR = "wikis";
|
|
53
54
|
export const SCHEMA_MD = "schema.md";
|
|
@@ -399,12 +400,11 @@ export function removeWiki(stashDir, name, options = {}) {
|
|
|
399
400
|
const isStashWiki = fs.existsSync(wikiDir) && isRecognizedStashWiki(wikiDir);
|
|
400
401
|
if (!isStashWiki && external) {
|
|
401
402
|
const config = loadUserConfig();
|
|
402
|
-
const filteredSources = (config
|
|
403
|
+
const filteredSources = getSources(config).filter((entry) => entry.wikiName !== name);
|
|
403
404
|
const installed = (config.installed ?? []).filter((entry) => entry.wikiName !== name);
|
|
404
405
|
saveConfig({
|
|
405
406
|
...config,
|
|
406
407
|
sources: filteredSources.length > 0 ? filteredSources : undefined,
|
|
407
|
-
stashes: undefined,
|
|
408
408
|
installed: installed.length > 0 ? installed : undefined,
|
|
409
409
|
});
|
|
410
410
|
return {
|
|
@@ -665,7 +665,7 @@ function withRawFrontmatter(content, slug) {
|
|
|
665
665
|
// tag the wikiRole for the indexer.
|
|
666
666
|
if (content.startsWith("---"))
|
|
667
667
|
return content;
|
|
668
|
-
const date =
|
|
668
|
+
const date = todayIso();
|
|
669
669
|
return `---\nwikiRole: raw\ningestedAt: ${date}\nslug: ${slug}\n---\n\n${content}`;
|
|
670
670
|
}
|
|
671
671
|
function ensureTrailingNewline(value) {
|
|
@@ -960,60 +960,9 @@ export function regenerateAllWikiIndexes(stashDir) {
|
|
|
960
960
|
export function buildIngestWorkflow(stashDir, name) {
|
|
961
961
|
const wikiDir = resolveWikiSource(stashDir, name).path;
|
|
962
962
|
const schemaPath = path.join(wikiDir, SCHEMA_MD);
|
|
963
|
-
const workflow =
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
Follow these steps. akm commands handle the invariants; use your native
|
|
969
|
-
Read/Write/Edit tools for page edits.
|
|
970
|
-
|
|
971
|
-
1. **Read the schema.** Open \`${schemaPath}\`. It defines the voice, page
|
|
972
|
-
kinds, contradiction policy, and any wiki-specific conventions. Do not
|
|
973
|
-
skip this step even on familiar wikis — the schema may have changed.
|
|
974
|
-
|
|
975
|
-
2. **File the source under \`raw/\`.**
|
|
976
|
-
\`\`\`sh
|
|
977
|
-
akm wiki stash ${name} <path-or-url-to-source>
|
|
978
|
-
# or: cat <source> | akm wiki stash ${name} -
|
|
979
|
-
\`\`\`
|
|
980
|
-
Returns \`{ slug, path, ref }\`. The raw copy is immutable — never edit it.
|
|
981
|
-
|
|
982
|
-
3. **Find related existing pages.**
|
|
983
|
-
\`\`\`sh
|
|
984
|
-
akm wiki search ${name} "<key terms from the source>"
|
|
985
|
-
\`\`\`
|
|
986
|
-
Read the top hits with \`akm show wiki:${name}/<page>\`. Use
|
|
987
|
-
\`akm show wiki:${name}/<page> toc\` for large pages.
|
|
988
|
-
|
|
989
|
-
4. **Decide for each candidate.** For each related page:
|
|
990
|
-
- **Append**: add a section or paragraph under the relevant heading.
|
|
991
|
-
Include the raw source in the page's \`sources:\` frontmatter list.
|
|
992
|
-
- **Contradict**: note the tension explicitly; don't silently overwrite.
|
|
993
|
-
Follow the schema's contradiction policy.
|
|
994
|
-
- **Skip**: source doesn't add to this page — move on.
|
|
995
|
-
|
|
996
|
-
5. **Create new pages for concepts/entities the source introduces.** Each
|
|
997
|
-
new page must have frontmatter with \`description\`, \`pageKind\`,
|
|
998
|
-
\`xrefs\`, and \`sources\`. Cross-reference with related pages both
|
|
999
|
-
directions.
|
|
1000
|
-
|
|
1001
|
-
6. **Update xrefs both ways.** If page A now xrefs page B, page B must xref
|
|
1002
|
-
page A. \`akm wiki lint ${name}\` will flag violations.
|
|
1003
|
-
|
|
1004
|
-
7. **Append to \`log.md\`.** One entry per ingest: date, source slug, one-line
|
|
1005
|
-
summary, refs to created/edited pages. Newest at the top.
|
|
1006
|
-
|
|
1007
|
-
8. **Regenerate the index + verify.**
|
|
1008
|
-
\`\`\`sh
|
|
1009
|
-
akm index
|
|
1010
|
-
akm wiki lint ${name}
|
|
1011
|
-
\`\`\`
|
|
1012
|
-
Resolve any lint findings before calling the ingest done.
|
|
1013
|
-
|
|
1014
|
-
That's it. \`akm\` never calls an LLM — reasoning is your job; it just owns
|
|
1015
|
-
the invariants (raw immutability, unique slugs, ref validation, index
|
|
1016
|
-
regeneration, structural lint).
|
|
1017
|
-
`;
|
|
963
|
+
const workflow = ingestWorkflowTemplate
|
|
964
|
+
.replaceAll("{{WIKI_NAME}}", name)
|
|
965
|
+
.replaceAll("{{WIKI_DIR}}", wikiDir)
|
|
966
|
+
.replaceAll("{{SCHEMA_PATH}}", schemaPath);
|
|
1018
967
|
return { wiki: name, path: wikiDir, schemaPath, workflow };
|
|
1019
968
|
}
|
|
@@ -5,6 +5,7 @@ import { isWithin, resolveStashDir } from "../core/common";
|
|
|
5
5
|
import { UsageError } from "../core/errors";
|
|
6
6
|
import { warn } from "../core/warn";
|
|
7
7
|
import { parseWorkflow } from "./parser";
|
|
8
|
+
import workflowTemplate from "./workflow-template.md" with { type: "text" };
|
|
8
9
|
const DEFAULT_WORKFLOW_TEMPLATE = renderWorkflowTemplate({
|
|
9
10
|
title: "Example Workflow",
|
|
10
11
|
firstStepTitle: "First Step",
|
|
@@ -134,29 +135,8 @@ export function validateWorkflowSource(target) {
|
|
|
134
135
|
return { path: target, parse: parseWorkflow(content, { path: target }) };
|
|
135
136
|
}
|
|
136
137
|
function renderWorkflowTemplate(input) {
|
|
137
|
-
return
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
params:
|
|
142
|
-
example_param: Explain this parameter
|
|
143
|
-
---
|
|
144
|
-
|
|
145
|
-
# Workflow: ${input.title}
|
|
146
|
-
|
|
147
|
-
## Step: ${input.firstStepTitle}
|
|
148
|
-
Step ID: ${input.firstStepId}
|
|
149
|
-
|
|
150
|
-
### Instructions
|
|
151
|
-
Describe what to do in this step.
|
|
152
|
-
|
|
153
|
-
### Completion Criteria
|
|
154
|
-
- Confirm the first step is complete
|
|
155
|
-
|
|
156
|
-
## Step: Second Step
|
|
157
|
-
Step ID: second-step
|
|
158
|
-
|
|
159
|
-
### Instructions
|
|
160
|
-
Describe what happens next.
|
|
161
|
-
`;
|
|
138
|
+
return workflowTemplate
|
|
139
|
+
.replace("{{TITLE}}", input.title)
|
|
140
|
+
.replace("{{FIRST_STEP_TITLE}}", input.firstStepTitle)
|
|
141
|
+
.replace("{{FIRST_STEP_ID}}", input.firstStepId);
|
|
162
142
|
}
|
package/dist/workflows/db.js
CHANGED
|
@@ -21,6 +21,7 @@ function ensureWorkflowSchema(db) {
|
|
|
21
21
|
CREATE TABLE IF NOT EXISTS workflow_runs (
|
|
22
22
|
id TEXT PRIMARY KEY,
|
|
23
23
|
workflow_ref TEXT NOT NULL,
|
|
24
|
+
scope_key TEXT,
|
|
24
25
|
workflow_entry_id INTEGER,
|
|
25
26
|
workflow_title TEXT NOT NULL,
|
|
26
27
|
status TEXT NOT NULL CHECK (status IN ('active', 'completed', 'blocked', 'failed')),
|
|
@@ -52,4 +53,12 @@ function ensureWorkflowSchema(db) {
|
|
|
52
53
|
CREATE INDEX IF NOT EXISTS idx_workflow_run_steps_run_sequence
|
|
53
54
|
ON workflow_run_steps(run_id, sequence_index);
|
|
54
55
|
`);
|
|
56
|
+
const columns = db
|
|
57
|
+
.query("PRAGMA table_info(workflow_runs)")
|
|
58
|
+
.all()
|
|
59
|
+
.map((column) => column.name);
|
|
60
|
+
if (!columns.includes("scope_key")) {
|
|
61
|
+
db.exec("ALTER TABLE workflow_runs ADD COLUMN scope_key TEXT");
|
|
62
|
+
}
|
|
63
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_workflow_runs_scope_ref_status ON workflow_runs(scope_key, workflow_ref, status)");
|
|
55
64
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { makeAssetRef } from "../core/asset-ref";
|
|
10
10
|
import { UsageError } from "../core/errors";
|
|
11
|
+
import { registerMetadataContributor } from "../indexer/metadata-contributors";
|
|
11
12
|
import { cacheWorkflowDocument } from "./document-cache";
|
|
12
13
|
import { parseWorkflow } from "./parser";
|
|
13
14
|
function shellQuote(value) {
|
|
@@ -54,8 +55,12 @@ export const workflowMdRenderer = {
|
|
|
54
55
|
})),
|
|
55
56
|
};
|
|
56
57
|
},
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
};
|
|
59
|
+
registerMetadataContributor({
|
|
60
|
+
name: "workflow-document-metadata",
|
|
61
|
+
appliesTo: ({ rendererName }) => rendererName === "workflow-md",
|
|
62
|
+
contribute(entry, { renderContext }) {
|
|
63
|
+
const doc = loadDocument(renderContext);
|
|
59
64
|
const hints = new Set(entry.searchHints ?? []);
|
|
60
65
|
hints.add(doc.title);
|
|
61
66
|
for (const step of doc.steps) {
|
|
@@ -75,4 +80,4 @@ export const workflowMdRenderer = {
|
|
|
75
80
|
}
|
|
76
81
|
cacheWorkflowDocument(entry, doc);
|
|
77
82
|
},
|
|
78
|
-
};
|
|
83
|
+
});
|