@agentic-kit/cli 0.8.1 → 0.9.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/esm/db-tools.js CHANGED
@@ -2,8 +2,8 @@ import * as fs from 'fs';
2
2
  import * as path from 'path';
3
3
  const EXTENSION_FILE = 'constructive-db-tools.js';
4
4
  /**
5
- * Environment variables the generated extension reads at tool-call time.
6
- * Without CONSTRUCTIVE_ACCESS_TOKEN the tools load but report "not signed in".
5
+ * Environment variables that override the stored session at tool-call time.
6
+ * Without env vars or a stored session the tools load but report "not signed in".
7
7
  */
8
8
  export const HOST_ENV_VARS = [
9
9
  'CONSTRUCTIVE_USER_ID',
@@ -14,26 +14,21 @@ export const HOST_ENV_VARS = [
14
14
  ];
15
15
  // pi's TUI loads extensions from files under <agentDir>/extensions (via jiti),
16
16
  // not from factories, so the db tools are wired by materializing a small
17
- // generated entry there. The @agentic-kit/pi entry path is resolved from THIS
18
- // package at assembly time and baked in, because node resolution from the
19
- // appstash agent dir would not find it.
20
- function extensionSource(pkgEntry) {
17
+ // generated entry there. Both entry paths are resolved from THIS package at
18
+ // assembly time and baked in, because node resolution from the appstash agent
19
+ // dir would not find them.
20
+ function extensionSource(pkgEntry, credentialsEntry) {
21
21
  return `// Generated by @agentic-kit/cli — do not edit (rewritten on every \`agent\` run).
22
22
  // Registers the Constructive typed db tools + confirm gate (@agentic-kit/pi)
23
- // with credentials read from the environment on each call.
23
+ // with credentials resolved on each call: CONSTRUCTIVE_* env vars first, then
24
+ // the \`agent login\` session store.
24
25
  const { createDbTools } = require(${JSON.stringify(pkgEntry)});
26
+ const { resolveAccount, resolveBackendConfig } = require(${JSON.stringify(credentialsEntry)});
25
27
 
26
28
  module.exports = createDbTools({
27
- account: () => {
28
- const userId = process.env.CONSTRUCTIVE_USER_ID;
29
- const accessToken = process.env.CONSTRUCTIVE_ACCESS_TOKEN;
30
- if (!userId || !accessToken) return null;
31
- return { userId, accessToken, apiKey: process.env.CONSTRUCTIVE_API_KEY };
32
- },
33
- backendConfig: () => ({
34
- apiEndpoint: process.env.CONSTRUCTIVE_API_ENDPOINT,
35
- modulesEndpoint: process.env.CONSTRUCTIVE_MODULES_ENDPOINT
36
- })
29
+ account: resolveAccount,
30
+ backendConfig: resolveBackendConfig,
31
+ signInHint: 'Run \`agent login\` to sign in.'
37
32
  });
38
33
  `;
39
34
  }
@@ -50,9 +45,10 @@ export function materializeDbTools(config, log) {
50
45
  log('db tools unavailable (@agentic-kit/pi not installed) — continuing without them');
51
46
  return null;
52
47
  }
48
+ const credentialsEntry = require.resolve('./credentials');
53
49
  const dir = path.join(config.agentDir, 'extensions');
54
50
  fs.mkdirSync(dir, { recursive: true });
55
51
  const file = path.join(dir, EXTENSION_FILE);
56
- fs.writeFileSync(file, extensionSource(pkgEntry));
52
+ fs.writeFileSync(file, extensionSource(pkgEntry, credentialsEntry));
57
53
  return file;
58
54
  }
package/esm/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { init, skillsList, skillsUpdate, usage } from './commands';
2
+ import { refreshApiKeyIfNeeded } from './auth';
3
+ import { BACKEND_PRESETS, loadBackendConfig } from './backend-store';
4
+ import { init, login, logout, skillsList, skillsUpdate, usage, whoami } from './commands';
3
5
  import { loadConfig } from './config';
4
6
  import { materializeDbTools } from './db-tools';
5
7
  import { assembleSkills } from './skills';
@@ -20,6 +22,18 @@ async function run(args) {
20
22
  await init(config, {});
21
23
  return;
22
24
  }
25
+ if (first === 'login') {
26
+ await login(config, {});
27
+ return;
28
+ }
29
+ if (first === 'logout') {
30
+ await logout(config);
31
+ return;
32
+ }
33
+ if (first === 'whoami') {
34
+ whoami(config);
35
+ return;
36
+ }
23
37
  if (first === 'skills') {
24
38
  if (second === 'update')
25
39
  await skillsUpdate(config);
@@ -30,6 +44,15 @@ async function run(args) {
30
44
  const log = (msg) => console.log(`[agent] ${msg}`);
31
45
  await assembleSkills(config, log);
32
46
  materializeDbTools(config, log);
47
+ // Fire-and-forget: keep the stored API key fresh (<7 days to expiry re-mints)
48
+ // without ever blocking startup. Only an expired login session gets a line.
49
+ const backend = loadBackendConfig(config.store) ?? BACKEND_PRESETS.localnet;
50
+ void refreshApiKeyIfNeeded({ store: config.store, authEndpoint: backend.authEndpoint })
51
+ .then((status) => {
52
+ if (status === 'reauth-required')
53
+ log('API key expired — run `agent login`');
54
+ })
55
+ .catch(() => { });
33
56
  // pi is ESM-only; tsc's CJS output would downlevel a plain `await import()`
34
57
  // into `require()`, which cannot load it. Indirect the import so it survives
35
58
  // transpilation in the CJS build.
package/index.js CHANGED
@@ -2,6 +2,8 @@
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.assembleSkills = exports.materializeDbTools = exports.HOST_ENV_VARS = exports.loadConfig = void 0;
5
+ const auth_1 = require("./auth");
6
+ const backend_store_1 = require("./backend-store");
5
7
  const commands_1 = require("./commands");
6
8
  const config_1 = require("./config");
7
9
  const db_tools_1 = require("./db-tools");
@@ -27,6 +29,18 @@ async function run(args) {
27
29
  await (0, commands_1.init)(config, {});
28
30
  return;
29
31
  }
32
+ if (first === 'login') {
33
+ await (0, commands_1.login)(config, {});
34
+ return;
35
+ }
36
+ if (first === 'logout') {
37
+ await (0, commands_1.logout)(config);
38
+ return;
39
+ }
40
+ if (first === 'whoami') {
41
+ (0, commands_1.whoami)(config);
42
+ return;
43
+ }
30
44
  if (first === 'skills') {
31
45
  if (second === 'update')
32
46
  await (0, commands_1.skillsUpdate)(config);
@@ -37,6 +51,15 @@ async function run(args) {
37
51
  const log = (msg) => console.log(`[agent] ${msg}`);
38
52
  await (0, skills_1.assembleSkills)(config, log);
39
53
  (0, db_tools_1.materializeDbTools)(config, log);
54
+ // Fire-and-forget: keep the stored API key fresh (<7 days to expiry re-mints)
55
+ // without ever blocking startup. Only an expired login session gets a line.
56
+ const backend = (0, backend_store_1.loadBackendConfig)(config.store) ?? backend_store_1.BACKEND_PRESETS.localnet;
57
+ void (0, auth_1.refreshApiKeyIfNeeded)({ store: config.store, authEndpoint: backend.authEndpoint })
58
+ .then((status) => {
59
+ if (status === 'reauth-required')
60
+ log('API key expired — run `agent login`');
61
+ })
62
+ .catch(() => { });
40
63
  // pi is ESM-only; tsc's CJS output would downlevel a plain `await import()`
41
64
  // into `require()`, which cannot load it. Indirect the import so it survives
42
65
  // transpilation in the CJS build.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentic-kit/cli",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "author": "Dan Lynch <pyramation@gmail.com>",
5
5
  "description": "agent — the pi coding agent with the Constructive harness baked in, purely a shell",
6
6
  "main": "index.js",
@@ -32,10 +32,12 @@
32
32
  "test:watch": "jest --watch"
33
33
  },
34
34
  "dependencies": {
35
- "@agentic-kit/harness": "0.9.0",
36
- "@agentic-kit/pi": "0.9.1",
35
+ "@agentic-kit/harness": "0.10.0",
36
+ "@agentic-kit/pi": "0.10.0",
37
+ "@constructive-io/sdk": "^1.11.3",
37
38
  "@earendil-works/pi-coding-agent": "0.79.6",
38
- "inquirerer": "^4.9.1"
39
+ "appstash": "^0.8.0",
40
+ "inquirerer": "^4.9.3"
39
41
  },
40
42
  "keywords": [
41
43
  "agentic-kit",
@@ -43,5 +45,5 @@
43
45
  "pi",
44
46
  "harness"
45
47
  ],
46
- "gitHead": "6da0705f8aa49d62dc2defb8b135b71674611483"
48
+ "gitHead": "43121004a8bedd2c5fcf7bf33208079d55bad01f"
47
49
  }